From f1cb55192c3b61768678a748a60e9b83f98133f3 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 2 Jan 2017 01:11:55 +0100 Subject: [PATCH] fixed linux warnings --- lib/common/threading.h | 4 ++-- lib/compress/zstdmt_compress.c | 18 +++++++++--------- programs/bench.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/common/threading.h b/lib/common/threading.h index d5dc8f75a..4572d71d5 100644 --- a/lib/common/threading.h +++ b/lib/common/threading.h @@ -80,13 +80,13 @@ int _pthread_join(pthread_t* thread, void** value_ptr); #else /* ZSTD_PTHREAD not defined */ /* No multithreading support */ -typedef int pthread_mutex_t; +#define pthread_mutex_t int /* #define rather than typedef, as sometimes pthread support is implicit, resulting in duplicated symbols */ #define pthread_mutex_init(a,b) #define pthread_mutex_destroy(a) #define pthread_mutex_lock(a) #define pthread_mutex_unlock(a) -typedef int pthread_cond_t; +#define pthread_cond_t int #define pthread_cond_init(a,b) #define pthread_cond_destroy(a) #define pthread_cond_wait(a,b) diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 294ce86d4..dd495c988 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -78,18 +78,18 @@ static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool) static buffer_t ZSTDMT_getBuffer(ZSTDMT_bufferPool* pool, size_t bSize) { if (pool->nbBuffers) { /* try to use an existing buffer */ - pool->nbBuffers--; - buffer_t const buf = pool->bTable[pool->nbBuffers]; + buffer_t const buf = pool->bTable[--(pool->nbBuffers)]; size_t const availBufferSize = buf.size; if ((availBufferSize >= bSize) & (availBufferSize <= 10*bSize)) /* large enough, but not too much */ return buf; free(buf.start); /* size conditions not respected : create a new buffer */ } /* create new buffer */ - buffer_t buf; - buf.size = bSize; - buf.start = malloc(bSize); - return buf; + { buffer_t buf; + buf.size = bSize; + buf.start = malloc(bSize); + return buf; + } } /* effectively store buffer for later re-use, up to pool capacity */ @@ -121,9 +121,8 @@ typedef struct { /* ZSTDMT_compressFrame() : POOL_function type */ void ZSTDMT_compressFrame(void* jobDescription) { - DEBUGLOG(5, "Entering ZSTDMT_compressFrame() "); ZSTDMT_jobDescription* const job = (ZSTDMT_jobDescription*)jobDescription; - DEBUGLOG(5, "compressing %u bytes from frame %u with ZSTD_compressCCtx : ", (unsigned)job->srcSize, job->jobCompleted); + DEBUGLOG(5, "thread : compressing %u bytes from frame %u with ZSTD_compressCCtx : ", (unsigned)job->srcSize, job->jobCompleted); job->cSize = ZSTD_compressCCtx(job->cctx, job->dstBuff.start, job->dstBuff.size, job->srcStart, job->srcSize, job->compressionLevel); DEBUGLOG(5, "compressed to %u bytes ", (unsigned)job->cSize); DEBUGLOG(5, "sending jobCompleted signal"); @@ -197,8 +196,9 @@ struct ZSTDMT_CCtx_s { ZSTDMT_CCtx *ZSTDMT_createCCtx(unsigned nbThreads) { + ZSTDMT_CCtx* cctx; if ((nbThreads < 1) | (nbThreads > ZSTDMT_NBTHREADS_MAX)) return NULL; - ZSTDMT_CCtx* const cctx = (ZSTDMT_CCtx*) calloc(1, sizeof(ZSTDMT_CCtx) + nbThreads*sizeof(ZSTDMT_jobDescription)); + cctx = (ZSTDMT_CCtx*) calloc(1, sizeof(ZSTDMT_CCtx) + nbThreads*sizeof(ZSTDMT_jobDescription)); if (!cctx) return NULL; cctx->nbThreads = nbThreads; cctx->factory = POOL_create(nbThreads, 1); diff --git a/programs/bench.c b/programs/bench.c index e846e9ef3..a3c013a8b 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -101,8 +101,8 @@ static clock_us_t BMK_clockMicroSec(void) static clock_t _ticksPerSecond = 0; if (_ticksPerSecond <= 0) _ticksPerSecond = sysconf(_SC_CLK_TCK); - struct tms junk; clock_t newTicks = (clock_t) times(&junk); (void)junk; - return ((((clock_us_t)newTicks)*(1000000))/_ticksPerSecond); + { struct tms junk; clock_t newTicks = (clock_t) times(&junk); (void)junk; + return ((((clock_us_t)newTicks)*(1000000))/_ticksPerSecond); } }