diff options
author | Jakob Koschel <jakobkoschel@gmail.com> | 2022-03-24 08:20:50 +0100 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2022-05-25 20:45:13 +0200 |
commit | 3302ffd44c3d70e77ad5764d15f5028a6ade540a (patch) | |
tree | 06e31d992e18d5141d4d93485b381ad3aa0a03a8 /drivers/block | |
parent | ceph: allow ceph.dir.rctime xattr to be updatable (diff) | |
download | linux-3302ffd44c3d70e77ad5764d15f5028a6ade540a.tar.xz linux-3302ffd44c3d70e77ad5764d15f5028a6ade540a.zip |
rbd: replace usage of found with dedicated list iterator variable
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.
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@gmail.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b844432bad20..5e2ee398b7dc 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 *rbdc = 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; + rbdc = iter; break; } } spin_unlock(&rbd_client_list_lock); - return found ? client_node : NULL; + return rbdc; } /* |