Skip to content

Commit 3302ffd

Browse files
Jakob-Koschelidryomov
authored andcommitted
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 <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent d7a2dc5 commit 3302ffd

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/block/rbd.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,24 +756,23 @@ static struct rbd_client *__rbd_get_client(struct rbd_client *rbdc)
756756
*/
757757
static struct rbd_client *rbd_client_find(struct ceph_options *ceph_opts)
758758
{
759-
struct rbd_client *client_node;
760-
bool found = false;
759+
struct rbd_client *rbdc = NULL, *iter;
761760

762761
if (ceph_opts->flags & CEPH_OPT_NOSHARE)
763762
return NULL;
764763

765764
spin_lock(&rbd_client_list_lock);
766-
list_for_each_entry(client_node, &rbd_client_list, node) {
767-
if (!ceph_compare_options(ceph_opts, client_node->client)) {
768-
__rbd_get_client(client_node);
765+
list_for_each_entry(iter, &rbd_client_list, node) {
766+
if (!ceph_compare_options(ceph_opts, iter->client)) {
767+
__rbd_get_client(iter);
769768

770-
found = true;
769+
rbdc = iter;
771770
break;
772771
}
773772
}
774773
spin_unlock(&rbd_client_list_lock);
775774

776-
return found ? client_node : NULL;
775+
return rbdc;
777776
}
778777

779778
/*

0 commit comments

Comments
 (0)