* [PATCH -next] cifs: convert list_for_each to entry variant in smb2misc.c
@ 2021-06-17 13:22 Baokun Li
2021-06-17 14:17 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Baokun Li @ 2021-06-17 13:22 UTC (permalink / raw)
To: libaokun1, Steve French
Cc: linux-cifs, samba-technical, kernel-janitors, Hulk Robot
convert list_for_each() to list_for_each_entry() where
applicable.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
fs/cifs/smb2misc.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 06d555d4da9a..cb08fc64ce68 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -164,12 +164,10 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
struct smb2_transform_hdr *thdr =
(struct smb2_transform_hdr *)buf;
struct cifs_ses *ses = NULL;
- struct list_head *tmp;
/* decrypt frame now that it is completely read in */
spin_lock(&cifs_tcp_ses_lock);
- list_for_each(tmp, &srvr->smb_ses_list) {
- ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
+ list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) {
if (ses->Suid == thdr->SessionId)
break;
@@ -548,7 +546,6 @@ static bool
smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp)
{
__u8 lease_state;
- struct list_head *tmp;
struct cifsFileInfo *cfile;
struct cifsInodeInfo *cinode;
int ack_req = le32_to_cpu(rsp->Flags &
@@ -556,8 +553,7 @@ smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp)
lease_state = le32_to_cpu(rsp->NewLeaseState);
- list_for_each(tmp, &tcon->openFileList) {
- cfile = list_entry(tmp, struct cifsFileInfo, tlist);
+ list_for_each_entry(cfile, &tcon->openFileList, tlist) {
cinode = CIFS_I(d_inode(cfile->dentry));
if (memcmp(cinode->lease_key, rsp->LeaseKey,
@@ -618,7 +614,7 @@ static bool
smb2_is_valid_lease_break(char *buffer)
{
struct smb2_lease_break *rsp = (struct smb2_lease_break *)buffer;
- struct list_head *tmp, *tmp1, *tmp2;
+ struct list_head *tmp1, *tmp2;
struct TCP_Server_Info *server;
struct cifs_ses *ses;
struct cifs_tcon *tcon;
@@ -628,9 +624,7 @@ smb2_is_valid_lease_break(char *buffer)
/* look up tcon based on tid & uid */
spin_lock(&cifs_tcp_ses_lock);
- list_for_each(tmp, &cifs_tcp_ses_list) {
- server = list_entry(tmp, struct TCP_Server_Info, tcp_ses_list);
-
+ list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
list_for_each(tmp1, &server->smb_ses_list) {
ses = list_entry(tmp1, struct cifs_ses, smb_ses_list);
@@ -687,7 +681,7 @@ bool
smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
{
struct smb2_oplock_break *rsp = (struct smb2_oplock_break *)buffer;
- struct list_head *tmp, *tmp1, *tmp2;
+ struct list_head *tmp1, *tmp2;
struct cifs_ses *ses;
struct cifs_tcon *tcon;
struct cifsInodeInfo *cinode;
@@ -710,9 +704,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
/* look up tcon based on tid & uid */
spin_lock(&cifs_tcp_ses_lock);
- list_for_each(tmp, &server->smb_ses_list) {
- ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
-
+ list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
list_for_each(tmp1, &ses->tcon_list) {
tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] cifs: convert list_for_each to entry variant in smb2misc.c
2021-06-17 13:22 [PATCH -next] cifs: convert list_for_each to entry variant in smb2misc.c Baokun Li
@ 2021-06-17 14:17 ` Dan Carpenter
2021-06-18 1:18 ` libaokun (A)
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-06-17 14:17 UTC (permalink / raw)
To: Baokun Li
Cc: Steve French, linux-cifs, samba-technical, kernel-janitors, Hulk Robot
On Thu, Jun 17, 2021 at 09:22:50PM +0800, Baokun Li wrote:
> @@ -628,9 +624,7 @@ smb2_is_valid_lease_break(char *buffer)
>
> /* look up tcon based on tid & uid */
> spin_lock(&cifs_tcp_ses_lock);
> - list_for_each(tmp, &cifs_tcp_ses_list) {
> - server = list_entry(tmp, struct TCP_Server_Info, tcp_ses_list);
> -
> + list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
> list_for_each(tmp1, &server->smb_ses_list) {
> ses = list_entry(tmp1, struct cifs_ses, smb_ses_list);
^^^^^^^^^^^^^^^^
Please convert this one as well.
>
> @@ -687,7 +681,7 @@ bool
> smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
> {
> struct smb2_oplock_break *rsp = (struct smb2_oplock_break *)buffer;
> - struct list_head *tmp, *tmp1, *tmp2;
> + struct list_head *tmp1, *tmp2;
> struct cifs_ses *ses;
> struct cifs_tcon *tcon;
> struct cifsInodeInfo *cinode;
> @@ -710,9 +704,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
>
> /* look up tcon based on tid & uid */
> spin_lock(&cifs_tcp_ses_lock);
> - list_for_each(tmp, &server->smb_ses_list) {
> - ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
> -
> + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
> list_for_each(tmp1, &ses->tcon_list) {
> tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
^^^^^^^^^^^^^^^^^
And this one.
regards,
dan carpenter
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] cifs: convert list_for_each to entry variant in smb2misc.c
2021-06-17 14:17 ` Dan Carpenter
@ 2021-06-18 1:18 ` libaokun (A)
0 siblings, 0 replies; 3+ messages in thread
From: libaokun (A) @ 2021-06-18 1:18 UTC (permalink / raw)
To: Dan Carpenter
Cc: Steve French, linux-cifs, samba-technical, kernel-janitors, Hulk Robot
Thank you for your advice.
I'm about to send a patch v2 with the changes suggested by you.
Best Regards.
在 2021/6/17 22:17, Dan Carpenter 写道:
> On Thu, Jun 17, 2021 at 09:22:50PM +0800, Baokun Li wrote:
>> @@ -628,9 +624,7 @@ smb2_is_valid_lease_break(char *buffer)
>>
>> /* look up tcon based on tid & uid */
>> spin_lock(&cifs_tcp_ses_lock);
>> - list_for_each(tmp, &cifs_tcp_ses_list) {
>> - server = list_entry(tmp, struct TCP_Server_Info, tcp_ses_list);
>> -
>> + list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
>> list_for_each(tmp1, &server->smb_ses_list) {
>> ses = list_entry(tmp1, struct cifs_ses, smb_ses_list);
> ^^^^^^^^^^^^^^^^
>
> Please convert this one as well.
>
>>
>> @@ -687,7 +681,7 @@ bool
>> smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
>> {
>> struct smb2_oplock_break *rsp = (struct smb2_oplock_break *)buffer;
>> - struct list_head *tmp, *tmp1, *tmp2;
>> + struct list_head *tmp1, *tmp2;
>> struct cifs_ses *ses;
>> struct cifs_tcon *tcon;
>> struct cifsInodeInfo *cinode;
>> @@ -710,9 +704,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
>>
>> /* look up tcon based on tid & uid */
>> spin_lock(&cifs_tcp_ses_lock);
>> - list_for_each(tmp, &server->smb_ses_list) {
>> - ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
>> -
>> + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
>> list_for_each(tmp1, &ses->tcon_list) {
>> tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
> ^^^^^^^^^^^^^^^^^
> And this one.
>
> regards,
> dan carpenter
>
>>
> .
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-18 1:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 13:22 [PATCH -next] cifs: convert list_for_each to entry variant in smb2misc.c Baokun Li
2021-06-17 14:17 ` Dan Carpenter
2021-06-18 1:18 ` libaokun (A)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).