linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] cifs: delete unnecessary NULL checks in cifs_chan_update_iface()
@ 2024-01-08  9:07 Dan Carpenter
  2024-01-08  9:08 ` [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dan Carpenter @ 2024-01-08  9:07 UTC (permalink / raw)
  To: Steve French
  Cc: Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	linux-cifs, samba-technical, linux-kernel, kernel-janitors

We return early if "iface" is NULL so there is no need to check here.
Delete those checks.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/smb/client/sess.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
index a16e175731eb..775c6a4a2f4b 100644
--- a/fs/smb/client/sess.c
+++ b/fs/smb/client/sess.c
@@ -467,27 +467,23 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 		kref_put(&old_iface->refcount, release_iface);
 	} else if (!chan_index) {
 		/* special case: update interface for primary channel */
-		if (iface) {
-			cifs_dbg(FYI, "referencing primary channel iface: %pIS\n",
-				 &iface->sockaddr);
-			iface->num_channels++;
-			iface->weight_fulfilled++;
-		}
+		cifs_dbg(FYI, "referencing primary channel iface: %pIS\n",
+			 &iface->sockaddr);
+		iface->num_channels++;
+		iface->weight_fulfilled++;
 	}
 	spin_unlock(&ses->iface_lock);
 
-	if (iface) {
-		spin_lock(&ses->chan_lock);
-		chan_index = cifs_ses_get_chan_index(ses, server);
-		if (chan_index == CIFS_INVAL_CHAN_INDEX) {
-			spin_unlock(&ses->chan_lock);
-			return 0;
-		}
-
-		ses->chans[chan_index].iface = iface;
+	spin_lock(&ses->chan_lock);
+	chan_index = cifs_ses_get_chan_index(ses, server);
+	if (chan_index == CIFS_INVAL_CHAN_INDEX) {
 		spin_unlock(&ses->chan_lock);
+		return 0;
 	}
 
+	ses->chans[chan_index].iface = iface;
+	spin_unlock(&ses->chan_lock);
+
 	return rc;
 }
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function
  2024-01-08  9:07 [PATCH 1/3] cifs: delete unnecessary NULL checks in cifs_chan_update_iface() Dan Carpenter
@ 2024-01-08  9:08 ` Dan Carpenter
  2024-01-08 19:09   ` Christophe JAILLET
  2024-01-09  4:42   ` Steve French
  2024-01-08  9:09 ` [PATCH 3/3] cifs: simplify a check in cifs_chan_update_iface() Dan Carpenter
  2024-01-09  0:52 ` [PATCH 1/3] cifs: delete unnecessary NULL checks " Steve French
  2 siblings, 2 replies; 9+ messages in thread
From: Dan Carpenter @ 2024-01-08  9:08 UTC (permalink / raw)
  To: Steve French
  Cc: Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	linux-cifs, samba-technical, linux-kernel, kernel-janitors

The return values for cifs_chan_update_iface() didn't match what the
documentation said and nothing was checking them anyway.  Just make it
a void function.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/smb/client/cifsproto.h |  2 +-
 fs/smb/client/sess.c      | 17 +++++++----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index afbab86331a1..a841bf4967fa 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -656,7 +656,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
 			  struct TCP_Server_Info *server);
 void
 cifs_disable_secondary_channels(struct cifs_ses *ses);
-int
+void
 cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
 int
 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
index 775c6a4a2f4b..f7b216dd06b2 100644
--- a/fs/smb/client/sess.c
+++ b/fs/smb/client/sess.c
@@ -356,10 +356,9 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)
 
 /*
  * update the iface for the channel if necessary.
- * will return 0 when iface is updated, 1 if removed, 2 otherwise
  * Must be called with chan_lock held.
  */
-int
+void
 cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 {
 	unsigned int chan_index;
@@ -368,20 +367,19 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	struct cifs_server_iface *old_iface = NULL;
 	struct cifs_server_iface *last_iface = NULL;
 	struct sockaddr_storage ss;
-	int rc = 0;
 
 	spin_lock(&ses->chan_lock);
 	chan_index = cifs_ses_get_chan_index(ses, server);
 	if (chan_index == CIFS_INVAL_CHAN_INDEX) {
 		spin_unlock(&ses->chan_lock);
-		return 0;
+		return;
 	}
 
 	if (ses->chans[chan_index].iface) {
 		old_iface = ses->chans[chan_index].iface;
 		if (old_iface->is_active) {
 			spin_unlock(&ses->chan_lock);
-			return 1;
+			return;
 		}
 	}
 	spin_unlock(&ses->chan_lock);
@@ -394,7 +392,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	if (!ses->iface_count) {
 		spin_unlock(&ses->iface_lock);
 		cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname);
-		return 0;
+		return;
 	}
 
 	last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
@@ -434,7 +432,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	}
 
 	if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
-		rc = 1;
 		iface = NULL;
 		cifs_dbg(FYI, "unable to find a suitable iface\n");
 	}
@@ -449,7 +446,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 		}
 
 		spin_unlock(&ses->iface_lock);
-		return 0;
+		return;
 	}
 
 	/* now drop the ref to the current iface */
@@ -478,13 +475,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	chan_index = cifs_ses_get_chan_index(ses, server);
 	if (chan_index == CIFS_INVAL_CHAN_INDEX) {
 		spin_unlock(&ses->chan_lock);
-		return 0;
+		return;
 	}
 
 	ses->chans[chan_index].iface = iface;
 	spin_unlock(&ses->chan_lock);
 
-	return rc;
+	return;
 }
 
 /*
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] cifs: simplify a check in cifs_chan_update_iface()
  2024-01-08  9:07 [PATCH 1/3] cifs: delete unnecessary NULL checks in cifs_chan_update_iface() Dan Carpenter
  2024-01-08  9:08 ` [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function Dan Carpenter
@ 2024-01-08  9:09 ` Dan Carpenter
  2024-01-09  0:52 ` [PATCH 1/3] cifs: delete unnecessary NULL checks " Steve French
  2 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2024-01-08  9:09 UTC (permalink / raw)
  To: Steve French
  Cc: Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	linux-cifs, samba-technical, linux-kernel, kernel-janitors

The loop iterator in a list_for_each() loop is never NULL at the end.
This condition uses a two step process of setting the iterator, "iface",
from non-NULL to NULL and then checking if it's NULL.  It's easier to do
in one step.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/smb/client/sess.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
index f7b216dd06b2..987188e1929e 100644
--- a/fs/smb/client/sess.c
+++ b/fs/smb/client/sess.c
@@ -363,7 +363,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 {
 	unsigned int chan_index;
 	size_t iface_weight = 0, iface_min_speed = 0;
-	struct cifs_server_iface *iface = NULL;
+	struct cifs_server_iface *iface;
 	struct cifs_server_iface *old_iface = NULL;
 	struct cifs_server_iface *last_iface = NULL;
 	struct sockaddr_storage ss;
@@ -432,11 +432,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	}
 
 	if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
-		iface = NULL;
-		cifs_dbg(FYI, "unable to find a suitable iface\n");
-	}
-
-	if (!iface) {
 		if (!chan_index)
 			cifs_dbg(FYI, "unable to get the interface matching: %pIS\n",
 				 &ss);
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function
  2024-01-08  9:08 ` [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function Dan Carpenter
@ 2024-01-08 19:09   ` Christophe JAILLET
  2024-01-09  4:41     ` Steve French
  2024-01-09  7:39     ` Dan Carpenter
  2024-01-09  4:42   ` Steve French
  1 sibling, 2 replies; 9+ messages in thread
From: Christophe JAILLET @ 2024-01-08 19:09 UTC (permalink / raw)
  To: Dan Carpenter, Steve French
  Cc: Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	linux-cifs, samba-technical, linux-kernel, kernel-janitors

Le 08/01/2024 à 10:08, Dan Carpenter a écrit :
> The return values for cifs_chan_update_iface() didn't match what the
> documentation said and nothing was checking them anyway.  Just make it
> a void function.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   fs/smb/client/cifsproto.h |  2 +-
>   fs/smb/client/sess.c      | 17 +++++++----------
>   2 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
> index afbab86331a1..a841bf4967fa 100644
> --- a/fs/smb/client/cifsproto.h
> +++ b/fs/smb/client/cifsproto.h
> @@ -656,7 +656,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
>   			  struct TCP_Server_Info *server);
>   void
>   cifs_disable_secondary_channels(struct cifs_ses *ses);
> -int
> +void
>   cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
>   int
>   SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
> diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
> index 775c6a4a2f4b..f7b216dd06b2 100644
> --- a/fs/smb/client/sess.c
> +++ b/fs/smb/client/sess.c
> @@ -356,10 +356,9 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)
>   
>   /*
>    * update the iface for the channel if necessary.
> - * will return 0 when iface is updated, 1 if removed, 2 otherwise
>    * Must be called with chan_lock held.
>    */
> -int
> +void
>   cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>   {
>   	unsigned int chan_index;
> @@ -368,20 +367,19 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>   	struct cifs_server_iface *old_iface = NULL;
>   	struct cifs_server_iface *last_iface = NULL;
>   	struct sockaddr_storage ss;
> -	int rc = 0;
>   
>   	spin_lock(&ses->chan_lock);
>   	chan_index = cifs_ses_get_chan_index(ses, server);
>   	if (chan_index == CIFS_INVAL_CHAN_INDEX) {
>   		spin_unlock(&ses->chan_lock);
> -		return 0;
> +		return;
>   	}
>   
>   	if (ses->chans[chan_index].iface) {
>   		old_iface = ses->chans[chan_index].iface;
>   		if (old_iface->is_active) {
>   			spin_unlock(&ses->chan_lock);
> -			return 1;
> +			return;
>   		}
>   	}
>   	spin_unlock(&ses->chan_lock);
> @@ -394,7 +392,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>   	if (!ses->iface_count) {
>   		spin_unlock(&ses->iface_lock);
>   		cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname);
> -		return 0;
> +		return;
>   	}
>   
>   	last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
> @@ -434,7 +432,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>   	}
>   
>   	if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
> -		rc = 1;
>   		iface = NULL;
>   		cifs_dbg(FYI, "unable to find a suitable iface\n");
>   	}
> @@ -449,7 +446,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>   		}
>   
>   		spin_unlock(&ses->iface_lock);
> -		return 0;
> +		return;
>   	}
>   
>   	/* now drop the ref to the current iface */
> @@ -478,13 +475,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>   	chan_index = cifs_ses_get_chan_index(ses, server);
>   	if (chan_index == CIFS_INVAL_CHAN_INDEX) {
>   		spin_unlock(&ses->chan_lock);
> -		return 0;
> +		return;
>   	}
>   
>   	ses->chans[chan_index].iface = iface;
>   	spin_unlock(&ses->chan_lock);
>   
> -	return rc;
> +	return;

just remove this one?

CJ

>   }
>   
>   /*


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] cifs: delete unnecessary NULL checks in cifs_chan_update_iface()
  2024-01-08  9:07 [PATCH 1/3] cifs: delete unnecessary NULL checks in cifs_chan_update_iface() Dan Carpenter
  2024-01-08  9:08 ` [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function Dan Carpenter
  2024-01-08  9:09 ` [PATCH 3/3] cifs: simplify a check in cifs_chan_update_iface() Dan Carpenter
@ 2024-01-09  0:52 ` Steve French
  2 siblings, 0 replies; 9+ messages in thread
From: Steve French @ 2024-01-09  0:52 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	linux-cifs, samba-technical, linux-kernel, kernel-janitors

merged into cifs-2.6.git for-next, still reviewing the other two

On Mon, Jan 8, 2024 at 3:08 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> We return early if "iface" is NULL so there is no need to check here.
> Delete those checks.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  fs/smb/client/sess.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
> index a16e175731eb..775c6a4a2f4b 100644
> --- a/fs/smb/client/sess.c
> +++ b/fs/smb/client/sess.c
> @@ -467,27 +467,23 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>                 kref_put(&old_iface->refcount, release_iface);
>         } else if (!chan_index) {
>                 /* special case: update interface for primary channel */
> -               if (iface) {
> -                       cifs_dbg(FYI, "referencing primary channel iface: %pIS\n",
> -                                &iface->sockaddr);
> -                       iface->num_channels++;
> -                       iface->weight_fulfilled++;
> -               }
> +               cifs_dbg(FYI, "referencing primary channel iface: %pIS\n",
> +                        &iface->sockaddr);
> +               iface->num_channels++;
> +               iface->weight_fulfilled++;
>         }
>         spin_unlock(&ses->iface_lock);
>
> -       if (iface) {
> -               spin_lock(&ses->chan_lock);
> -               chan_index = cifs_ses_get_chan_index(ses, server);
> -               if (chan_index == CIFS_INVAL_CHAN_INDEX) {
> -                       spin_unlock(&ses->chan_lock);
> -                       return 0;
> -               }
> -
> -               ses->chans[chan_index].iface = iface;
> +       spin_lock(&ses->chan_lock);
> +       chan_index = cifs_ses_get_chan_index(ses, server);
> +       if (chan_index == CIFS_INVAL_CHAN_INDEX) {
>                 spin_unlock(&ses->chan_lock);
> +               return 0;
>         }
>
> +       ses->chans[chan_index].iface = iface;
> +       spin_unlock(&ses->chan_lock);
> +
>         return rc;
>  }
>
> --
> 2.42.0
>
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function
  2024-01-08 19:09   ` Christophe JAILLET
@ 2024-01-09  4:41     ` Steve French
  2024-01-09  7:44       ` Dan Carpenter
  2024-01-09  7:39     ` Dan Carpenter
  1 sibling, 1 reply; 9+ messages in thread
From: Steve French @ 2024-01-09  4:41 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Dan Carpenter, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Tom Talpey, linux-cifs, samba-technical,
	linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 4407 bytes --]

added the trivial change Christophe Suggested


On Mon, Jan 8, 2024 at 1:09 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 08/01/2024 à 10:08, Dan Carpenter a écrit :
> > The return values for cifs_chan_update_iface() didn't match what the
> > documentation said and nothing was checking them anyway.  Just make it
> > a void function.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >   fs/smb/client/cifsproto.h |  2 +-
> >   fs/smb/client/sess.c      | 17 +++++++----------
> >   2 files changed, 8 insertions(+), 11 deletions(-)
> >
> > diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
> > index afbab86331a1..a841bf4967fa 100644
> > --- a/fs/smb/client/cifsproto.h
> > +++ b/fs/smb/client/cifsproto.h
> > @@ -656,7 +656,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
> >                         struct TCP_Server_Info *server);
> >   void
> >   cifs_disable_secondary_channels(struct cifs_ses *ses);
> > -int
> > +void
> >   cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
> >   int
> >   SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
> > diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
> > index 775c6a4a2f4b..f7b216dd06b2 100644
> > --- a/fs/smb/client/sess.c
> > +++ b/fs/smb/client/sess.c
> > @@ -356,10 +356,9 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)
> >
> >   /*
> >    * update the iface for the channel if necessary.
> > - * will return 0 when iface is updated, 1 if removed, 2 otherwise
> >    * Must be called with chan_lock held.
> >    */
> > -int
> > +void
> >   cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >   {
> >       unsigned int chan_index;
> > @@ -368,20 +367,19 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >       struct cifs_server_iface *old_iface = NULL;
> >       struct cifs_server_iface *last_iface = NULL;
> >       struct sockaddr_storage ss;
> > -     int rc = 0;
> >
> >       spin_lock(&ses->chan_lock);
> >       chan_index = cifs_ses_get_chan_index(ses, server);
> >       if (chan_index == CIFS_INVAL_CHAN_INDEX) {
> >               spin_unlock(&ses->chan_lock);
> > -             return 0;
> > +             return;
> >       }
> >
> >       if (ses->chans[chan_index].iface) {
> >               old_iface = ses->chans[chan_index].iface;
> >               if (old_iface->is_active) {
> >                       spin_unlock(&ses->chan_lock);
> > -                     return 1;
> > +                     return;
> >               }
> >       }
> >       spin_unlock(&ses->chan_lock);
> > @@ -394,7 +392,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >       if (!ses->iface_count) {
> >               spin_unlock(&ses->iface_lock);
> >               cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname);
> > -             return 0;
> > +             return;
> >       }
> >
> >       last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
> > @@ -434,7 +432,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >       }
> >
> >       if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
> > -             rc = 1;
> >               iface = NULL;
> >               cifs_dbg(FYI, "unable to find a suitable iface\n");
> >       }
> > @@ -449,7 +446,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >               }
> >
> >               spin_unlock(&ses->iface_lock);
> > -             return 0;
> > +             return;
> >       }
> >
> >       /* now drop the ref to the current iface */
> > @@ -478,13 +475,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >       chan_index = cifs_ses_get_chan_index(ses, server);
> >       if (chan_index == CIFS_INVAL_CHAN_INDEX) {
> >               spin_unlock(&ses->chan_lock);
> > -             return 0;
> > +             return;
> >       }
> >
> >       ses->chans[chan_index].iface = iface;
> >       spin_unlock(&ses->chan_lock);
> >
> > -     return rc;
> > +     return;
>
> just remove this one?
>
> CJ
>
> >   }
> >
> >   /*
>
>


-- 
Thanks,

Steve

[-- Attachment #2: 0017-cifs-remove-unneeded-return-statement.patch --]
[-- Type: text/x-patch, Size: 820 bytes --]

From a3f763fdcb2f784c355aed66ddac6748ff8dbfa6 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Mon, 8 Jan 2024 22:37:10 -0600
Subject: [PATCH 17/17] cifs: remove unneeded return statement

Return statement was not needed at end of cifs_chan_update_iface

Suggested-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/smb/client/sess.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
index f7b216dd06b2..cde81042bebd 100644
--- a/fs/smb/client/sess.c
+++ b/fs/smb/client/sess.c
@@ -480,8 +480,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 
 	ses->chans[chan_index].iface = iface;
 	spin_unlock(&ses->chan_lock);
-
-	return;
 }
 
 /*
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function
  2024-01-08  9:08 ` [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function Dan Carpenter
  2024-01-08 19:09   ` Christophe JAILLET
@ 2024-01-09  4:42   ` Steve French
  1 sibling, 0 replies; 9+ messages in thread
From: Steve French @ 2024-01-09  4:42 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, linux-cifs, samba-technical, linux-kernel,
	kernel-janitors

merged into cifs-2.6.git for-next

On Mon, Jan 8, 2024 at 3:08 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The return values for cifs_chan_update_iface() didn't match what the
> documentation said and nothing was checking them anyway.  Just make it
> a void function.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  fs/smb/client/cifsproto.h |  2 +-
>  fs/smb/client/sess.c      | 17 +++++++----------
>  2 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
> index afbab86331a1..a841bf4967fa 100644
> --- a/fs/smb/client/cifsproto.h
> +++ b/fs/smb/client/cifsproto.h
> @@ -656,7 +656,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
>                           struct TCP_Server_Info *server);
>  void
>  cifs_disable_secondary_channels(struct cifs_ses *ses);
> -int
> +void
>  cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
>  int
>  SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
> diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
> index 775c6a4a2f4b..f7b216dd06b2 100644
> --- a/fs/smb/client/sess.c
> +++ b/fs/smb/client/sess.c
> @@ -356,10 +356,9 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)
>
>  /*
>   * update the iface for the channel if necessary.
> - * will return 0 when iface is updated, 1 if removed, 2 otherwise
>   * Must be called with chan_lock held.
>   */
> -int
> +void
>  cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>  {
>         unsigned int chan_index;
> @@ -368,20 +367,19 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>         struct cifs_server_iface *old_iface = NULL;
>         struct cifs_server_iface *last_iface = NULL;
>         struct sockaddr_storage ss;
> -       int rc = 0;
>
>         spin_lock(&ses->chan_lock);
>         chan_index = cifs_ses_get_chan_index(ses, server);
>         if (chan_index == CIFS_INVAL_CHAN_INDEX) {
>                 spin_unlock(&ses->chan_lock);
> -               return 0;
> +               return;
>         }
>
>         if (ses->chans[chan_index].iface) {
>                 old_iface = ses->chans[chan_index].iface;
>                 if (old_iface->is_active) {
>                         spin_unlock(&ses->chan_lock);
> -                       return 1;
> +                       return;
>                 }
>         }
>         spin_unlock(&ses->chan_lock);
> @@ -394,7 +392,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>         if (!ses->iface_count) {
>                 spin_unlock(&ses->iface_lock);
>                 cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname);
> -               return 0;
> +               return;
>         }
>
>         last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
> @@ -434,7 +432,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>         }
>
>         if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
> -               rc = 1;
>                 iface = NULL;
>                 cifs_dbg(FYI, "unable to find a suitable iface\n");
>         }
> @@ -449,7 +446,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>                 }
>
>                 spin_unlock(&ses->iface_lock);
> -               return 0;
> +               return;
>         }
>
>         /* now drop the ref to the current iface */
> @@ -478,13 +475,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
>         chan_index = cifs_ses_get_chan_index(ses, server);
>         if (chan_index == CIFS_INVAL_CHAN_INDEX) {
>                 spin_unlock(&ses->chan_lock);
> -               return 0;
> +               return;
>         }
>
>         ses->chans[chan_index].iface = iface;
>         spin_unlock(&ses->chan_lock);
>
> -       return rc;
> +       return;
>  }
>
>  /*
> --
> 2.42.0
>
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function
  2024-01-08 19:09   ` Christophe JAILLET
  2024-01-09  4:41     ` Steve French
@ 2024-01-09  7:39     ` Dan Carpenter
  1 sibling, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2024-01-09  7:39 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, linux-cifs, samba-technical, linux-kernel,
	kernel-janitors

On Mon, Jan 08, 2024 at 08:09:17PM +0100, Christophe JAILLET wrote:
> > @@ -478,13 +475,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
> >   	chan_index = cifs_ses_get_chan_index(ses, server);
> >   	if (chan_index == CIFS_INVAL_CHAN_INDEX) {
> >   		spin_unlock(&ses->chan_lock);
> > -		return 0;
> > +		return;
> >   	}
> >   	ses->chans[chan_index].iface = iface;
> >   	spin_unlock(&ses->chan_lock);
> > -	return rc;
> > +	return;
> 
> just remove this one?
> 

Doh.  Yeah.  I'll send a v2 of this tomorrow.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function
  2024-01-09  4:41     ` Steve French
@ 2024-01-09  7:44       ` Dan Carpenter
  0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2024-01-09  7:44 UTC (permalink / raw)
  To: Steve French
  Cc: Christophe JAILLET, Steve French, Paulo Alcantara,
	Ronnie Sahlberg, Shyam Prasad N, Tom Talpey, linux-cifs,
	samba-technical, linux-kernel, kernel-janitors

On Mon, Jan 08, 2024 at 10:41:35PM -0600, Steve French wrote:
> added the trivial change Christophe Suggested
> 

Thanks, Steve.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-01-09  7:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08  9:07 [PATCH 1/3] cifs: delete unnecessary NULL checks in cifs_chan_update_iface() Dan Carpenter
2024-01-08  9:08 ` [PATCH 2/3] cifs: make cifs_chan_update_iface() a void function Dan Carpenter
2024-01-08 19:09   ` Christophe JAILLET
2024-01-09  4:41     ` Steve French
2024-01-09  7:44       ` Dan Carpenter
2024-01-09  7:39     ` Dan Carpenter
2024-01-09  4:42   ` Steve French
2024-01-08  9:09 ` [PATCH 3/3] cifs: simplify a check in cifs_chan_update_iface() Dan Carpenter
2024-01-09  0:52 ` [PATCH 1/3] cifs: delete unnecessary NULL checks " Steve French

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).