All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>,
	Guenter Roeck <linux@roeck-us.net>, Lee Jones <lee@kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org
Subject: [PATCH 3/9] Kbuild: avoid duplicate warning options
Date: Fri, 11 Aug 2023 16:03:21 +0200	[thread overview]
Message-ID: <20230811140327.3754597-4-arnd@kernel.org> (raw)
In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org>

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


  parent reply	other threads:[~2023-08-11 14:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Arnd Bergmann [this message]
2023-08-12  9:21   ` [PATCH 3/9] Kbuild: avoid duplicate warning options 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230811140327.3754597-4-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=lee@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.