lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221028181430.GA2079477@roeck-us.net>
Date:   Fri, 28 Oct 2022 11:14:30 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Nathan Chancellor <nathan@...nel.org>
Cc:     Jean Delvare <jdelvare@...e.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Tom Rix <trix@...hat.com>,
        Quan Nguyen <quan@...amperecomputing.com>,
        linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
        llvm@...ts.linux.dev, patches@...ts.linux.dev
Subject: Re: [PATCH -next v2] hwmon: (smpro-hwmon) Improve switch statments
 in smpro_is_visible()

On Thu, Oct 27, 2022 at 04:16:12PM -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. Additionally, adjust the
> indentation of a break and add a default case to the inner switch
> statement.
> 
> Fixes: a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1751
> Signed-off-by: Nathan Chancellor <nathan@...nel.org>

Applied.

Thanks,
Guenter

> ---
> 
> v2:
> 
>     * Add missing default case to inner switch statement (Guenter)
>     * Fix indentation of break in inner switch statement (Guenter)
>     * Reword commit message to include these changes
> 
> v1: https://lore.kernel.org/20221027195238.1789586-1-nathan@kernel.org/
> 
>  drivers/hwmon/smpro-hwmon.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 
> base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
> 
> diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c
> index ee54e21c2c12..a76c49dd8438 100644
> --- a/drivers/hwmon/smpro-hwmon.c
> +++ b/drivers/hwmon/smpro-hwmon.c
> @@ -373,8 +373,11 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type,
>  			ret = regmap_read(hwmon->regmap, temperature[channel].reg, &value);
>  			if (ret || value == 0xFFFF)
>  				return 0;
> -		break;
> +			break;
> +		default:
> +			break;
>  		}
> +		break;
>  	default:
>  		break;
>  	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ