diff mbox series

[next] Input: Fix fall-through warning for Clang

Message ID 20210607214852.GA65141@embeddedor (mailing list archive)
State New
Headers show
Series [next] Input: Fix fall-through warning for Clang | expand

Commit Message

Gustavo A. R. Silva June 7, 2021, 9:48 p.m. UTC
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(+)

Comments

Joe Perches June 7, 2021, 10:02 p.m. UTC | #1
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;
Dmitry Torokhov June 14, 2021, 10:12 p.m. UTC | #2
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.
diff mbox series

Patch

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;