linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Kbuild: warning options cleanup and more warnings
@ 2023-08-11 14:03 Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc Arnd Bergmann
                   ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

This is a series I've had in my randconfig test tree for a long
time, and I'd like to get these patches applied in mainline so I
can stop rebasing them on top of other changes, as well as get
fewer regressions.

There are roughly three groups of changes in here:

1. Clean up the Makefile and Makefile.extrawarn to be organized
   more logically so we can see which warnings are actually enabled
   at which level

2. Enable some of the warnings that have traditionally been disabled
   at either the W=1 or W=2 levels where they arguably should have
   been to start with

3. Enable some of the W=1 warnings by default now that the warnings
   we got in the past have been addressed.

I sent the -Wmissing-prototypes enablement separately, since that is
really the big one that probably found the most bugs but also still
caused the most warnings until my recent cleanups.

Along the same lines as that other series, I would hope that we
can get the first eight patches into the merge window, but should
probably give the last patch another release in linux-next before
any remaining output has been addressed and we can apply it.

     Arnd

Arnd Bergmann (9):
  Kbuild: only pass -fno-inline-functions-called-once for gcc
  Kbuild: consolidate warning flags in scripts/Makefile.extrawarn
  Kbuild: avoid duplicate warning options
  extrawarn: don't turn off -Wshift-negative-value for gcc-9
  extrawarn: enable format and stringop overflow warnings in W=1
  extrawarn: move -Wrestrict into W=1 warnings
  extrawarn: do not disable -Wmain at W=1 level
  extrawarn: enable more warnings in W=2
  [RFC] extrawarn: enable more W=1 warnings by default

 Makefile                   |  90 +------------------------
 scripts/Makefile.extrawarn | 133 ++++++++++++++++++++++++++++++++-----
 2 files changed, 118 insertions(+), 105 deletions(-)

-- 
2.39.2

Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Lee Jones <lee@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-arch@vger.kernel.org

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

* [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-11 14:14   ` Nathan Chancellor
  2023-08-11 14:03 ` [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn Arnd Bergmann
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

clang ignores the -fno-inline-functions-called-once option, but warns
when building with -Wignored-optimization-argument enabled:

clang: error: optimization flag '-fno-inline-functions-called-once' is not supported [-Werror,-Wignored-optimization-argument]

Move it back to using cc-option for this one.

Fixes: 7d73c3e9c514 ("Makefile: remove stale cc-option checks")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index bf5a6100cf66e..991c02f8e9ac0 100644
--- a/Makefile
+++ b/Makefile
@@ -967,7 +967,7 @@ endif
 
 # We trigger additional mismatches with less inlining
 ifdef CONFIG_DEBUG_SECTION_MISMATCH
-KBUILD_CFLAGS += -fno-inline-functions-called-once
+KBUILD_CFLAGS += $(call cc-option,-fno-inline-functions-called-once)
 endif
 
 # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
-- 
2.39.2


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

* [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-11 14:19   ` Nathan Chancellor
  2023-08-11 14:03 ` [PATCH 3/9] Kbuild: avoid duplicate warning options Arnd Bergmann
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

Warning options are enabled and disabled in inconsistent ways and
inconsistent locations. Start rearranging those by moving all options
into Makefile.extrawarn.

This should not change any behavior, but makes sure we can group them
in a way that ensures that each warning that got temporarily disabled
is turned back on at an appropriate W=1 level later on.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile                   | 88 -------------------------------------
 scripts/Makefile.extrawarn | 90 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 88 deletions(-)

diff --git a/Makefile b/Makefile
index 991c02f8e9ac0..781ff496f4aed 100644
--- a/Makefile
+++ b/Makefile
@@ -563,14 +563,6 @@ KBUILD_CFLAGS += -funsigned-char
 KBUILD_CFLAGS += -fno-common
 KBUILD_CFLAGS += -fno-PIE
 KBUILD_CFLAGS += -fno-strict-aliasing
-KBUILD_CFLAGS += -Wall
-KBUILD_CFLAGS += -Wundef
-KBUILD_CFLAGS += -Werror=implicit-function-declaration
-KBUILD_CFLAGS += -Werror=implicit-int
-KBUILD_CFLAGS += -Werror=return-type
-KBUILD_CFLAGS += -Werror=strict-prototypes
-KBUILD_CFLAGS += -Wno-format-security
-KBUILD_CFLAGS += -Wno-trigraphs
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_RUSTFLAGS := $(rust_common_flags) \
@@ -823,10 +815,6 @@ endif # may-sync-config
 endif # need-config
 
 KBUILD_CFLAGS	+= -fno-delete-null-pointer-checks
-KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
-KBUILD_CFLAGS	+= $(call cc-disable-warning, format-truncation)
-KBUILD_CFLAGS	+= $(call cc-disable-warning, format-overflow)
-KBUILD_CFLAGS	+= $(call cc-disable-warning, address-of-packed-member)
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
 KBUILD_CFLAGS += -O2
@@ -857,40 +845,15 @@ ifdef CONFIG_READABLE_ASM
 KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
 endif
 
-ifneq ($(CONFIG_FRAME_WARN),0)
-KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
-endif
-
 stackp-flags-y                                    := -fno-stack-protector
 stackp-flags-$(CONFIG_STACKPROTECTOR)             := -fstack-protector
 stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
 
 KBUILD_CFLAGS += $(stackp-flags-y)
 
-KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
-KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
-KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
-
 KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
 KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y)
 
-ifdef CONFIG_CC_IS_CLANG
-# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
-KBUILD_CFLAGS += -Wno-gnu
-else
-
-# gcc inanely warns about local variables called 'main'
-KBUILD_CFLAGS += -Wno-main
-endif
-
-# These warnings generated too much noise in a regular build.
-# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
-
-# These result in bogus false positives
-KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
-
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
@@ -1025,51 +988,12 @@ endif
 # arch Makefile may override CC so keep this after arch Makefile is included
 NOSTDINC_FLAGS += -nostdinc
 
-# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
-KBUILD_CFLAGS += -Wvla
-
-# disable pointer signed / unsigned warnings in gcc 4.0
-KBUILD_CFLAGS += -Wno-pointer-sign
-
-# In order to make sure new function cast mismatches are not introduced
-# in the kernel (to avoid tripping CFI checking), the kernel should be
-# globally built with -Wcast-function-type.
-KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
-
 # To gain proper coverage for CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE,
 # the kernel uses only C99 flexible arrays for dynamically sized trailing
 # arrays. Enforce this for everything that may examine structure sizes and
 # perform bounds checking.
 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
 
-# disable stringop warnings in gcc 8+
-KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
-
-# We'll want to enable this eventually, but it's not going away for 5.7 at least
-KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
-
-# Another good warning that we'll want to enable eventually
-KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
-
-# Enabled with W=2, disabled by default as noisy
-ifdef CONFIG_CC_IS_GCC
-KBUILD_CFLAGS += -Wno-maybe-uninitialized
-endif
-
-# The allocators already balk at large sizes, so silence the compiler
-# warnings for bounds checks involving those possible values. While
-# -Wno-alloc-size-larger-than would normally be used here, earlier versions
-# of gcc (<9.1) weirdly don't handle the option correctly when _other_
-# warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
-# doesn't work (as it is documented to), silently resolving to "0" prior to
-# version 9.1 (and producing an error more recently). Numeric values larger
-# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently
-# ignored, continuing to default to PTRDIFF_MAX. So, left with no other
-# choice, we must perform a versioned check to disable this warning.
-# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au
-KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
-KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
-
 # disable invalid "can't wrap" optimizations for signed / pointers
 KBUILD_CFLAGS	+= -fno-strict-overflow
 
@@ -1081,18 +1005,6 @@ ifdef CONFIG_CC_IS_GCC
 KBUILD_CFLAGS   += -fconserve-stack
 endif
 
-# Prohibit date/time macros, which would make the build non-deterministic
-KBUILD_CFLAGS   += -Werror=date-time
-
-# enforce correct pointer usage
-KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
-
-# Require designated initializers for all marked structures
-KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
-
-# Warn if there is an enum types mismatch
-KBUILD_CFLAGS	+= $(call cc-option,-Wenum-conversion)
-
 # change __FILE__ to the relative path from the srctree
 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
 
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 40cd13eca82e8..9cc0e52ebd7eb 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -6,6 +6,96 @@
 # They are independent, and can be combined like W=12 or W=123e.
 # ==========================================================================
 
+# Default set of warnings, always enabled
+KBUILD_CFLAGS += -Wall
+KBUILD_CFLAGS += -Wundef
+KBUILD_CFLAGS += -Werror=implicit-function-declaration
+KBUILD_CFLAGS += -Werror=implicit-int
+KBUILD_CFLAGS += -Werror=return-type
+KBUILD_CFLAGS += -Werror=strict-prototypes
+KBUILD_CFLAGS += -Wno-format-security
+KBUILD_CFLAGS += -Wno-trigraphs
+KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+
+ifneq ($(CONFIG_FRAME_WARN),0)
+KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
+endif
+
+KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
+KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
+KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
+
+ifdef CONFIG_CC_IS_CLANG
+# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
+KBUILD_CFLAGS += -Wno-gnu
+else
+
+# gcc inanely warns about local variables called 'main'
+KBUILD_CFLAGS += -Wno-main
+endif
+
+# These warnings generated too much noise in a regular build.
+# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+
+# These result in bogus false positives
+KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
+
+# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
+KBUILD_CFLAGS += -Wvla
+
+# disable pointer signed / unsigned warnings in gcc 4.0
+KBUILD_CFLAGS += -Wno-pointer-sign
+
+# In order to make sure new function cast mismatches are not introduced
+# in the kernel (to avoid tripping CFI checking), the kernel should be
+# globally built with -Wcast-function-type.
+KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
+
+# disable stringop warnings in gcc 8+
+KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
+
+# We'll want to enable this eventually, but it's not going away for 5.7 at least
+KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
+
+# Another good warning that we'll want to enable eventually
+KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
+
+# Enabled with W=2, disabled by default as noisy
+ifdef CONFIG_CC_IS_GCC
+KBUILD_CFLAGS += -Wno-maybe-uninitialized
+endif
+
+# The allocators already balk at large sizes, so silence the compiler
+# warnings for bounds checks involving those possible values. While
+# -Wno-alloc-size-larger-than would normally be used here, earlier versions
+# of gcc (<9.1) weirdly don't handle the option correctly when _other_
+# warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
+# doesn't work (as it is documented to), silently resolving to "0" prior to
+# version 9.1 (and producing an error more recently). Numeric values larger
+# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently
+# ignored, continuing to default to PTRDIFF_MAX. So, left with no other
+# choice, we must perform a versioned check to disable this warning.
+# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au
+KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
+KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
+
+# Prohibit date/time macros, which would make the build non-deterministic
+KBUILD_CFLAGS += -Werror=date-time
+
+# enforce correct pointer usage
+KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
+
+# Require designated initializers for all marked structures
+KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
+
+# Warn if there is an enum types mismatch
+KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
+
 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
 
 # backward compatibility
-- 
2.39.2


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

* [PATCH 3/9] Kbuild: avoid duplicate warning options
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-12  9:21   ` Masahiro Yamada
  2023-08-11 14:03 ` [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9 Arnd Bergmann
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

Some warning options are disabled at one place and then conditionally
re-enabled later in scripts/Makefile.extrawarn.

For consistency, rework this file so each of those warnings only
gets etiher enabled or disabled based on the W= flags but not both.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 43 +++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 9cc0e52ebd7eb..8afbe4706ff11 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -56,20 +56,12 @@ KBUILD_CFLAGS += -Wno-pointer-sign
 # globally built with -Wcast-function-type.
 KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
 
-# disable stringop warnings in gcc 8+
-KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
-
 # We'll want to enable this eventually, but it's not going away for 5.7 at least
 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
 
 # Another good warning that we'll want to enable eventually
 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
 
-# Enabled with W=2, disabled by default as noisy
-ifdef CONFIG_CC_IS_GCC
-KBUILD_CFLAGS += -Wno-maybe-uninitialized
-endif
-
 # The allocators already balk at large sizes, so silence the compiler
 # warnings for bounds checks involving those possible values. While
 # -Wno-alloc-size-larger-than would normally be used here, earlier versions
@@ -96,8 +88,6 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
 # Warn if there is an enum types mismatch
 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
 
-KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
-
 # backward compatibility
 KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
 
@@ -122,11 +112,6 @@ KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
 KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
-# The following turn off the warnings enabled by -Wextra
-KBUILD_CFLAGS += -Wno-missing-field-initializers
-KBUILD_CFLAGS += -Wno-sign-compare
-KBUILD_CFLAGS += -Wno-type-limits
-KBUILD_CFLAGS += -Wno-shift-negative-value
 
 KBUILD_CPPFLAGS += -Wundef
 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
@@ -135,9 +120,12 @@ else
 
 # Some diagnostics enabled by default are noisy.
 # Suppress them by using -Wno... except for W=1.
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
+KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
 
 ifdef CONFIG_CC_IS_CLANG
-KBUILD_CFLAGS += -Wno-initializer-overrides
 # Clang before clang-16 would warn on default argument promotions.
 ifneq ($(call clang-min-version, 160000),y)
 # Disable -Wformat
@@ -151,7 +139,6 @@ ifeq ($(call clang-min-version, 120000),y)
 KBUILD_CFLAGS += -Wformat-insufficient-args
 endif
 endif
-KBUILD_CFLAGS += -Wno-sign-compare
 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
 KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
@@ -173,8 +160,25 @@ KBUILD_CFLAGS += -Wtype-limits
 KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
 
+ifdef CONFIG_CC_IS_CLANG
+KBUILD_CFLAGS += -Winitializer-overrides
+endif
+
 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
 
+else
+
+# The following turn off the warnings enabled by -Wextra
+KBUILD_CFLAGS += -Wno-missing-field-initializers
+KBUILD_CFLAGS += -Wno-type-limits
+KBUILD_CFLAGS += -Wno-shift-negative-value
+
+ifdef CONFIG_CC_IS_CLANG
+KBUILD_CFLAGS += -Wno-initializer-overrides
+else
+KBUILD_CFLAGS += -Wno-maybe-uninitialized
+endif
+
 endif
 
 #
@@ -196,6 +200,11 @@ KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
 
 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN3
 
+else
+
+# The following turn off the warnings enabled by -Wextra
+KBUILD_CFLAGS += -Wno-sign-compare
+
 endif
 
 #
-- 
2.39.2


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

* [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
                   ` (2 preceding siblings ...)
  2023-08-11 14:03 ` [PATCH 3/9] Kbuild: avoid duplicate warning options Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-12 12:04   ` Masahiro Yamada
  2023-08-11 14:03 ` [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1 Arnd Bergmann
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

The warning does nothing for newer versions of gcc since -fno-strict-overflow
is used, on old versions it warns about lines that would be undefined
otherwise:

fs/isofs/util.c: In function 'iso_date':
fs/isofs/util.c:40:14: error: left shift of negative value [-Werror=shift-negative-value]
    tz |= (-1 << 8);
              ^~
drivers/video/fbdev/tdfxfb.c: In function 'tdfxfb_probe':
drivers/video/fbdev/tdfxfb.c:1482:17: error: left shift of negative value [-Werror=shift-negative-value]
      (PAGE_MASK << 1);
                 ^~
drivers/tty/serial/8250/8250_core.c: In function 'serial8250_request_rsa_resource':
drivers/tty/serial/8250/8250_core.c:350:38: error: left shift of negative value [-Werror=shift-negative-value]
  unsigned long start = UART_RSA_BASE << up->port.regshift;
                                      ^~
drivers/tty/serial/8250/8250_core.c: In function 'serial8250_release_rsa_resource':
drivers/tty/serial/8250/8250_core.c:371:39: error: left shift of negative value [-Werror=shift-negative-value]
  unsigned long offset = UART_RSA_BASE << up->port.regshift;
                                       ^~
drivers/clk/mvebu/dove-divider.c: In function 'dove_set_clock':
drivers/clk/mvebu/dove-divider.c:145:14: error: left shift of negative value [-Werror=shift-negative-value]
  mask = ~(~0 << dc->div_bit_size) << dc->div_bit_start;
              ^~
drivers/block/drbd/drbd_main.c: In function 'dcbp_set_pad_bits':
drivers/block/drbd/drbd_main.c:1098:37: error: left shift of negative value [-Werror=shift-negative-value]
  p->encoding = (p->encoding & (~0x7 << 4)) | (n << 4);

Disable these conditionally to keep the command line a little shorter.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 8afbe4706ff11..87bfe153198f1 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -171,12 +171,14 @@ else
 # The following turn off the warnings enabled by -Wextra
 KBUILD_CFLAGS += -Wno-missing-field-initializers
 KBUILD_CFLAGS += -Wno-type-limits
-KBUILD_CFLAGS += -Wno-shift-negative-value
 
 ifdef CONFIG_CC_IS_CLANG
 KBUILD_CFLAGS += -Wno-initializer-overrides
 else
 KBUILD_CFLAGS += -Wno-maybe-uninitialized
+ifneq ($(call gcc-min-version, 90100),y)
+KBUILD_CFLAGS += $(call cc-disable-warning, shift-negative-value)
+endif
 endif
 
 endif
-- 
2.39.2


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

* [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
                   ` (3 preceding siblings ...)
  2023-08-11 14:03 ` [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9 Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-12 13:10   ` Masahiro Yamada
  2023-08-11 14:03 ` [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings Arnd Bergmann
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

The stringop and format warnings got disabled globally when they were
newly introduced in commit bd664f6b3e376 ("disable new gcc-7.1.1 warnings
for now"), 217c3e0196758 ("disable stringop truncation warnings for now")
and 5a76021c2eff7 ("gcc-10: disable 'stringop-overflow' warning for now").

In all cases, the sentiment at the time was that the warnings are
useful, and we actually addressed a number of real bugs based on
them, but we never managed to eliminate them all because even the
build bots using W=1 builds only see the -Wstringop-truncation
warnings that are enabled at that level.

Move these into the W=1 section to give them a larger build coverage
and actually eliminate them over time.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 87bfe153198f1..ec528972371fa 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -16,8 +16,6 @@ KBUILD_CFLAGS += -Werror=strict-prototypes
 KBUILD_CFLAGS += -Wno-format-security
 KBUILD_CFLAGS += -Wno-trigraphs
 KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
-KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
-KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 
 ifneq ($(CONFIG_FRAME_WARN),0)
@@ -56,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign
 # globally built with -Wcast-function-type.
 KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
 
-# We'll want to enable this eventually, but it's not going away for 5.7 at least
-KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
-
 # Another good warning that we'll want to enable eventually
 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
 
@@ -111,6 +106,9 @@ KBUILD_CFLAGS += -Wmissing-include-dirs
 KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
+KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
+KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
+KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
 KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
 
 KBUILD_CPPFLAGS += -Wundef
@@ -123,6 +121,9 @@ else
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 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)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
+KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
 
 ifdef CONFIG_CC_IS_CLANG
-- 
2.39.2


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

* [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
                   ` (4 preceding siblings ...)
  2023-08-11 14:03 ` [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1 Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-12 13:20   ` Masahiro Yamada
  2023-08-20  1:45   ` Masahiro Yamada
  2023-08-11 14:03 ` [PATCH 7/9] extrawarn: do not disable -Wmain at W=1 level Arnd Bergmann
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

There are few of these, so enable them whenever W=1 is enabled.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index ec528972371fa..8abe90270b335 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -54,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign
 # globally built with -Wcast-function-type.
 KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
 
-# Another good warning that we'll want to enable eventually
-KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
-
 # The allocators already balk at large sizes, so silence the compiler
 # warnings for bounds checks involving those possible values. While
 # -Wno-alloc-size-larger-than would normally be used here, earlier versions
@@ -99,6 +96,7 @@ ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 
 KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
 KBUILD_CFLAGS += -Wmissing-declarations
+KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
 KBUILD_CFLAGS += -Wmissing-format-attribute
 KBUILD_CFLAGS += -Wmissing-prototypes
 KBUILD_CFLAGS += -Wold-style-definition
@@ -120,6 +118,7 @@ else
 # Suppress them by using -Wno... except for W=1.
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
-- 
2.39.2


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

* [PATCH 7/9] extrawarn: do not disable -Wmain at W=1 level
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
                   ` (5 preceding siblings ...)
  2023-08-11 14:03 ` [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 8/9] extrawarn: enable more warnings in W=2 Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default Arnd Bergmann
  8 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

There is only one function in architecture independent code that has
a local variable named main(), and it seems fine to warn about this
at the W=1 level, so move it there to declutter the normal command
line slightly.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 8abe90270b335..8fd76da9042f8 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -29,10 +29,6 @@ KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
 ifdef CONFIG_CC_IS_CLANG
 # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
 KBUILD_CFLAGS += -Wno-gnu
-else
-
-# gcc inanely warns about local variables called 'main'
-KBUILD_CFLAGS += -Wno-main
 endif
 
 # These warnings generated too much noise in a regular build.
@@ -143,6 +139,8 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
 KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
 KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
 KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
+else
+KBUILD_CFLAGS += -Wno-main
 endif
 
 endif
-- 
2.39.2


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

* [PATCH 8/9] extrawarn: enable more warnings in W=2
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
                   ` (6 preceding siblings ...)
  2023-08-11 14:03 ` [PATCH 7/9] extrawarn: do not disable -Wmain at W=1 level Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-11 14:03 ` [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default Arnd Bergmann
  8 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

These four warning options are always disabled, but actually meet the
criteria for W=2, as they are sometimes useful and not prohibitively
noisy:

 -Wformat-security
 -Wframe-address
 -Waddress-of-packed-member
 -Wtrigraphs

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 8fd76da9042f8..1e6822b22c260 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -13,10 +13,6 @@ KBUILD_CFLAGS += -Werror=implicit-function-declaration
 KBUILD_CFLAGS += -Werror=implicit-int
 KBUILD_CFLAGS += -Werror=return-type
 KBUILD_CFLAGS += -Werror=strict-prototypes
-KBUILD_CFLAGS += -Wno-format-security
-KBUILD_CFLAGS += -Wno-trigraphs
-KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
-KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 
 ifneq ($(CONFIG_FRAME_WARN),0)
 KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
@@ -157,6 +153,10 @@ KBUILD_CFLAGS += -Wmissing-field-initializers
 KBUILD_CFLAGS += -Wtype-limits
 KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
+KBUILD_CFLAGS += $(call cc-option, -Waddress-of-packed-member)
+KBUILD_CFLAGS += $(call cc-option, -Wframe-address)
+KBUILD_CFLAGS += -Wformat-security
+KBUILD_CFLAGS += -Wtrigraphs
 
 ifdef CONFIG_CC_IS_CLANG
 KBUILD_CFLAGS += -Winitializer-overrides
@@ -169,6 +169,10 @@ else
 # The following turn off the warnings enabled by -Wextra
 KBUILD_CFLAGS += -Wno-missing-field-initializers
 KBUILD_CFLAGS += -Wno-type-limits
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+KBUILD_CFLAGS += $(call cc-disable-warning, frame-address)
+KBUILD_CFLAGS += -Wno-format-security
+KBUILD_CFLAGS += -Wno-trigraphs
 
 ifdef CONFIG_CC_IS_CLANG
 KBUILD_CFLAGS += -Wno-initializer-overrides
-- 
2.39.2


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

* [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default
  2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
                   ` (7 preceding siblings ...)
  2023-08-11 14:03 ` [PATCH 8/9] extrawarn: enable more warnings in W=2 Arnd Bergmann
@ 2023-08-11 14:03 ` Arnd Bergmann
  2023-08-11 16:09   ` Nathan Chancellor
  8 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

From: Arnd Bergmann <arnd@arndb.de>

A number of warning options from the W=1 set are completely clean in current
kernels, so we should just enable them by default, including a lot of warnings
that are part of -Wextra, so just turn on -Wextra by default.

The -Woverride-init, -Wvoid-pointer-to-enum-cast and
-Wmissing-format-attribute warnings are part of -Wextra but still produce
some legitimate warnings that need to be fixed, so leave them at the
W=1 level but turn them off otherwise.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1e6822b22c260..9185d69727542 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -72,6 +72,12 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
 # Warn if there is an enum types mismatch
 KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
 
+KBUILD_CFLAGS += -Wextra
+KBUILD_CFLAGS += -Wunused -Wno-unused-parameter
+KBUILD_CFLAGS += -Wold-style-definition
+KBUILD_CFLAGS += -Wmissing-include-dirs
+KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
+
 # backward compatibility
 KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
 
@@ -86,16 +92,11 @@ export KBUILD_EXTRA_WARN
 #
 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
 
-KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
 KBUILD_CFLAGS += -Wmissing-declarations
-KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
 KBUILD_CFLAGS += -Wmissing-format-attribute
 KBUILD_CFLAGS += -Wmissing-prototypes
-KBUILD_CFLAGS += -Wold-style-definition
-KBUILD_CFLAGS += -Wmissing-include-dirs
 KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
-KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
 KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
 KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
 KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
@@ -110,8 +111,7 @@ else
 # Suppress them by using -Wno... except for W=1.
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
-KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
+KBUILD_CFLAGS += $(call cc-disable-warning, missing-format-attribute)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
 KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
@@ -131,12 +131,10 @@ ifeq ($(call clang-min-version, 120000),y)
 KBUILD_CFLAGS += -Wformat-insufficient-args
 endif
 endif
-KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
-KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
-KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
-KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
+KBUILD_CFLAGS += -Wno-void-pointer-to-enum-cast
 else
 KBUILD_CFLAGS += -Wno-main
+KBUILD_CFLAGS += -Wno-override-init
 endif
 
 endif
-- 
2.39.2


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

* Re: [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc
  2023-08-11 14:03 ` [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc Arnd Bergmann
@ 2023-08-11 14:14   ` Nathan Chancellor
  2023-08-11 14:23     ` Arnd Bergmann
  0 siblings, 1 reply; 28+ messages in thread
From: Nathan Chancellor @ 2023-08-11 14:14 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Masahiro Yamada, Arnd Bergmann, Nick Desaulniers, Nicolas Schier,
	Guenter Roeck, Lee Jones, Stephen Rothwell, linux-kbuild,
	linux-arch

On Fri, Aug 11, 2023 at 04:03:19PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang ignores the -fno-inline-functions-called-once option, but warns
> when building with -Wignored-optimization-argument enabled:
> 
> clang: error: optimization flag '-fno-inline-functions-called-once' is not supported [-Werror,-Wignored-optimization-argument]
> 
> Move it back to using cc-option for this one.
> 
> Fixes: 7d73c3e9c514 ("Makefile: remove stale cc-option checks")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

How can this even be hit with clang, as CONFIG_DEBUG_SECTION_MISMATCH
was changed to depend on GCC in the same commit?

> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index bf5a6100cf66e..991c02f8e9ac0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -967,7 +967,7 @@ endif
>  
>  # We trigger additional mismatches with less inlining
>  ifdef CONFIG_DEBUG_SECTION_MISMATCH
> -KBUILD_CFLAGS += -fno-inline-functions-called-once
> +KBUILD_CFLAGS += $(call cc-option,-fno-inline-functions-called-once)
>  endif
>  
>  # `rustc`'s `-Zfunction-sections` applies to data too (as of 1.59.0).
> -- 
> 2.39.2
> 

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

* Re: [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn
  2023-08-11 14:03 ` [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn Arnd Bergmann
@ 2023-08-11 14:19   ` Nathan Chancellor
  2023-08-11 14:26     ` Arnd Bergmann
  0 siblings, 1 reply; 28+ messages in thread
From: Nathan Chancellor @ 2023-08-11 14:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Masahiro Yamada, Arnd Bergmann, Nick Desaulniers, Nicolas Schier,
	Guenter Roeck, Lee Jones, Stephen Rothwell, linux-kbuild,
	linux-arch

On Fri, Aug 11, 2023 at 04:03:20PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Warning options are enabled and disabled in inconsistent ways and
> inconsistent locations. Start rearranging those by moving all options
> into Makefile.extrawarn.
> 
> This should not change any behavior, but makes sure we can group them
> in a way that ensures that each warning that got temporarily disabled
> is turned back on at an appropriate W=1 level later on.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  Makefile                   | 88 -------------------------------------
>  scripts/Makefile.extrawarn | 90 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+), 88 deletions(-)

This shuffle seems reasonable to me. Would it make sense to rename the
Makefile from Makefile.extrawarn to just Makefile.warn or
Makefile.warnings? They are still "extra" warnings but to me, the
meaning of the Makefile is changing so it seems reasonable to drop the
"extra" part.

Cheers,
Nathan

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

* Re: [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc
  2023-08-11 14:14   ` Nathan Chancellor
@ 2023-08-11 14:23     ` Arnd Bergmann
  0 siblings, 0 replies; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:23 UTC (permalink / raw)
  To: Nathan Chancellor, Arnd Bergmann
  Cc: Masahiro Yamada, Nick Desaulniers, Nicolas Schier, Guenter Roeck,
	Lee Jones, Stephen Rothwell, linux-kbuild, Linux-Arch

On Fri, Aug 11, 2023, at 16:14, Nathan Chancellor wrote:
> On Fri, Aug 11, 2023 at 04:03:19PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> clang ignores the -fno-inline-functions-called-once option, but warns
>> when building with -Wignored-optimization-argument enabled:
>> 
>> clang: error: optimization flag '-fno-inline-functions-called-once' is not supported [-Werror,-Wignored-optimization-argument]
>> 
>> Move it back to using cc-option for this one.
>> 
>> Fixes: 7d73c3e9c514 ("Makefile: remove stale cc-option checks")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> How can this even be hit with clang, as CONFIG_DEBUG_SECTION_MISMATCH
> was changed to depend on GCC in the same commit?

Good question, I have not noticed that part, but I'm pretty
sure I keep hitting this issue. I'll drop it from my
series to see if I can reproduce it.

Maybe what happens is that this triggers when changing from
gcc to clang in an output directory, the stake CONFIG_*
symbols are still evaluated while parsing the initial
Makefile but then cause problems.

     Arnd

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

* Re: [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn
  2023-08-11 14:19   ` Nathan Chancellor
@ 2023-08-11 14:26     ` Arnd Bergmann
  2023-08-12  7:21       ` Masahiro Yamada
  2023-08-20  1:36       ` Masahiro Yamada
  0 siblings, 2 replies; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 14:26 UTC (permalink / raw)
  To: Nathan Chancellor, Arnd Bergmann
  Cc: Masahiro Yamada, Nick Desaulniers, Nicolas Schier, Guenter Roeck,
	Lee Jones, Stephen Rothwell, linux-kbuild, Linux-Arch

On Fri, Aug 11, 2023, at 16:19, Nathan Chancellor wrote:
> On Fri, Aug 11, 2023 at 04:03:20PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> Warning options are enabled and disabled in inconsistent ways and
>> inconsistent locations. Start rearranging those by moving all options
>> into Makefile.extrawarn.
>> 
>> This should not change any behavior, but makes sure we can group them
>> in a way that ensures that each warning that got temporarily disabled
>> is turned back on at an appropriate W=1 level later on.
>> 
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>>  Makefile                   | 88 -------------------------------------
>>  scripts/Makefile.extrawarn | 90 ++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 90 insertions(+), 88 deletions(-)
>
> This shuffle seems reasonable to me. Would it make sense to rename the
> Makefile from Makefile.extrawarn to just Makefile.warn or
> Makefile.warnings? They are still "extra" warnings but to me, the
> meaning of the Makefile is changing so it seems reasonable to drop the
> "extra" part.

Renaming the file seems fine, but I'd much prefer to do that separately
if we decide to do it, otherwise rebasing my patches is going to
be even more painful.

     Arnd

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

* Re: [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default
  2023-08-11 14:03 ` [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default Arnd Bergmann
@ 2023-08-11 16:09   ` Nathan Chancellor
  2023-08-11 18:23     ` Arnd Bergmann
  0 siblings, 1 reply; 28+ messages in thread
From: Nathan Chancellor @ 2023-08-11 16:09 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Masahiro Yamada, Arnd Bergmann, Nick Desaulniers, Nicolas Schier,
	Guenter Roeck, Lee Jones, Stephen Rothwell, linux-kbuild,
	linux-arch

On Fri, Aug 11, 2023 at 04:03:27PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> A number of warning options from the W=1 set are completely clean in current
> kernels, so we should just enable them by default, including a lot of warnings
> that are part of -Wextra, so just turn on -Wextra by default.
> 
> The -Woverride-init, -Wvoid-pointer-to-enum-cast and
> -Wmissing-format-attribute warnings are part of -Wextra but still produce
> some legitimate warnings that need to be fixed, so leave them at the
> W=1 level but turn them off otherwise.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
...
> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
> -KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
> -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)

I am still running through my builds but I don't think that dropping
these three is acceptable at the moment. I see a good number of all of
these warnings in -next still. I see some patches that I have picked up
to address a couple of the really noisy ones but some others that I
looked at are not fixed. I'll have a list eventually.

Cheers,
Nathan

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

* Re: [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default
  2023-08-11 16:09   ` Nathan Chancellor
@ 2023-08-11 18:23     ` Arnd Bergmann
  2023-08-14 19:52       ` Nathan Chancellor
  0 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-11 18:23 UTC (permalink / raw)
  To: Nathan Chancellor, Arnd Bergmann
  Cc: Masahiro Yamada, Nick Desaulniers, Nicolas Schier, Guenter Roeck,
	Lee Jones, Stephen Rothwell, linux-kbuild, Linux-Arch

On Fri, Aug 11, 2023, at 18:09, Nathan Chancellor wrote:
> On Fri, Aug 11, 2023 at 04:03:27PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> A number of warning options from the W=1 set are completely clean in current
>> kernels, so we should just enable them by default, including a lot of warnings
>> that are part of -Wextra, so just turn on -Wextra by default.
>> 
>> The -Woverride-init, -Wvoid-pointer-to-enum-cast and
>> -Wmissing-format-attribute warnings are part of -Wextra but still produce
>> some legitimate warnings that need to be fixed, so leave them at the
>> W=1 level but turn them off otherwise.
>> 
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ...
>> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
>> -KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
>> -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
>
> I am still running through my builds but I don't think that dropping
> these three is acceptable at the moment. I see a good number of all of
> these warnings in -next still. I see some patches that I have picked up
> to address a couple of the really noisy ones but some others that I
> looked at are not fixed. I'll have a list eventually.

Ok, thanks. I have a backlog of warning fixes in my randconfig
tree, which is currently clean with these warnings addressed, at
least on arm/arm64/x86 and it looks like there are a couple that
I've never sent out so far. I'll drop the above for now, as I
won't have time to send all the fixes before my vacation.

I can provide the ones I have off-list for reference, but there
are a couple that are missing changelog texts or that I'm not
entirely sure about myself.

    Arnd

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

* Re: [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn
  2023-08-11 14:26     ` Arnd Bergmann
@ 2023-08-12  7:21       ` Masahiro Yamada
  2023-08-20  1:36       ` Masahiro Yamada
  1 sibling, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-12  7:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Nathan Chancellor, Arnd Bergmann, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, Linux-Arch

On Fri, Aug 11, 2023 at 11:45 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Fri, Aug 11, 2023, at 16:19, Nathan Chancellor wrote:
> > On Fri, Aug 11, 2023 at 04:03:20PM +0200, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >>
> >> Warning options are enabled and disabled in inconsistent ways and
> >> inconsistent locations. Start rearranging those by moving all options
> >> into Makefile.extrawarn.
> >>
> >> This should not change any behavior, but makes sure we can group them
> >> in a way that ensures that each warning that got temporarily disabled
> >> is turned back on at an appropriate W=1 level later on.
> >>
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >> ---
> >>  Makefile                   | 88 -------------------------------------
> >>  scripts/Makefile.extrawarn | 90 ++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 90 insertions(+), 88 deletions(-)
> >
> > This shuffle seems reasonable to me. Would it make sense to rename the
> > Makefile from Makefile.extrawarn to just Makefile.warn or
> > Makefile.warnings? They are still "extra" warnings but to me, the
> > meaning of the Makefile is changing so it seems reasonable to drop the
> > "extra" part.
>
> Renaming the file seems fine, but I'd much prefer to do that separately
> if we decide to do it, otherwise rebasing my patches is going to
> be even more painful.
>
>      Arnd


Nice cleanups.
I like this, and renaming the file
(as a separate patch).



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 3/9] Kbuild: avoid duplicate warning options
  2023-08-11 14:03 ` [PATCH 3/9] Kbuild: avoid duplicate warning options Arnd Bergmann
@ 2023-08-12  9:21   ` Masahiro Yamada
  2023-08-12  9:28     ` Arnd Bergmann
  0 siblings, 1 reply; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-12  9:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

On Sat, Aug 12, 2023 at 5:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Some warning options are disabled at one place and then conditionally
> re-enabled later in scripts/Makefile.extrawarn.
>
> For consistency, rework this file so each of those warnings only
> gets etiher enabled or disabled based on the W= flags but not both.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  scripts/Makefile.extrawarn | 43 +++++++++++++++++++++++---------------
>  1 file changed, 26 insertions(+), 17 deletions(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 9cc0e52ebd7eb..8afbe4706ff11 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -56,20 +56,12 @@ KBUILD_CFLAGS += -Wno-pointer-sign
>  # globally built with -Wcast-function-type.
>  KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
>
> -# disable stringop warnings in gcc 8+
> -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
> -
>  # We'll want to enable this eventually, but it's not going away for 5.7 at least
>  KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
>
>  # Another good warning that we'll want to enable eventually
>  KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>
> -# Enabled with W=2, disabled by default as noisy
> -ifdef CONFIG_CC_IS_GCC
> -KBUILD_CFLAGS += -Wno-maybe-uninitialized
> -endif
> -
>  # The allocators already balk at large sizes, so silence the compiler
>  # warnings for bounds checks involving those possible values. While
>  # -Wno-alloc-size-larger-than would normally be used here, earlier versions
> @@ -96,8 +88,6 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
>  # Warn if there is an enum types mismatch
>  KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
>
> -KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
> -
>  # backward compatibility
>  KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
>
> @@ -122,11 +112,6 @@ KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
>  KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
>  KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
>  KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
> -# The following turn off the warnings enabled by -Wextra
> -KBUILD_CFLAGS += -Wno-missing-field-initializers
> -KBUILD_CFLAGS += -Wno-sign-compare
> -KBUILD_CFLAGS += -Wno-type-limits
> -KBUILD_CFLAGS += -Wno-shift-negative-value
>
>  KBUILD_CPPFLAGS += -Wundef
>  KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
> @@ -135,9 +120,12 @@ else
>
>  # Some diagnostics enabled by default are noisy.
>  # Suppress them by using -Wno... except for W=1.
> +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
> +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
> +KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
> +KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
>
>  ifdef CONFIG_CC_IS_CLANG
> -KBUILD_CFLAGS += -Wno-initializer-overrides
>  # Clang before clang-16 would warn on default argument promotions.
>  ifneq ($(call clang-min-version, 160000),y)
>  # Disable -Wformat
> @@ -151,7 +139,6 @@ ifeq ($(call clang-min-version, 120000),y)
>  KBUILD_CFLAGS += -Wformat-insufficient-args
>  endif
>  endif
> -KBUILD_CFLAGS += -Wno-sign-compare
>  KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
>  KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
>  KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
> @@ -173,8 +160,25 @@ KBUILD_CFLAGS += -Wtype-limits
>  KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
>  KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
>
> +ifdef CONFIG_CC_IS_CLANG
> +KBUILD_CFLAGS += -Winitializer-overrides
> +endif
> +
>  KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
>
> +else
> +
> +# The following turn off the warnings enabled by -Wextra
> +KBUILD_CFLAGS += -Wno-missing-field-initializers
> +KBUILD_CFLAGS += -Wno-type-limits
> +KBUILD_CFLAGS += -Wno-shift-negative-value
> +
> +ifdef CONFIG_CC_IS_CLANG
> +KBUILD_CFLAGS += -Wno-initializer-overrides
> +else
> +KBUILD_CFLAGS += -Wno-maybe-uninitialized




GCC manual says -Wall implies -Wmaybe-uninitialized.

If you move -Wno-maybe-uninitialize to the "W != 2" part,
-Wmaybe-uninitialized is unneeded in the 'W == 2" part.

Maybe, the same applies to -Wunused-but-set-parameter.

Shall we drop warnings implied by another, or
is it clearer to explicitly add either -Wfoo or -Wno-foo?

If desired, we can do such a clean-up later, though.







--
Best Regards
Masahiro Yamada

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

* Re: [PATCH 3/9] Kbuild: avoid duplicate warning options
  2023-08-12  9:21   ` Masahiro Yamada
@ 2023-08-12  9:28     ` Arnd Bergmann
  2023-08-20  1:38       ` Masahiro Yamada
  0 siblings, 1 reply; 28+ messages in thread
From: Arnd Bergmann @ 2023-08-12  9:28 UTC (permalink / raw)
  To: Masahiro Yamada, Arnd Bergmann
  Cc: Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	Guenter Roeck, Lee Jones, Stephen Rothwell, linux-kbuild,
	Linux-Arch

On Sat, Aug 12, 2023, at 11:21, Masahiro Yamada wrote:
> On Sat, Aug 12, 2023 at 5:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> GCC manual says -Wall implies -Wmaybe-uninitialized.
>
> If you move -Wno-maybe-uninitialize to the "W != 2" part,
> -Wmaybe-uninitialized is unneeded in the 'W == 2" part.
>
> Maybe, the same applies to -Wunused-but-set-parameter.
>
> Shall we drop warnings implied by another, or
> is it clearer to explicitly add either -Wfoo or -Wno-foo?
>
> If desired, we can do such a clean-up later, though.

Right, we can probably drop that, I've gone back and forth
on this how to handle these. Some of the warnings are
handled differently between gcc and clang, or differently
between compiler versions, where they are sometimes
implied and sometimes need to be specified explicitly.

What I've tried to do here is to do the change in the least
invasive way to ensure that this larger patch does not
change the behavior. My preference would be for you
to merge it like this unless you see a bug, and then
do another cleanup pass where we remove the ones implied
by either -Wall or -Wextra on all known versions.

I'll be on vacation the next few weeks starting on
Tuesday and will be able to reply to emails, but won't
have a chance to sufficiently test any significant
reworks of my series before the merge window.

    Arnd

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

* Re: [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9
  2023-08-11 14:03 ` [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9 Arnd Bergmann
@ 2023-08-12 12:04   ` Masahiro Yamada
  0 siblings, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-12 12:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

On Sat, Aug 12, 2023 at 5:00 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> The warning does nothing for newer versions of gcc since -fno-strict-overflow
> is used, on old versions it warns about lines that would be undefined
> otherwise:
>
> fs/isofs/util.c: In function 'iso_date':
> fs/isofs/util.c:40:14: error: left shift of negative value [-Werror=shift-negative-value]
>     tz |= (-1 << 8);
>               ^~
> drivers/video/fbdev/tdfxfb.c: In function 'tdfxfb_probe':
> drivers/video/fbdev/tdfxfb.c:1482:17: error: left shift of negative value [-Werror=shift-negative-value]
>       (PAGE_MASK << 1);
>                  ^~
> drivers/tty/serial/8250/8250_core.c: In function 'serial8250_request_rsa_resource':
> drivers/tty/serial/8250/8250_core.c:350:38: error: left shift of negative value [-Werror=shift-negative-value]
>   unsigned long start = UART_RSA_BASE << up->port.regshift;
>                                       ^~
> drivers/tty/serial/8250/8250_core.c: In function 'serial8250_release_rsa_resource':
> drivers/tty/serial/8250/8250_core.c:371:39: error: left shift of negative value [-Werror=shift-negative-value]
>   unsigned long offset = UART_RSA_BASE << up->port.regshift;
>                                        ^~
> drivers/clk/mvebu/dove-divider.c: In function 'dove_set_clock':
> drivers/clk/mvebu/dove-divider.c:145:14: error: left shift of negative value [-Werror=shift-negative-value]
>   mask = ~(~0 << dc->div_bit_size) << dc->div_bit_start;
>               ^~
> drivers/block/drbd/drbd_main.c: In function 'dcbp_set_pad_bits':
> drivers/block/drbd/drbd_main.c:1098:37: error: left shift of negative value [-Werror=shift-negative-value]
>   p->encoding = (p->encoding & (~0x7 << 4)) | (n << 4);
>
> Disable these conditionally to keep the command line a little shorter.



Just a nit for the commit subject and description.

It mentions only gcc, but also affects clang.




Is the following a better subject?

  extrawarn: don't turn off -Wshift-negative-value for gcc-9+ or clang

or

  extrawarn: turn off -Wshift-negative-value only for gcc < 9






-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1
  2023-08-11 14:03 ` [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1 Arnd Bergmann
@ 2023-08-12 13:10   ` Masahiro Yamada
  2023-08-20  1:40     ` Masahiro Yamada
  2023-08-21 18:26     ` Nick Desaulniers
  0 siblings, 2 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-12 13:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

On Sat, Aug 12, 2023 at 10:50 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> The stringop and format warnings got disabled globally when they were
> newly introduced in commit bd664f6b3e376 ("disable new gcc-7.1.1 warnings
> for now"), 217c3e0196758 ("disable stringop truncation warnings for now")
> and 5a76021c2eff7 ("gcc-10: disable 'stringop-overflow' warning for now").
>
> In all cases, the sentiment at the time was that the warnings are
> useful, and we actually addressed a number of real bugs based on
> them, but we never managed to eliminate them all because even the
> build bots using W=1 builds only see the -Wstringop-truncation
> warnings that are enabled at that level.
>
> Move these into the W=1 section to give them a larger build coverage
> and actually eliminate them over time.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  scripts/Makefile.extrawarn | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 87bfe153198f1..ec528972371fa 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -16,8 +16,6 @@ KBUILD_CFLAGS += -Werror=strict-prototypes
>  KBUILD_CFLAGS += -Wno-format-security
>  KBUILD_CFLAGS += -Wno-trigraphs
>  KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
> -KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
> -KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
>  KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
>
>  ifneq ($(CONFIG_FRAME_WARN),0)
> @@ -56,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign
>  # globally built with -Wcast-function-type.
>  KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
>
> -# We'll want to enable this eventually, but it's not going away for 5.7 at least
> -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
> -
>  # Another good warning that we'll want to enable eventually
>  KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>
> @@ -111,6 +106,9 @@ KBUILD_CFLAGS += -Wmissing-include-dirs
>  KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
>  KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
>  KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
> +KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
> +KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)


These are redundant because -Wall implies
-Wformat-overflow and -Wformat-truncation
according to the GCC manual.




-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings
  2023-08-11 14:03 ` [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings Arnd Bergmann
@ 2023-08-12 13:20   ` Masahiro Yamada
  2023-08-20  1:45   ` Masahiro Yamada
  1 sibling, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-12 13:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

On Sat, Aug 12, 2023 at 4:40 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> There are few of these, so enable them whenever W=1 is enabled.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  scripts/Makefile.extrawarn | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index ec528972371fa..8abe90270b335 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -54,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign
>  # globally built with -Wcast-function-type.
>  KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
>
> -# Another good warning that we'll want to enable eventually
> -KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
> -
>  # The allocators already balk at large sizes, so silence the compiler
>  # warnings for bounds checks involving those possible values. While
>  # -Wno-alloc-size-larger-than would normally be used here, earlier versions
> @@ -99,6 +96,7 @@ ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
>
>  KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
>  KBUILD_CFLAGS += -Wmissing-declarations
> +KBUILD_CFLAGS += $(call cc-option, -Wrestrict)


Like the previous patch, -Wall implies -Wrestrict.

I'd like to remove it as we can save cc-option call.




>  KBUILD_CFLAGS += -Wmissing-format-attribute
>  KBUILD_CFLAGS += -Wmissing-prototypes
>  KBUILD_CFLAGS += -Wold-style-definition
> @@ -120,6 +118,7 @@ else
>  # Suppress them by using -Wno... except for W=1.
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
> +KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>  KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
> --
> 2.39.2
>


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default
  2023-08-11 18:23     ` Arnd Bergmann
@ 2023-08-14 19:52       ` Nathan Chancellor
  0 siblings, 0 replies; 28+ messages in thread
From: Nathan Chancellor @ 2023-08-14 19:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Masahiro Yamada, Nick Desaulniers, Nicolas Schier,
	Guenter Roeck, Lee Jones, Stephen Rothwell, linux-kbuild,
	Linux-Arch

On Fri, Aug 11, 2023 at 08:23:45PM +0200, Arnd Bergmann wrote:
> On Fri, Aug 11, 2023, at 18:09, Nathan Chancellor wrote:
> > On Fri, Aug 11, 2023 at 04:03:27PM +0200, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >> 
> >> A number of warning options from the W=1 set are completely clean in current
> >> kernels, so we should just enable them by default, including a lot of warnings
> >> that are part of -Wextra, so just turn on -Wextra by default.
> >> 
> >> The -Woverride-init, -Wvoid-pointer-to-enum-cast and
> >> -Wmissing-format-attribute warnings are part of -Wextra but still produce
> >> some legitimate warnings that need to be fixed, so leave them at the
> >> W=1 level but turn them off otherwise.
> >> 
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ...
> >> -KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare
> >> -KBUILD_CFLAGS += $(call cc-disable-warning, unaligned-access)
> >> -KBUILD_CFLAGS += $(call cc-disable-warning, cast-function-type-strict)
> >
> > I am still running through my builds but I don't think that dropping
> > these three is acceptable at the moment. I see a good number of all of
> > these warnings in -next still. I see some patches that I have picked up
> > to address a couple of the really noisy ones but some others that I
> > looked at are not fixed. I'll have a list eventually.
> 
> Ok, thanks. I have a backlog of warning fixes in my randconfig
> tree, which is currently clean with these warnings addressed, at
> least on arm/arm64/x86 and it looks like there are a couple that
> I've never sent out so far. I'll drop the above for now, as I
> won't have time to send all the fixes before my vacation.

Thanks, that takes care of the vast majority of extra warnings that this
series produces. I have included all my build logs at [1].

The slightly-filtered-warnings file is the result of searching for all
warnings in the log files and passing them through 'sort | uniq -c',
additionally ignoring the instances of -Wnull-pointer-arithmetic that
are present in certain configurations, as those are pretty well known at
this point.

The more-filtered-warnings file does the same thing but also ignores
instances of the three warnings above, which just reveals some instances
of -Wunused-but-set-parameter, which I am pretty sure I have seen you
sent fixes for recently, so I think with those three warnings left as
disabled, this series should be safe.

[1]: https://github.com/nathanchance/bug-files/tree/9100c6a21cbdce3c03fbca1bd00a7c34f316a137/enable-more-W%3D1-warnings-by-default

Cheers,
Nathan

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

* Re: [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn
  2023-08-11 14:26     ` Arnd Bergmann
  2023-08-12  7:21       ` Masahiro Yamada
@ 2023-08-20  1:36       ` Masahiro Yamada
  1 sibling, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-20  1:36 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Nathan Chancellor, Arnd Bergmann, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, Linux-Arch

On Fri, Aug 11, 2023 at 11:45 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Fri, Aug 11, 2023, at 16:19, Nathan Chancellor wrote:
> > On Fri, Aug 11, 2023 at 04:03:20PM +0200, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >>
> >> Warning options are enabled and disabled in inconsistent ways and
> >> inconsistent locations. Start rearranging those by moving all options
> >> into Makefile.extrawarn.
> >>
> >> This should not change any behavior, but makes sure we can group them
> >> in a way that ensures that each warning that got temporarily disabled
> >> is turned back on at an appropriate W=1 level later on.
> >>
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >> ---
> >>  Makefile                   | 88 -------------------------------------
> >>  scripts/Makefile.extrawarn | 90 ++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 90 insertions(+), 88 deletions(-)
> >
> > This shuffle seems reasonable to me. Would it make sense to rename the
> > Makefile from Makefile.extrawarn to just Makefile.warn or
> > Makefile.warnings? They are still "extra" warnings but to me, the
> > meaning of the Makefile is changing so it seems reasonable to drop the
> > "extra" part.
>
> Renaming the file seems fine, but I'd much prefer to do that separately
> if we decide to do it, otherwise rebasing my patches is going to
> be even more painful.
>
>      Arnd

Applied  to linux-kbuild. Thanks.


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 3/9] Kbuild: avoid duplicate warning options
  2023-08-12  9:28     ` Arnd Bergmann
@ 2023-08-20  1:38       ` Masahiro Yamada
  0 siblings, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-20  1:38 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, Linux-Arch

On Sun, Aug 13, 2023 at 2:45 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sat, Aug 12, 2023, at 11:21, Masahiro Yamada wrote:
> > On Sat, Aug 12, 2023 at 5:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > GCC manual says -Wall implies -Wmaybe-uninitialized.
> >
> > If you move -Wno-maybe-uninitialize to the "W != 2" part,
> > -Wmaybe-uninitialized is unneeded in the 'W == 2" part.
> >
> > Maybe, the same applies to -Wunused-but-set-parameter.
> >
> > Shall we drop warnings implied by another, or
> > is it clearer to explicitly add either -Wfoo or -Wno-foo?
> >
> > If desired, we can do such a clean-up later, though.
>
> Right, we can probably drop that, I've gone back and forth
> on this how to handle these. Some of the warnings are
> handled differently between gcc and clang, or differently
> between compiler versions, where they are sometimes
> implied and sometimes need to be specified explicitly.
>
> What I've tried to do here is to do the change in the least
> invasive way to ensure that this larger patch does not
> change the behavior. My preference would be for you
> to merge it like this unless you see a bug, and then
> do another cleanup pass where we remove the ones implied
> by either -Wall or -Wextra on all known versions.
>
> I'll be on vacation the next few weeks starting on
> Tuesday and will be able to reply to emails, but won't
> have a chance to sufficiently test any significant
> reworks of my series before the merge window.
>
>     Arnd

Applied  to linux-kbuild. Thanks.

-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1
  2023-08-12 13:10   ` Masahiro Yamada
@ 2023-08-20  1:40     ` Masahiro Yamada
  2023-08-21 18:26     ` Nick Desaulniers
  1 sibling, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-20  1:40 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

On Sat, Aug 12, 2023 at 10:10 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Sat, Aug 12, 2023 at 10:50 AM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > The stringop and format warnings got disabled globally when they were
> > newly introduced in commit bd664f6b3e376 ("disable new gcc-7.1.1 warnings
> > for now"), 217c3e0196758 ("disable stringop truncation warnings for now")
> > and 5a76021c2eff7 ("gcc-10: disable 'stringop-overflow' warning for now").
> >
> > In all cases, the sentiment at the time was that the warnings are
> > useful, and we actually addressed a number of real bugs based on
> > them, but we never managed to eliminate them all because even the
> > build bots using W=1 builds only see the -Wstringop-truncation
> > warnings that are enabled at that level.
> >
> > Move these into the W=1 section to give them a larger build coverage
> > and actually eliminate them over time.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  scripts/Makefile.extrawarn | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> > index 87bfe153198f1..ec528972371fa 100644
> > --- a/scripts/Makefile.extrawarn
> > +++ b/scripts/Makefile.extrawarn
> > @@ -16,8 +16,6 @@ KBUILD_CFLAGS += -Werror=strict-prototypes
> >  KBUILD_CFLAGS += -Wno-format-security
> >  KBUILD_CFLAGS += -Wno-trigraphs
> >  KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
> > -KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
> > -KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
> >  KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
> >
> >  ifneq ($(CONFIG_FRAME_WARN),0)
> > @@ -56,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign
> >  # globally built with -Wcast-function-type.
> >  KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
> >
> > -# We'll want to enable this eventually, but it's not going away for 5.7 at least
> > -KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
> > -
> >  # Another good warning that we'll want to enable eventually
> >  KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
> >
> > @@ -111,6 +106,9 @@ KBUILD_CFLAGS += -Wmissing-include-dirs
> >  KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
> >  KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
> >  KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
> > +KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
> > +KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
>
>
> These are redundant because -Wall implies
> -Wformat-overflow and -Wformat-truncation
> according to the GCC manual.
>
>
>
>
> --
> Best Regards
> Masahiro Yamada


Applied  to linux-kbuild. Thanks.


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings
  2023-08-11 14:03 ` [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings Arnd Bergmann
  2023-08-12 13:20   ` Masahiro Yamada
@ 2023-08-20  1:45   ` Masahiro Yamada
  1 sibling, 0 replies; 28+ messages in thread
From: Masahiro Yamada @ 2023-08-20  1:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Guenter Roeck, Lee Jones, Stephen Rothwell,
	linux-kbuild, linux-arch

On Sat, Aug 12, 2023 at 4:40 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> There are few of these, so enable them whenever W=1 is enabled.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  scripts/Makefile.extrawarn | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index ec528972371fa..8abe90270b335 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -54,9 +54,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign
>  # globally built with -Wcast-function-type.
>  KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
>
> -# Another good warning that we'll want to enable eventually
> -KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
> -
>  # The allocators already balk at large sizes, so silence the compiler
>  # warnings for bounds checks involving those possible values. While
>  # -Wno-alloc-size-larger-than would normally be used here, earlier versions
> @@ -99,6 +96,7 @@ ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
>
>  KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
>  KBUILD_CFLAGS += -Wmissing-declarations
> +KBUILD_CFLAGS += $(call cc-option, -Wrestrict)
>  KBUILD_CFLAGS += -Wmissing-format-attribute
>  KBUILD_CFLAGS += -Wmissing-prototypes
>  KBUILD_CFLAGS += -Wold-style-definition
> @@ -120,6 +118,7 @@ else
>  # Suppress them by using -Wno... except for W=1.
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
> +KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>  KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
> --
> 2.39.2
>

Applied  to linux-kbuild. Thanks.
-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1
  2023-08-12 13:10   ` Masahiro Yamada
  2023-08-20  1:40     ` Masahiro Yamada
@ 2023-08-21 18:26     ` Nick Desaulniers
  1 sibling, 0 replies; 28+ messages in thread
From: Nick Desaulniers @ 2023-08-21 18:26 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Arnd Bergmann, Arnd Bergmann, Nathan Chancellor, Nicolas Schier,
	Guenter Roeck, Lee Jones, Stephen Rothwell, linux-kbuild,
	linux-arch, clang-built-linux

On Sat, Aug 12, 2023 at 6:11 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> These are redundant because -Wall implies
> -Wformat-overflow and -Wformat-truncation
> according to the GCC manual.

To triple check this grouping behavior in clang, there's a utility
called `diagtool`.

$ diagtool tree

will print the hierarchy of diagnostics and color code them to explain
whether they're on/off by default or not-implemented-but-recognized.

For the above two -Wformat-* warnings, note that clang does not yet
implement those.  I've filed
https://github.com/llvm/llvm-project/issues/64871 to track that.
-- 
Thanks,
~Nick Desaulniers

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

end of thread, other threads:[~2023-08-21 18:26 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11 14:03 [PATCH 0/9] Kbuild: warning options cleanup and more warnings Arnd Bergmann
2023-08-11 14:03 ` [PATCH 1/9] Kbuild: only pass -fno-inline-functions-called-once for gcc Arnd Bergmann
2023-08-11 14:14   ` Nathan Chancellor
2023-08-11 14:23     ` Arnd Bergmann
2023-08-11 14:03 ` [PATCH 2/9] Kbuild: consolidate warning flags in scripts/Makefile.extrawarn Arnd Bergmann
2023-08-11 14:19   ` Nathan Chancellor
2023-08-11 14:26     ` Arnd Bergmann
2023-08-12  7:21       ` Masahiro Yamada
2023-08-20  1:36       ` Masahiro Yamada
2023-08-11 14:03 ` [PATCH 3/9] Kbuild: avoid duplicate warning options Arnd Bergmann
2023-08-12  9:21   ` Masahiro Yamada
2023-08-12  9:28     ` Arnd Bergmann
2023-08-20  1:38       ` Masahiro Yamada
2023-08-11 14:03 ` [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9 Arnd Bergmann
2023-08-12 12:04   ` Masahiro Yamada
2023-08-11 14:03 ` [PATCH 5/9] extrawarn: enable format and stringop overflow warnings in W=1 Arnd Bergmann
2023-08-12 13:10   ` Masahiro Yamada
2023-08-20  1:40     ` Masahiro Yamada
2023-08-21 18:26     ` Nick Desaulniers
2023-08-11 14:03 ` [PATCH 6/9] extrawarn: move -Wrestrict into W=1 warnings Arnd Bergmann
2023-08-12 13:20   ` Masahiro Yamada
2023-08-20  1:45   ` Masahiro Yamada
2023-08-11 14:03 ` [PATCH 7/9] extrawarn: do not disable -Wmain at W=1 level Arnd Bergmann
2023-08-11 14:03 ` [PATCH 8/9] extrawarn: enable more warnings in W=2 Arnd Bergmann
2023-08-11 14:03 ` [PATCH 9/9] [RFC] extrawarn: enable more W=1 warnings by default Arnd Bergmann
2023-08-11 16:09   ` Nathan Chancellor
2023-08-11 18:23     ` Arnd Bergmann
2023-08-14 19:52       ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).