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] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jVUjXNZ+03QBXkyjCbDnB7LAOUwKSeVt95LqkeiK33BQ@mail.gmail.com>
Date:   Tue, 22 Aug 2023 22:12:39 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Liao Chang <liaochang1@...wei.com>
Cc:     rafael@...nel.org, viresh.kumar@...aro.org,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: Use clamp helper macro to improve the code readability

On Wed, Aug 16, 2023 at 4:00 AM Liao Chang <liaochang1@...wei.com> wrote:
>
> The valid values of policy.{min, max} should be between 'min' and 'max',
> so use clamp() helper macro to makes cpufreq_verify_within_limits() more
> readable.
>
> Signed-off-by: Liao Chang <liaochang1@...wei.com>
> ---
>  include/linux/cpufreq.h | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 99da27466b8f..43b363a99215 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -19,6 +19,7 @@
>  #include <linux/pm_qos.h>
>  #include <linux/spinlock.h>
>  #include <linux/sysfs.h>
> +#include <linux/minmax.h>
>
>  /*********************************************************************
>   *                        CPUFREQ INTERFACE                          *
> @@ -467,17 +468,8 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy_data *poli
>                                                 unsigned int min,
>                                                 unsigned int max)
>  {
> -       if (policy->min < min)
> -               policy->min = min;
> -       if (policy->max < min)
> -               policy->max = min;
> -       if (policy->min > max)
> -               policy->min = max;
> -       if (policy->max > max)
> -               policy->max = max;
> -       if (policy->min > policy->max)
> -               policy->min = policy->max;
> -       return;
> +       policy->max = clamp(policy->max, min, max);
> +       policy->min = clamp(policy->min, min, policy->max);
>  }
>
>  static inline void
> --

Applied (with minor edits in the subject and changelog) as 6.6 material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ