]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed gcc warning on uninitialized structure variable
authorYann Collet <yann.collet.73@gmail.com>
Sun, 12 Jun 2016 20:51:52 +0000 (22:51 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Sun, 12 Jun 2016 20:51:52 +0000 (22:51 +0200)
lib/common/bitstream.h

index 694df4e3ba09741a2688af4c164d67d7f51099ac..e96798fe47b2019c175c2cd5f58c1a79e86960d1 100644 (file)
@@ -266,8 +266,8 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
         bitD->ptr   = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
         bitD->bitContainer = MEM_readLEST(bitD->ptr);
         { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
-          if (lastByte == 0) return ERROR(GENERIC);   /* endMark not present */
-          bitD->bitsConsumed = 8 - BIT_highbit32(lastByte); }
+          bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
+          if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
     } else {
         bitD->start = (const char*)srcBuffer;
         bitD->ptr   = bitD->start;
@@ -283,8 +283,8 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
             default:;
         }
         { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
-          if (lastByte == 0) return ERROR(GENERIC);   /* endMark not present */
-          bitD->bitsConsumed = 8 - BIT_highbit32(lastByte); }
+          bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
+          if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
         bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
     }