diff mbox series

[-next,v2] cifs: convert list_for_each to entry variant in smb2misc.c

Message ID 20210618040232.2550645-1-libaokun1@huawei.com
State New
Headers show
Series [-next,v2] cifs: convert list_for_each to entry variant in smb2misc.c | expand

Commit Message

libaokun (A) June 18, 2021, 4:02 a.m. UTC
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>
---
V1->V2:
	Convert the missing list_for_each to entry

 fs/cifs/smb2misc.c | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

Comments

Steve French June 18, 2021, 4:16 a.m. UTC | #1
tentatively merged into cifs-2.6.git for-next

On Thu, Jun 17, 2021 at 11:02 PM Baokun Li <libaokun1@huawei.com> wrote:
>
> 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>
> ---
> V1->V2:
>         Convert the missing list_for_each to entry
>
>  fs/cifs/smb2misc.c | 33 ++++++++-------------------------
>  1 file changed, 8 insertions(+), 25 deletions(-)
>
> diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
> index 06d555d4da9a..aba048153f79 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,6 @@ 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 TCP_Server_Info *server;
>         struct cifs_ses *ses;
>         struct cifs_tcon *tcon;
> @@ -628,15 +623,9 @@ 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(tmp1, &server->smb_ses_list) {
> -                       ses = list_entry(tmp1, struct cifs_ses, smb_ses_list);
> -
> -                       list_for_each(tmp2, &ses->tcon_list) {
> -                               tcon = list_entry(tmp2, struct cifs_tcon,
> -                                                 tcon_list);
> +       list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
> +               list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
> +                       list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
>                                 spin_lock(&tcon->open_file_lock);
>                                 cifs_stats_inc(
>                                     &tcon->stats.cifs_stats.num_oplock_brks);
> @@ -687,7 +676,6 @@ 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 cifs_ses *ses;
>         struct cifs_tcon *tcon;
>         struct cifsInodeInfo *cinode;
> @@ -710,16 +698,11 @@ 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(tmp1, &ses->tcon_list) {
> -                       tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
> +       list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
> +               list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
>
>                         spin_lock(&tcon->open_file_lock);
> -                       list_for_each(tmp2, &tcon->openFileList) {
> -                               cfile = list_entry(tmp2, struct cifsFileInfo,
> -                                                    tlist);
> +                       list_for_each_entry(cfile, &tcon->openFileList, tlist) {
>                                 if (rsp->PersistentFid !=
>                                     cfile->fid.persistent_fid ||
>                                     rsp->VolatileFid !=
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 06d555d4da9a..aba048153f79 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,6 @@  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 TCP_Server_Info *server;
 	struct cifs_ses *ses;
 	struct cifs_tcon *tcon;
@@ -628,15 +623,9 @@  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(tmp1, &server->smb_ses_list) {
-			ses = list_entry(tmp1, struct cifs_ses, smb_ses_list);
-
-			list_for_each(tmp2, &ses->tcon_list) {
-				tcon = list_entry(tmp2, struct cifs_tcon,
-						  tcon_list);
+	list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
+		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
+			list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
 				spin_lock(&tcon->open_file_lock);
 				cifs_stats_inc(
 				    &tcon->stats.cifs_stats.num_oplock_brks);
@@ -687,7 +676,6 @@  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 cifs_ses *ses;
 	struct cifs_tcon *tcon;
 	struct cifsInodeInfo *cinode;
@@ -710,16 +698,11 @@  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(tmp1, &ses->tcon_list) {
-			tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
+	list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
+		list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
 
 			spin_lock(&tcon->open_file_lock);
-			list_for_each(tmp2, &tcon->openFileList) {
-				cfile = list_entry(tmp2, struct cifsFileInfo,
-						     tlist);
+			list_for_each_entry(cfile, &tcon->openFileList, tlist) {
 				if (rsp->PersistentFid !=
 				    cfile->fid.persistent_fid ||
 				    rsp->VolatileFid !=