Input: Fix fall-through warning for Clang
Subsystems (2)
PATCH 1/1 Input: Fix fall-through warning for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough; statement.
---
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(+)
drivers/input/joystick/sidewinder.c +1 -0
@@ -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 ;
Signature · 1 line
2.27.0
Quoted 2 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough; statement.
[]
drivers/input/joystick/sidewinder.c
Quoted 1 line
drivers/input/joystick/sidewinder.c +0
-0
[]
Quoted 8 lines
drivers/input/joystick/sidewinder.c +0
-0@@ -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 */drivers/input/joystick/sidewinder.c +1
-0+ 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;Dmitry Torokhov
maintainerHi Joe,
Quoted 6 lines · Joe Perches
Quoted 2 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough; statement.
[]
drivers/input/joystick/sidewinder.c
Quoted 1 line
drivers/input/joystick/sidewinder.c +0
-0[]
Quoted 10 lines
Quoted 8 lines
drivers/input/joystick/sidewinder.c +0
-0@@ -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 */drivers/input/joystick/sidewinder.c +1
-0+ 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 :(
Quoted 15 lines
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.
Signature · 1 line
Dmitry
Quoted 20 lines · Dmitry Torokhov
Hi Joe,
Quoted 6 lines · Joe Perches
Quoted 2 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough; statement.
[]
drivers/input/joystick/sidewinder.c
Quoted 1 line
drivers/input/joystick/sidewinder.c +0
-0[]
Quoted 10 lines
Quoted 8 lines
drivers/input/joystick/sidewinder.c +0
-0@@ -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 */drivers/input/joystick/sidewinder.c +1
-0+ fallthrough;case 43:
sw->type=SW_ID_FSP; break;Yuck. Super ugly. There's no need to play games with indentation.
Quoted 1 line
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 atdrivers/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
Quoted 23 lines
Quoted 4 lines
Perhaps the simpler:
Quoted 12 lines
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.
Signature · 1 line
Dmitry