mbox series

[GIT,PULL] Enable -Wimplicit-fallthrough for Clang for 5.16-rc1

Message ID 20211113214125.GA23640@embeddedor (mailing list archive)
State Rejected
Delegated to: Gustavo A. R. Silva
Headers show
Series [GIT,PULL] Enable -Wimplicit-fallthrough for Clang for 5.16-rc1 | expand

Pull-request

git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git tags/enable-clang-fallthrough-5.16-rc1

Message

Gustavo A. R. Silva Nov. 13, 2021, 9:41 p.m. UTC
The following changes since commit 3906fe9bb7f1a2c8667ae54e967dc8690824f4ea:

  Linux 5.15-rc7 (2021-10-25 11:30:31 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git tags/enable-clang-fallthrough-5.16-rc1

for you to fetch changes up to 428a8bf629ecc118d1eadbb629312c25fde2103f:

  Makefile: Enable -Wimplicit-fallthrough for Clang (2021-11-13 15:24:33 -0600)

----------------------------------------------------------------
Enable -Wimplicit-fallthrough for Clang for 5.16-rc1

Hi Linus,

Please, pull the following patch that enables -Wimplicit-fallthrough
for Clang 14+, globally.

We had almost 40,000[1] of these issues for Clang in the beginning,
and now I think we are in good shape and it is now possible to enable
-Wimplicit-fallthrough for Clang, with this finally getting rid of
the unintentional fallthrough bug-class in the kernel, entirely. :)

I have to say that I'm sending this pull-request this late in the
merge window, intentionally. I first wated to make sure that no other
warning shows up before sending it.

This patch has been baking in linux-next for a couple of developement
cycles, now. So, I think we are pretty much ready to merge it into
mainline.

[1] https://github.com/KSPP/linux/issues/115

Thanks!

----------------------------------------------------------------
Gustavo A. R. Silva (1):
      Makefile: Enable -Wimplicit-fallthrough for Clang

 Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Linus Torvalds Nov. 13, 2021, 11:20 p.m. UTC | #1
On Sat, Nov 13, 2021 at 1:36 PM Gustavo A. R. Silva
<gustavoars@kernel.org> wrote:
>
> This patch has been baking in linux-next for a couple of developement
> cycles, now. So, I think we are pretty much ready to merge it into
> mainline.

Ugh. It's also very ugly.

Wouldn't something like this (TOTALLY UNTESTED!) work and do the right thing?

This seems like a natural for a Kconfig decision.

Also, does -Wimplicit-fallthrough=5 work with clang too? That would
simplify things a bit, and then we could just use a regular boolean
and do

  KBUILD_CFLAGS-$(CC_IMPLICIT_FALLTHROUGH) += -Wimplicit-fallthrough=5

in the Makefile, which is more in like with what we do for other
config-time cflags..

           Linus
Gustavo A. R. Silva Nov. 14, 2021, 12:08 a.m. UTC | #2
On Sat, Nov 13, 2021 at 03:20:19PM -0800, Linus Torvalds wrote:
> On Sat, Nov 13, 2021 at 1:36 PM Gustavo A. R. Silva
> <gustavoars@kernel.org> wrote:
[..]
> Wouldn't something like this (TOTALLY UNTESTED!) work and do the right thing?
> 
> This seems like a natural for a Kconfig decision.
> 
> Also, does -Wimplicit-fallthrough=5 work with clang too? That would
> simplify things a bit, and then we could just use a regular boolean
> and do
> 
>   KBUILD_CFLAGS-$(CC_IMPLICIT_FALLTHROUGH) += -Wimplicit-fallthrough=5

It doesn't work:

error: unknown warning option '-Wimplicit-fallthrough=5'; did you mean '-Wimplicit-fallthrough'? [-Werror,-Wunknown-warning-option]

However, your patch does work. :)

I'll send it as a proper patch, shortly.

Thanks
--
Gustavo