Skip to contentSkip to conversation

time: Mark expected switch fall-throughs

PATCH New Gustavo A. R. Silva 2 participants 2 messages Jan 23, 2019 – Jan 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 time: 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:

kernel/time/hrtimer.c: In function ‘hrtimer_fixup_activate’:
./include/linux/compiler.h:77:22: warning: this statement may fall through [-Wimplicit-fallthrough=]

 # define unlikely(x) __builtin_expect(!!(x), 0)
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bug.h:125:2: note: in expansion of macro ‘unlikely’
  unlikely(__ret_warn_on);     \
  ^~~~~~~~
kernel/time/hrtimer.c:366:3: note: in expansion of macro ‘WARN_ON’
   WARN_ON(1);
   ^~~~~~~
kernel/time/hrtimer.c:368:2: note: here
  default:
  ^~~~~~~

kernel/time/timer.c: In function ‘timer_fixup_activate’:
./include/linux/compiler.h:77:22: warning: this statement may fall through [-Wimplicit-fallthrough=]

 # define unlikely(x) __builtin_expect(!!(x), 0)
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/bug.h:125:2: note: in expansion of macro ‘unlikely’
  unlikely(__ret_warn_on);     \
  ^~~~~~~~
kernel/time/timer.c:649:3: note: in expansion of macro ‘WARN_ON’
   WARN_ON(1);
   ^~~~~~~
kernel/time/timer.c:651:2: note: here
  default:
  ^~~~~~~

kernel/time/tick-broadcast.c: In function ‘tick_broadcast_control’:
kernel/time/tick-broadcast.c:377:25: warning: this statement may fall through [-Wimplicit-fallthrough=]
tick_broadcast_forced = 1;
~~~~~~~~~~~~~~~~~~~~~~^~~
kernel/time/tick-broadcast.c:378:2: note: here
case TICK_BROADCAST_ON:
^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enabling -Wimplicit-fallthrough.

---
 kernel/time/hrtimer.c        | 1 +
 kernel/time/tick-broadcast.c | 1 +
 kernel/time/timer.c          | 1 +
 3 files changed, 3 insertions(+)
kernel/time/hrtimer.c +1 -0
index 0f5f96075110..5fc8c8add815 100644
@@ -364,6 +364,7 @@ static bool hrtimer_fixup_activate(void *addr, enum debug_obj_state state)
 	switch (state) {
 	case ODEBUG_STATE_ACTIVE:
 		WARN_ON(1);
+		/* fall through */
 
 	default:
 		return false;
kernel/time/tick-broadcast.c +1 -0
index 803fa67aace9..ee834d4fb814 100644
@@ -375,6 +375,7 @@ void tick_broadcast_control(enum tick_broadcast_mode mode)
 	switch (mode) {
 	case TICK_BROADCAST_FORCE:
 		tick_broadcast_forced = 1;
+		/* fall through */
 	case TICK_BROADCAST_ON:
 		cpumask_set_cpu(cpu, tick_broadcast_on);
 		if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) {
kernel/time/timer.c +1 -0
index 6eb7cc4b6d52..b1425b7d84d5 100644
@@ -647,6 +647,7 @@ static bool timer_fixup_activate(void *addr, enum debug_obj_state state)
 
 	case ODEBUG_STATE_ACTIVE:
 		WARN_ON(1);
+		/* fall through */
 
 	default:
 		return false;
Signature · 1 line
2.20.1
#1 lore raw

[tip:timers/core] timers: Mark expected switch fall-throughs

timers: Mark expected switch fall-throughs
Commit-ID:  75b710af7139768fd4ba2d4e05335d2344796279
Gitweb:     https://git.kernel.org/tip/75b710af7139768fd4ba2d4e05335d2344796279
Author:     Gustavo A. R. Silva <[email protected]>
AuthorDate: Wed, 23 Jan 2019 02:14:13 -0600
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 29 Jan 2019 20:08:42 +0100

timers: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where fall through is indeed expected.

---
 kernel/time/hrtimer.c        | 2 +-
 kernel/time/tick-broadcast.c | 1 +
 kernel/time/timer.c          | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
kernel/time/hrtimer.c +1 -1
index f5cfa1b73d6f..6418e1bdc549 100644
@@ -364,7 +364,7 @@ static bool hrtimer_fixup_activate(void *addr, enum debug_obj_state state)
 	switch (state) {
 	case ODEBUG_STATE_ACTIVE:
 		WARN_ON(1);
-
+		/* fall through */
 	default:
 		return false;
 	}
kernel/time/tick-broadcast.c +1 -0
index 803fa67aace9..ee834d4fb814 100644
@@ -375,6 +375,7 @@ void tick_broadcast_control(enum tick_broadcast_mode mode)
 	switch (mode) {
 	case TICK_BROADCAST_FORCE:
 		tick_broadcast_forced = 1;
+		/* fall through */
 	case TICK_BROADCAST_ON:
 		cpumask_set_cpu(cpu, tick_broadcast_on);
 		if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) {
kernel/time/timer.c +1 -1
index 444156debfa0..167e71f9ed3c 100644
@@ -647,7 +647,7 @@ static bool timer_fixup_activate(void *addr, enum debug_obj_state state)
 
 	case ODEBUG_STATE_ACTIVE:
 		WARN_ON(1);
-
+		/* fall through */
 	default:
 		return false;
 	}