x86/kernel: Mark expected switch fall-throughs
PATCH 1/1 x86/kernel: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
This patch fixes the following warnings:
arch/x86/kernel/hw_breakpoint.c:278:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kernel/cpu/cacheinfo.c:250:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kernel/kgdb.c:468:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kernel/uprobes.c:747:8: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kernel/apic/io_apic.c: In function ‘irq_trigger’:./include/linux/printk.h:305:2: warning: this statement may fall through [-Wimplicit-fallthrough=]
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./include/linux/printk.h:306:17: note: in expansion of macro ‘pr_warning’
#define pr_warn pr_warning
^~~~~~~~~~arch/x86/kernel/apic/io_apic.c:861:3: note: in expansion of macro ‘pr_warn’
pr_warn("IOAPIC: Invalid trigger mode 2 defaulting to level\n");
^~~~~~~arch/x86/kernel/apic/io_apic.c:862:2: note: here
case MP_IRQTRIG_LEVEL:
^~~~arch/x86/kernel/apic/io_apic.c: In function ‘irq_polarity’:./include/linux/printk.h:305:2: warning: this statement may fall through [-Wimplicit-fallthrough=]
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~./include/linux/printk.h:306:17: note: in expansion of macro ‘pr_warning’
#define pr_warn pr_warning
^~~~~~~~~~arch/x86/kernel/apic/io_apic.c:814:3: note: in expansion of macro ‘pr_warn’
pr_warn("IOAPIC: Invalid polarity: 2, defaulting to low\n"); ^~~~~~~arch/x86/kernel/apic/io_apic.c:815:2: note: here
case MP_IRQPOL_ACTIVE_LOW:
^~~~
Warning level 3 was used: -Wimplicit-fallthrough=3
This patch is part of the ongoing efforts to enabling -Wimplicit-fallthrough.
--- arch/x86/kernel/apic/io_apic.c | 2 ++ arch/x86/kernel/cpu/cacheinfo.c | 1 + arch/x86/kernel/hw_breakpoint.c | 1 + arch/x86/kernel/kgdb.c | 1 + arch/x86/kernel/uprobes.c | 1 + 5 files changed, 6 insertions(+)
arch/x86/kernel/apic/io_apic.c +2 -0
@@ -812,6 +812,7 @@ static int irq_polarity(int idx)return IOAPIC_POL_HIGH ;case MP_IRQPOL_RESERVED :pr_warn ("IOAPIC: Invalid polarity: 2, defaulting to low\n" ); +/* fall through */ case MP_IRQPOL_ACTIVE_LOW :default :/* Pointless default required due to do gcc stupidity */ return IOAPIC_POL_LOW ;
@@ -859,6 +860,7 @@ static int irq_trigger(int idx)return IOAPIC_EDGE ;case MP_IRQTRIG_RESERVED :pr_warn ("IOAPIC: Invalid trigger mode 2 defaulting to level\n" ); +/* fall through */ case MP_IRQTRIG_LEVEL :default :/* Pointless default required due to do gcc stupidity */ return IOAPIC_LEVEL ;
arch/x86/kernel/cpu/cacheinfo.c +1 -0
@@ -248,6 +248,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,switch (leaf) {case 1 : l1 = &l1i; +/* fall through */ case 0 :if (!l1->val)return ;
arch/x86/kernel/hw_breakpoint.c +1 -0
@@ -279,6 +279,7 @@ static int arch_build_bp_info(struct perf_event *bp, hw->len =X86_BREAKPOINT_LEN_X ;return 0 ; } +/* fall through */ default :return -EINVAL ; }
arch/x86/kernel/kgdb.c +1 -0
@@ -467,6 +467,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code, ptr = &remcomInBuffer[1 ];if (kgdb_hex2long (&ptr, &addr)) linux_regs->ip = addr; +/* fall through */ case 'D' :case 'k' :/* clear the trace bit */
arch/x86/kernel/uprobes.c +1 -0
@@ -745,6 +745,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)* OPCODE1() of the "short" jmp which checks the same condition. */ opc1 =OPCODE2 (insn) -0x10 ; +/* fall through */ default :if (!is_cond_jmp_opcode (opc1))return -ENOSYS ;
Signature · 1 line
2.20.1
tip-bot for Gustavo A. R. Silva
merge bot[tip:x86/cleanups] x86/kernel: Mark expected switch-case fall-throughs
x86/kernel: Mark expected switch-case fall-throughs
Commit-ID: 6fcebf1302b43e7a610d1d2fa89f41e693249aa5 Gitweb: https://git.kernel.org/tip/6fcebf1302b43e7a610d1d2fa89f41e693249aa5 Author: Gustavo A. R. Silva <[email protected]> AuthorDate: Fri, 25 Jan 2019 12:39:03 -0600 Committer: Borislav Petkov <[email protected]> CommitDate: Sat, 26 Jan 2019 11:19:13 +0100
x86/kernel: Mark expected switch-case fall-throughs
In preparation to enable -Wimplicit-fallthrough by default, mark switch-case statements where fall-through is intentional, explicitly in order to fix a couple of -Wimplicit-fallthrough warnings.
Warning level 3 was used: -Wimplicit-fallthrough=3.
[ bp: Massasge and trim commit message. ]
--- arch/x86/kernel/apic/io_apic.c | 2 ++ arch/x86/kernel/cpu/cacheinfo.c | 1 + arch/x86/kernel/hw_breakpoint.c | 1 + arch/x86/kernel/kgdb.c | 1 + arch/x86/kernel/uprobes.c | 1 + 5 files changed, 6 insertions(+)
arch/x86/kernel/apic/io_apic.c +2 -0
@@ -812,6 +812,7 @@ static int irq_polarity(int idx)return IOAPIC_POL_HIGH ;case MP_IRQPOL_RESERVED :pr_warn ("IOAPIC: Invalid polarity: 2, defaulting to low\n" ); +/* fall through */ case MP_IRQPOL_ACTIVE_LOW :default :/* Pointless default required due to do gcc stupidity */ return IOAPIC_POL_LOW ;
@@ -859,6 +860,7 @@ static int irq_trigger(int idx)return IOAPIC_EDGE ;case MP_IRQTRIG_RESERVED :pr_warn ("IOAPIC: Invalid trigger mode 2 defaulting to level\n" ); +/* fall through */ case MP_IRQTRIG_LEVEL :default :/* Pointless default required due to do gcc stupidity */ return IOAPIC_LEVEL ;
arch/x86/kernel/cpu/cacheinfo.c +1 -0
@@ -248,6 +248,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,switch (leaf) {case 1 : l1 = &l1i; +/* fall through */ case 0 :if (!l1->val)return ;
arch/x86/kernel/hw_breakpoint.c +1 -0
@@ -279,6 +279,7 @@ static int arch_build_bp_info(struct perf_event *bp, hw->len =X86_BREAKPOINT_LEN_X ;return 0 ; } +/* fall through */ default :return -EINVAL ; }
arch/x86/kernel/kgdb.c +1 -0
@@ -467,6 +467,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code, ptr = &remcomInBuffer[1 ];if (kgdb_hex2long (&ptr, &addr)) linux_regs->ip = addr; +/* fall through */ case 'D' :case 'k' :/* clear the trace bit */
arch/x86/kernel/uprobes.c +1 -0
@@ -745,6 +745,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)* OPCODE1() of the "short" jmp which checks the same condition. */ opc1 =OPCODE2 (insn) -0x10 ; +/* fall through */ default :if (!is_cond_jmp_opcode (opc1))return -ENOSYS ;