2019-12-10 08:39:43

by Kuninori Morimoto

[permalink] [raw]
Subject: [PATCH] sh: kgdb: Mark expected switch fall-throughs


From: Kuninori Morimoto <[email protected]>

Mark switch cases where we are expecting to fall through.

This patch fixes the following error:

LINUX/arch/sh/kernel/kgdb.c: In function 'kgdb_arch_handle_exception':
LINUX/arch/sh/kernel/kgdb.c:267:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (kgdb_hex2long(&ptr, &addr))
^
LINUX/arch/sh/kernel/kgdb.c:269:2: note: here
case 'D':
^~~~

Signed-off-by: Kuninori Morimoto <[email protected]>
Acked-by: Daniel Thompson <[email protected]>
---
arch/sh/kernel/kgdb.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c
index 6d61f8c..0d5f3c9 100644
--- a/arch/sh/kernel/kgdb.c
+++ b/arch/sh/kernel/kgdb.c
@@ -266,6 +266,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
ptr = &remcomInBuffer[1];
if (kgdb_hex2long(&ptr, &addr))
linux_regs->pc = addr;
+ /* fallthrough */
case 'D':
case 'k':
atomic_set(&kgdb_cpu_doing_single_step, -1);
--
2.7.4


2019-12-10 08:48:56

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH] sh: kgdb: Mark expected switch fall-throughs



On 12/10/2019 08:39 AM, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <[email protected]>
>
> Mark switch cases where we are expecting to fall through.
>
> This patch fixes the following error:
>
> LINUX/arch/sh/kernel/kgdb.c: In function 'kgdb_arch_handle_exception':
> LINUX/arch/sh/kernel/kgdb.c:267:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
> if (kgdb_hex2long(&ptr, &addr))
> ^
> LINUX/arch/sh/kernel/kgdb.c:269:2: note: here
> case 'D':
> ^~~~
>
> Signed-off-by: Kuninori Morimoto <[email protected]>
> Acked-by: Daniel Thompson <[email protected]>

I guess you should also add:

Fixes: ab6e570ba33d ("sh: Generic kgdb stub support.")
Cc: [email protected]

Christophe

2019-12-11 15:55:49

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH] sh: kgdb: Mark expected switch fall-throughs

On Tue, Dec 10, 2019 at 05:39:00PM +0900, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <[email protected]>
>
> Mark switch cases where we are expecting to fall through.
>
> This patch fixes the following error:
>
> LINUX/arch/sh/kernel/kgdb.c: In function 'kgdb_arch_handle_exception':
> LINUX/arch/sh/kernel/kgdb.c:267:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
> if (kgdb_hex2long(&ptr, &addr))
> ^
> LINUX/arch/sh/kernel/kgdb.c:269:2: note: here
> case 'D':
> ^~~~
>
> Signed-off-by: Kuninori Morimoto <[email protected]>
> Acked-by: Daniel Thompson <[email protected]>
> ---
> arch/sh/kernel/kgdb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c
> index 6d61f8c..0d5f3c9 100644
> --- a/arch/sh/kernel/kgdb.c
> +++ b/arch/sh/kernel/kgdb.c
> @@ -266,6 +266,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
> ptr = &remcomInBuffer[1];
> if (kgdb_hex2long(&ptr, &addr))
> linux_regs->pc = addr;
> + /* fallthrough */

Since v5.5-rc1 there is the fallthrough pseudo keyword to document
these cases:
https://elixir.bootlin.com/linux/v5.5-rc1/source/Documentation/process/coding-style.rst#L59


Daniel.


> case 'D':
> case 'k':
> atomic_set(&kgdb_cpu_doing_single_step, -1);
> --
> 2.7.4
>