From: Gianfranco Costamagna Date: Fri, 7 Jul 2023 07:26:30 +0000 (+0200) Subject: Update fileio.c: fix build failure with enabled LTO X-Git-Tag: v1.5.6^2~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de6b46dfc80d950a32176c7eca79bb229d47f501;p=thirdparty%2Fzstd.git 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=/<>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fdebug-prefix-map=/<>=/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 --- diff --git a/programs/fileio.c b/programs/fileio.c index 84a0f48f7..217232542 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2222,6 +2222,7 @@ static dRess_t FIO_createDResources(FIO_prefs_t* const prefs, const char* dictFi int forceNoUseMMap = prefs->mmapDict == ZSTD_ps_disable; stat_t statbuf; dRess_t ress; + memset(&statbuf, 0, sizeof(statbuf)); memset(&ress, 0, sizeof(ress)); FIO_getDictFileStat(dictFileName, &statbuf);