public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: Disable -Wdefault-const-init-var-unsafe
@ 2025-05-07  9:13 WangYuli
  2025-05-07 19:56 ` Nathan Chancellor
  0 siblings, 1 reply; 2+ messages in thread
From: WangYuli @ 2025-05-07  9:13 UTC (permalink / raw)
  To: masahiroy, nathan, nicolas.schier
  Cc: linux-kbuild, linux-kernel, m.seyfarth, zhanjun, niecheng1,
	guanwentao, WangYuli

Similar to ("kbuild: Disable -Wdefault-const-init-field-unsafe")
from list, -Wdefault-const-init-var-unsafe need to be disabled too.

While I haven't found this warning triggered in the kernel code
itself (my testing covers just a tiny fraction), it's clearly
something that should be disabled for the same reason.

Additionally, because dkms uses kernel compile parameters, some
out-of-tree modules might also hit this warning, like the Mucse
network driver.

Fix follow error with -Werror:
  drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c:6126:11: error: default initialization of an object of type 'const u8[6]' (aka 'const unsigned char[6]') leaves the object uninitialized and is incompatible with C++ [-Werror,-Wdefault-const-init-var-unsafe]
   6126 |         const u8 target_addr[ETH_ALEN];
        |                  ^
  1 error generated.

Link: https://lore.kernel.org/all/20250501-default-const-init-clang-v1-0-3d2c6c185dbb@kernel.org/
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 scripts/Makefile.extrawarn | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index a7b680df5b24..14e22310fbbf 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -44,6 +44,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
 # the field is within a union with other non-const members, or the containing
 # object is not const so the field can be modified via memcpy() / memset().
 KBUILD_CFLAGS += $(call cc-disable-warning, default-const-init-field-unsafe)
+KBUILD_CFLAGS += $(call cc-disable-warning, default-const-init-var-unsafe)
 else
 
 # gcc inanely warns about local variables called 'main'
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-07 19:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07  9:13 [PATCH] kbuild: Disable -Wdefault-const-init-var-unsafe WangYuli
2025-05-07 19:56 ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox