Skip to contentSkip to conversation

lib/maple_tree: Fix clang -Wimplicit-fallthrough in mte_set_pivot()

PATCH In review Nathan Chancellor 2 participants 2 messages Feb 24, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/maple_tree: Fix clang -Wimplicit-fallthrough in mte_set_pivot()

Clang warns:

lib/maple_tree.c:764:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

          case maple_dense:
          ^
  lib/maple_tree.c:764:2: note: insert 'break;' to avoid fall-through
          case maple_dense:
          ^
          break;

1 error generated.

Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing break to silence the warning.

---
 lib/maple_tree.c | 1 +
 1 file changed, 1 insertion(+)
lib/maple_tree.c +1 -0
index 5132495f86a6..5d8c39cbd517 100644
@@ -761,6 +761,7 @@ static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
 		break;
 	case maple_arange_64:
 		(&node->ma64)->pivot[piv] = val;
+		break;
 	case maple_dense:
 		break;
 	}

base-commit: 7ec16b08f9e0b656c96d20424b1cbbff4c78329c

Signature · 1 line
2.35.1
#1 lore raw
Quoted 29 lines · Nathan Chancellor

Clang warns:

lib/maple_tree.c:764:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

          case maple_dense:
          ^
  lib/maple_tree.c:764:2: note: insert 'break;' to avoid fall-through
          case maple_dense:
          ^
          break;

1 error generated.

Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing break to silence the warning.

---
 lib/maple_tree.c | 1 +
 1 file changed, 1 insertion(+)
lib/maple_tree.c +0 -0
index 5132495f86a6..5d8c39cbd517 100644

lib/maple_tree.c static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv, · line 764

Quoted 4 lines
lib/maple_tree.c +1 -0
@@ -761,6 +761,7 @@ static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
 		break;
 	case maple_arange_64:
 		(&node->ma64)->pivot[piv] = val;
+		break;

I will add this to linux-next and clean up the line above while I'm at it.

Quoted 8 lines
lib/maple_tree.c +0 -0
 	case maple_dense:
 		break;
 	}

base-commit: 7ec16b08f9e0b656c96d20424b1cbbff4c78329c

Signature · 1 line
2.35.1