All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: "Marek Behún" <kabel@kernel.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Nathan Chancellor" <natechancellor@gmail.com>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Andrew Lunn" <andrew@lunn.ch>,
	netdev@vger.kernel.org
Subject: [PATCH kbuild] Makefile.extrawarn: disable -Woverride-init in W=1
Date: Wed,  7 Apr 2021 02:24:50 +0200	[thread overview]
Message-ID: <20210407002450.10015-1-kabel@kernel.org> (raw)

The -Wextra flag enables -Woverride-init in newer versions of GCC.

This causes the compiler to warn when a value is written twice in a
designated initializer, for example:
  int x[1] = {
    [0] = 3,
    [0] = 3,
  };

Note that for clang, this was disabled from the beginning with
-Wno-initializer-overrides in commit a1494304346a3 ("kbuild: add all
Clang-specific flags unconditionally").

This prevents us from implementing complex macros for compile-time
initializers.

For example a macro of the form INITIALIZE_BITMAP(bits...) that can be
used as
  static DECLARE_BITMAP(bm, 64) = INITIALIZE_BITMAP(0, 1, 32, 33);
can only be implemented by allowing a designated initializer to
initialize the same members multiple times (because the compiler
complains even if the multiple initializations initialize to the same
value).

Disable the -Woverride-init flag.

Signed-off-by: Marek Behún <kabel@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Nathan Chancellor <natechancellor@gmail.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org
---
 scripts/Makefile.extrawarn | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index d53825503874..cf7bc1eec5e3 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -36,6 +36,7 @@ KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
 KBUILD_CFLAGS += -Wno-missing-field-initializers
 KBUILD_CFLAGS += -Wno-sign-compare
 KBUILD_CFLAGS += -Wno-type-limits
+KBUILD_CFLAGS += $(call cc-disable-warning, override-init)
 
 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
 
-- 
2.26.2


             reply	other threads:[~2021-04-07  0:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07  0:24 Marek Behún [this message]
2021-04-07  7:14 ` Arnd Bergmann
2021-04-07 14:49   ` Marek Behún
2021-04-07 20:44   ` Marek Behún

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=20210407002450.10015-1-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH kbuild] Makefile.extrawarn: disable -Woverride-init in W=1' \
    /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

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.