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: <CAHp75VdSZCCqzJQ3k0ut0+USBxs0FdfjRXEC74yivQg7Vee3VA@mail.gmail.com>
Date:   Tue, 5 Jun 2018 16:21:26 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Yisheng Xie <xieyisheng1@...wei.com>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v2 14/21] sched/debug: use match_string() helper

On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1@...wei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.
>

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>


> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
> ---
> v2:
>  - rename i to ret to show the change in returned value meaning - per Andy
>
>  kernel/sched/debug.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index 15b10e2..5591147 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -111,20 +111,19 @@ static int sched_feat_set(char *cmp)
>                 cmp += 3;
>         }
>
> -       for (i = 0; i < __SCHED_FEAT_NR; i++) {
> -               if (strcmp(cmp, sched_feat_names[i]) == 0) {
> -                       if (neg) {
> -                               sysctl_sched_features &= ~(1UL << i);
> -                               sched_feat_disable(i);
> -                       } else {
> -                               sysctl_sched_features |= (1UL << i);
> -                               sched_feat_enable(i);
> -                       }
> -                       break;
> -               }
> +       i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
> +       if (i < 0)
> +               return i;
> +
> +       if (neg) {
> +               sysctl_sched_features &= ~(1UL << i);
> +               sched_feat_disable(i);
> +       } else {
> +               sysctl_sched_features |= (1UL << i);
> +               sched_feat_enable(i);
>         }
>
> -       return i;
> +       return 0;
>  }
>
>  static ssize_t
> @@ -133,7 +132,7 @@ static int sched_feat_set(char *cmp)
>  {
>         char buf[64];
>         char *cmp;
> -       int i;
> +       int ret;
>         struct inode *inode;
>
>         if (cnt > 63)
> @@ -148,10 +147,10 @@ static int sched_feat_set(char *cmp)
>         /* Ensure the static_key remains in a consistent state */
>         inode = file_inode(filp);
>         inode_lock(inode);
> -       i = sched_feat_set(cmp);
> +       ret = sched_feat_set(cmp);
>         inode_unlock(inode);
> -       if (i == __SCHED_FEAT_NR)
> -               return -EINVAL;
> +       if (ret < 0)
> +               return ret;
>
>         *ppos += cnt;
>
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ