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: <CAOi1vP-kHch7eF--yuH=y+V2DyY0v09qTA826=Tqr_YnQDfMBQ@mail.gmail.com>
Date:   Fri, 25 Mar 2022 17:56:58 +0100
From:   Ilya Dryomov <idryomov@...il.com>
To:     Jakob Koschel <jakobkoschel@...il.com>
Cc:     Dongsheng Yang <dongsheng.yang@...ystack.cn>,
        Jens Axboe <axboe@...nel.dk>,
        Ceph Development <ceph-devel@...r.kernel.org>,
        linux-block <linux-block@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Mike Rapoport <rppt@...nel.org>,
        Brian Johannesmeyer <bjohannesmeyer@...il.com>,
        Cristiano Giuffrida <c.giuffrida@...nl>,
        "Bos, H.J." <h.j.bos@...nl>
Subject: Re: [PATCH] rbd: replace usage of found with dedicated list iterator variable

On Thu, Mar 24, 2022 at 8:21 AM Jakob Koschel <jakobkoschel@...il.com> wrote:
>
> To move the list iterator variable into the list_for_each_entry_*()
> macro in the future it should be avoided to use the list iterator
> variable after the loop body.
>
> To *never* use the list iterator variable after the loop it was
> concluded to use a separate iterator variable instead of a
> found boolean [1].
>
> This removes the need to use a found variable and simply checking if
> the variable was set, can determine if the break/goto was hit.
>
> Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
> Signed-off-by: Jakob Koschel <jakobkoschel@...il.com>
> ---
>  drivers/block/rbd.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index b844432bad20..e5f891d058e8 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -756,24 +756,23 @@ static struct rbd_client *__rbd_get_client(struct rbd_client *rbdc)
>   */
>  static struct rbd_client *rbd_client_find(struct ceph_options *ceph_opts)
>  {
> -       struct rbd_client *client_node;
> -       bool found = false;
> +       struct rbd_client *client_node = NULL, *iter;
>
>         if (ceph_opts->flags & CEPH_OPT_NOSHARE)
>                 return NULL;
>
>         spin_lock(&rbd_client_list_lock);
> -       list_for_each_entry(client_node, &rbd_client_list, node) {
> -               if (!ceph_compare_options(ceph_opts, client_node->client)) {
> -                       __rbd_get_client(client_node);
> +       list_for_each_entry(iter, &rbd_client_list, node) {
> +               if (!ceph_compare_options(ceph_opts, iter->client)) {
> +                       __rbd_get_client(iter);
>
> -                       found = true;
> +                       client_node = iter;
>                         break;
>                 }
>         }
>         spin_unlock(&rbd_client_list_lock);
>
> -       return found ? client_node : NULL;
> +       return client_node;
>  }
>
>  /*
>
> base-commit: f443e374ae131c168a065ea1748feac6b2e76613
> --
> 2.25.1
>

Applied.

Thanks,

                Ilya

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ