Re: [PATCH 086/141] hwmon: (corsair-cpro) Fix fall-through warnings for Clang

From: Guenter Roeck
Date: Sat Nov 21 2020 - 20:00:40 EST


On Sat, Nov 21, 2020 at 12:00:30PM -0800, Joe Perches wrote:
> On Sat, 2020-11-21 at 10:50 -0800, Guenter Roeck wrote:
> > On Fri, Nov 20, 2020 at 12:36:04PM -0600, Gustavo A. R. Silva wrote:
> > > In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
> > > by explicitly adding a break statement instead of letting the code fall
> > > through to the next case.
> > >
> > > Link: https://github.com/KSPP/linux/issues/115
> > > Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
> >
> > Acked-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> []
> > > diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c
> []
> > > @@ -310,6 +310,7 @@ static int ccp_write(struct device *dev, enum hwmon_sensor_types type,
> > >   default:
> > >   break;
> > >   }
> > > + break;
>
> The
> default:
> break;
>
> bit above (but not below as it's a switch on an enum) could also be deleted no?
>

I prefer to keep it the way it is to indicate that the default case was not
forgotten (unless that is against coding style).

Guenter

> > >   default:
> > >   break;
> > >   }
>
> ---
> drivers/hwmon/corsair-cpro.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c
> index 591929ec217a..580173fca0f6 100644
> --- a/drivers/hwmon/corsair-cpro.c
> +++ b/drivers/hwmon/corsair-cpro.c
> @@ -299,17 +299,14 @@ static int ccp_write(struct device *dev, enum hwmon_sensor_types type,
> switch (attr) {
> case hwmon_pwm_input:
> return set_pwm(ccp, channel, val);
> - default:
> - break;
> }
> break;
> case hwmon_fan:
> switch (attr) {
> case hwmon_fan_target:
> return set_target(ccp, channel, val);
> - default:
> - break;
> }
> + break;
> default:
> break;
> }
>
>