All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2
@ 2019-08-29 12:02 Michal Suchanek
  2019-08-30 11:09 ` Joe Perches
  2019-08-31  5:12 ` Gustavo A. R. Silva
  0 siblings, 2 replies; 4+ messages in thread
From: Michal Suchanek @ 2019-08-29 12:02 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Michal Suchanek, Masahiro Yamada, Michal Marek, linux-kernel

From gcc documentation:

-Wimplicit-fallthrough=0
  disables the warning altogether.
-Wimplicit-fallthrough=1
  matches .* regular expression, any comment is used as fallthrough comment.
-Wimplicit-fallthrough=2
  case insensitively matches .*falls?[ \t-]*thr(ough|u).* regular expression.
-Wimplicit-fallthrough=3
  case sensitively matches one of the following regular expressions:
   -fallthrough
   @fallthrough@
   lint -fallthrough[ \t]*
   [ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?
   FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?
   [ \t.!]*(Else,? |Intentional(ly)? )?
   Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?
   [ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?
   fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?
-Wimplicit-fallthrough=4
  case sensitively matches one of the following regular expressions:
   -fallthrough
   @fallthrough@
   lint -fallthrough[ \t]*
   [ \t]*FALLTHR(OUGH|U)[ \t]*
-Wimplicit-fallthrough=5
  doesn’t recognize any comments as fallthrough comments, only attributes disable the warning.

In particular the default value of 3 does not match the comments like
/* falls through to do foobar */
generating suprious warnings on properly annotated code.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index f125625efd60..641ec413c2a6 100644
--- a/Makefile
+++ b/Makefile
@@ -846,7 +846,7 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 KBUILD_CFLAGS += -Wdeclaration-after-statement
 
 # Warn about unmarked fall-throughs in switch statement.
-KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=2,)
 
 # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
 KBUILD_CFLAGS += -Wvla
-- 
2.22.0


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

* Re: [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2
  2019-08-29 12:02 [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2 Michal Suchanek
@ 2019-08-30 11:09 ` Joe Perches
  2019-08-30 12:12   ` Miguel Ojeda
  2019-08-31  5:12 ` Gustavo A. R. Silva
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2019-08-30 11:09 UTC (permalink / raw)
  To: Michal Suchanek, linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

On Thu, 2019-08-29 at 14:02 +0200, Michal Suchanek wrote:
> In particular the default value of 3 does not match the comments like
> /* falls through to do foobar */

How many comments are there like this in the kernel?

Also you have to deal with gcc/clang differences.
As far as I know, clang doesn't take a value for this.



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

* Re: [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2
  2019-08-30 11:09 ` Joe Perches
@ 2019-08-30 12:12   ` Miguel Ojeda
  0 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2019-08-30 12:12 UTC (permalink / raw)
  To: Joe Perches
  Cc: Michal Suchanek, Linux Kbuild mailing list, Masahiro Yamada,
	Michal Marek, linux-kernel

On Fri, Aug 30, 2019 at 1:09 PM Joe Perches <joe@perches.com> wrote:
>
> On Thu, 2019-08-29 at 14:02 +0200, Michal Suchanek wrote:
> > In particular the default value of 3 does not match the comments like
> > /* falls through to do foobar */
>
> How many comments are there like this in the kernel?

+1 Given we are trying to move to attr-only and therefore
-Wimplicit-fallthrough=5, going back a level needs to be backed by a
good argument. It would be way better to fix those comments instead.

Cheers,
Miguel

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

* Re: [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2
  2019-08-29 12:02 [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2 Michal Suchanek
  2019-08-30 11:09 ` Joe Perches
@ 2019-08-31  5:12 ` Gustavo A. R. Silva
  1 sibling, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-08-31  5:12 UTC (permalink / raw)
  To: Michal Suchanek, linux-kbuild
  Cc: Masahiro Yamada, Michal Marek, linux-kernel, Kees Cook



On 8/29/19 7:02 AM, Michal Suchanek wrote:
> From gcc documentation:
> 
> -Wimplicit-fallthrough=0
>   disables the warning altogether.
> -Wimplicit-fallthrough=1
>   matches .* regular expression, any comment is used as fallthrough comment.
> -Wimplicit-fallthrough=2
>   case insensitively matches .*falls?[ \t-]*thr(ough|u).* regular expression.
> -Wimplicit-fallthrough=3
>   case sensitively matches one of the following regular expressions:
>    -fallthrough
>    @fallthrough@
>    lint -fallthrough[ \t]*
>    [ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?
>    FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?
>    [ \t.!]*(Else,? |Intentional(ly)? )?
>    Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?
>    [ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?
>    fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?
> -Wimplicit-fallthrough=4
>   case sensitively matches one of the following regular expressions:
>    -fallthrough
>    @fallthrough@
>    lint -fallthrough[ \t]*
>    [ \t]*FALLTHR(OUGH|U)[ \t]*
> -Wimplicit-fallthrough=5
>   doesn’t recognize any comments as fallthrough comments, only attributes disable the warning.
> 
> In particular the default value of 3 does not match the comments like
> /* falls through to do foobar */
> generating suprious warnings on properly annotated code.
> 

NACK

How many of those case do you see? if any...

In any case, those comments can be easily transformed to:

/* falls through - to do foobar */

like in this case:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d2d833e0bf2bad221a955626b942b38312630894

Also, notice that code in linux-next is already ahead... :

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=e2079e93f562c7f7a030eb7642017ee5eabaaa10

--
Gustavo

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

end of thread, other threads:[~2019-08-31  5:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-29 12:02 [PATCH] Makefile: Convert -Wimplicit-fallthrough to -Wimplicit-fallthrough=2 Michal Suchanek
2019-08-30 11:09 ` Joe Perches
2019-08-30 12:12   ` Miguel Ojeda
2019-08-31  5:12 ` Gustavo A. R. Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.