diff mbox series

MIPS: op_model_mipsxx: Fix non-executable code bug

Message ID 20200819045813.GA24181@embeddedor (mailing list archive)
State Accepted
Commit 5900acb374fe2f4f42bbcb2c84db64f582d917a1
Headers show
Series MIPS: op_model_mipsxx: Fix non-executable code bug | expand

Commit Message

Gustavo A. R. Silva Aug. 19, 2020, 4:58 a.m. UTC
The fallthrough pseudo-keyword is being wrongly used and is causing
the non-executable code error below:

arch/mips/oprofile/op_model_mipsxx.c: In function ‘mipsxx_perfcount_handler’:
./include/linux/compiler_attributes.h:214:41: warning: statement will never be executed [-Wswitch-unreachable]
 # define fallthrough                    __attribute__((__fallthrough__))
                                         ^
arch/mips/oprofile/op_model_mipsxx.c:248:2: note: in expansion of macro ‘fallthrough’
  fallthrough;       \
  ^~~~~~~~~~~
arch/mips/oprofile/op_model_mipsxx.c:258:2: note: in expansion of macro ‘HANDLE_COUNTER’
  HANDLE_COUNTER(3)
  ^~~~~~~~~~~~~~

Fix this by placing the fallthrough macro at the proper place.

Fixes: c9b029903466 ("MIPS: Use fallthrough for arch/mips")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 arch/mips/oprofile/op_model_mipsxx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Bogendoerfer Aug. 21, 2020, 7:46 a.m. UTC | #1
On Tue, Aug 18, 2020 at 11:58:13PM -0500, Gustavo A. R. Silva wrote:
> The fallthrough pseudo-keyword is being wrongly used and is causing
> the non-executable code error below:
> 
> arch/mips/oprofile/op_model_mipsxx.c: In function ‘mipsxx_perfcount_handler’:
> ./include/linux/compiler_attributes.h:214:41: warning: statement will never be executed [-Wswitch-unreachable]
>  # define fallthrough                    __attribute__((__fallthrough__))
>                                          ^
> arch/mips/oprofile/op_model_mipsxx.c:248:2: note: in expansion of macro ‘fallthrough’
>   fallthrough;       \
>   ^~~~~~~~~~~
> arch/mips/oprofile/op_model_mipsxx.c:258:2: note: in expansion of macro ‘HANDLE_COUNTER’
>   HANDLE_COUNTER(3)
>   ^~~~~~~~~~~~~~
> 
> Fix this by placing the fallthrough macro at the proper place.
> 
> Fixes: c9b029903466 ("MIPS: Use fallthrough for arch/mips")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>  arch/mips/oprofile/op_model_mipsxx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-fixes.

Thomas.
diff mbox series

Patch

diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 1493c49ca47a..f200b97bdef7 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -245,7 +245,6 @@  static int mipsxx_perfcount_handler(void)
 
 	switch (counters) {
 #define HANDLE_COUNTER(n)						\
-	fallthrough;							\
 	case n + 1:							\
 		control = r_c0_perfctrl ## n();				\
 		counter = r_c0_perfcntr ## n();				\
@@ -254,7 +253,8 @@  static int mipsxx_perfcount_handler(void)
 			oprofile_add_sample(get_irq_regs(), n);		\
 			w_c0_perfcntr ## n(reg.counter[n]);		\
 			handled = IRQ_HANDLED;				\
-		}
+		}							\
+	fallthrough;
 	HANDLE_COUNTER(3)
 	HANDLE_COUNTER(2)
 	HANDLE_COUNTER(1)