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 <[email protected]> Fixes: df561f6 ("treewide: Use fallthrough pseudo-keyword") Signed-off-by: Gustavo A. R. Silva <[email protected]> Reviewed-and-tested-by: Nathan Chancellor <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9907ab3 commit 6a9dc5f

16 files changed

+64
-64
lines changed

lib/asn1_decoder.c

+2-2
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

+1-1
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

+2-2
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

+5-5
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

+1-1
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

+2-2
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

+1-1
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

+18-18
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

+1-1
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

+7-7
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 '%':

lib/xz/xz_dec_lzma2.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
10431043

10441044
s->lzma2.sequence = SEQ_LZMA_PREPARE;
10451045

1046-
fallthrough;
1046+
/* fall through */
10471047

10481048
case SEQ_LZMA_PREPARE:
10491049
if (s->lzma2.compressed < RC_INIT_BYTES)
@@ -1055,7 +1055,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
10551055
s->lzma2.compressed -= RC_INIT_BYTES;
10561056
s->lzma2.sequence = SEQ_LZMA_RUN;
10571057

1058-
fallthrough;
1058+
/* fall through */
10591059

10601060
case SEQ_LZMA_RUN:
10611061
/*

lib/xz/xz_dec_stream.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
583583
if (ret != XZ_OK)
584584
return ret;
585585

586-
fallthrough;
586+
/* fall through */
587587

588588
case SEQ_BLOCK_START:
589589
/* We need one byte of input to continue. */
@@ -608,7 +608,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
608608
s->temp.pos = 0;
609609
s->sequence = SEQ_BLOCK_HEADER;
610610

611-
fallthrough;
611+
/* fall through */
612612

613613
case SEQ_BLOCK_HEADER:
614614
if (!fill_temp(s, b))
@@ -620,7 +620,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
620620

621621
s->sequence = SEQ_BLOCK_UNCOMPRESS;
622622

623-
fallthrough;
623+
/* fall through */
624624

625625
case SEQ_BLOCK_UNCOMPRESS:
626626
ret = dec_block(s, b);
@@ -629,7 +629,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
629629

630630
s->sequence = SEQ_BLOCK_PADDING;
631631

632-
fallthrough;
632+
/* fall through */
633633

634634
case SEQ_BLOCK_PADDING:
635635
/*
@@ -651,7 +651,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
651651

652652
s->sequence = SEQ_BLOCK_CHECK;
653653

654-
fallthrough;
654+
/* fall through */
655655

656656
case SEQ_BLOCK_CHECK:
657657
if (s->check_type == XZ_CHECK_CRC32) {
@@ -675,7 +675,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
675675

676676
s->sequence = SEQ_INDEX_PADDING;
677677

678-
fallthrough;
678+
/* fall through */
679679

680680
case SEQ_INDEX_PADDING:
681681
while ((s->index.size + (b->in_pos - s->in_start))
@@ -699,7 +699,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
699699

700700
s->sequence = SEQ_INDEX_CRC32;
701701

702-
fallthrough;
702+
/* fall through */
703703

704704
case SEQ_INDEX_CRC32:
705705
ret = crc32_validate(s, b);
@@ -709,7 +709,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
709709
s->temp.size = STREAM_HEADER_SIZE;
710710
s->sequence = SEQ_STREAM_FOOTER;
711711

712-
fallthrough;
712+
/* fall through */
713713

714714
case SEQ_STREAM_FOOTER:
715715
if (!fill_temp(s, b))

lib/zstd/bitstream.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, s
259259
bitD->bitContainer = *(const BYTE *)(bitD->start);
260260
switch (srcSize) {
261261
case 7: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[6]) << (sizeof(bitD->bitContainer) * 8 - 16);
262-
fallthrough;
262+
/* fall through */
263263
case 6: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[5]) << (sizeof(bitD->bitContainer) * 8 - 24);
264-
fallthrough;
264+
/* fall through */
265265
case 5: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[4]) << (sizeof(bitD->bitContainer) * 8 - 32);
266-
fallthrough;
266+
/* fall through */
267267
case 4: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[3]) << 24;
268-
fallthrough;
268+
/* fall through */
269269
case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16;
270-
fallthrough;
270+
/* fall through */
271271
case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8;
272272
default:;
273273
}

lib/zstd/compress.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3182,7 +3182,7 @@ static size_t ZSTD_compressStream_generic(ZSTD_CStream *zcs, void *dst, size_t *
31823182
zcs->outBuffFlushedSize = 0;
31833183
zcs->stage = zcss_flush; /* pass-through to flush stage */
31843184
}
3185-
fallthrough;
3185+
/* fall through */
31863186

31873187
case zcss_flush: {
31883188
size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;

0 commit comments

Comments
 (0)