lib: Revert use of fallthrough pseudo-keyword in lib/
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 24 Aug 2020 20:36:14 +0000 (15:36 -0500)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 24 Aug 2020 21:17:44 +0000 (14:17 -0700)
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: df561f6688fe ("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>
16 files changed:
lib/asn1_decoder.c
lib/assoc_array.c
lib/bootconfig.c
lib/cmdline.c
lib/dim/net_dim.c
lib/dim/rdma_dim.c
lib/glob.c
lib/siphash.c
lib/ts_fsm.c
lib/vsprintf.c
lib/xz/xz_dec_lzma2.c
lib/xz/xz_dec_stream.c
lib/zstd/bitstream.h
lib/zstd/compress.c
lib/zstd/decompress.c
lib/zstd/huf_compress.c

index 13da529e2e724700b9f714d425470ba3c36bb14f..58f72b25f8e9e4e9e6e4c6cdf19c4631d62de378 100644 (file)
@@ -381,7 +381,7 @@ next_op:
        case ASN1_OP_END_SET_ACT:
                if (unlikely(!(flags & FLAG_MATCHED)))
                        goto tag_mismatch;
-               fallthrough;
+               /* fall through */
 
        case ASN1_OP_END_SEQ:
        case ASN1_OP_END_SET_OF:
@@ -448,7 +448,7 @@ next_op:
                        pc += asn1_op_lengths[op];
                        goto next_op;
                }
-               fallthrough;
+               /* fall through */
 
        case ASN1_OP_ACT:
                ret = actions[machine[pc + 1]](context, hdr, tag, data + tdp, len);
index 04c98799c3baf288aee4d66ce8b1f04f7024ce9a..6f4bcf5245547187876a498dfe9688b6e207d1d0 100644 (file)
@@ -1113,7 +1113,7 @@ struct assoc_array_edit *assoc_array_delete(struct assoc_array *array,
                                                index_key))
                                goto found_leaf;
                }
-               fallthrough;
+               /* fall through */
        case assoc_array_walk_tree_empty:
        case assoc_array_walk_found_wrong_shortcut:
        default:
index 1b5de2a45b277ac18f67e1ec54f85287e2cae40c..2c905a91d4ebe51d81574764b6a8c6a29cc4c693 100644 (file)
@@ -817,7 +817,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
                                                        q - 2);
                                break;
                        }
-                       fallthrough;
+                       /* fall through */
                case '=':
                        ret = xbc_parse_kv(&p, q, c);
                        break;
@@ -826,7 +826,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
                        break;
                case '#':
                        q = skip_comment(q);
-                       fallthrough;
+                       /* fall through */
                case ';':
                case '\n':
                        ret = xbc_parse_key(&p, q);
index 55768b4f3f587f709cf9940f1dea471574fe855d..fbb9981a04a41b0e5c5599340362aa50f1e2f5c6 100644 (file)
@@ -132,23 +132,23 @@ unsigned long long memparse(const char *ptr, char **retptr)
        case 'E':
        case 'e':
                ret <<= 10;
-               fallthrough;
+               /* fall through */
        case 'P':
        case 'p':
                ret <<= 10;
-               fallthrough;
+               /* fall through */
        case 'T':
        case 't':
                ret <<= 10;
-               fallthrough;
+               /* fall through */
        case 'G':
        case 'g':
                ret <<= 10;
-               fallthrough;
+               /* fall through */
        case 'M':
        case 'm':
                ret <<= 10;
-               fallthrough;
+               /* fall through */
        case 'K':
        case 'k':
                ret <<= 10;
index 06811d866775c0c353a885f119879c7cc992db5d..a4db51c2126633c35c3f0ee789022a3562596b80 100644 (file)
@@ -233,7 +233,7 @@ void net_dim(struct dim *dim, struct dim_sample end_sample)
                        schedule_work(&dim->work);
                        break;
                }
-               fallthrough;
+               /* fall through */
        case DIM_START_MEASURE:
                dim_update_sample(end_sample.event_ctr, end_sample.pkt_ctr,
                                  end_sample.byte_ctr, &dim->start_sample);
index 15462d54758d3b77c66cf6e6e1afe6d3fca2f9f2..f7e26c7b4749fc725c9756a4f9899de7a9163ed1 100644 (file)
@@ -59,7 +59,7 @@ static bool rdma_dim_decision(struct dim_stats *curr_stats, struct dim *dim)
                        break;
                case DIM_STATS_WORSE:
                        dim_turn(dim);
-                       fallthrough;
+                       /* fall through */
                case DIM_STATS_BETTER:
                        step_res = rdma_dim_step(dim);
                        if (step_res == DIM_ON_EDGE)
@@ -94,7 +94,7 @@ void rdma_dim(struct dim *dim, u64 completions)
                        schedule_work(&dim->work);
                        break;
                }
-               fallthrough;
+               /* fall through */
        case DIM_START_MEASURE:
                dim->state = DIM_MEASURE_IN_PROGRESS;
                dim_update_sample_with_comps(curr_sample->event_ctr, 0, 0,
index 85ecbda45cd8c1f889e6ec892bad86f7eef0a160..52e3ed7e4a9b8d331148a7dec6a640c43b0104ba 100644 (file)
@@ -102,7 +102,7 @@ bool __pure glob_match(char const *pat, char const *str)
                        break;
                case '\\':
                        d = *pat++;
-                       fallthrough;
+                       /* fall through */
                default:        /* Literal character */
 literal:
                        if (c == d) {
index a90112ee72a1fee70ddab19281d354734b9b1bec..c47bb6ff21499780b125543eccc3d4406787bf5a 100644 (file)
@@ -68,11 +68,11 @@ u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
                                                  bytemask_from_count(left)));
 #else
        switch (left) {
-       case 7: b |= ((u64)end[6]) << 48; fallthrough;
-       case 6: b |= ((u64)end[5]) << 40; fallthrough;
-       case 5: b |= ((u64)end[4]) << 32; fallthrough;
+       case 7: b |= ((u64)end[6]) << 48; /* fall through */
+       case 6: b |= ((u64)end[5]) << 40; /* fall through */
+       case 5: b |= ((u64)end[4]) << 32; /* fall through */
        case 4: b |= le32_to_cpup(data); break;
-       case 3: b |= ((u64)end[2]) << 16; fallthrough;
+       case 3: b |= ((u64)end[2]) << 16; /* fall through */
        case 2: b |= le16_to_cpup(data); break;
        case 1: b |= end[0];
        }
@@ -101,11 +101,11 @@ u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key)
                                                  bytemask_from_count(left)));
 #else
        switch (left) {
-       case 7: b |= ((u64)end[6]) << 48; fallthrough;
-       case 6: b |= ((u64)end[5]) << 40; fallthrough;
-       case 5: b |= ((u64)end[4]) << 32; fallthrough;
+       case 7: b |= ((u64)end[6]) << 48; /* fall through */
+       case 6: b |= ((u64)end[5]) << 40; /* fall through */
+       case 5: b |= ((u64)end[4]) << 32; /* fall through */
        case 4: b |= get_unaligned_le32(end); break;
-       case 3: b |= ((u64)end[2]) << 16; fallthrough;
+       case 3: b |= ((u64)end[2]) << 16; /* fall through */
        case 2: b |= get_unaligned_le16(end); break;
        case 1: b |= end[0];
        }
@@ -268,11 +268,11 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
                                                  bytemask_from_count(left)));
 #else
        switch (left) {
-       case 7: b |= ((u64)end[6]) << 48; fallthrough;
-       case 6: b |= ((u64)end[5]) << 40; fallthrough;
-       case 5: b |= ((u64)end[4]) << 32; fallthrough;
+       case 7: b |= ((u64)end[6]) << 48; /* fall through */
+       case 6: b |= ((u64)end[5]) << 40; /* fall through */
+       case 5: b |= ((u64)end[4]) << 32; /* fall through */
        case 4: b |= le32_to_cpup(data); break;
-       case 3: b |= ((u64)end[2]) << 16; fallthrough;
+       case 3: b |= ((u64)end[2]) << 16; /* fall through */
        case 2: b |= le16_to_cpup(data); break;
        case 1: b |= end[0];
        }
@@ -301,11 +301,11 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
                                                  bytemask_from_count(left)));
 #else
        switch (left) {
-       case 7: b |= ((u64)end[6]) << 48; fallthrough;
-       case 6: b |= ((u64)end[5]) << 40; fallthrough;
-       case 5: b |= ((u64)end[4]) << 32; fallthrough;
+       case 7: b |= ((u64)end[6]) << 48; /* fall through */
+       case 6: b |= ((u64)end[5]) << 40; /* fall through */
+       case 5: b |= ((u64)end[4]) << 32; /* fall through */
        case 4: b |= get_unaligned_le32(end); break;
-       case 3: b |= ((u64)end[2]) << 16; fallthrough;
+       case 3: b |= ((u64)end[2]) << 16; /* fall through */
        case 2: b |= get_unaligned_le16(end); break;
        case 1: b |= end[0];
        }
@@ -431,7 +431,7 @@ u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
                v0 ^= m;
        }
        switch (left) {
-       case 3: b |= ((u32)end[2]) << 16; fallthrough;
+       case 3: b |= ((u32)end[2]) << 16; /* fall through */
        case 2: b |= le16_to_cpup(data); break;
        case 1: b |= end[0];
        }
@@ -454,7 +454,7 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
                v0 ^= m;
        }
        switch (left) {
-       case 3: b |= ((u32)end[2]) << 16; fallthrough;
+       case 3: b |= ((u32)end[2]) << 16; /* fall through */
        case 2: b |= get_unaligned_le16(end); break;
        case 1: b |= end[0];
        }
index 64fd9015ad80beb2d24efda1c1eabc1e5ee618eb..ab749ec10ab538550729e5cc570107b683038a23 100644 (file)
@@ -193,7 +193,7 @@ startover:
                                TOKEN_MISMATCH();
 
                        block_idx++;
-                       fallthrough;
+                       /* fall through */
 
                case TS_FSM_ANY:
                        if (next == NULL)
index 19ebe1b257eca098a6d0601170550f88933430cf..afb9521ddf91975aa6ebb2e853712f50f3f94cc3 100644 (file)
@@ -1265,7 +1265,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr,
 
        case 'R':
                reversed = true;
-               fallthrough;
+               /* fall through */
 
        default:
                separator = ':';
@@ -1682,7 +1682,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
        switch (*(++fmt)) {
        case 'L':
                uc = true;
-               fallthrough;
+               /* fall through */
        case 'l':
                index = guid_index;
                break;
@@ -2219,7 +2219,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
        case 'S':
        case 's':
                ptr = dereference_symbol_descriptor(ptr);
-               fallthrough;
+               /* fall through */
        case 'B':
                return symbol_string(buf, end, ptr, spec, fmt);
        case 'R':
@@ -2450,7 +2450,7 @@ qualifier:
 
        case 'x':
                spec->flags |= SMALL;
-               fallthrough;
+               /* fall through */
 
        case 'X':
                spec->base = 16;
@@ -2468,7 +2468,7 @@ qualifier:
                 * utility, treat it as any other invalid or
                 * unsupported format specifier.
                 */
-               fallthrough;
+               /* fall through */
 
        default:
                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)
                        break;
                case 'i':
                        base = 0;
-                       fallthrough;
+                       /* fall through */
                case 'd':
                        is_sign = true;
-                       fallthrough;
+                       /* fall through */
                case 'u':
                        break;
                case '%':
index ca2603abee08e136ae3a817834eadd1173003f55..65a1aad8c223b95bf442519c9aa12bfd665dccc3 100644 (file)
@@ -1043,7 +1043,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
 
                        s->lzma2.sequence = SEQ_LZMA_PREPARE;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_LZMA_PREPARE:
                        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,
                        s->lzma2.compressed -= RC_INIT_BYTES;
                        s->lzma2.sequence = SEQ_LZMA_RUN;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_LZMA_RUN:
                        /*
index fea86deaaa01dae8883d20b12430d7bf6127fe7c..32ab2a08b7cbc9ff5a874d1ffe5cfd12d221e901 100644 (file)
@@ -583,7 +583,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
                        if (ret != XZ_OK)
                                return ret;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_BLOCK_START:
                        /* 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)
                        s->temp.pos = 0;
                        s->sequence = SEQ_BLOCK_HEADER;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_BLOCK_HEADER:
                        if (!fill_temp(s, b))
@@ -620,7 +620,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_BLOCK_UNCOMPRESS;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_BLOCK_UNCOMPRESS:
                        ret = dec_block(s, b);
@@ -629,7 +629,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_BLOCK_PADDING;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_BLOCK_PADDING:
                        /*
@@ -651,7 +651,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_BLOCK_CHECK;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_BLOCK_CHECK:
                        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)
 
                        s->sequence = SEQ_INDEX_PADDING;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_INDEX_PADDING:
                        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)
 
                        s->sequence = SEQ_INDEX_CRC32;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_INDEX_CRC32:
                        ret = crc32_validate(s, b);
@@ -709,7 +709,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
                        s->temp.size = STREAM_HEADER_SIZE;
                        s->sequence = SEQ_STREAM_FOOTER;
 
-                       fallthrough;
+                       /* fall through */
 
                case SEQ_STREAM_FOOTER:
                        if (!fill_temp(s, b))
index 7c65c66e41fd48ed65c5204362d6fb0e52d95602..3a49784d5c61a8d36ae4a61dfe806d9e9cbf816d 100644 (file)
@@ -259,15 +259,15 @@ ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, s
                bitD->bitContainer = *(const BYTE *)(bitD->start);
                switch (srcSize) {
                case 7: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[6]) << (sizeof(bitD->bitContainer) * 8 - 16);
-                       fallthrough;
+                       /* fall through */
                case 6: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[5]) << (sizeof(bitD->bitContainer) * 8 - 24);
-                       fallthrough;
+                       /* fall through */
                case 5: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[4]) << (sizeof(bitD->bitContainer) * 8 - 32);
-                       fallthrough;
+                       /* fall through */
                case 4: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[3]) << 24;
-                       fallthrough;
+                       /* fall through */
                case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16;
-                       fallthrough;
+                       /* fall through */
                case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8;
                default:;
                }
index b080264ed3adf3900a37f0070e9bfddc0e3caec1..5e0b67003e55050d830244f13fa860520dc0e1b2 100644 (file)
@@ -3182,7 +3182,7 @@ static size_t ZSTD_compressStream_generic(ZSTD_CStream *zcs, void *dst, size_t *
                                zcs->outBuffFlushedSize = 0;
                                zcs->stage = zcss_flush; /* pass-through to flush stage */
                        }
-                       fallthrough;
+                       /* fall through */
 
                case zcss_flush: {
                        size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;
index 66cd487a326a818471e877fcafc2ef42b1b67a5b..db6761ea4deb5949a4c41249ae48145a8ebfc8fb 100644 (file)
@@ -442,7 +442,7 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize
                case set_repeat:
                        if (dctx->litEntropy == 0)
                                return ERROR(dictionary_corrupted);
-                       fallthrough;
+                       /* fall through */
                case set_compressed:
                        if (srcSize < 5)
                                return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for case 3 */
@@ -1768,7 +1768,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, c
                        return 0;
                }
                dctx->expected = 0; /* not necessary to copy more */
-               fallthrough;
+               /* fall through */
 
        case ZSTDds_decodeFrameHeader:
                memcpy(dctx->headerBuffer + ZSTD_frameHeaderSize_prefix, src, dctx->expected);
@@ -2309,7 +2309,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                switch (zds->stage) {
                case zdss_init:
                        ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */
-                       fallthrough;
+                       /* fall through */
 
                case zdss_loadHeader: {
                        size_t const hSize = ZSTD_getFrameParams(&zds->fParams, zds->headerBuffer, zds->lhSize);
@@ -2376,7 +2376,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                        }
                        zds->stage = zdss_read;
                }
-                       fallthrough;
+                       /* fall through */
 
                case zdss_read: {
                        size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx);
@@ -2405,7 +2405,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                        zds->stage = zdss_load;
                        /* pass-through */
                }
-                       fallthrough;
+                       /* fall through */
 
                case zdss_load: {
                        size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx);
@@ -2438,7 +2438,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                                /* pass-through */
                        }
                }
-                       fallthrough;
+                       /* fall through */
 
                case zdss_flush: {
                        size_t const toFlushSize = zds->outEnd - zds->outStart;
index 08b4ae80aed43d36147817e3f2dcd30242f7feda..e727812d12aad1d07dfcfc34a3b2708f02c34143 100644 (file)
@@ -556,9 +556,9 @@ size_t HUF_compress1X_usingCTable(void *dst, size_t dstSize, const void *src, si
        n = srcSize & ~3; /* join to mod 4 */
        switch (srcSize & 3) {
        case 3: HUF_encodeSymbol(&bitC, ip[n + 2], CTable); HUF_FLUSHBITS_2(&bitC);
-               fallthrough;
+               /* fall through */
        case 2: HUF_encodeSymbol(&bitC, ip[n + 1], CTable); HUF_FLUSHBITS_1(&bitC);
-               fallthrough;
+               /* fall through */
        case 1: HUF_encodeSymbol(&bitC, ip[n + 0], CTable); HUF_FLUSHBITS(&bitC);
        case 0:
        default:;