* [PATCH] spi: slave: Fix missing break in switch
@ 2018-10-03 12:33 Gustavo A. R. Silva
2018-10-03 14:46 ` Geert Uytterhoeven
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-03 12:33 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-kernel, Gustavo A. R. Silva
Apparently, this code does not actually fall through to the next case
because the machine restarts before it has a chance. However, for the
sake of maintenance and readability, we better add the missing break
statement.
Addresses-Coverity-ID: 1437892 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/spi/spi-slave-system-control.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/spi/spi-slave-system-control.c b/drivers/spi/spi-slave-system-control.c
index c0257e9..169f3d5 100644
--- a/drivers/spi/spi-slave-system-control.c
+++ b/drivers/spi/spi-slave-system-control.c
@@ -60,6 +60,7 @@ static void spi_slave_system_control_complete(void *arg)
case CMD_REBOOT:
dev_info(&priv->spi->dev, "Rebooting system...\n");
kernel_restart(NULL);
+ break;
case CMD_POWEROFF:
dev_info(&priv->spi->dev, "Powering off system...\n");
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: slave: Fix missing break in switch
2018-10-03 12:33 [PATCH] spi: slave: Fix missing break in switch Gustavo A. R. Silva
@ 2018-10-03 14:46 ` Geert Uytterhoeven
2018-10-03 15:01 ` Mark Brown
0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2018-10-03 14:46 UTC (permalink / raw)
To: gustavo; +Cc: Mark Brown, linux-spi, Linux Kernel Mailing List
Hi Gustavo,
On Wed, Oct 3, 2018 at 2:57 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> Apparently, this code does not actually fall through to the next case
> because the machine restarts before it has a chance. However, for the
> sake of maintenance and readability, we better add the missing break
> statement.
>
> Addresses-Coverity-ID: 1437892 ("Missing break in switch")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/spi/spi-slave-system-control.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/spi/spi-slave-system-control.c b/drivers/spi/spi-slave-system-control.c
> index c0257e9..169f3d5 100644
> --- a/drivers/spi/spi-slave-system-control.c
> +++ b/drivers/spi/spi-slave-system-control.c
> @@ -60,6 +60,7 @@ static void spi_slave_system_control_complete(void *arg)
> case CMD_REBOOT:
> dev_info(&priv->spi->dev, "Rebooting system...\n");
> kernel_restart(NULL);
> + break;
>
> case CMD_POWEROFF:
> dev_info(&priv->spi->dev, "Powering off system...\n");
Alternatively, kernel_restart() and friends could be marked __noreturn.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: slave: Fix missing break in switch
2018-10-03 14:46 ` Geert Uytterhoeven
@ 2018-10-03 15:01 ` Mark Brown
2018-10-03 15:05 ` Gustavo A. R. Silva
0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2018-10-03 15:01 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: gustavo, linux-spi, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
On Wed, Oct 03, 2018 at 04:46:45PM +0200, Geert Uytterhoeven wrote:
> On Wed, Oct 3, 2018 at 2:57 PM Gustavo A. R. Silva
> > case CMD_REBOOT:
> > dev_info(&priv->spi->dev, "Rebooting system...\n");
> > kernel_restart(NULL);
> > + break;
> Alternatively, kernel_restart() and friends could be marked __noreturn.
Yes, that seems more sensible though there's no harm in this patch even
with that. It'd definitely avoid other issues in future.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: slave: Fix missing break in switch
2018-10-03 15:01 ` Mark Brown
@ 2018-10-03 15:05 ` Gustavo A. R. Silva
2018-10-03 15:10 ` Geert Uytterhoeven
2018-10-03 15:24 ` Mark Brown
0 siblings, 2 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-03 15:05 UTC (permalink / raw)
To: Mark Brown, Geert Uytterhoeven; +Cc: linux-spi, Linux Kernel Mailing List
Hi,
On 10/3/18 5:01 PM, Mark Brown wrote:
> On Wed, Oct 03, 2018 at 04:46:45PM +0200, Geert Uytterhoeven wrote:
>> On Wed, Oct 3, 2018 at 2:57 PM Gustavo A. R. Silva
>
>>> case CMD_REBOOT:
>>> dev_info(&priv->spi->dev, "Rebooting system...\n");
>>> kernel_restart(NULL);
>>> + break;
>
>> Alternatively, kernel_restart() and friends could be marked __noreturn.
>
> Yes, that seems more sensible though there's no harm in this patch even
> with that. It'd definitely avoid other issues in future.
>
I'll include the __noreturn in addition to the break statement.
I'll send v2 shortly.
Thank you both for the feedback.
--
Gustavo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: slave: Fix missing break in switch
2018-10-03 15:05 ` Gustavo A. R. Silva
@ 2018-10-03 15:10 ` Geert Uytterhoeven
2018-10-03 18:22 ` Gustavo A. R. Silva
2018-10-03 15:24 ` Mark Brown
1 sibling, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2018-10-03 15:10 UTC (permalink / raw)
To: gustavo; +Cc: Mark Brown, linux-spi, Linux Kernel Mailing List
Hi Gustavo,
On Wed, Oct 3, 2018 at 5:05 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> On 10/3/18 5:01 PM, Mark Brown wrote:
> > On Wed, Oct 03, 2018 at 04:46:45PM +0200, Geert Uytterhoeven wrote:
> >> On Wed, Oct 3, 2018 at 2:57 PM Gustavo A. R. Silva
> >
> >>> case CMD_REBOOT:
> >>> dev_info(&priv->spi->dev, "Rebooting system...\n");
> >>> kernel_restart(NULL);
> >>> + break;
> >
> >> Alternatively, kernel_restart() and friends could be marked __noreturn.
> >
> > Yes, that seems more sensible though there's no harm in this patch even
> > with that. It'd definitely avoid other issues in future.
>
> I'll include the __noreturn in addition to the break statement.
> I'll send v2 shortly.
Please note that adding __noreturn is not a trivial task, due to the complex
call chains, and the different implementations on the various architectures
and platforms. So that will be a big patch series.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: slave: Fix missing break in switch
2018-10-03 15:05 ` Gustavo A. R. Silva
2018-10-03 15:10 ` Geert Uytterhoeven
@ 2018-10-03 15:24 ` Mark Brown
1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2018-10-03 15:24 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Geert Uytterhoeven, linux-spi, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 273 bytes --]
On Wed, Oct 03, 2018 at 05:05:04PM +0200, Gustavo A. R. Silva wrote:
> I'll include the __noreturn in addition to the break statement.
> I'll send v2 shortly.
No need for a v2, I already applied this - adding __noreturn seems like
a separate (although desirable) effort.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] spi: slave: Fix missing break in switch
2018-10-03 15:10 ` Geert Uytterhoeven
@ 2018-10-03 18:22 ` Gustavo A. R. Silva
0 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-03 18:22 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, Linux Kernel Mailing List
On 10/3/18 5:10 PM, Geert Uytterhoeven wrote:
> Hi Gustavo,
>
> On Wed, Oct 3, 2018 at 5:05 PM Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>> On 10/3/18 5:01 PM, Mark Brown wrote:
>>> On Wed, Oct 03, 2018 at 04:46:45PM +0200, Geert Uytterhoeven wrote:
>>>> On Wed, Oct 3, 2018 at 2:57 PM Gustavo A. R. Silva
>>>
>>>>> case CMD_REBOOT:
>>>>> dev_info(&priv->spi->dev, "Rebooting system...\n");
>>>>> kernel_restart(NULL);
>>>>> + break;
>>>
>>>> Alternatively, kernel_restart() and friends could be marked __noreturn.
>>>
>>> Yes, that seems more sensible though there's no harm in this patch even
>>> with that. It'd definitely avoid other issues in future.
>>
>> I'll include the __noreturn in addition to the break statement.
>> I'll send v2 shortly.
>
> Please note that adding __noreturn is not a trivial task, due to the complex
> call chains, and the different implementations on the various architectures
> and platforms. So that will be a big patch series.
>
I see. In that case, it might be an interesting side project.
I appreciate the feedback, Geert.
--
Gustavo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-10-03 18:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 12:33 [PATCH] spi: slave: Fix missing break in switch Gustavo A. R. Silva
2018-10-03 14:46 ` Geert Uytterhoeven
2018-10-03 15:01 ` Mark Brown
2018-10-03 15:05 ` Gustavo A. R. Silva
2018-10-03 15:10 ` Geert Uytterhoeven
2018-10-03 18:22 ` Gustavo A. R. Silva
2018-10-03 15:24 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).