Skip to content

Commit 3de24f3

Browse files
Jakob-KoschelTrond Myklebust
authored andcommitted
NFS: 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/ Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 3848e96 commit 3de24f3

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

fs/nfs/nfs42proc.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ static int handle_async_copy(struct nfs42_copy_res *res,
175175
nfs4_stateid *src_stateid,
176176
bool *restart)
177177
{
178-
struct nfs4_copy_state *copy, *tmp_copy;
178+
struct nfs4_copy_state *copy, *tmp_copy = NULL, *iter;
179179
int status = NFS4_OK;
180-
bool found_pending = false;
181180
struct nfs_open_context *dst_ctx = nfs_file_open_context(dst);
182181
struct nfs_open_context *src_ctx = nfs_file_open_context(src);
183182

@@ -186,17 +185,17 @@ static int handle_async_copy(struct nfs42_copy_res *res,
186185
return -ENOMEM;
187186

188187
spin_lock(&dst_server->nfs_client->cl_lock);
189-
list_for_each_entry(tmp_copy,
188+
list_for_each_entry(iter,
190189
&dst_server->nfs_client->pending_cb_stateids,
191190
copies) {
192-
if (memcmp(&res->write_res.stateid, &tmp_copy->stateid,
191+
if (memcmp(&res->write_res.stateid, &iter->stateid,
193192
NFS4_STATEID_SIZE))
194193
continue;
195-
found_pending = true;
196-
list_del(&tmp_copy->copies);
194+
tmp_copy = iter;
195+
list_del(&iter->copies);
197196
break;
198197
}
199-
if (found_pending) {
198+
if (tmp_copy) {
200199
spin_unlock(&dst_server->nfs_client->cl_lock);
201200
kfree(copy);
202201
copy = tmp_copy;

0 commit comments

Comments
 (0)