diff --git a/cmds/reflink.c b/cmds/reflink.c index 5ed9a127..53f47848 100644 --- a/cmds/reflink.c +++ b/cmds/reflink.c @@ -120,7 +120,7 @@ static int cmd_reflink_clone(const struct cmd_struct *cmd, int argc, char **argv switch (c) { case 's': same_file = true; - /* fallthrough */ + fallthrough; case 'r': range = malloc(sizeof(struct reflink_range)); if (!range) { diff --git a/cmds/scrub.c b/cmds/scrub.c index e6513b39..782a1310 100644 --- a/cmds/scrub.c +++ b/cmds/scrub.c @@ -602,7 +602,7 @@ again: memset(p[curr], 0, sizeof(**p)); p[curr + 1] = NULL; ++state; - /* fall through */ + fallthrough; case 2: /* start of line, skip space */ while (isspace(l[i]) && i < avail) { if (l[i] == '\n') @@ -613,7 +613,7 @@ again: (!eof && !memchr(l + i, '\n', avail - i))) goto again; ++state; - /* fall through */ + fallthrough; case 3: /* read fsid */ if (i == avail) continue; @@ -629,7 +629,7 @@ again: _SCRUB_INVALID; i += j + 1; ++state; - /* fall through */ + fallthrough; case 4: /* read dev id */ for (j = 0; isdigit(l[i + j]) && i+j < avail; ++j) ; @@ -638,7 +638,7 @@ again: p[curr]->devid = atoll(&l[i]); i += j + 1; ++state; - /* fall through */ + fallthrough; case 5: /* read key/value pair */ ret = 0; _SCRUB_KVREAD(ret, &i, data_extents_scrubbed, avail, l, @@ -682,7 +682,7 @@ again: if (ret != 1) _SCRUB_INVALID; ++state; - /* fall through */ + fallthrough; case 6: /* after number */ if (l[i] == '|') state = 5; diff --git a/common/format-output.c b/common/format-output.c index c7e021b5..18993ad6 100644 --- a/common/format-output.c +++ b/common/format-output.c @@ -74,7 +74,7 @@ static void print_escaped(const char *str) case '"': case '\\': putchar('\\'); - /* fallthrough */ + fallthrough; default: putchar(*str); } diff --git a/common/parse-utils.c b/common/parse-utils.c index f16b7aac..bb3c2bbf 100644 --- a/common/parse-utils.c +++ b/common/parse-utils.c @@ -184,22 +184,22 @@ u64 parse_size_from_string(const char *s) switch (c) { case 'e': mult *= 1024; - /* fallthrough */ + fallthrough; case 'p': mult *= 1024; - /* fallthrough */ + fallthrough; case 't': mult *= 1024; - /* fallthrough */ + fallthrough; case 'g': mult *= 1024; - /* fallthrough */ + fallthrough; case 'm': mult *= 1024; - /* fallthrough */ + fallthrough; case 'k': mult *= 1024; - /* fallthrough */ + fallthrough; case 'b': break; default: diff --git a/common/units.c b/common/units.c index 698dc1d0..8d708cdd 100644 --- a/common/units.c +++ b/common/units.c @@ -89,15 +89,15 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod case UNITS_TBYTES: base *= mult; num_divs++; - /* fallthrough */ + fallthrough; case UNITS_GBYTES: base *= mult; num_divs++; - /* fallthrough */ + fallthrough; case UNITS_MBYTES: base *= mult; num_divs++; - /* fallthrough */ + fallthrough; case UNITS_KBYTES: num_divs++; break; diff --git a/crypto/xxhash.c b/crypto/xxhash.c index c2f1be9f..7f7f3f74 100644 --- a/crypto/xxhash.c +++ b/crypto/xxhash.c @@ -116,6 +116,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp #define XXH_STATIC_LINKING_ONLY #include "xxhash.h" +#include "kerncompat.h" /* ************************************* * Compiler Specific Options @@ -397,41 +398,41 @@ XXH32_finalize(U32 h32, const void* ptr, size_t len, XXH_alignment align) } else { switch(len&15) /* or switch(bEnd - p) */ { case 12: PROCESS4; - /* fallthrough */ + fallthrough; case 8: PROCESS4; - /* fallthrough */ + fallthrough; case 4: PROCESS4; return XXH32_avalanche(h32); case 13: PROCESS4; - /* fallthrough */ + fallthrough; case 9: PROCESS4; - /* fallthrough */ + fallthrough; case 5: PROCESS4; PROCESS1; return XXH32_avalanche(h32); case 14: PROCESS4; - /* fallthrough */ + fallthrough; case 10: PROCESS4; - /* fallthrough */ + fallthrough; case 6: PROCESS4; PROCESS1; PROCESS1; return XXH32_avalanche(h32); case 15: PROCESS4; - /* fallthrough */ + fallthrough; case 11: PROCESS4; - /* fallthrough */ + fallthrough; case 7: PROCESS4; - /* fallthrough */ + fallthrough; case 3: PROCESS1; - /* fallthrough */ + fallthrough; case 2: PROCESS1; - /* fallthrough */ + fallthrough; case 1: PROCESS1; - /* fallthrough */ + fallthrough; case 0: return XXH32_avalanche(h32); } XXH_ASSERT(0); @@ -825,63 +826,63 @@ XXH64_finalize(U64 h64, const void* ptr, size_t len, XXH_alignment align) } else { switch(len & 31) { case 24: PROCESS8_64; - /* fallthrough */ + fallthrough; case 16: PROCESS8_64; - /* fallthrough */ + fallthrough; case 8: PROCESS8_64; return XXH64_avalanche(h64); case 28: PROCESS8_64; - /* fallthrough */ + fallthrough; case 20: PROCESS8_64; - /* fallthrough */ + fallthrough; case 12: PROCESS8_64; - /* fallthrough */ + fallthrough; case 4: PROCESS4_64; return XXH64_avalanche(h64); case 25: PROCESS8_64; - /* fallthrough */ + fallthrough; case 17: PROCESS8_64; - /* fallthrough */ + fallthrough; case 9: PROCESS8_64; PROCESS1_64; return XXH64_avalanche(h64); case 29: PROCESS8_64; - /* fallthrough */ + fallthrough; case 21: PROCESS8_64; - /* fallthrough */ + fallthrough; case 13: PROCESS8_64; - /* fallthrough */ + fallthrough; case 5: PROCESS4_64; PROCESS1_64; return XXH64_avalanche(h64); case 26: PROCESS8_64; - /* fallthrough */ + fallthrough; case 18: PROCESS8_64; - /* fallthrough */ + fallthrough; case 10: PROCESS8_64; PROCESS1_64; PROCESS1_64; return XXH64_avalanche(h64); case 30: PROCESS8_64; - /* fallthrough */ + fallthrough; case 22: PROCESS8_64; - /* fallthrough */ + fallthrough; case 14: PROCESS8_64; - /* fallthrough */ + fallthrough; case 6: PROCESS4_64; PROCESS1_64; PROCESS1_64; return XXH64_avalanche(h64); case 27: PROCESS8_64; - /* fallthrough */ + fallthrough; case 19: PROCESS8_64; - /* fallthrough */ + fallthrough; case 11: PROCESS8_64; PROCESS1_64; PROCESS1_64; @@ -889,19 +890,19 @@ XXH64_finalize(U64 h64, const void* ptr, size_t len, XXH_alignment align) return XXH64_avalanche(h64); case 31: PROCESS8_64; - /* fallthrough */ + fallthrough; case 23: PROCESS8_64; - /* fallthrough */ + fallthrough; case 15: PROCESS8_64; - /* fallthrough */ + fallthrough; case 7: PROCESS4_64; - /* fallthrough */ + fallthrough; case 3: PROCESS1_64; - /* fallthrough */ + fallthrough; case 2: PROCESS1_64; - /* fallthrough */ + fallthrough; case 1: PROCESS1_64; - /* fallthrough */ + fallthrough; case 0: return XXH64_avalanche(h64); } } diff --git a/image/main.c b/image/main.c index e1ef3699..dd75b47c 100644 --- a/image/main.c +++ b/image/main.c @@ -1432,7 +1432,7 @@ static int restore_one_work(struct mdrestore_struct *mdres, switch (ret) { case Z_NEED_DICT: ret = Z_DATA_ERROR; - __attribute__ ((fallthrough)); + fallthrough; case Z_DATA_ERROR: case Z_MEM_ERROR: goto out; diff --git a/kerncompat.h b/kerncompat.h index 6fb79ac8..4dce65c0 100644 --- a/kerncompat.h +++ b/kerncompat.h @@ -227,6 +227,16 @@ static inline int mutex_is_locked(struct mutex *m) #define __attribute_const__ __attribute__((__const__)) #endif +/* To silence compilers (like clang) that don't understand fallthrough comments. */ + +#if defined __has_attribute +# if __has_attribute(__fallthrough__) +# define fallthrough __attribute__((__fallthrough__)) +# endif +#else +# define fallthrough do {} while (0) /* fallthrough */ +#endif + /** * __set_bit - Set a bit in memory * @nr: the bit to set diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index ba1caa88..53416628 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -796,7 +796,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type) fprintf(stream, "FIRST_CHUNK_TREE"); break; } - /* fall-thru */ + fallthrough; default: fprintf(stream, "%llu", (unsigned long long)objectid); }