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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200602140746.GA82514@roeck-us.net>
Date:   Tue, 2 Jun 2020 07:07:46 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Serge Semin <Sergey.Semin@...kalelectronics.ru>
Cc:     Jean Delvare <jdelvare@...e.com>,
        Serge Semin <fancer.lancer@...il.com>,
        kbuild test robot <lkp@...el.com>,
        Maxim Kaurkin <Maxim.Kaurkin@...kalelectronics.ru>,
        Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>,
        linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when
 alarms are enabled

On Tue, Jun 02, 2020 at 12:12:19PM +0300, Serge Semin wrote:
> Clang-based kernel building with W=1 warns that some static const
> variables are unused:
> 
> drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
> static const struct pvt_poly poly_temp_to_N = {
>                              ^
> drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]
> static const struct pvt_poly poly_volt_to_N = {
>                              ^
> 
> Indeed these polynomials are utilized only when the PVT sensor alarms are
> enabled. In that case they are used to convert the temperature and
> voltage alarm limits from normal quantities (Volts and degree Celsius) to
> the sensor data representation N = [0, 1023]. Otherwise when alarms are
> disabled the driver only does the detected data conversion to the human
> readable form and doesn't need that polynomials defined. So let's declare
> the Temp-to-N and Volt-to-N polynomials only if the PVT alarms are
> switched on at compile-time.
> 
> Note gcc with W=1 doesn't notice the problem.
> 
> Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver")
> Reported-by: kbuild test robot <lkp@...el.com>
> Signed-off-by: Serge Semin <Sergey.Semin@...kalelectronics.ru>
> Cc: Maxim Kaurkin <Maxim.Kaurkin@...kalelectronics.ru>
> Cc: Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>

I don't really like the added #if. Can you use __maybe_unused instead ?

Thanks,
Guenter

> ---
>  drivers/hwmon/bt1-pvt.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c
> index 1a9772fb1f73..1a5212c04549 100644
> --- a/drivers/hwmon/bt1-pvt.c
> +++ b/drivers/hwmon/bt1-pvt.c
> @@ -64,6 +64,7 @@ static const struct pvt_sensor_info pvt_info[] = {
>   *     48380,
>   * where T = [-48380, 147438] mC and N = [0, 1023].
>   */
> +#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
>  static const struct pvt_poly poly_temp_to_N = {
>  	.total_divider = 10000,
>  	.terms = {
> @@ -74,6 +75,7 @@ static const struct pvt_poly poly_temp_to_N = {
>  		{0, 1720400, 1, 1}
>  	}
>  };
> +#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
>  
>  static const struct pvt_poly poly_N_to_temp = {
>  	.total_divider = 1,
> @@ -96,6 +98,7 @@ static const struct pvt_poly poly_N_to_temp = {
>   * N = (18658e-3*V - 11572) / 10,
>   * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
>   */
> +#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
>  static const struct pvt_poly poly_volt_to_N = {
>  	.total_divider = 10,
>  	.terms = {
> @@ -103,6 +106,7 @@ static const struct pvt_poly poly_volt_to_N = {
>  		{0, -11572, 1, 1}
>  	}
>  };
> +#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
>  
>  static const struct pvt_poly poly_N_to_volt = {
>  	.total_divider = 10,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ