linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (tmp401) Fix clang -Wimplicit-fallthrough in tmp401_is_visible()
@ 2021-11-16 15:44 Nathan Chancellor
  2021-11-16 16:33 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2021-11-16 15:44 UTC (permalink / raw)
  To: Guenter Roeck, Jean Delvare
  Cc: Nick Desaulniers, linux-hwmon, linux-kernel, llvm, Nathan Chancellor

Clang warns:

drivers/hwmon/tmp401.c:526:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
        default:
        ^
drivers/hwmon/tmp401.c:526: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.

Link: https://github.com/ClangBuiltLinux/linux/issues/1505
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---

Feel free to squash this into the offending commit.

 drivers/hwmon/tmp401.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
index f7b6a2c4fbcf..b86d9df7105d 100644
--- a/drivers/hwmon/tmp401.c
+++ b/drivers/hwmon/tmp401.c
@@ -523,6 +523,7 @@ static umode_t tmp401_is_visible(const void *data, enum hwmon_sensor_types type,
 		default:
 			break;
 		}
+		break;
 	default:
 		break;
 	}

base-commit: 82b520da9134a594eb9816759ed66ba6ef44888e
-- 
2.34.0


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

* Re: [PATCH] hwmon: (tmp401) Fix clang -Wimplicit-fallthrough in tmp401_is_visible()
  2021-11-16 15:44 [PATCH] hwmon: (tmp401) Fix clang -Wimplicit-fallthrough in tmp401_is_visible() Nathan Chancellor
@ 2021-11-16 16:33 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-11-16 16:33 UTC (permalink / raw)
  To: Nathan Chancellor, Jean Delvare
  Cc: Nick Desaulniers, linux-hwmon, linux-kernel, llvm

On 11/16/21 7:44 AM, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/hwmon/tmp401.c:526:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
>          default:
>          ^
> drivers/hwmon/tmp401.c:526: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.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1505
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> 
> Feel free to squash this into the offending commit.

Done, thanks a lot for the feedback.

Guenter

> 
>   drivers/hwmon/tmp401.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
> index f7b6a2c4fbcf..b86d9df7105d 100644
> --- a/drivers/hwmon/tmp401.c
> +++ b/drivers/hwmon/tmp401.c
> @@ -523,6 +523,7 @@ static umode_t tmp401_is_visible(const void *data, enum hwmon_sensor_types type,
>   		default:
>   			break;
>   		}
> +		break;
>   	default:
>   		break;
>   	}
> 
> base-commit: 82b520da9134a594eb9816759ed66ba6ef44888e
> 


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

end of thread, other threads:[~2021-11-16 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 15:44 [PATCH] hwmon: (tmp401) Fix clang -Wimplicit-fallthrough in tmp401_is_visible() Nathan Chancellor
2021-11-16 16:33 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).