linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] signal: Mark expected switch fall-throughs
@ 2018-10-13 11:48 Gustavo A. R. Silva
  2018-10-15 21:29 ` Kees Cook
  2018-10-16  0:08 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-13 11:48 UTC (permalink / raw)
  To: Andrew Morton, Kees Cook, Michael Ellerman
  Cc: linux-kernel, Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 include/linux/signal.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/signal.h b/include/linux/signal.h
index 200ed96..f428e86 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -129,9 +129,11 @@ static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
 		b3 = b->sig[3]; b2 = b->sig[2];				\
 		r->sig[3] = op(a3, b3);					\
 		r->sig[2] = op(a2, b2);					\
+		/* fall through */					\
 	case 2:								\
 		a1 = a->sig[1]; b1 = b->sig[1];				\
 		r->sig[1] = op(a1, b1);					\
+		/* fall through */					\
 	case 1:								\
 		a0 = a->sig[0]; b0 = b->sig[0];				\
 		r->sig[0] = op(a0, b0);					\
@@ -161,7 +163,9 @@ static inline void name(sigset_t *set)					\
 	switch (_NSIG_WORDS) {						\
 	case 4:	set->sig[3] = op(set->sig[3]);				\
 		set->sig[2] = op(set->sig[2]);				\
+		/* fall through */					\
 	case 2:	set->sig[1] = op(set->sig[1]);				\
+		/* fall through */					\
 	case 1:	set->sig[0] = op(set->sig[0]);				\
 		    break;						\
 	default:							\
@@ -182,6 +186,7 @@ static inline void sigemptyset(sigset_t *set)
 		memset(set, 0, sizeof(sigset_t));
 		break;
 	case 2: set->sig[1] = 0;
+		/* fall through */
 	case 1:	set->sig[0] = 0;
 		break;
 	}
@@ -194,6 +199,7 @@ static inline void sigfillset(sigset_t *set)
 		memset(set, -1, sizeof(sigset_t));
 		break;
 	case 2: set->sig[1] = -1;
+		/* fall through */
 	case 1:	set->sig[0] = -1;
 		break;
 	}
-- 
2.7.4


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

* Re: [PATCH] signal: Mark expected switch fall-throughs
  2018-10-13 11:48 [PATCH] signal: Mark expected switch fall-throughs Gustavo A. R. Silva
@ 2018-10-15 21:29 ` Kees Cook
  2018-10-16 11:23   ` Gustavo A. R. Silva
  2018-10-16  0:08 ` Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Kees Cook @ 2018-10-15 21:29 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Andrew Morton, Michael Ellerman, LKML

On Sat, Oct 13, 2018 at 4:48 AM, Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Yes, please. :) I love every step closer we get to being able to use
-Wimplicit-fallthrough.

Acked-by: Kees Cook <keescook@chromium.org>

-Kees


> ---
>  include/linux/signal.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index 200ed96..f428e86 100644
> --- a/include/linux/signal.h
> +++ b/include/linux/signal.h
> @@ -129,9 +129,11 @@ static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
>                 b3 = b->sig[3]; b2 = b->sig[2];                         \
>                 r->sig[3] = op(a3, b3);                                 \
>                 r->sig[2] = op(a2, b2);                                 \
> +               /* fall through */                                      \
>         case 2:                                                         \
>                 a1 = a->sig[1]; b1 = b->sig[1];                         \
>                 r->sig[1] = op(a1, b1);                                 \
> +               /* fall through */                                      \
>         case 1:                                                         \
>                 a0 = a->sig[0]; b0 = b->sig[0];                         \
>                 r->sig[0] = op(a0, b0);                                 \
> @@ -161,7 +163,9 @@ static inline void name(sigset_t *set)                                      \
>         switch (_NSIG_WORDS) {                                          \
>         case 4: set->sig[3] = op(set->sig[3]);                          \
>                 set->sig[2] = op(set->sig[2]);                          \
> +               /* fall through */                                      \
>         case 2: set->sig[1] = op(set->sig[1]);                          \
> +               /* fall through */                                      \
>         case 1: set->sig[0] = op(set->sig[0]);                          \
>                     break;                                              \
>         default:                                                        \
> @@ -182,6 +186,7 @@ static inline void sigemptyset(sigset_t *set)
>                 memset(set, 0, sizeof(sigset_t));
>                 break;
>         case 2: set->sig[1] = 0;
> +               /* fall through */
>         case 1: set->sig[0] = 0;
>                 break;
>         }
> @@ -194,6 +199,7 @@ static inline void sigfillset(sigset_t *set)
>                 memset(set, -1, sizeof(sigset_t));
>                 break;
>         case 2: set->sig[1] = -1;
> +               /* fall through */
>         case 1: set->sig[0] = -1;
>                 break;
>         }
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security

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

* Re: [PATCH] signal: Mark expected switch fall-throughs
  2018-10-13 11:48 [PATCH] signal: Mark expected switch fall-throughs Gustavo A. R. Silva
  2018-10-15 21:29 ` Kees Cook
@ 2018-10-16  0:08 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2018-10-16  0:08 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Andrew Morton, Kees Cook
  Cc: linux-kernel, Gustavo A. R. Silva, ebiederm

[ Cc += ebiederm@xmission.com ]

"Gustavo A. R. Silva" <gustavo@embeddedor.com> writes:
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  include/linux/signal.h | 6 ++++++
>  1 file changed, 6 insertions(+)

These all look correct to me.

Reviewed-by: Michael Ellerman <mpe@ellerman.id.au>

> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index 200ed96..f428e86 100644
> --- a/include/linux/signal.h
> +++ b/include/linux/signal.h
> @@ -129,9 +129,11 @@ static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
>  		b3 = b->sig[3]; b2 = b->sig[2];				\
>  		r->sig[3] = op(a3, b3);					\
>  		r->sig[2] = op(a2, b2);					\
> +		/* fall through */					\
>  	case 2:								\
>  		a1 = a->sig[1]; b1 = b->sig[1];				\
>  		r->sig[1] = op(a1, b1);					\
> +		/* fall through */					\
>  	case 1:								\
>  		a0 = a->sig[0]; b0 = b->sig[0];				\
>  		r->sig[0] = op(a0, b0);					\
> @@ -161,7 +163,9 @@ static inline void name(sigset_t *set)					\
>  	switch (_NSIG_WORDS) {						\
>  	case 4:	set->sig[3] = op(set->sig[3]);				\
>  		set->sig[2] = op(set->sig[2]);				\
> +		/* fall through */					\
>  	case 2:	set->sig[1] = op(set->sig[1]);				\
> +		/* fall through */					\
>  	case 1:	set->sig[0] = op(set->sig[0]);				\
>  		    break;						\
>  	default:							\
> @@ -182,6 +186,7 @@ static inline void sigemptyset(sigset_t *set)
>  		memset(set, 0, sizeof(sigset_t));
>  		break;
>  	case 2: set->sig[1] = 0;
> +		/* fall through */
>  	case 1:	set->sig[0] = 0;
>  		break;
>  	}
> @@ -194,6 +199,7 @@ static inline void sigfillset(sigset_t *set)
>  		memset(set, -1, sizeof(sigset_t));
>  		break;
>  	case 2: set->sig[1] = -1;
> +		/* fall through */
>  	case 1:	set->sig[0] = -1;
>  		break;
>  	}

I think _NSIG_WORDS is always constant. So these last two seem like they
could just be replaced with memset() and a modern compiler would do the
right thing.

cheers

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

* Re: [PATCH] signal: Mark expected switch fall-throughs
  2018-10-15 21:29 ` Kees Cook
@ 2018-10-16 11:23   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-16 11:23 UTC (permalink / raw)
  To: Kees Cook; +Cc: Andrew Morton, Michael Ellerman, LKML



On 10/15/18 11:29 PM, Kees Cook wrote:
> On Sat, Oct 13, 2018 at 4:48 AM, Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>> where we are expecting to fall through.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Yes, please. :) I love every step closer we get to being able to use
> -Wimplicit-fallthrough.
> 

Yep. We are getting there. :D

> Acked-by: Kees Cook <keescook@chromium.org>
> 

Thanks
--
Gustavo

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

end of thread, other threads:[~2018-10-16 11:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-13 11:48 [PATCH] signal: Mark expected switch fall-throughs Gustavo A. R. Silva
2018-10-15 21:29 ` Kees Cook
2018-10-16 11:23   ` Gustavo A. R. Silva
2018-10-16  0:08 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).