Skip to content

Commit 5c486e3

Browse files
committed
network: Add [[fallthrough]] to cascading switch-case
1 parent 5cfd8ae commit 5c486e3

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

src/network/utils/ipv6-address.cc

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,22 @@ extern "C"
108108

109109
/* handle the last 11 bytes */
110110
c += length;
111-
switch (len) /* all the case statements fall through */
111+
switch (len)
112112
{
113-
case 11:
114-
c += ((ub4)k[10] << 24);
115-
case 10:
116-
c += ((ub4)k[9] << 16);
117-
case 9:
118-
c += ((ub4)k[8] << 8); /* the first byte of c is reserved for the length */
119-
case 8:
120-
b += ((ub4)k[7] << 24);
121-
case 7:
122-
b += ((ub4)k[6] << 16);
123-
case 6:
124-
b += ((ub4)k[5] << 8);
125-
case 5:
126-
b += k[4];
127-
case 4:
128-
a += ((ub4)k[3] << 24);
129-
case 3:
130-
a += ((ub4)k[2] << 16);
131-
case 2:
132-
a += ((ub4)k[1] << 8);
133-
case 1:
134-
a += k[0];
113+
// clang-format off
114+
case 11: c += ((ub4)k[10] << 24); [[fallthrough]];
115+
case 10: c += ((ub4)k[9] << 16); [[fallthrough]];
116+
case 9: c += ((ub4)k[8] << 8); [[fallthrough]]; /* the first byte of c is reserved for the length */
117+
case 8: b += ((ub4)k[7] << 24); [[fallthrough]];
118+
case 7: b += ((ub4)k[6] << 16); [[fallthrough]];
119+
case 6: b += ((ub4)k[5] << 8); [[fallthrough]];
120+
case 5: b += k[4]; [[fallthrough]];
121+
case 4: a += ((ub4)k[3] << 24); [[fallthrough]];
122+
case 3: a += ((ub4)k[2] << 16); [[fallthrough]];
123+
case 2: a += ((ub4)k[1] << 8); [[fallthrough]];
124+
case 1: a += k[0];
135125
/* case 0: nothing left to add */
126+
// clang-format on
136127
}
137128
mixHashKey(a, b, c);
138129

0 commit comments

Comments
 (0)