[PATCH] extrawarn: Use cc-disable-warning for shift-negative-value

WangYuli posted 1 patch 7 months, 1 week ago
scripts/Makefile.extrawarn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] extrawarn: Use cc-disable-warning for shift-negative-value
Posted by WangYuli 7 months, 1 week ago
The -Wno-shift-negative-value option is not supported by GCC 5.4.0.

This could potentially result in extra warnings under certain
circumstances.

Utilize cc-disable-warning to prevent the following from occurring:
  mm/vmscan.c: At top level:
  cc1: error: unrecognized command line option ‘-Wno-shift-negative-value’ [-Werror]
  cc1: all warnings being treated as errors

Link: https://lore.kernel.org/all/62726950F697595A+20250507040827.1147510-1-wangyuli@uniontech.com/
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 scripts/Makefile.extrawarn | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index d88acdf40855..375475e7b3bd 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -158,7 +158,7 @@ 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
+KBUILD_CFLAGS += $(call cc-disable-warning, shift-negative-value)
 
 ifdef CONFIG_CC_IS_CLANG
 KBUILD_CFLAGS += -Wno-enum-enum-conversion
-- 
2.49.0

Re: [PATCH] extrawarn: Use cc-disable-warning for shift-negative-value
Posted by Nathan Chancellor 7 months, 1 week ago
On Wed, May 07, 2025 at 01:47:05PM +0800, WangYuli wrote:
> The -Wno-shift-negative-value option is not supported by GCC 5.4.0.

The patch is fine (albeit slightly incomplete because other places add
this unconditionally) but this is not going to matter soon because the
minimum version of GCC is being bumped to 8.1:

https://git.kernel.org/next/linux-next/c/118c40b7b50340bf7ff7e0adee8e3bab6e552c82

Even though we claim to support GCC 5, I suspect that basically nobody
uses it in practice since this flag was added by 1344794a59db2.

> This could potentially result in extra warnings under certain
> circumstances.
> 
> Utilize cc-disable-warning to prevent the following from occurring:
>   mm/vmscan.c: At top level:
>   cc1: error: unrecognized command line option ‘-Wno-shift-negative-value’ [-Werror]
>   cc1: all warnings being treated as errors
> 
> Link: https://lore.kernel.org/all/62726950F697595A+20250507040827.1147510-1-wangyuli@uniontech.com/
> Signed-off-by: WangYuli <wangyuli@uniontech.com>
> ---
>  scripts/Makefile.extrawarn | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index d88acdf40855..375475e7b3bd 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -158,7 +158,7 @@ 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
> +KBUILD_CFLAGS += $(call cc-disable-warning, shift-negative-value)
>  
>  ifdef CONFIG_CC_IS_CLANG
>  KBUILD_CFLAGS += -Wno-enum-enum-conversion
> -- 
> 2.49.0
>