x86: Use fallthrough pseudo-keyword
Subsystems (3)
PATCH 1/1 x86: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case.
--- arch/x86/boot/cmdline.c | 4 ++-- arch/x86/boot/compressed/kaslr.c | 2 +- arch/x86/kernel/alternative.c | 3 +-- arch/x86/kernel/apic/io_apic.c | 4 ++-- arch/x86/kernel/apic/probe_32.c | 2 +- arch/x86/kernel/cpu/cacheinfo.c | 2 +- arch/x86/kernel/cpu/mtrr/cyrix.c | 2 +- arch/x86/kernel/hw_breakpoint.c | 2 +- arch/x86/kernel/kgdb.c | 4 ++-- arch/x86/kernel/mpparse.c | 4 ++-- arch/x86/kernel/ptrace.c | 2 +- arch/x86/kernel/reboot.c | 2 +- arch/x86/kernel/signal.c | 2 +- arch/x86/kernel/uprobes.c | 4 ++-- arch/x86/lib/cmdline.c | 8 ++++---- arch/x86/lib/insn-eval.c | 7 ++----- 16 files changed, 25 insertions(+), 29 deletions(-)
arch/x86/boot/cmdline.c +2 -2
@@ -54,7 +54,7 @@ int __cmdline_find_option(unsigned long cmdline_ptr, const char *option, char *b/* else */ state = st_wordcmp; opptr = option; -/* fall through */ + fallthrough;case st_wordcmp:if (c =='=' && !*opptr) {
@@ -129,7 +129,7 @@ int __cmdline_find_option_bool(unsigned long cmdline_ptr, const char *option) state = st_wordcmp; opptr = option; wstart = pos; -/* fall through */ + fallthrough;case st_wordcmp:if (!*opptr)
arch/x86/boot/compressed/kaslr.c +1 -1
@@ -185,7 +185,7 @@ parse_memmap(char *p, unsigned long long *start, unsigned long long *size, } *size =0 ; } -/* Fall through */ + fallthrough;default :/* * If w/o offset, only size specified, memmap=nn[KMG] has the
arch/x86/kernel/alternative.c +1 -2
@@ -235,8 +235,7 @@ void __init arch_init_ideal_nops(void) ideal_nops = p6_nops;return ; } - -/* fall through */ + fallthrough;default :#ifdef CONFIG_X86_64
arch/x86/kernel/apic/io_apic.c +2 -2
@@ -800,7 +800,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 */ + fallthrough;case MP_IRQPOL_ACTIVE_LOW :default :/* Pointless default required due to do gcc stupidity */ return IOAPIC_POL_LOW ;
@@ -848,7 +848,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 */ + fallthrough;case MP_IRQTRIG_LEVEL :default :/* Pointless default required due to do gcc stupidity */ return IOAPIC_LEVEL ;
arch/x86/kernel/apic/probe_32.c +1 -1
@@ -148,7 +148,7 @@ void __init default_setup_apic_routing(void)break ; }/* P4 and above */ -/* fall through */ + fallthrough;case X86_VENDOR_HYGON :case X86_VENDOR_AMD : def_to_bigsmp =1 ;
arch/x86/kernel/cpu/cacheinfo.c +1 -1
@@ -248,7 +248,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,switch (leaf) {case 1 : l1 = &l1i; -/* fall through */ + fallthrough;case 0 :if (!l1->val)return ;
arch/x86/kernel/cpu/mtrr/cyrix.c +1 -1
@@ -98,7 +98,7 @@ cyrix_get_free_region(unsigned long base, unsigned long size, int replace_reg)case 7 :if (size <0x40 )break ; -/* Else, fall through */ + fallthrough;case 6 :case 5 :case 4 :
arch/x86/kernel/hw_breakpoint.c +1 -1
@@ -349,7 +349,7 @@ static int arch_build_bp_info(struct perf_event *bp, hw->len =X86_BREAKPOINT_LEN_X ;return 0 ; } -/* fall through */ + fallthrough;default :return -EINVAL ; }
arch/x86/kernel/kgdb.c +2 -2
@@ -450,7 +450,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 */ + fallthrough;case 'D' :case 'k' :/* clear the trace bit */
@@ -539,7 +539,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)* a system call which should be ignored */ return NOTIFY_DONE ; -/* fall through */ + fallthrough;default :if (user_mode (regs))return NOTIFY_DONE ;
arch/x86/kernel/mpparse.c +2 -2
@@ -311,7 +311,7 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)case 2 :if (i ==0 || i ==13 )continue ;/* IRQ0 & IRQ13 not connected */ -/* fall through */ + fallthrough;default :if (i ==2 )continue ;/* IRQ2 is never connected */
@@ -355,7 +355,7 @@ static void __init construct_ioapic_table(int mpc_default_type)default :pr_err ("???\nUnknown standard configuration %d\n" , mpc_default_type); -/* fall through */ + fallthrough;case 1 :case 5 :memcpy (bus.bustype,"ISA " ,6 );
arch/x86/kernel/ptrace.c +1 -1
@@ -204,7 +204,7 @@ static int set_segment_reg(struct task_struct *task,case offsetof(struct user_regs_struct , ss):if (unlikely (value ==0 ))return -EIO ; -/* Else, fall through */ + fallthrough;default : *pt_regs_access (task_pt_regs (task), offset) = value;
arch/x86/kernel/reboot.c +1 -1
@@ -654,7 +654,7 @@ static void native_machine_emergency_restart(void)case BOOT_CF9_FORCE : port_cf9_safe = true; -/* Fall through */ + fallthrough;case BOOT_CF9_SAFE :if (port_cf9_safe) {
arch/x86/kernel/signal.c +1 -1
@@ -725,7 +725,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs) regs->ax = -EINTR ;break ; } -/* fallthrough */ + fallthrough;case -ERESTARTNOINTR : regs->ax = regs->orig_ax; regs->ip -=2 ;
arch/x86/kernel/uprobes.c +2 -2
@@ -735,7 +735,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 */ + fallthrough;default :if (!is_cond_jmp_opcode (opc1))return -ENOSYS ;
@@ -892,7 +892,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, fix_ip_or_call =0 ;break ; } -/* fall through */ + fallthrough;default :riprel_analyze (auprobe, &insn); }
arch/x86/lib/cmdline.c +4 -4
@@ -58,7 +58,7 @@ __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size, state = st_wordcmp; opptr = option; wstart = pos; -/* fall through */ + fallthrough;case st_wordcmp:if (!*opptr) {
@@ -89,7 +89,7 @@ __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size,break ; } state = st_wordskip; -/* fall through */ + fallthrough;case st_wordskip:if (!c)
@@ -151,7 +151,7 @@ __cmdline_find_option(const char *cmdline, int max_cmdline_size, state = st_wordcmp; opptr = option; -/* fall through */ + fallthrough;case st_wordcmp:if ((c =='=' ) && !*opptr) {
@@ -172,7 +172,7 @@ __cmdline_find_option(const char *cmdline, int max_cmdline_size,break ; } state = st_wordskip; -/* fall through */ + fallthrough;case st_wordskip:if (myisspace (c))
arch/x86/lib/insn-eval.c +2 -5
@@ -178,8 +178,7 @@ static int resolve_default_seg(struct insn *insn, struct pt_regs *regs, int off)/* Need insn to verify address size. */ if (insn->addr_bytes ==2 )return -EINVAL ; - -/* fall through */ + fallthrough;case -EDOM :case offsetof(struct pt_regs , bx):
@@ -362,7 +361,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)case INAT_SEG_REG_GS :return vm86regs->gs;case INAT_SEG_REG_IGNORE : -/* fall through */ default :return -EINVAL ; }
@@ -386,7 +384,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)*/ return get_user_gs (regs);case INAT_SEG_REG_IGNORE : -/* fall through */ default :return -EINVAL ; }
@@ -786,7 +783,7 @@ int insn_get_code_seg_params(struct pt_regs *regs)*/ return INSN_CODE_SEG_PARAMS (4 ,8 );case 3 :/* Invalid setting. CS.L=1, CS.D=1 */ -/* fall through */ + fallthrough;default :return -EINVAL ; }
Borislav Petkov
maintainerQuoted 5 lines · Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case.
...
Quoted 9 lines
arch/x86/lib/insn-eval.c +0
-1@@ -362,7 +361,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)case INAT_SEG_REG_GS :return vm86regs->gs;case INAT_SEG_REG_IGNORE : -/* fall through */ default :return -EINVAL ; }
arch/x86/lib/insn-eval.c static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx) · line 389
Quoted 7 lines
arch/x86/lib/insn-eval.c +0
-1@@ -386,7 +384,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)*/ return get_user_gs (regs);case INAT_SEG_REG_IGNORE : -/* fall through */ default :return -EINVAL ; }
What's the logic for those two to not get a fallthrough; marker?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 19 lines · Borislav Petkov
Quoted 5 lines · Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case.
...
Quoted 10 lines
arch/x86/lib/insn-eval.c +0
-1@@ -362,7 +361,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)case INAT_SEG_REG_GS :return vm86regs->gs;case INAT_SEG_REG_IGNORE : -/* fall through */ default :return -EINVAL ; }@@ -386,7 +384,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)*/
Quoted 8 lines
arch/x86/lib/insn-eval.c static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx) · line 389
Quoted 6 lines
arch/x86/lib/insn-eval.c +0
-1return get_user_gs (regs);case INAT_SEG_REG_IGNORE : -/* fall through */ default :return -EINVAL ; }What's the logic for those two to not get a fallthrough; marker?
consecutive case labels do not need one.
Borislav Petkov
maintainerQuoted 3 lines · Joe Perches
Quoted 1 line
What's the logic for those two to not get a fallthrough; marker?
consecutive case labels do not need one.
Because?
Also, this along with the reason why needs to be documented here too:
https://www.kernel.org/doc/html/latest/process/deprecated.html#implicit-switch-case-fall-through
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette