lkml.org 
[lkml]   [2019]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iio: mma8452: mark expected switch fall-through
On Mon, 11 Feb 2019 16:23:18 -0600
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:

> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warning:
>
> drivers/iio/accel/mma8452.c: In function ‘mma8452_probe’:
> drivers/iio/accel/mma8452.c:1581:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (ret == data->chip_info->chip_id)
> ^
> drivers/iio/accel/mma8452.c:1584:2: note: here
> default:
> ^~~~~~~
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> Notice that, in this particular case, the code comment is modified
> in accordance with what GCC is expecting to find.
>
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
I know Peter probably won't like this, as it doesn't
read a as well, with the else dropped, but I'm going to take
it as we have had a lot of bugs caught by this code and this
is generating a false positive.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
> drivers/iio/accel/mma8452.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 302781126bc6..00e100fc845a 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1580,7 +1580,7 @@ static int mma8452_probe(struct i2c_client *client,
> case FXLS8471_DEVICE_ID:
> if (ret == data->chip_info->chip_id)
> break;
> - /* else: fall through */
> + /* fall through */
> default:
> ret = -ENODEV;
> goto disable_regulators;

\
 
 \ /
  Last update: 2019-02-20 13:18    [W:0.153 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site