Skip to contentSkip to conversation

mips/oprofile: Fix fallthrough placement

PATCH In review [email protected] 3 participants 5 messages Aug 20, 2020 – Aug 21, 2020 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips/oprofile: Fix fallthrough placement

From: He Zhe <[email protected]>

We want neither
"
include/linux/compiler_attributes.h:201:41: warning: statement will never be executed [-Wswitch-unreachable]
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"
nor
"
include/linux/compiler_attributes.h:201:41: warning: attribute 'fallthrough' not preceding a case label or default label
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"

It's not worth adding one more macro. Let's simply place the fallthrough in between the expansions.

---
 arch/mips/oprofile/op_model_mipsxx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/oprofile/op_model_mipsxx.c +3 -1
index 1493c49ca47a..55d7b7fd18b6 100644
@@ -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();				\
@@ -256,8 +255,11 @@ static int mipsxx_perfcount_handler(void)
 			handled = IRQ_HANDLED;				\
 		}
 	HANDLE_COUNTER(3)
+	fallthrough;
 	HANDLE_COUNTER(2)
+	fallthrough;
 	HANDLE_COUNTER(1)
+	fallthrough;
 	HANDLE_COUNTER(0)
 	}
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · On Thu, Aug 20, 2020 at 08:54:40PM +0800, [email protected] wrote:

From: He Zhe <[email protected]>

We want neither
"
include/linux/compiler_attributes.h:201:41: warning: statement will never be executed [-Wswitch-unreachable]
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"
nor
"
include/linux/compiler_attributes.h:201:41: warning: attribute 'fallthrough' not preceding a case label or default label
201 | # define fallthrough __attribute__((__fallthrough__))

Quoted 7 lines
      |                      ^~~~~~~~~~~~~

"

It's not worth adding one more macro. Let's simply place the fallthrough in between the expansions.

there is already another patch for the problem, which I've applied to mips-fixes.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
author
#2 lore raw
Quoted 18 lines · Thomas Bogendoerfer
Quoted 17 lines · On Thu, Aug 20, 2020 at 08:54:40PM +0800, [email protected] wrote:

From: He Zhe <[email protected]>

We want neither
"
include/linux/compiler_attributes.h:201:41: warning: statement will never be executed [-Wswitch-unreachable]
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"
nor
"
include/linux/compiler_attributes.h:201:41: warning: attribute 'fallthrough' not preceding a case label or default label
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"

Quoted 6 lines
Quoted 4 lines

It's not worth adding one more macro. Let's simply place the fallthrough in between the expansions.

there is already another patch for the problem, which I've applied to mips-fixes.

You mean the below one?
https://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git/commit/?h=mips-fixes&id=5900acb374fe2f4f42bbcb2c84db64f582d917a1

That patch handles the first warning in my commit log but does not handle the second one which is introduced since gcc v10.1.0 commit 6c80b1b56dec ("Make more bad uses of fallthrough attribute into pedwarns.").

Zhe

Quoted 3 lines

Thomas.

#3 lore raw
Quoted 28 lines · He Zhe
Quoted 18 lines · Thomas Bogendoerfer
Quoted 17 lines · On Thu, Aug 20, 2020 at 08:54:40PM +0800, [email protected] wrote:

From: He Zhe <[email protected]>

We want neither
"
include/linux/compiler_attributes.h:201:41: warning: statement will never be executed [-Wswitch-unreachable]
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"
nor
"
include/linux/compiler_attributes.h:201:41: warning: attribute 'fallthrough' not preceding a case label or default label
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"

Quoted 6 lines
Quoted 4 lines

It's not worth adding one more macro. Let's simply place the fallthrough in between the expansions.

there is already another patch for the problem, which I've applied to mips-fixes.

Quoted 7 lines

You mean the below one?
https://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git/commit/?h=mips-fixes&id=5900acb374fe2f4f42bbcb2c84db64f582d917a1

That patch handles the first warning in my commit log but does not handle the second one which is introduced since gcc v10.1.0 commit 6c80b1b56dec ("Make more bad uses of fallthrough attribute into pedwarns.").

This is true.

Thomas, please apply this patch instead of mine. Also, consider adding the Fixes tag and CC stable due to the non-executable code error, and my Reviewed-by:

Fixes c9b029903466 ("MIPS: Use fallthrough for arch/mips")

Thanks
--
Gustavo

#4 lore raw
Quoted 41 lines · Gustavo A. R. Silva
Quoted 28 lines · He Zhe
Quoted 18 lines · Thomas Bogendoerfer
Quoted 17 lines · On Thu, Aug 20, 2020 at 08:54:40PM +0800, [email protected] wrote:

From: He Zhe <[email protected]>

We want neither
"
include/linux/compiler_attributes.h:201:41: warning: statement will never be executed [-Wswitch-unreachable]
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"
nor
"
include/linux/compiler_attributes.h:201:41: warning: attribute 'fallthrough' not preceding a case label or default label
201 | # define fallthrough __attribute__((__fallthrough__))

      |                      ^~~~~~~~~~~~~

"

Quoted 6 lines
Quoted 4 lines

It's not worth adding one more macro. Let's simply place the fallthrough in between the expansions.

there is already another patch for the problem, which I've applied to mips-fixes.

Quoted 7 lines

You mean the below one?
https://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git/commit/?h=mips-fixes&id=5900acb374fe2f4f42bbcb2c84db64f582d917a1

That patch handles the first warning in my commit log but does not handle the second one which is introduced since gcc v10.1.0 commit 6c80b1b56dec ("Make more bad uses of fallthrough attribute into pedwarns.").

This is true.

Quoted 7 lines

Thomas, please apply this patch instead of mine. Also, consider adding the Fixes tag and CC stable due to the non-executable code error, and my Reviewed-by:

Fixes c9b029903466 ("MIPS: Use fallthrough for arch/mips")

done.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]