arm: perf: Mark expected switch fall-through
Subsystems (3)
PATCH 1/1 arm: perf: Mark expected switch fall-through
When fall-through warnings was enabled by default, d93512ef0f0e ("Makefile: Globally enable fall-through warning"), we could see the following warnings was starting to show up. However, this was originally introduced in commit 6ee33c2712fc ("ARM: hw_breakpoint: correct and simplify alignment fixup code"). Commit d968d2b801d8 ("ARM: 7497/1:hw_breakpoint: allow single-byte watchpoints on all addresses") was written with the intent to allow single-byte watchpoints on all addresses but forgot to move 'case 1:' down below 'case 2:'.
../arch/arm/kernel/hw_breakpoint.c: In function ‘hw_breakpoint_arch_parse’:../arch/arm/kernel/hw_breakpoint.c:609:7: warning: this statement may fall
through [-Wimplicit-fallthrough=]
if (hw->ctrl.len == ARM_BREAKPOINT_LEN_2)
^../arch/arm/kernel/hw_breakpoint.c:611:3: note: here
case 3:
^~~~../arch/arm/kernel/hw_breakpoint.c:613:7: warning: this statement may fall
through [-Wimplicit-fallthrough=]
if (hw->ctrl.len == ARM_BREAKPOINT_LEN_1)
^../arch/arm/kernel/hw_breakpoint.c:615:3: note: here
default:
^~~~~~~
Rework so 'case 1:' are next to 'case 3:' and also add '/* Fall through */' so that the compiler doesn't warn about fall-through.
--- arch/arm/kernel/hw_breakpoint.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +3 -1
@@ -603,15 +603,17 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,case 0 :/* Aligned */ break ; -case 1 :case 2 :/* Allow halfword watchpoints and breakpoints. */ if (hw->ctrl.len ==ARM_BREAKPOINT_LEN_2 )break ; +/* Fall through */ +case 1 :case 3 :/* Allow single byte watchpoint. */ if (hw->ctrl.len ==ARM_BREAKPOINT_LEN_1 )break ; +/* Fall through */ default : ret = -EINVAL ; goto out;
Signature · 1 line
2.20.1
Will Deacon
maintainerQuoted 40 lines · Anders Roxell
When fall-through warnings was enabled by default,
d93512ef0f0e("Makefile: Globally enable fall-through warning"), we could see the following warnings was starting to show up. However, this was originally introduced in commit6ee33c2712fc("ARM:hw_breakpoint: correct and simplify alignment fixup code"). Commitd968d2b801d8("ARM: 7497/1:hw_breakpoint: allow single-byte watchpoints on all addresses") was written with the intent to allow single-byte watchpoints on all addresses but forgot to move 'case 1:' down below 'case 2:'.
../arch/arm/kernel/hw_breakpoint.c: In function ‘hw_breakpoint_arch_parse’:../arch/arm/kernel/hw_breakpoint.c:609:7: warning: this statement may fall
through [-Wimplicit-fallthrough=]if (hw->ctrl.len == ARM_BREAKPOINT_LEN_2) ^ ../arch/arm/kernel/hw_breakpoint.c:611:3: note: here case 3: ^~~~ ../arch/arm/kernel/hw_breakpoint.c:613:7: warning: this statement may fall through [-Wimplicit-fallthrough=] if (hw->ctrl.len == ARM_BREAKPOINT_LEN_1) ^ ../arch/arm/kernel/hw_breakpoint.c:615:3: note: here default: ^~~~~~~Rework so 'case 1:' are next to 'case 3:' and also add '/* Fall through */' so that the compiler doesn't warn about fall-through.
Cc [email protected] # v3.16Fixes 6ee33c2712fc ("ARM: hw_breakpoint: correct and simplify alignment fixup code")Signed-off-by Anders Roxell <[email protected]>--- arch/arm/kernel/hw_breakpoint.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm/kernel/hw_breakpoint.c +0
-0
arch/arm/kernel/hw_breakpoint.c int hw_breakpoint_arch_parse(struct perf_event *bp, · line 611
Quoted 10 lines
arch/arm/kernel/hw_breakpoint.c +2
-1@@ -603,15 +603,17 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,case 0 :/* Aligned */ break ; -case 1 :case 2 :/* Allow halfword watchpoints and breakpoints. */ if (hw->ctrl.len ==ARM_BREAKPOINT_LEN_2 )break ; +/* Fall through */ +case 1 :
Why are you moving the 'case 1:' here? AFAICT, your patch now rejects byte-aligned watchpoints of length 2.
Will