From 2401022342f650ac7d845a14c7b9bf1cd87cead6 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 11 Feb 2019 11:20:29 -0700 Subject: [PATCH 1/1] Document switch fall-through cases Signed-off-by: Jens Axboe --- crc/murmur3.c | 2 ++ engines/http.c | 4 +++- hash.h | 22 +++++++++++----------- init.c | 1 + lib/lfsr.c | 16 ++++++++++++++++ t/lfsr-test.c | 5 ++++- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/crc/murmur3.c b/crc/murmur3.c index e316f592..f4f2f2c6 100644 --- a/crc/murmur3.c +++ b/crc/murmur3.c @@ -29,8 +29,10 @@ static uint32_t murmur3_tail(const uint8_t *data, const int nblocks, switch (len & 3) { case 3: k1 ^= tail[2] << 16; + /* fall through */ case 2: k1 ^= tail[1] << 8; + /* fall through */ case 1: k1 ^= tail[0]; k1 *= c1; diff --git a/engines/http.c b/engines/http.c index d81e4288..a35c0332 100644 --- a/engines/http.c +++ b/engines/http.c @@ -296,9 +296,11 @@ static int _curl_trace(CURL *handle, curl_infotype type, switch (type) { case CURLINFO_TEXT: - fprintf(stderr, "== Info: %s", data); + fprintf(stderr, "== Info: %s", data); + /* fall through */ default: case CURLINFO_SSL_DATA_OUT: + /* fall through */ case CURLINFO_SSL_DATA_IN: return 0; diff --git a/hash.h b/hash.h index d227b938..66dd3d69 100644 --- a/hash.h +++ b/hash.h @@ -141,17 +141,17 @@ static inline uint32_t jhash(const void *key, uint32_t length, uint32_t initval) /* Last block: affect all 32 bits of (c) */ /* All the case statements fall through */ switch (length) { - case 12: c += (uint32_t) k[11] << 24; - case 11: c += (uint32_t) k[10] << 16; - case 10: c += (uint32_t) k[9] << 8; - case 9: c += k[8]; - case 8: b += (uint32_t) k[7] << 24; - case 7: b += (uint32_t) k[6] << 16; - case 6: b += (uint32_t) k[5] << 8; - case 5: b += k[4]; - case 4: a += (uint32_t) k[3] << 24; - case 3: a += (uint32_t) k[2] << 16; - case 2: a += (uint32_t) k[1] << 8; + case 12: c += (uint32_t) k[11] << 24; /* fall through */ + case 11: c += (uint32_t) k[10] << 16; /* fall through */ + case 10: c += (uint32_t) k[9] << 8; /* fall through */ + case 9: c += k[8]; /* fall through */ + case 8: b += (uint32_t) k[7] << 24; /* fall through */ + case 7: b += (uint32_t) k[6] << 16; /* fall through */ + case 6: b += (uint32_t) k[5] << 8; /* fall through */ + case 5: b += k[4]; /* fall through */ + case 4: a += (uint32_t) k[3] << 24; /* fall through */ + case 3: a += (uint32_t) k[2] << 16; /* fall through */ + case 2: a += (uint32_t) k[1] << 8; /* fall through */ case 1: a += k[0]; __jhash_final(a, b, c); case 0: /* Nothing left to add */ diff --git a/init.c b/init.c index a2b70c4a..e6378715 100644 --- a/init.c +++ b/init.c @@ -2907,6 +2907,7 @@ int parse_cmd_line(int argc, char *argv[], int client_type) log_err("%s: unrecognized option '%s'\n", argv[0], argv[optind - 1]); show_closest_option(argv[optind - 1]); + /* fall through */ default: do_exit++; exit_val = 1; diff --git a/lib/lfsr.c b/lib/lfsr.c index 49e34a8c..32fbec56 100644 --- a/lib/lfsr.c +++ b/lib/lfsr.c @@ -88,21 +88,37 @@ static inline void __lfsr_next(struct fio_lfsr *fl, unsigned int spin) */ switch (spin) { case 15: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 14: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 13: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 12: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 11: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 10: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 9: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 8: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 7: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 6: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 5: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 4: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 3: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 2: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 1: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ case 0: __LFSR_NEXT(fl, fl->last_val); + /* fall through */ default: break; } } diff --git a/t/lfsr-test.c b/t/lfsr-test.c index a01f2cfc..ea8c8ddb 100644 --- a/t/lfsr-test.c +++ b/t/lfsr-test.c @@ -39,9 +39,12 @@ int main(int argc, char *argv[]) /* Read arguments */ switch (argc) { case 5: if (strncmp(argv[4], "verify", 7) == 0) - verify = 1; + verify = 1; + /* fall through */ case 4: spin = atoi(argv[3]); + /* fall through */ case 3: seed = atol(argv[2]); + /* fall through */ case 2: numbers = strtol(argv[1], NULL, 16); break; default: usage(); -- 2.25.1