Skip to content

Commit 57be05b

Browse files
committed
zstd: initialize blockProperties to avoid compiler warning
On older versions of GCC, the former code produces a compiler warning: ``` zstd/zstdlib.c: In function ‘ZSTD_decompressMultiFrame’: zstd/zstdlib.c:38866:27: error: ‘blockProperties.origSize’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 38866 | decodedSize = ZSTD_setRleBlock(op, (size_t)(oend-op), *ip, blockProperties.origSize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ zstd/zstdlib.c:38849:27: note: ‘blockProperties.origSize’ was declared here 38849 | blockProperties_t blockProperties; | ^~~~~~~~~~~~~~~ zstd/zstdlib.c:38857:9: error: ‘blockProperties’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 38857 | switch(blockProperties.blockType) | ^~~~~~ zstd/zstdlib.c:38849:27: note: ‘blockProperties’ was declared here 38849 | blockProperties_t blockProperties; | ^~~~~~~~~~~~~~~ ``` This commit works around it.
1 parent 970d822 commit 57be05b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

zstd/zstdlib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38847,6 +38847,8 @@ static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
3884738847
while (1) {
3884838848
size_t decodedSize;
3884938849
blockProperties_t blockProperties;
38850+
blockProperties.blockType = bt_reserved;
38851+
blockProperties.origSize = 0;
3885038852
size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSrcSize, &blockProperties);
3885138853
if (ZSTD_isError(cBlockSize)) return cBlockSize;
3885238854

0 commit comments

Comments
 (0)