* [PATCH][next] Input: Fix fall-through warning for Clang
@ 2021-06-07 21:48 Gustavo A. R. Silva
2021-06-07 22:02 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2021-06-07 21:48 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, linux-kernel, Gustavo A. R. Silva, linux-hardening,
Kees Cook
In preparation to enable -Wimplicit-fallthrough for Clang, fix a
warning by explicitly adding a fallthrough; statement.
Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
JFYI: We had thousands of these sorts of warnings and now we are down
to just 13 in linux-next(20210607). This is one of those last
remaining warnings. :)
drivers/input/joystick/sidewinder.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index fac91ea14f17..8e9672deb1eb 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -660,6 +660,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
fallthrough;
case 45: /* Ambiguous packet length */
if (j <= 40) { /* ID length less or eq 40 -> FSP */
+ fallthrough;
case 43:
sw->type = SW_ID_FSP;
break;
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] Input: Fix fall-through warning for Clang
2021-06-07 21:48 [PATCH][next] Input: Fix fall-through warning for Clang Gustavo A. R. Silva
@ 2021-06-07 22:02 ` Joe Perches
2021-06-14 22:12 ` Dmitry Torokhov
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2021-06-07 22:02 UTC (permalink / raw)
To: Gustavo A. R. Silva, Dmitry Torokhov
Cc: linux-input, linux-kernel, linux-hardening, Kees Cook
On Mon, 2021-06-07 at 16:48 -0500, Gustavo A. R. Silva wrote:
> In preparation to enable -Wimplicit-fallthrough for Clang, fix a
> warning by explicitly adding a fallthrough; statement.
[]
> diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
[]
> @@ -660,6 +660,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
> fallthrough;
> case 45: /* Ambiguous packet length */
> if (j <= 40) { /* ID length less or eq 40 -> FSP */
> + fallthrough;
> case 43:
> sw->type = SW_ID_FSP;
> break;
Yuck. Super ugly. There's no need to play games with indentation.
Perhaps the simpler:
case 43:
sw->type = SW_ID_FSP;
break;
case 45: /* Ambiguous packet length */
if (j <= 40) { /* ID length less or eq 40 -> FSP */
sw->type = SW_ID_FSP;
break;
}
sw->number++;
fallthrough;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] Input: Fix fall-through warning for Clang
2021-06-07 22:02 ` Joe Perches
@ 2021-06-14 22:12 ` Dmitry Torokhov
2021-06-29 14:05 ` Gustavo A. R. Silva
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2021-06-14 22:12 UTC (permalink / raw)
To: Joe Perches
Cc: Gustavo A. R. Silva, linux-input, linux-kernel, linux-hardening,
Kees Cook
Hi Joe,
On Mon, Jun 07, 2021 at 03:02:40PM -0700, Joe Perches wrote:
> On Mon, 2021-06-07 at 16:48 -0500, Gustavo A. R. Silva wrote:
> > In preparation to enable -Wimplicit-fallthrough for Clang, fix a
> > warning by explicitly adding a fallthrough; statement.
> []
> > diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
> []
> > @@ -660,6 +660,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
> > fallthrough;
> > case 45: /* Ambiguous packet length */
> > if (j <= 40) { /* ID length less or eq 40 -> FSP */
> > + fallthrough;
> > case 43:
> > sw->type = SW_ID_FSP;
> > break;
>
> Yuck. Super ugly. There's no need to play games with indentation.
Yeah, the original code is not pretty :(
>
> Perhaps the simpler:
>
> case 43:
> sw->type = SW_ID_FSP;
> break;
> case 45: /* Ambiguous packet length */
> if (j <= 40) { /* ID length less or eq 40 -> FSP */
> sw->type = SW_ID_FSP;
> break;
> }
> sw->number++;
> fallthrough;
>
>
Could you resubmit this version properly formatted?
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] Input: Fix fall-through warning for Clang
2021-06-14 22:12 ` Dmitry Torokhov
@ 2021-06-29 14:05 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2021-06-29 14:05 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Joe Perches, linux-input, linux-kernel, linux-hardening, Kees Cook
On Mon, Jun 14, 2021 at 03:12:31PM -0700, Dmitry Torokhov wrote:
> Hi Joe,
>
> On Mon, Jun 07, 2021 at 03:02:40PM -0700, Joe Perches wrote:
> > On Mon, 2021-06-07 at 16:48 -0500, Gustavo A. R. Silva wrote:
> > > In preparation to enable -Wimplicit-fallthrough for Clang, fix a
> > > warning by explicitly adding a fallthrough; statement.
> > []
> > > diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
> > []
> > > @@ -660,6 +660,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
> > > fallthrough;
> > > case 45: /* Ambiguous packet length */
> > > if (j <= 40) { /* ID length less or eq 40 -> FSP */
> > > + fallthrough;
> > > case 43:
> > > sw->type = SW_ID_FSP;
> > > break;
> >
> > Yuck. Super ugly. There's no need to play games with indentation.
>
> Yeah, the original code is not pretty :(
Isn't this a Duff device for performance[1]?
In which case it might be better not to modify it and just go
with the fallthrough marking?
Another similar case can be found at
drivers/scsi/aic94xx/aic94xx_sds.c:714:
714 static void *asd_find_ll_by_id(void * const start, const u8 id0, const u8 id1)
715 {
716 struct asd_ll_el *el = start;
717
718 do {
719 switch (id1) {
720 default:
721 if (el->id1 == id1)
722 case 0xFF:
723 if (el->id0 == id0)
724 return el;
725 }
726 el = start + le16_to_cpu(el->next);
727 } while (el != start);
728
729 return NULL;
730 }
--
Gustavo
[1] https://www.drdobbs.com/a-reusable-duff-device/184406208
>
> >
> > Perhaps the simpler:
> >
> > case 43:
> > sw->type = SW_ID_FSP;
> > break;
> > case 45: /* Ambiguous packet length */
> > if (j <= 40) { /* ID length less or eq 40 -> FSP */
> > sw->type = SW_ID_FSP;
> > break;
> > }
> > sw->number++;
> > fallthrough;
> >
> >
>
> Could you resubmit this version properly formatted?
>
> Thanks.
>
> --
> Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-29 14:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 21:48 [PATCH][next] Input: Fix fall-through warning for Clang Gustavo A. R. Silva
2021-06-07 22:02 ` Joe Perches
2021-06-14 22:12 ` Dmitry Torokhov
2021-06-29 14:05 ` Gustavo A. R. Silva
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).