]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed linux warnings
authorYann Collet <cyan@fb.com>
Mon, 2 Jan 2017 00:11:55 +0000 (01:11 +0100)
committerYann Collet <cyan@fb.com>
Mon, 2 Jan 2017 00:11:55 +0000 (01:11 +0100)
lib/common/threading.h
lib/compress/zstdmt_compress.c
programs/bench.c

index d5dc8f75ae0a424f205da52ecbb0f2f83ea60d61..4572d71d52a9151d2b34982df2ed1450aad198e8 100644 (file)
@@ -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)
index 294ce86d4f4af075e4e8e2d38442c2c59545fb91..dd495c98845148013449ea1f55c27fe5e873f51b 100644 (file)
@@ -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);
index e846e9ef3a63339ecae99de318aa07339c0d65c7..a3c013a8bfb5972045bc7402f9d39e4e6825cd3c 100644 (file)
@@ -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); }
 }