[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] tests/cpu-policy: fix format-overflow warning by null terminating strings
On Tue, 2019-07-30 at 17:23 +0100, Andrew Cooper wrote: > On 30/07/2019 16:51, Jan Beulich wrote: > > On 25.07.2019 02:53, christopher.w.clark@xxxxxxxxx wrote: > > > From: Christopher Clark <christopher.w.clark@xxxxxxxxx> > > > > > > gcc 9.1.0 reports: > > > > > > > test-cpu-policy.c:64:18: error: '%.12s' directive argument is > > > > not a nul-terminated string [-Werror=format-overflow=] > > > > 64 | fail(" Test '%.12s', expected vendor %u, > > > > got %u\n", > > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > ~~~~~~~~ > > > > test-cpu-policy.c:20:12: note: in definition of macro 'fail' > > > > 20 | printf(fmt, ##__VA_ARGS__); \ > > > > | ^~~ > > > > test-cpu-policy.c:64:27: note: format string is defined here > > > > 64 | fail(" Test '%.12s', expected vendor %u, > > > > got %u\n", > > > > | ^~~~~ > > > > test-cpu-policy.c:44:7: note: referenced argument declared here > > > > 44 | } tests[] = { > > > > | ^~~~~ > > In order to possibly create a bug report against gcc I've tried > > this: > > > > #include <stdio.h> > > > > struct s { > > char ac[12]; > > int i; > > }; > > > > void test(const struct s*ps) { > > printf("'%.12s'\n", ps->ac); > > } > > > > There's no warning here. Could you check whether the compiler warns > > on > > that simple test for you? If it does - are we talking about plain > > upstream 9.1.0 (in which case I'd be really puzzled by the > > difference > > in behavior)? > > CC Dario who also reported this build failure. > Yep, this thread was on my radar already. But thanks! :-P So, I'm using the following gcc (stock opensuse Tumbleweed provided one): dario@Palanthas:~/src/xen/xen.git> gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/9/lto-wrapper OFFLOAD_TARGET_NAMES=hsa:nvptx-none Target: x86_64-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d --enable-offload-targets=hsa,nvptx-none=/usr/nvptx-none, --without-cuda-driver --disable-werror --with-gxx-include-dir=/usr/include/c++/9 --enable-ssp --disable-libssp --disable-libvtv --disable-cet --disable-libcc1 --enable-plugin --with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-libphobos --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-9 --without-system-libunwind --enable-multilib --with-arch-32=x86-64 --with-tune=generic --with-build-config=bootstrap-lto-lean --enable-link-mutex --build=x86_64-suse-linux --host=x86_64-suse-linux Thread model: posix gcc version 9.1.1 20190703 [gcc-9-branch revision 273008] (SUSE Linux) Jan's example above, seem to compile **without any warnings** for me as well. If I add a main(), I can even get the code above to print the content of the array. And yet, building the tools without a patch like Christoper's one (which was also what I was using locally, and raised to Andy), I get: make[6]: Entering directory '/build/tools/tests/cpu-policy' gcc -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -g3 -O0 -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MF .test-cpu-policy.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Werror -I/build/tools/tests/cpu-policy/../../../tools/include -D__XEN_TOOLS__ -O3 -c -o test-cpu-policy.o test-cpu-policy.c test-cpu-policy.c: In function 'main': test-cpu-policy.c:64:18: error: '%.12s' directive argument is not a nul-terminated string [-Werror=format-overflow=] 64 | fail(" Test '%.12s', expected vendor %u, got %u\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test-cpu-policy.c:20:12: note: in definition of macro 'fail' 20 | printf(fmt, ##__VA_ARGS__); \ | ^~~ test-cpu-policy.c:64:27: note: format string is defined here 64 | fail(" Test '%.12s', expected vendor %u, got %u\n", | ^~~~~ test-cpu-policy.c:44:7: note: referenced argument declared here 44 | } tests[] = { | ^~~~~ I'm happy to do more tests. Regards -- Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere) Attachment:
signature.asc _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |