signal: Mark expected switch fall-throughs
PATCH 1/1 signal: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
--- include/linux/signal.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/linux/signal.h +6 -0
@@ -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 ; }
Signature · 1 line
2.7.4
Quoted 4 lines · 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 <[email protected]>
Yes, please. :) I love every step closer we get to being able to use -Wimplicit-fallthrough.
-Kees
Quoted 49 lines
--- include/linux/signal.h | 6 ++++++ 1 file changed, 6 insertions(+)include/linux/signal.h +6
-1@@ -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
Signature · 2 lines
Kees Cook Pixel Security
[ Cc += [email protected] ]
Quoted 7 lines · 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 <[email protected]>--- include/linux/signal.h | 6 ++++++ 1 file changed, 6 insertions(+)
These all look correct to me.
Quoted 35 lines
include/linux/signal.h +5
-0@@ -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 ; }
include/linux/signal.h static inline void sigfillset(sigset_t *set) · line 205
Quoted 7 lines
include/linux/signal.h +1
-0@@ -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
Quoted 10 lines · Kees Cook
Quoted 4 lines · 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 <[email protected]>Yes, please. :) I love every step closer we get to being able to use -Wimplicit-fallthrough.
Yep. We are getting there. :D
Quoted 2 lines
Acked-by Kees Cook <[email protected]>
Thanks
--
Gustavo