lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 29 Jun 2021 09:05:25 -0500
From:   "Gustavo A. R. Silva" <gustavoars@...nel.org>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:     Joe Perches <joe@...ches.com>, linux-input@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org,
        Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH][next] Input: Fix fall-through warning for Clang

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ