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: <CAJZ5v0hPbH9BMOLbrGOKcy1sGAXbq=7OTyFECA966i37wBp_AQ@mail.gmail.com>
Date:   Thu, 30 Mar 2023 19:11:32 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Jiangshan Yi <yijiangshan@...inos.cn>
Cc:     rafael@...nel.org, rui.zhang@...el.com, lenb@...nel.org,
        linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
        13667453960@....com
Subject: Re: [PATCH] ACPI: thermal: replace ternary operator with min_t()

On Tue, Mar 28, 2023 at 5:17 AM Jiangshan Yi <yijiangshan@...inos.cn> wrote:
>
> Fix the following coccicheck warning:

This is not a fix, because the current code is correct AFAICS.

It merely makes the code follow the coccicheck recommendation, which
is a cleanup (although arguably a good one).

But because the new code is way more readable, I've applied this as
6.4 material (with edits in the changelog).

Thanks!

> drivers/acpi/thermal.c:422: WARNING opportunity for min().
>
> min_t() macro is defined in include/linux/minmax.h. It avoids multiple
> evaluations of the arguments when non-constant and performs strict
> type-checking.
>
> Signed-off-by: Jiangshan Yi <yijiangshan@...inos.cn>
> ---
>  drivers/acpi/thermal.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index 0b4b844f9d4c..179f41196a9d 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -419,10 +419,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
>                                          * the next higher trip point
>                                          */
>                                         tz->trips.active[i-1].temperature =
> -                                               (tz->trips.active[i-2].temperature <
> -                                               celsius_to_deci_kelvin(act) ?
> -                                               tz->trips.active[i-2].temperature :
> -                                               celsius_to_deci_kelvin(act));
> +                                               min_t(unsigned long,
> +                                                     tz->trips.active[i-2].temperature,
> +                                                     celsius_to_deci_kelvin(act));
>
>                                 break;
>                         } else {
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ