All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible()
@ 2022-10-27 19:52 Nathan Chancellor
  2022-10-27 21:00 ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2022-10-27 19:52 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck
  Cc: Nick Desaulniers, Tom Rix, Quan Nguyen, linux-hwmon,
	linux-kernel, llvm, patches, Nathan Chancellor

Clang warns:

  drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
          default:
          ^
  drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through
          default:
          ^
          break;
  1 error generated.

Clang is a little more pedantic than GCC, which does not warn when
falling through to a case that is just break or return. Clang's version
is more in line with the kernel's own stance in deprecated.rst, which
states that all switch/case blocks must end in either break,
fallthrough, continue, goto, or return. Add the missing break to silence
the warning.

Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")
Link: https://github.com/ClangBuiltLinux/linux/issues/1751
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/hwmon/smpro-hwmon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c
index ee54e21c2c12..667e88b6bae5 100644
--- a/drivers/hwmon/smpro-hwmon.c
+++ b/drivers/hwmon/smpro-hwmon.c
@@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type,
 				return 0;
 		break;
 		}
+		break;
 	default:
 		break;
 	}

base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible()
  2022-10-27 19:52 [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible() Nathan Chancellor
@ 2022-10-27 21:00 ` Guenter Roeck
  2022-10-27 21:03   ` Nathan Chancellor
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2022-10-27 21:00 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Jean Delvare, Nick Desaulniers, Tom Rix, Quan Nguyen,
	linux-hwmon, linux-kernel, llvm, patches

On Thu, Oct 27, 2022 at 12:52:38PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
>   drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
>           default:
>           ^
>   drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through
>           default:
>           ^
>           break;
>   1 error generated.
> 
> Clang is a little more pedantic than GCC, which does not warn when
> falling through to a case that is just break or return. Clang's version
> is more in line with the kernel's own stance in deprecated.rst, which
> states that all switch/case blocks must end in either break,
> fallthrough, continue, goto, or return. Add the missing break to silence
> the warning.
> 
> Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1751
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/hwmon/smpro-hwmon.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c
> index ee54e21c2c12..667e88b6bae5 100644
> --- a/drivers/hwmon/smpro-hwmon.c
> +++ b/drivers/hwmon/smpro-hwmon.c
> @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type,
>  				return 0;
>  		break;
>  		}
> +		break;

The alignment of the break; statement above is also bad, and a default:
for switch (attr) is missing.

Guenter

>  	default:
>  		break;
>  	}
> 
> base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
> -- 
> 2.38.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible()
  2022-10-27 21:00 ` Guenter Roeck
@ 2022-10-27 21:03   ` Nathan Chancellor
  2022-10-27 22:25     ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2022-10-27 21:03 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Jean Delvare, Nick Desaulniers, Tom Rix, Quan Nguyen,
	linux-hwmon, linux-kernel, llvm, patches

On Thu, Oct 27, 2022 at 02:00:16PM -0700, Guenter Roeck wrote:
> On Thu, Oct 27, 2022 at 12:52:38PM -0700, Nathan Chancellor wrote:
> > Clang warns:
> > 
> >   drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
> >           default:
> >           ^
> >   drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through
> >           default:
> >           ^
> >           break;
> >   1 error generated.
> > 
> > Clang is a little more pedantic than GCC, which does not warn when
> > falling through to a case that is just break or return. Clang's version
> > is more in line with the kernel's own stance in deprecated.rst, which
> > states that all switch/case blocks must end in either break,
> > fallthrough, continue, goto, or return. Add the missing break to silence
> > the warning.
> > 
> > Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1751
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  drivers/hwmon/smpro-hwmon.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c
> > index ee54e21c2c12..667e88b6bae5 100644
> > --- a/drivers/hwmon/smpro-hwmon.c
> > +++ b/drivers/hwmon/smpro-hwmon.c
> > @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type,
> >  				return 0;
> >  		break;
> >  		}
> > +		break;
> 
> The alignment of the break; statement above is also bad, and a default:
> for switch (attr) is missing.

Would you prefer those fixed in the same patch or a separate one?

> >  	default:
> >  		break;
> >  	}
> > 
> > base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
> > -- 
> > 2.38.1
> > 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible()
  2022-10-27 21:03   ` Nathan Chancellor
@ 2022-10-27 22:25     ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2022-10-27 22:25 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Jean Delvare, Nick Desaulniers, Tom Rix, Quan Nguyen,
	linux-hwmon, linux-kernel, llvm, patches

On Thu, Oct 27, 2022 at 02:03:56PM -0700, Nathan Chancellor wrote:
> On Thu, Oct 27, 2022 at 02:00:16PM -0700, Guenter Roeck wrote:
> > On Thu, Oct 27, 2022 at 12:52:38PM -0700, Nathan Chancellor wrote:
> > > Clang warns:
> > > 
> > >   drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
> > >           default:
> > >           ^
> > >   drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through
> > >           default:
> > >           ^
> > >           break;
> > >   1 error generated.
> > > 
> > > Clang is a little more pedantic than GCC, which does not warn when
> > > falling through to a case that is just break or return. Clang's version
> > > is more in line with the kernel's own stance in deprecated.rst, which
> > > states that all switch/case blocks must end in either break,
> > > fallthrough, continue, goto, or return. Add the missing break to silence
> > > the warning.
> > > 
> > > Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/1751
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > ---
> > >  drivers/hwmon/smpro-hwmon.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c
> > > index ee54e21c2c12..667e88b6bae5 100644
> > > --- a/drivers/hwmon/smpro-hwmon.c
> > > +++ b/drivers/hwmon/smpro-hwmon.c
> > > @@ -375,6 +375,7 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type,
> > >  				return 0;
> > >  		break;
> > >  		}
> > > +		break;
> > 
> > The alignment of the break; statement above is also bad, and a default:
> > for switch (attr) is missing.
> 
> Would you prefer those fixed in the same patch or a separate one?
> 

Same patch, please. The resulting code is ultimately the same.

Thanks,
Guenter

> > >  	default:
> > >  		break;
> > >  	}
> > > 
> > > base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
> > > -- 
> > > 2.38.1
> > > 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-27 22:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 19:52 [PATCH -next] hwmon: (smpro-hwmon) Add missing break in smpro_is_visible() Nathan Chancellor
2022-10-27 21:00 ` Guenter Roeck
2022-10-27 21:03   ` Nathan Chancellor
2022-10-27 22:25     ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.