Skip to content

Commit de6b46d

Browse files
LocutusOfBorgterrelln
authored andcommitted
Update fileio.c: fix build failure with enabled LTO
For some reasons when LTO is enabled, the compiler complains about statbuf variable not being correctly initialized, even though the variable has an assert != NULL just few lines below (FIO_getDictFileStat) This is the fixed build failure: x86_64-linux-gnu-gcc -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/libzstd-1.5.5+dfsg2-1 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -Wpointer-arith -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings -Wredundant-decls -Wmissing-prototypes -Wc++-compat -g -Werror -Wa,--noexecstack -Wdate-time -D_FORTIFY_SOURCE=2 -DXXH_NAMESPACE=ZSTD_ -DDEBUGLEVEL=1 -DZSTD_LEGACY_SUPPORT=5 -DZSTD_MULTITHREAD -DZSTD_GZCOMPRESS -DZSTD_GZDECOMPRESS -DZSTD_LZMACOMPRESS -DZSTD_LZMADECOMPRESS -DZSTD_LZ4COMPRESS -DZSTD_LZ4DECOMPRESS -DZSTD_LEGACY_SUPPORT=5 -c -MT obj/conf_086c46a51a716b674719b8acb8484eb8/zstdcli_trace.o -MMD -MP -MF obj/conf_086c46a51a716b674719b8acb8484eb8/zstdcli_trace.d -o obj/conf_086c46a51a716b674719b8acb8484eb8/zstdcli_trace.o zstdcli_trace.c In function ‘UTIL_isRegularFileStat’, inlined from ‘UTIL_getFileSizeStat’ at util.c:524:10, inlined from ‘FIO_createDResources’ at fileio.c:2230:30: util.c:209:12: error: ‘statbuf.st_mode’ may be used uninitialized [-Werror=maybe-uninitialized] 209 | return S_ISREG(statbuf->st_mode) != 0; | ^ fileio.c: In function ‘FIO_createDResources’: fileio.c:2223:12: note: ‘statbuf’ declared here 2223 | stat_t statbuf; | ^ lto1: all warnings being treated as errors
1 parent 55ff3e4 commit de6b46d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

programs/fileio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,7 @@ static dRess_t FIO_createDResources(FIO_prefs_t* const prefs, const char* dictFi
22222222
int forceNoUseMMap = prefs->mmapDict == ZSTD_ps_disable;
22232223
stat_t statbuf;
22242224
dRess_t ress;
2225+
memset(&statbuf, 0, sizeof(statbuf));
22252226
memset(&ress, 0, sizeof(ress));
22262227

22272228
FIO_getDictFileStat(dictFileName, &statbuf);

0 commit comments

Comments
 (0)