Re: [PATCH] iio: cros_ec_accel_legacy: Mark expected switch fall-throughs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 20 Feb 2019 10:20:39 -0800
Kees Cook <keescook@xxxxxxxxxxxx> wrote:

> On Mon, Oct 8, 2018 at 10:24 AM Gustavo A. R. Silva
> <gustavo@xxxxxxxxxxxxxx> wrote:
> >
> > In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> > where we are expecting to fall through.
> >
> > Addresses-Coverity-ID: 1397962 ("Missing break in switch")
> > Signed-off-by: Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx>
> > ---
> >  drivers/iio/accel/cros_ec_accel_legacy.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/iio/accel/cros_ec_accel_legacy.c b/drivers/iio/accel/cros_ec_accel_legacy.c
> > index 063e89e..d609654 100644
> > --- a/drivers/iio/accel/cros_ec_accel_legacy.c
> > +++ b/drivers/iio/accel/cros_ec_accel_legacy.c
> > @@ -385,8 +385,10 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
> >                 switch (i) {
> >                 case X:
> >                         ec_accel_channels[X].scan_index = Y;
> > +                       /* fall through */
> >                 case Y:
> >                         ec_accel_channels[Y].scan_index = X;
> > +                       /* fall through */
> >                 case Z:
> >                         ec_accel_channels[Z].scan_index = Z;
> >                 }  
> 
> Shouldn't these actually be "break;"s ? It seems like the loop is
> stepping through X, Y, and Z. The _result_ is accidentally the same:
> 
> X: set X, Y, and Z
> Y: set Y and Z
> Z: set Z
> 
> result: X, Y, and Z are set correctly. But the code is technically wrong.
> 

Agreed, it's 'novel'.  Waiting for Gwendal or someone else to come
back and check it wasn't meant to be doing something else.

Jonathan

> 




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux