Skip to content

Commit

Permalink
Merge tag 'fallthrough-fixes-clang-5.11-rc1' of git://git.kernel.org/…
Browse files Browse the repository at this point in the history
…pub/scm/linux/kernel/git/gustavoars/linux

Pull fallthrough fixes from Gustavo A. R. Silva:
 "Fix many fall-through warnings when building with Clang 12.0.0
  using -Wimplicit-fallthrough.

   - powerpc: boot: include compiler_attributes.h (Nick Desaulniers)

   - Revert "lib: Revert use of fallthrough pseudo-keyword in lib/"
     (Nick Desaulniers)

   - powerpc: fix -Wimplicit-fallthrough (Nick Desaulniers)

   - lib: Fix fall-through warnings for Clang (Gustavo A. R. Silva)"

* tag 'fallthrough-fixes-clang-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux:
  lib: Fix fall-through warnings for Clang
  powerpc: fix -Wimplicit-fallthrough
  Revert "lib: Revert use of fallthrough pseudo-keyword in lib/"
  powerpc: boot: include compiler_attributes.h
  • Loading branch information
torvalds committed Dec 16, 2020
2 parents 706451d + 36f9ff9 commit 5e60366
Show file tree
Hide file tree
Showing 24 changed files with 86 additions and 78 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/boot/Makefile
Expand Up @@ -31,6 +31,7 @@ endif
BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
-pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
-include $(srctree)/include/linux/compiler_attributes.h \
$(LINUXINCLUDE)

ifdef CONFIG_PPC64_BOOT_WRAPPER
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/boot/decompress.c
Expand Up @@ -21,7 +21,6 @@

#define STATIC static
#define INIT
#define __always_inline inline

/*
* The build process will copy the required zlib source files and headers
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/kernel/prom_init.c
Expand Up @@ -355,6 +355,7 @@ static int __init prom_strtobool(const char *s, bool *res)
default:
break;
}
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/kernel/uprobes.c
Expand Up @@ -141,6 +141,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self,
case DIE_SSTEP:
if (uprobe_post_sstep_notifier(regs))
return NOTIFY_STOP;
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/perf/imc-pmu.c
Expand Up @@ -1500,6 +1500,7 @@ static int update_pmu_ops(struct imc_pmu *pmu)
pmu->pmu.stop = trace_imc_event_stop;
pmu->pmu.read = trace_imc_event_read;
pmu->attr_groups[IMC_FORMAT_ATTR] = &trace_imc_format_group;
break;
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/asn1_decoder.c
Expand Up @@ -381,7 +381,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
case ASN1_OP_END_SET_ACT:
if (unlikely(!(flags & FLAG_MATCHED)))
goto tag_mismatch;
/* fall through */
fallthrough;

case ASN1_OP_END_SEQ:
case ASN1_OP_END_SET_OF:
Expand Down Expand Up @@ -448,7 +448,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
pc += asn1_op_lengths[op];
goto next_op;
}
/* fall through */
fallthrough;

case ASN1_OP_ACT:
ret = actions[machine[pc + 1]](context, hdr, tag, data + tdp, len);
Expand Down
2 changes: 1 addition & 1 deletion lib/assoc_array.c
Expand Up @@ -1113,7 +1113,7 @@ struct assoc_array_edit *assoc_array_delete(struct assoc_array *array,
index_key))
goto found_leaf;
}
/* fall through */
fallthrough;
case assoc_array_walk_tree_empty:
case assoc_array_walk_found_wrong_shortcut:
default:
Expand Down
4 changes: 2 additions & 2 deletions lib/bootconfig.c
Expand Up @@ -827,7 +827,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
q - 2);
break;
}
/* fall through */
fallthrough;
case '=':
ret = xbc_parse_kv(&p, q, c);
break;
Expand All @@ -836,7 +836,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
break;
case '#':
q = skip_comment(q);
/* fall through */
fallthrough;
case ';':
case '\n':
ret = xbc_parse_key(&p, q);
Expand Down
11 changes: 6 additions & 5 deletions lib/cmdline.c
Expand Up @@ -144,27 +144,28 @@ unsigned long long memparse(const char *ptr, char **retptr)
case 'E':
case 'e':
ret <<= 10;
/* fall through */
fallthrough;
case 'P':
case 'p':
ret <<= 10;
/* fall through */
fallthrough;
case 'T':
case 't':
ret <<= 10;
/* fall through */
fallthrough;
case 'G':
case 'g':
ret <<= 10;
/* fall through */
fallthrough;
case 'M':
case 'm':
ret <<= 10;
/* fall through */
fallthrough;
case 'K':
case 'k':
ret <<= 10;
endptr++;
fallthrough;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dim/net_dim.c
Expand Up @@ -233,7 +233,7 @@ void net_dim(struct dim *dim, struct dim_sample end_sample)
schedule_work(&dim->work);
break;
}
/* fall through */
fallthrough;
case DIM_START_MEASURE:
dim_update_sample(end_sample.event_ctr, end_sample.pkt_ctr,
end_sample.byte_ctr, &dim->start_sample);
Expand Down
4 changes: 2 additions & 2 deletions lib/dim/rdma_dim.c
Expand Up @@ -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);
/* fall through */
fallthrough;
case DIM_STATS_BETTER:
step_res = rdma_dim_step(dim);
if (step_res == DIM_ON_EDGE)
Expand Down Expand Up @@ -94,7 +94,7 @@ void rdma_dim(struct dim *dim, u64 completions)
schedule_work(&dim->work);
break;
}
/* fall through */
fallthrough;
case DIM_START_MEASURE:
dim->state = DIM_MEASURE_IN_PROGRESS;
dim_update_sample_with_comps(curr_sample->event_ctr, 0, 0,
Expand Down
2 changes: 1 addition & 1 deletion lib/glob.c
Expand Up @@ -102,7 +102,7 @@ bool __pure glob_match(char const *pat, char const *str)
break;
case '\\':
d = *pat++;
/* fall through */
fallthrough;
default: /* Literal character */
literal:
if (c == d) {
Expand Down
1 change: 1 addition & 0 deletions lib/kstrtox.c
Expand Up @@ -355,6 +355,7 @@ int kstrtobool(const char *s, bool *res)
default:
break;
}
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/nlattr.c
Expand Up @@ -432,7 +432,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
err = -EINVAL;
goto out_err;
}
/* fall through */
fallthrough;

case NLA_STRING:
if (attrlen < 1)
Expand Down
36 changes: 18 additions & 18 deletions lib/siphash.c
Expand Up @@ -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; /* fall through */
case 6: b |= ((u64)end[5]) << 40; /* fall through */
case 5: b |= ((u64)end[4]) << 32; /* fall through */
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 4: b |= le32_to_cpup(data); break;
case 3: b |= ((u64)end[2]) << 16; /* fall through */
case 3: b |= ((u64)end[2]) << 16; fallthrough;
case 2: b |= le16_to_cpup(data); break;
case 1: b |= end[0];
}
Expand Down Expand Up @@ -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; /* fall through */
case 6: b |= ((u64)end[5]) << 40; /* fall through */
case 5: b |= ((u64)end[4]) << 32; /* fall through */
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 4: b |= get_unaligned_le32(end); break;
case 3: b |= ((u64)end[2]) << 16; /* fall through */
case 3: b |= ((u64)end[2]) << 16; fallthrough;
case 2: b |= get_unaligned_le16(end); break;
case 1: b |= end[0];
}
Expand Down Expand Up @@ -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; /* fall through */
case 6: b |= ((u64)end[5]) << 40; /* fall through */
case 5: b |= ((u64)end[4]) << 32; /* fall through */
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 4: b |= le32_to_cpup(data); break;
case 3: b |= ((u64)end[2]) << 16; /* fall through */
case 3: b |= ((u64)end[2]) << 16; fallthrough;
case 2: b |= le16_to_cpup(data); break;
case 1: b |= end[0];
}
Expand Down Expand Up @@ -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; /* fall through */
case 6: b |= ((u64)end[5]) << 40; /* fall through */
case 5: b |= ((u64)end[4]) << 32; /* fall through */
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 4: b |= get_unaligned_le32(end); break;
case 3: b |= ((u64)end[2]) << 16; /* fall through */
case 3: b |= ((u64)end[2]) << 16; fallthrough;
case 2: b |= get_unaligned_le16(end); break;
case 1: b |= end[0];
}
Expand Down Expand Up @@ -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; /* fall through */
case 3: b |= ((u32)end[2]) << 16; fallthrough;
case 2: b |= le16_to_cpup(data); break;
case 1: b |= end[0];
}
Expand All @@ -454,7 +454,7 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
v0 ^= m;
}
switch (left) {
case 3: b |= ((u32)end[2]) << 16; /* fall through */
case 3: b |= ((u32)end[2]) << 16; fallthrough;
case 2: b |= get_unaligned_le16(end); break;
case 1: b |= end[0];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ts_fsm.c
Expand Up @@ -193,7 +193,7 @@ static unsigned int fsm_find(struct ts_config *conf, struct ts_state *state)
TOKEN_MISMATCH();

block_idx++;
/* fall through */
fallthrough;

case TS_FSM_ANY:
if (next == NULL)
Expand Down
15 changes: 8 additions & 7 deletions lib/vsprintf.c
Expand Up @@ -1265,7 +1265,7 @@ char *mac_address_string(char *buf, char *end, u8 *addr,

case 'R':
reversed = true;
/* fall through */
fallthrough;

default:
separator = ':';
Expand Down Expand Up @@ -1682,7 +1682,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
switch (*(++fmt)) {
case 'L':
uc = true;
/* fall through */
fallthrough;
case 'l':
index = guid_index;
break;
Expand Down Expand Up @@ -2219,7 +2219,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
case 'S':
case 's':
ptr = dereference_symbol_descriptor(ptr);
/* fall through */
fallthrough;
case 'B':
return symbol_string(buf, end, ptr, spec, fmt);
case 'R':
Expand Down Expand Up @@ -2450,7 +2450,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)

case 'x':
spec->flags |= SMALL;
/* fall through */
fallthrough;

case 'X':
spec->base = 16;
Expand All @@ -2459,6 +2459,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
case 'd':
case 'i':
spec->flags |= SIGN;
break;
case 'u':
break;

Expand All @@ -2468,7 +2469,7 @@ int format_decode(const char *fmt, struct printf_spec *spec)
* utility, treat it as any other invalid or
* unsupported format specifier.
*/
/* fall through */
fallthrough;

default:
WARN_ONCE(1, "Please remove unsupported %%%c in format string\n", *fmt);
Expand Down Expand Up @@ -3411,10 +3412,10 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
break;
case 'i':
base = 0;
/* fall through */
fallthrough;
case 'd':
is_sign = true;
/* fall through */
fallthrough;
case 'u':
break;
case '%':
Expand Down
4 changes: 2 additions & 2 deletions lib/xz/xz_dec_lzma2.c
Expand Up @@ -1043,7 +1043,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,

s->lzma2.sequence = SEQ_LZMA_PREPARE;

/* fall through */
fallthrough;

case SEQ_LZMA_PREPARE:
if (s->lzma2.compressed < RC_INIT_BYTES)
Expand All @@ -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;

/* fall through */
fallthrough;

case SEQ_LZMA_RUN:
/*
Expand Down

0 comments on commit 5e60366

Please sign in to comment.