]> git.proxmox.com Git - mirror_zfs.git/commitdiff
config: use -Wno-format-truncation globally
authorRob Norris <robn@despairlabs.com>
Mon, 19 Feb 2024 10:13:59 +0000 (21:13 +1100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 26 Feb 2024 20:23:55 +0000 (12:23 -0800)
-Wformat-truncation looks for places where the return code of snprintf()
is unchecked and the provided buffer might be too short. This is based
on a heuristic that can change between compiler versions.

It has been seen to get this wrong in ddt_object_name(), leading to
DDT_NAMELEN being increased somewhat arbitrarily.

There's no good reason to have this warning enabled, so here we disable
it everywhere. Truncation may be undesirable, but snprintf() is
guaranteed to emit a trailing null, so at worst we get a short string,
not a buffer overrun.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Closes #15908

cmd/Makefile.am
config/Rules.am

index 6d6de4adb42a30c858918d88e9895e548b1a80dc..2bd9d039f20e644a004ffff6668dc225dc73d0a2 100644 (file)
@@ -39,8 +39,6 @@ zhack_LDADD = \
 
 
 ztest_CFLAGS    = $(AM_CFLAGS) $(KERNEL_CFLAGS)
-# Get rid of compiler warning for unchecked truncating snprintfs on gcc 7.1.1
-ztest_CFLAGS   += $(NO_FORMAT_TRUNCATION)
 ztest_CPPFLAGS  = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS)
 
 sbin_PROGRAMS   += ztest
index 2e463ae6083a4932e3e20550eed24d0d367bcac9..30c5f353cd230c003a541eace08b037e4bf9e10c 100644 (file)
@@ -21,7 +21,9 @@ AM_CFLAGS += $(IMPLICIT_FALLTHROUGH)
 AM_CFLAGS += $(DEBUG_CFLAGS)
 AM_CFLAGS += $(ASAN_CFLAGS)
 AM_CFLAGS += $(UBSAN_CFLAGS)
-AM_CFLAGS += $(CODE_COVERAGE_CFLAGS) $(NO_FORMAT_ZERO_LENGTH)
+AM_CFLAGS += $(CODE_COVERAGE_CFLAGS)
+AM_CFLAGS += $(NO_FORMAT_ZERO_LENGTH)
+AM_CFLAGS += $(NO_FORMAT_TRUNCATION)
 if BUILD_FREEBSD
 AM_CFLAGS += -fPIC -Werror -Wno-unknown-pragmas -Wno-enum-conversion
 AM_CFLAGS += -include $(top_srcdir)/include/os/freebsd/spl/sys/ccompile.h