The patch titled Subject: kbuild: enable -Wformat-truncation on clang has been added to the -mm mm-nonmm-unstable branch. Its filename is kbuild-enable-wformat-truncation-on-clang.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kbuild-enable-wformat-truncation-on-clang.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Arnd Bergmann <arnd@xxxxxxxx> Subject: kbuild: enable -Wformat-truncation on clang Date: Mon, 15 Apr 2024 14:20:35 +0200 This warning option still produces output on gcc but is now clean when building with clang, so enable it conditionally on the compiler for now. As far as I can tell, the remaining warnings with gcc are the result of analysing the code more deeply across inlining, while clang only does this within a function. Link: https://lore.kernel.org/lkml/20240326230511.GA2796782@dev-arch.thelio-3990X/ Link: https://lore.kernel.org/linux-patches/20231002-disable-wformat-truncation-overflow-non-kprintf-v1-1-35179205c8d9@xxxxxxxxxx/ Link: https://lkml.kernel.org/r/20240415122037.1983124-5-arnd@xxxxxxxxxx Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Masahiro Yamada <masahiroy@xxxxxxxxxx> Cc: Nathan Chancellor <nathan@xxxxxxxxxx> Cc: Nicolas Schier <nicolas@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/Makefile.extrawarn | 7 +++++++ 1 file changed, 7 insertions(+) --- a/scripts/Makefile.extrawarn~kbuild-enable-wformat-truncation-on-clang +++ a/scripts/Makefile.extrawarn @@ -100,7 +100,14 @@ KBUILD_CFLAGS += $(call cc-disable-warni KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +else +# Clang checks for overflow/truncation with '%p', while GCC does not: +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219 +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf) +endif KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang _ Patches currently in -mm which might be from arnd@xxxxxxxx are fix-missing-vmalloch-includes-fix-5.patch kcov-avoid-clang-out-of-range-warning.patch test_hexdump-avoid-string-truncation-warning.patch block-partitions-ldm-convert-strncpy-to-strscpy.patch blktrace-convert-strncpy-to-strscpy_pad.patch kbuild-turn-on-wextra-by-default.patch kbuild-remove-redundant-extra-warning-flags.patch kbuild-turn-on-wrestrict-by-default.patch kbuild-enable-wformat-truncation-on-clang.patch kbuild-enable-wcast-function-type-strict-unconditionally.patch kbuild-enable-wstringop-truncation-globally.patch