Skip to content

Commit 6a9dc5f

Browse files
GustavoARSilvatorvalds
authored andcommitted
lib: Revert use of fallthrough pseudo-keyword in lib/
The following build error for powerpc64 was reported by Nathan Chancellor: "$ scripts/config --file arch/powerpc/configs/powernv_defconfig -e KERNEL_XZ $ make -skj"$(nproc)" ARCH=powerpc CROSS_COMPILE=powerpc64le-linux- distclean powernv_defconfig zImage ... In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:234, from arch/powerpc/boot/decompress.c:38: arch/powerpc/boot/../../../lib/xz/xz_dec_stream.c: In function 'dec_main': arch/powerpc/boot/../../../lib/xz/xz_dec_stream.c:586:4: error: 'fallthrough' undeclared (first use in this function) 586 | fallthrough; | ^~~~~~~~~~~ This will end up affecting distribution configurations such as Debian and OpenSUSE according to my testing. I am not sure what the solution is, the PowerPC wrapper does not set -D__KERNEL__ so I am not sure that compiler_attributes.h can be safely included." In order to avoid these sort of problems, it seems that the best solution is to use /* fall through */ comments instead of the fallthrough pseudo-keyword macro in lib/, for now. Reported-by: Nathan Chancellor <natechancellor@gmail.com> Fixes: df561f6 ("treewide: Use fallthrough pseudo-keyword") Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-and-tested-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9907ab3 commit 6a9dc5f

16 files changed

Lines changed: 64 additions & 64 deletions

‎lib/asn1_decoder.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
381381
case ASN1_OP_END_SET_ACT:
382382
if (unlikely(!(flags & FLAG_MATCHED)))
383383
goto tag_mismatch;
384-
fallthrough;
384+
/* fall through */
385385

386386
case ASN1_OP_END_SEQ:
387387
case ASN1_OP_END_SET_OF:
@@ -448,7 +448,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
448448
pc += asn1_op_lengths[op];
449449
goto next_op;
450450
}
451-
fallthrough;
451+
/* fall through */
452452

453453
case ASN1_OP_ACT:
454454
ret = actions[machine[pc + 1]](context, hdr, tag, data + tdp, len);

‎lib/assoc_array.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ struct assoc_array_edit *assoc_array_delete(struct assoc_array *array,
11131113
index_key))
11141114
goto found_leaf;
11151115
}
1116-
fallthrough;
1116+
/* fall through */
11171117
case assoc_array_walk_tree_empty:
11181118
case assoc_array_walk_found_wrong_shortcut:
11191119
default:

‎lib/bootconfig.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
817817
q - 2);
818818
break;
819819
}
820-
fallthrough;
820+
/* fall through */
821821
case '=':
822822
ret = xbc_parse_kv(&p, q, c);
823823
break;
@@ -826,7 +826,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
826826
break;
827827
case '#':
828828
q = skip_comment(q);
829-
fallthrough;
829+
/* fall through */
830830
case ';':
831831
case '\n':
832832
ret = xbc_parse_key(&p, q);

‎lib/cmdline.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,23 @@ unsigned long long memparse(const char *ptr, char **retptr)
132132
case 'E':
133133
case 'e':
134134
ret <<= 10;
135-
fallthrough;
135+
/* fall through */
136136
case 'P':
137137
case 'p':
138138
ret <<= 10;
139-
fallthrough;
139+
/* fall through */
140140
case 'T':
141141
case 't':
142142
ret <<= 10;
143-
fallthrough;
143+
/* fall through */
144144
case 'G':
145145
case 'g':
146146
ret <<= 10;
147-
fallthrough;
147+
/* fall through */
148148
case 'M':
149149
case 'm':
150150
ret <<= 10;
151-
fallthrough;
151+
/* fall through */
152152
case 'K':
153153
case 'k':
154154
ret <<= 10;

‎lib/dim/net_dim.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void net_dim(struct dim *dim, struct dim_sample end_sample)
233233
schedule_work(&dim->work);
234234
break;
235235
}
236-
fallthrough;
236+
/* fall through */
237237
case DIM_START_MEASURE:
238238
dim_update_sample(end_sample.event_ctr, end_sample.pkt_ctr,
239239
end_sample.byte_ctr, &dim->start_sample);

‎lib/dim/rdma_dim.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static bool rdma_dim_decision(struct dim_stats *curr_stats, struct dim *dim)
5959
break;
6060
case DIM_STATS_WORSE:
6161
dim_turn(dim);
62-
fallthrough;
62+
/* fall through */
6363
case DIM_STATS_BETTER:
6464
step_res = rdma_dim_step(dim);
6565
if (step_res == DIM_ON_EDGE)
@@ -94,7 +94,7 @@ void rdma_dim(struct dim *dim, u64 completions)
9494
schedule_work(&dim->work);
9595
break;
9696
}
97-
fallthrough;
97+
/* fall through */
9898
case DIM_START_MEASURE:
9999
dim->state = DIM_MEASURE_IN_PROGRESS;
100100
dim_update_sample_with_comps(curr_sample->event_ctr, 0, 0,

‎lib/glob.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool __pure glob_match(char const *pat, char const *str)
102102
break;
103103
case '\\':
104104
d = *pat++;
105-
fallthrough;
105+
/* fall through */
106106
default: /* Literal character */
107107
literal:
108108
if (c == d) {

‎lib/siphash.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
6868
bytemask_from_count(left)));
6969
#else
7070
switch (left) {
71-
case 7: b |= ((u64)end[6]) << 48; fallthrough;
72-
case 6: b |= ((u64)end[5]) << 40; fallthrough;
73-
case 5: b |= ((u64)end[4]) << 32; fallthrough;
71+
case 7: b |= ((u64)end[6]) << 48; /* fall through */
72+
case 6: b |= ((u64)end[5]) << 40; /* fall through */
73+
case 5: b |= ((u64)end[4]) << 32; /* fall through */
7474
case 4: b |= le32_to_cpup(data); break;
75-
case 3: b |= ((u64)end[2]) << 16; fallthrough;
75+
case 3: b |= ((u64)end[2]) << 16; /* fall through */
7676
case 2: b |= le16_to_cpup(data); break;
7777
case 1: b |= end[0];
7878
}
@@ -101,11 +101,11 @@ u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key)
101101
bytemask_from_count(left)));
102102
#else
103103
switch (left) {
104-
case 7: b |= ((u64)end[6]) << 48; fallthrough;
105-
case 6: b |= ((u64)end[5]) << 40; fallthrough;
106-
case 5: b |= ((u64)end[4]) << 32; fallthrough;
104+
case 7: b |= ((u64)end[6]) << 48; /* fall through */
105+
case 6: b |= ((u64)end[5]) << 40; /* fall through */
106+
case 5: b |= ((u64)end[4]) << 32; /* fall through */
107107
case 4: b |= get_unaligned_le32(end); break;
108-
case 3: b |= ((u64)end[2]) << 16; fallthrough;
108+
case 3: b |= ((u64)end[2]) << 16; /* fall through */
109109
case 2: b |= get_unaligned_le16(end); break;
110110
case 1: b |= end[0];
111111
}
@@ -268,11 +268,11 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
268268
bytemask_from_count(left)));
269269
#else
270270
switch (left) {
271-
case 7: b |= ((u64)end[6]) << 48; fallthrough;
272-
case 6: b |= ((u64)end[5]) << 40; fallthrough;
273-
case 5: b |= ((u64)end[4]) << 32; fallthrough;
271+
case 7: b |= ((u64)end[6]) << 48; /* fall through */
272+
case 6: b |= ((u64)end[5]) << 40; /* fall through */
273+
case 5: b |= ((u64)end[4]) << 32; /* fall through */
274274
case 4: b |= le32_to_cpup(data); break;
275-
case 3: b |= ((u64)end[2]) << 16; fallthrough;
275+
case 3: b |= ((u64)end[2]) << 16; /* fall through */
276276
case 2: b |= le16_to_cpup(data); break;
277277
case 1: b |= end[0];
278278
}
@@ -301,11 +301,11 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
301301
bytemask_from_count(left)));
302302
#else
303303
switch (left) {
304-
case 7: b |= ((u64)end[6]) << 48; fallthrough;
305-
case 6: b |= ((u64)end[5]) << 40; fallthrough;
306-
case 5: b |= ((u64)end[4]) << 32; fallthrough;
304+
case 7: b |= ((u64)end[6]) << 48; /* fall through */
305+
case 6: b |= ((u64)end[5]) << 40; /* fall through */
306+
case 5: b |= ((u64)end[4]) << 32; /* fall through */
307307
case 4: b |= get_unaligned_le32(end); break;
308-
case 3: b |= ((u64)end[2]) << 16; fallthrough;
308+
case 3: b |= ((u64)end[2]) << 16; /* fall through */
309309
case 2: b |= get_unaligned_le16(end); break;
310310
case 1: b |= end[0];
311311
}
@@ -431,7 +431,7 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
431431
v0 ^= m;
432432
}
433433
switch (left) {
434-
case 3: b |= ((u32)end[2]) << 16; fallthrough;
434+
case 3: b |= ((u32)end[2]) << 16; /* fall through */
435435
case 2: b |= le16_to_cpup(data); break;
436436
case 1: b |= end[0];
437437
}
@@ -454,7 +454,7 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
454454
v0 ^= m;
455455
}
456456
switch (left) {
457-
case 3: b |= ((u32)end[2]) << 16; fallthrough;
457+
case 3: b |= ((u32)end[2]) << 16; /* fall through */
458458
case 2: b |= get_unaligned_le16(end); break;
459459
case 1: b |= end[0];
460460
}

‎lib/ts_fsm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static unsigned int fsm_find(struct ts_config *conf, struct ts_state *state)
193193
TOKEN_MISMATCH();
194194

195195
block_idx++;
196-
fallthrough;
196+
/* fall through */
197197

198198
case TS_FSM_ANY:
199199
if (next == NULL)

‎lib/vsprintf.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr,
12651265

12661266
case 'R':
12671267
reversed = true;
1268-
fallthrough;
1268+
/* fall through */
12691269

12701270
default:
12711271
separator = ':';
@@ -1682,7 +1682,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
16821682
switch (*(++fmt)) {
16831683
case 'L':
16841684
uc = true;
1685-
fallthrough;
1685+
/* fall through */
16861686
case 'l':
16871687
index = guid_index;
16881688
break;
@@ -2219,7 +2219,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
22192219
case 'S':
22202220
case 's':
22212221
ptr = dereference_symbol_descriptor(ptr);
2222-
fallthrough;
2222+
/* fall through */
22232223
case 'B':
22242224
return symbol_string(buf, end, ptr, spec, fmt);
22252225
case 'R':
@@ -2450,7 +2450,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
24502450

24512451
case 'x':
24522452
spec->flags |= SMALL;
2453-
fallthrough;
2453+
/* fall through */
24542454

24552455
case 'X':
24562456
spec->base = 16;
@@ -2468,7 +2468,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
24682468
* utility, treat it as any other invalid or
24692469
* unsupported format specifier.
24702470
*/
2471-
fallthrough;
2471+
/* fall through */
24722472

24732473
default:
24742474
WARN_ONCE(1, "Please remove unsupported %%%c in format string\n", *fmt);
@@ -3411,10 +3411,10 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
34113411
break;
34123412
case 'i':
34133413
base = 0;
3414-
fallthrough;
3414+
/* fall through */
34153415
case 'd':
34163416
is_sign = true;
3417-
fallthrough;
3417+
/* fall through */
34183418
case 'u':
34193419
break;
34203420
case '%':

0 commit comments

Comments
 (0)