Skip to contentSkip to conversation

kernel/compat.c: mark expected switch fall-throughs

PATCH New Stephen Rothwell 1 participant 1 message May 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/compat.c: mark expected switch fall-throughs

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

This patch aims to suppress 3 missing-break-in-switch false positives on some architectures.

Cc Deepa Dinamani <[email protected]>
Cc Gustavo A. R. Silva <[email protected]>
Cc Kees Cook <[email protected]>
Cc Jann Horn <[email protected]>
---
 kernel/compat.c | 3 +++
 1 file changed, 3 insertions(+)

Hi Linus,

This has been sitting in my fixes tree in linux-next for quite some time. It silences some warnings that irritated me in my builds since I am building with -Wimplicit-fallthrough to help Gustavo catch new additions.

kernel/compat.c +3 -0
index d8a36c6ad7c9..b5f7063c0db6 100644
@@ -346,8 +346,11 @@ get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat)
 		return -EFAULT;
 	switch (_NSIG_WORDS) {
 	case 4: set->sig[3] = v.sig[6] | (((long)v.sig[7]) << 32 );
+		/* fall through */
 	case 3: set->sig[2] = v.sig[4] | (((long)v.sig[5]) << 32 );
+		/* fall through */
 	case 2: set->sig[1] = v.sig[2] | (((long)v.sig[3]) << 32 );
+		/* fall through */
 	case 1: set->sig[0] = v.sig[0] | (((long)v.sig[1]) << 32 );
 	}
 #else
Signature · 5 lines
2.20.1

-- 
Cheers,
Stephen Rothwell