diff mbox series

kbuild: Enable -Wenum-conversion by default

Message ID 20230704221951.7396-1-bp@alien8.de (mailing list archive)
State New, archived
Headers show
Series kbuild: Enable -Wenum-conversion by default | expand

Commit Message

Borislav Petkov July 4, 2023, 10:19 p.m. UTC
From: "Borislav Petkov (AMD)" <bp@alien8.de>

This diagnostic checks whether there is a type mismatch when
converting enums (assign an enum of type A to an enum of type B, for
example) and it caught a legit issue recently. The reason it didn't show
is because that warning is enabled only with -Wextra with GCC. Clang,
however, enables it by default.

GCC folks were considering enabling it by default but it was too noisy
back then:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736

Now that due to clang all those warnings have been fixed, enable it with
GCC too.

allmodconfig tests done with: x86, arm{,64}, powerpc{,64}, riscv
crossbuilds.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nathan Chancellor July 5, 2023, 4:20 p.m. UTC | #1
On Wed, Jul 05, 2023 at 12:19:51AM +0200, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
> 
> This diagnostic checks whether there is a type mismatch when
> converting enums (assign an enum of type A to an enum of type B, for
> example) and it caught a legit issue recently. The reason it didn't show
> is because that warning is enabled only with -Wextra with GCC. Clang,
> however, enables it by default.
> 
> GCC folks were considering enabling it by default but it was too noisy
> back then:
> 
>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736
> 
> Now that due to clang all those warnings have been fixed, enable it with
> GCC too.
> 
> allmodconfig tests done with: x86, arm{,64}, powerpc{,64}, riscv
> crossbuilds.
> 
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>

Yes please :)

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 7a5a175f708f..428132b3d6dd 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1082,6 +1082,9 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
>  # Require designated initializers for all marked structures
>  KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
>  
> +# Warn if there is an enum types mismatch
> +KBUILD_CFLAGS	+= $(call cc-option,-Wenum-conversion)
> +
>  # change __FILE__ to the relative path from the srctree
>  KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
>  
> -- 
> 2.41.0
>
Masahiro Yamada July 15, 2023, 5:46 a.m. UTC | #2
On Thu, Jul 6, 2023 at 1:20 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Wed, Jul 05, 2023 at 12:19:51AM +0200, Borislav Petkov wrote:
> > From: "Borislav Petkov (AMD)" <bp@alien8.de>
> >
> > This diagnostic checks whether there is a type mismatch when
> > converting enums (assign an enum of type A to an enum of type B, for
> > example) and it caught a legit issue recently. The reason it didn't show
> > is because that warning is enabled only with -Wextra with GCC. Clang,
> > however, enables it by default.
> >
> > GCC folks were considering enabling it by default but it was too noisy
> > back then:
> >
> >   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78736
> >
> > Now that due to clang all those warnings have been fixed, enable it with
> > GCC too.
> >
> > allmodconfig tests done with: x86, arm{,64}, powerpc{,64}, riscv
> > crossbuilds.
> >
> > Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>
> Yes please :)
>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
>




Applied to linux-kbuild.
Thanks.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 7a5a175f708f..428132b3d6dd 100644
--- a/Makefile
+++ b/Makefile
@@ -1082,6 +1082,9 @@  KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 # Require designated initializers for all marked structures
 KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 
+# Warn if there is an enum types mismatch
+KBUILD_CFLAGS	+= $(call cc-option,-Wenum-conversion)
+
 # change __FILE__ to the relative path from the srctree
 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)