mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: Move -Wenum-enum-conversion to W=2
@ 2024-10-17 17:09 Nathan Chancellor
  2024-10-17 20:19 ` Arnd Bergmann
  2024-12-02 16:16 ` Nathan Chancellor
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2024-10-17 17:09 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Arnd Bergmann, Aleksei Vetrov, linux-kbuild, linux-kernel, llvm,
	patches, stable, Nathan Chancellor

-Wenum-enum-conversion was strengthened in clang-19 to warn for C, which
caused the kernel to move it to W=1 in commit 75b5ab134bb5 ("kbuild:
Move -Wenum-{compare-conditional,enum-conversion} into W=1") because
there were numerous instances that would break builds with -Werror.
Unfortunately, this is not a full solution, as more and more developers,
subsystems, and distributors are building with W=1 as well, so they
continue to see the numerous instances of this warning.

Since the move to W=1, there have not been many new instances that have
appeared through various build reports and the ones that have appeared
seem to be following similar existing patterns, suggesting that most
instances of this warning will not be real issues. The only alternatives
for silencing this warning are adding casts (which is generally seen as
an ugly practice) or refactoring the enums to macro defines or a unified
enum (which may be undesirable because of type safety in other parts of
the code).

Move the warning to W=2, where warnings that occur frequently but may be
relevant should reside.

Cc: stable@vger.kernel.org
Fixes: 75b5ab134bb5 ("kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1")
Link: https://lore.kernel.org/ZwRA9SOcOjjLJcpi@google.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Changes in v2:
- Move -Wenum-enum-conversion to W=2, instead of disabling it
  outright (Arnd)
- Leave -Wenum-compare-conditional in W=1, as there are not that
  many instances, so it can be turned on fully at some point (Arnd)
- Link to v1: https://lore.kernel.org/r/20241016-disable-two-clang-enum-warnings-v1-1-ae886d7a0269@kernel.org
---
 scripts/Makefile.extrawarn | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 1d13cecc7cc7808610e635ddc03476cf92b3a8c1..04faf15ed316a9c291dc952b6cc40fb6c8c330cf 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -130,7 +130,6 @@ 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 += -Wno-enum-compare-conditional
-KBUILD_CFLAGS += -Wno-enum-enum-conversion
 endif
 
 endif
@@ -154,6 +153,10 @@ 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-enum-enum-conversion
+endif
+
 ifdef CONFIG_CC_IS_GCC
 KBUILD_CFLAGS += -Wno-maybe-uninitialized
 endif

---
base-commit: 8e929cb546ee42c9a61d24fae60605e9e3192354
change-id: 20241016-disable-two-clang-enum-warnings-e7994d44f948

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


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

* Re: [PATCH v2] kbuild: Move -Wenum-enum-conversion to W=2
  2024-10-17 17:09 [PATCH v2] kbuild: Move -Wenum-enum-conversion to W=2 Nathan Chancellor
@ 2024-10-17 20:19 ` Arnd Bergmann
  2024-12-02 16:16 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2024-10-17 20:19 UTC (permalink / raw)
  To: Nathan Chancellor, Masahiro Yamada
  Cc: Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Aleksei Vetrov, linux-kbuild, linux-kernel, llvm, patches,
	stable

On Thu, Oct 17, 2024, at 17:09, Nathan Chancellor wrote:
> -Wenum-enum-conversion was strengthened in clang-19 to warn for C, which
> caused the kernel to move it to W=1 in commit 75b5ab134bb5 ("kbuild:
> Move -Wenum-{compare-conditional,enum-conversion} into W=1") because
> there were numerous instances that would break builds with -Werror.
> Unfortunately, this is not a full solution, as more and more developers,
> subsystems, and distributors are building with W=1 as well, so they
> continue to see the numerous instances of this warning.
>
> Since the move to W=1, there have not been many new instances that have
> appeared through various build reports and the ones that have appeared
> seem to be following similar existing patterns, suggesting that most
> instances of this warning will not be real issues. The only alternatives
> for silencing this warning are adding casts (which is generally seen as
> an ugly practice) or refactoring the enums to macro defines or a unified
> enum (which may be undesirable because of type safety in other parts of
> the code).
>
> Move the warning to W=2, where warnings that occur frequently but may be
> relevant should reside.
>
> Cc: stable@vger.kernel.org
> Fixes: 75b5ab134bb5 ("kbuild: Move 
> -Wenum-{compare-conditional,enum-conversion} into W=1")
> Link: https://lore.kernel.org/ZwRA9SOcOjjLJcpi@google.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH v2] kbuild: Move -Wenum-enum-conversion to W=2
  2024-10-17 17:09 [PATCH v2] kbuild: Move -Wenum-enum-conversion to W=2 Nathan Chancellor
  2024-10-17 20:19 ` Arnd Bergmann
@ 2024-12-02 16:16 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2024-12-02 16:16 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Arnd Bergmann, Aleksei Vetrov, linux-kbuild, linux-kernel, llvm,
	patches, stable

Masahiro, could you please pick this up? The lore link is below in case
it is no longer in your inbox (or I can resend).

https://lore.kernel.org/20241017-disable-two-clang-enum-warnings-v2-1-163ac04346ae@kernel.org/

On Thu, Oct 17, 2024 at 10:09:22AM -0700, Nathan Chancellor wrote:
> -Wenum-enum-conversion was strengthened in clang-19 to warn for C, which
> caused the kernel to move it to W=1 in commit 75b5ab134bb5 ("kbuild:
> Move -Wenum-{compare-conditional,enum-conversion} into W=1") because
> there were numerous instances that would break builds with -Werror.
> Unfortunately, this is not a full solution, as more and more developers,
> subsystems, and distributors are building with W=1 as well, so they
> continue to see the numerous instances of this warning.
> 
> Since the move to W=1, there have not been many new instances that have
> appeared through various build reports and the ones that have appeared
> seem to be following similar existing patterns, suggesting that most
> instances of this warning will not be real issues. The only alternatives
> for silencing this warning are adding casts (which is generally seen as
> an ugly practice) or refactoring the enums to macro defines or a unified
> enum (which may be undesirable because of type safety in other parts of
> the code).
> 
> Move the warning to W=2, where warnings that occur frequently but may be
> relevant should reside.
> 
> Cc: stable@vger.kernel.org
> Fixes: 75b5ab134bb5 ("kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1")
> Link: https://lore.kernel.org/ZwRA9SOcOjjLJcpi@google.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Changes in v2:
> - Move -Wenum-enum-conversion to W=2, instead of disabling it
>   outright (Arnd)
> - Leave -Wenum-compare-conditional in W=1, as there are not that
>   many instances, so it can be turned on fully at some point (Arnd)
> - Link to v1: https://lore.kernel.org/r/20241016-disable-two-clang-enum-warnings-v1-1-ae886d7a0269@kernel.org
> ---
>  scripts/Makefile.extrawarn | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 1d13cecc7cc7808610e635ddc03476cf92b3a8c1..04faf15ed316a9c291dc952b6cc40fb6c8c330cf 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -130,7 +130,6 @@ 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 += -Wno-enum-compare-conditional
> -KBUILD_CFLAGS += -Wno-enum-enum-conversion
>  endif
>  
>  endif
> @@ -154,6 +153,10 @@ 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-enum-enum-conversion
> +endif
> +
>  ifdef CONFIG_CC_IS_GCC
>  KBUILD_CFLAGS += -Wno-maybe-uninitialized
>  endif
> 
> ---
> base-commit: 8e929cb546ee42c9a61d24fae60605e9e3192354
> change-id: 20241016-disable-two-clang-enum-warnings-e7994d44f948
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
> 

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

end of thread, other threads:[~2024-12-02 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-17 17:09 [PATCH v2] kbuild: Move -Wenum-enum-conversion to W=2 Nathan Chancellor
2024-10-17 20:19 ` Arnd Bergmann
2024-12-02 16:16 ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®