Skip to contentSkip to conversation

compat: Mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Oct 13, 2018 – Oct 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compat: Mark expected switch fall-throughs

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

---
 include/linux/compat.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/compat.h +3 -0
index d30e4db..06e7747 100644
@@ -488,8 +488,11 @@ put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
 	compat_sigset_t v;
 	switch (_NSIG_WORDS) {
 	case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
+		/* fall through */
 	case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
+		/* fall through */
 	case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
+		/* fall through */
 	case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
 	}
 	return copy_to_user(compat, &v, size) ? -EFAULT : 0;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Gustavo A. R. Silva

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

-Kees

Quoted 23 lines
---
 include/linux/compat.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/compat.h +3 -1
index d30e4db..06e7747 100644
@@ -488,8 +488,11 @@ put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
        compat_sigset_t v;
        switch (_NSIG_WORDS) {
        case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
+               /* fall through */
        case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
+               /* fall through */
        case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
+               /* fall through */
        case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
        }
        return copy_to_user(compat, &v, size) ? -EFAULT : 0;
--

2.7.4

Signature · 2 lines
Kees Cook
Pixel Security