Skip to content

Commit edf5f05

Browse files
Jakob-Koschelsmfrench
authored andcommitted
ksmbd: 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> Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 56b401f commit edf5f05

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

fs/ksmbd/smb2pdu.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6618,8 +6618,7 @@ int smb2_cancel(struct ksmbd_work *work)
66186618
struct ksmbd_conn *conn = work->conn;
66196619
struct smb2_hdr *hdr = smb2_get_msg(work->request_buf);
66206620
struct smb2_hdr *chdr;
6621-
struct ksmbd_work *cancel_work = NULL;
6622-
int canceled = 0;
6621+
struct ksmbd_work *cancel_work = NULL, *iter;
66236622
struct list_head *command_list;
66246623

66256624
ksmbd_debug(SMB, "smb2 cancel called on mid %llu, async flags 0x%x\n",
@@ -6629,44 +6628,44 @@ int smb2_cancel(struct ksmbd_work *work)
66296628
command_list = &conn->async_requests;
66306629

66316630
spin_lock(&conn->request_lock);
6632-
list_for_each_entry(cancel_work, command_list,
6631+
list_for_each_entry(iter, command_list,
66336632
async_request_entry) {
6634-
chdr = smb2_get_msg(cancel_work->request_buf);
6633+
chdr = smb2_get_msg(iter->request_buf);
66356634

6636-
if (cancel_work->async_id !=
6635+
if (iter->async_id !=
66376636
le64_to_cpu(hdr->Id.AsyncId))
66386637
continue;
66396638

66406639
ksmbd_debug(SMB,
66416640
"smb2 with AsyncId %llu cancelled command = 0x%x\n",
66426641
le64_to_cpu(hdr->Id.AsyncId),
66436642
le16_to_cpu(chdr->Command));
6644-
canceled = 1;
6643+
cancel_work = iter;
66456644
break;
66466645
}
66476646
spin_unlock(&conn->request_lock);
66486647
} else {
66496648
command_list = &conn->requests;
66506649

66516650
spin_lock(&conn->request_lock);
6652-
list_for_each_entry(cancel_work, command_list, request_entry) {
6653-
chdr = smb2_get_msg(cancel_work->request_buf);
6651+
list_for_each_entry(iter, command_list, request_entry) {
6652+
chdr = smb2_get_msg(iter->request_buf);
66546653

66556654
if (chdr->MessageId != hdr->MessageId ||
6656-
cancel_work == work)
6655+
iter == work)
66576656
continue;
66586657

66596658
ksmbd_debug(SMB,
66606659
"smb2 with mid %llu cancelled command = 0x%x\n",
66616660
le64_to_cpu(hdr->MessageId),
66626661
le16_to_cpu(chdr->Command));
6663-
canceled = 1;
6662+
cancel_work = iter;
66646663
break;
66656664
}
66666665
spin_unlock(&conn->request_lock);
66676666
}
66686667

6669-
if (canceled) {
6668+
if (cancel_work) {
66706669
cancel_work->state = KSMBD_WORK_CANCELLED;
66716670
if (cancel_work->cancel_fn)
66726671
cancel_work->cancel_fn(cancel_work->cancel_argv);

0 commit comments

Comments
 (0)