[SLOF] [PATCH] Silence initializer-string warnings
Thomas Huth
thuth at redhat.com
Fri Oct 17 17:33:20 AEDT 2025
From: Thomas Huth <thuth at redhat.com>
Recent versions GCC (v15.2) started to complain with a lot of warnings
like these:
./dict.xt:1510:115: warning: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (9 chars into 8 available) [-Wunterminated-string-initialization]
1510 | _gpt_X2d_add_X2d_entry, { .a = xt_tpm_X2d_gpt_X2d_set_X2d_lba1 }, { .c = "\000\021tpm-gp" }, { .c = "t-add-en" }, { .c = "try" },) cod(tpm_X2d_gpt_X2d_add_X2d_entry)
| ^~~~~~~~~~
.../slof/slof/prep.h:23:62: note: in definition of macro ‘header’
23 | #define header(_xt, _header...) static cell xt_ ## _xt[] = { _header
| ^~~~~~~
./dict.xt:1512:83: warning: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (9 chars into 8 available) [-Wunterminated-string-initialization]
1512 | header(tpm_X2d_measure_X2d_gpt, { .a = xt_tpm_X2d_gpt_X2d_add_X2d_entry }, { .c = "\000\017tpm-me" }, { .c = "asure-gp" }, { .c = "t" },) cod(tpm_X2d_measure_X2d_gpt)
| ^~~~~~~~~~~~~~~~
.../slof/slof/prep.h:23:62: note: in definition of macro ‘header’
23 | #define header(_xt, _header...) static cell xt_ ## _xt[] = { _header
| ^~~~~~~
etc.
It's one of those new extra warnings that are enabled by -Wextra.
Of course we could try to go through the code bit by bit, trying
to fix those warnings, but in my experience -Wextra often causes
more hassle than being really helpful. Thus let's simply drop
it from our CFLAGS. We can then also remove the -Wno-unused-parameter
which we already had to use to tame the warnings that were enabled
by -Wextra.
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
make.rules | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/make.rules b/make.rules
index aea57fe..3505da5 100644
--- a/make.rules
+++ b/make.rules
@@ -32,7 +32,7 @@ endif
CELLSIZE ?= 64
HOSTCC ?= gcc
-HOSTCFLAGS = -g -Wall -W -O2 -I. -I../include
+HOSTCFLAGS = -g -Wall -O2 -I. -I../include
DD = dd
ONLY_CC = $(CROSS)gcc -m$(CELLSIZE) $(EXTRA_CC)
@@ -72,7 +72,7 @@ AR ?= $(CROSS)ar
RANLIB ?= $(CROSS)ranlib
CPP ?= $(CROSS)cpp
-WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter
+WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security
CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \
-fno-strict-aliasing -mno-altivec -mabi=no-altivec \
-fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS) \
--
2.51.0
More information about the SLOF
mailing list