diff options
author | Jakob Koschel <jakobkoschel@gmail.com> | 2022-04-06 21:05:31 +0300 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-04-06 22:03:14 +0300 |
commit | dc1acd5c94699389a9ed023e94dd860c846ea1f6 (patch) | |
tree | 899a5eb3825eeb1e273f825e859bb98b218e79f9 /fs/dlm/plock.c | |
parent | c490b3afaa579ab238f78c762d703441ccc898bd (diff) | |
download | linux-dc1acd5c94699389a9ed023e94dd860c846ea1f6.tar.xz |
dlm: 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 [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/ [1]
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/plock.c')
-rw-r--r-- | fs/dlm/plock.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c index 16241fe6ac3c..0993eebf2060 100644 --- a/fs/dlm/plock.c +++ b/fs/dlm/plock.c @@ -407,9 +407,9 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count, static ssize_t dev_write(struct file *file, const char __user *u, size_t count, loff_t *ppos) { + struct plock_op *op = NULL, *iter; struct dlm_plock_info info; - struct plock_op *op; - int found = 0, do_callback = 0; + int do_callback = 0; if (count != sizeof(info)) return -EINVAL; @@ -421,23 +421,23 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count, return -EINVAL; spin_lock(&ops_lock); - list_for_each_entry(op, &recv_list, list) { - if (op->info.fsid == info.fsid && - op->info.number == info.number && - op->info.owner == info.owner) { - list_del_init(&op->list); - memcpy(&op->info, &info, sizeof(info)); - if (op->data) + list_for_each_entry(iter, &recv_list, list) { + if (iter->info.fsid == info.fsid && + iter->info.number == info.number && + iter->info.owner == info.owner) { + list_del_init(&iter->list); + memcpy(&iter->info, &info, sizeof(info)); + if (iter->data) do_callback = 1; else - op->done = 1; - found = 1; + iter->done = 1; + op = iter; break; } } spin_unlock(&ops_lock); - if (found) { + if (op) { if (do_callback) dlm_plock_callback(op); else |