linux-kbuild.vger.kernel.org archive mirror
 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 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9
Date: Fri, 11 Aug 2023 16:03:22 +0200	[thread overview]
Message-ID: <20230811140327.3754597-5-arnd@kernel.org> (raw)
In-Reply-To: <20230811140327.3754597-1-arnd@kernel.org>

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


  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 ` [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 ` Arnd Bergmann [this message]
2023-08-12 12:04   ` [PATCH 4/9] extrawarn: don't turn off -Wshift-negative-value for gcc-9 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-5-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 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).