Skip to content

Commit e9338ab

Browse files
committed
Merge tag 'Wimplicit-fallthrough-clang-5.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux
Pull fallthrough fixes from Gustavo Silva: "This fixes many fall-through warnings when building with Clang and -Wimplicit-fallthrough, and also enables -Wimplicit-fallthrough for Clang, globally. It's also important to notice that since we have adopted the use of the pseudo-keyword macro fallthrough, we also want to avoid having more /* fall through */ comments being introduced. Contrary to GCC, Clang doesn't recognize any comments as implicit fall-through markings when the -Wimplicit-fallthrough option is enabled. So, in order to avoid having more comments being introduced, we use the option -Wimplicit-fallthrough=5 for GCC, which similar to Clang, will cause a warning in case a code comment is intended to be used as a fall-through marking. The patch for Makefile also enforces this. We had almost 4,000 of these issues for Clang in the beginning, and there might be a couple more out there when building some architectures with certain configurations. However, with the recent fixes I think we are in good shape and it is now possible to enable the warning for Clang" * tag 'Wimplicit-fallthrough-clang-5.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux: (27 commits) Makefile: Enable -Wimplicit-fallthrough for Clang powerpc/smp: Fix fall-through warning for Clang dmaengine: mpc512x: Fix fall-through warning for Clang usb: gadget: fsl_qe_udc: Fix fall-through warning for Clang powerpc/powernv: Fix fall-through warning for Clang MIPS: Fix unreachable code issue MIPS: Fix fall-through warnings for Clang ASoC: Mediatek: MT8183: Fix fall-through warning for Clang power: supply: Fix fall-through warnings for Clang dmaengine: ti: k3-udma: Fix fall-through warning for Clang s390: Fix fall-through warnings for Clang dmaengine: ipu: Fix fall-through warning for Clang iommu/arm-smmu-v3: Fix fall-through warning for Clang mmc: jz4740: Fix fall-through warning for Clang PCI: Fix fall-through warning for Clang scsi: libsas: Fix fall-through warning for Clang video: fbdev: Fix fall-through warning for Clang math-emu: Fix fall-through warning cpufreq: Fix fall-through warning for Clang drm/msm: Fix fall-through warning in msm_gem_new_impl() ...
2 parents dd9c7df + b7eb335 commit e9338ab

File tree

31 files changed

+44
-27
lines changed

31 files changed

+44
-27
lines changed

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,6 @@ KBUILD_CFLAGS += -Wno-gnu
797797
# source of a reference will be _MergedGlobals and not on of the whitelisted names.
798798
# See modpost pattern 2
799799
KBUILD_CFLAGS += -mno-global-merge
800-
else
801-
802-
# Warn about unmarked fall-throughs in switch statement.
803-
# Disabled for clang while comment to attribute conversion happens and
804-
# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
805-
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
806800
endif
807801

808802
# These warnings generated too much noise in a regular build.
@@ -983,6 +977,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
983977
# warn about C99 declaration after statement
984978
KBUILD_CFLAGS += -Wdeclaration-after-statement
985979

980+
# Warn about unmarked fall-throughs in switch statement.
981+
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=5,$(call cc-option,-Wimplicit-fallthrough,))
982+
986983
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
987984
KBUILD_CFLAGS += -Wvla
988985

arch/mips/include/asm/fpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static inline int __enable_fpu(enum fpu_mode mode)
7676
/* we only have a 32-bit FPU */
7777
return SIGFPE;
7878
#endif
79-
fallthrough;
79+
/* fallthrough */
8080
case FPU_32BIT:
8181
if (cpu_has_fre) {
8282
/* clear FRE */

arch/mips/mm/tlbex.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,7 @@ static void build_r4000_tlb_refill_handler(void)
13831383
switch (boot_cpu_type()) {
13841384
default:
13851385
if (sizeof(long) == 4) {
1386+
fallthrough;
13861387
case CPU_LOONGSON2EF:
13871388
/* Loongson2 ebase is different than r4k, we have more space */
13881389
if ((p - tlb_handler) > 64)
@@ -2169,6 +2170,7 @@ static void build_r4000_tlb_load_handler(void)
21692170
default:
21702171
if (cpu_has_mips_r2_exec_hazard) {
21712172
uasm_i_ehb(&p);
2173+
fallthrough;
21722174

21732175
case CPU_CAVIUM_OCTEON:
21742176
case CPU_CAVIUM_OCTEON_PLUS:

arch/powerpc/platforms/powermac/smp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ static inline void psurge_clr_ipi(int cpu)
146146
switch(psurge_type) {
147147
case PSURGE_DUAL:
148148
out_8(psurge_sec_intr, ~0);
149+
break;
149150
case PSURGE_NONE:
150151
break;
151152
default:

arch/s390/kernel/uprobes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
126126
case DIE_SSTEP:
127127
if (uprobe_post_sstep_notifier(regs))
128128
return NOTIFY_STOP;
129+
break;
129130
default:
130131
break;
131132
}

drivers/char/powernv-op-panel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static int __op_panel_update_display(void)
7575
rc);
7676
break;
7777
}
78+
break;
7879
case OPAL_SUCCESS:
7980
break;
8081
default:

drivers/cpufreq/longhaul.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,6 @@ static int __init longhaul_init(void)
942942
return cpufreq_register_driver(&longhaul_driver);
943943
case 10:
944944
pr_err("Use acpi-cpufreq driver for VIA C7\n");
945-
default:
946-
;
947945
}
948946

949947
return -ENODEV;

drivers/dma/ipu/ipu_idmac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ static int ipu_enable_channel(struct idmac *idmac, struct idmac_channel *ichan)
618618
case IDMAC_SDC_1:
619619
case IDMAC_IC_7:
620620
ipu_channel_set_priority(ipu, channel, true);
621+
break;
621622
default:
622623
break;
623624
}
@@ -978,6 +979,7 @@ static int ipu_init_channel(struct idmac *idmac, struct idmac_channel *ichan)
978979
case IDMAC_SDC_0:
979980
case IDMAC_SDC_1:
980981
n_desc = 4;
982+
break;
981983
default:
982984
break;
983985
}

drivers/dma/mpc512x_dma.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ inline bool is_buswidth_valid(u8 buswidth, bool is_mpc8308)
813813
case 16:
814814
if (is_mpc8308)
815815
return false;
816+
break;
816817
case 1:
817818
case 2:
818819
case 4:

drivers/dma/ti/k3-udma.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4948,6 +4948,7 @@ static int setup_resources(struct udma_dev *ud)
49484948
ud->tchan_cnt),
49494949
ud->rchan_cnt - bitmap_weight(ud->rchan_map,
49504950
ud->rchan_cnt));
4951+
break;
49514952
default:
49524953
break;
49534954
}

0 commit comments

Comments
 (0)