public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFS Client: remove supurflous goto from nfs_create_client()
@ 2006-03-09  9:23 Horms
  2006-03-10  1:03 ` Sam Vilain
  0 siblings, 1 reply; 3+ messages in thread
From: Horms @ 2006-03-09  9:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Trond Myklebust

The out_fail label in nfs_create_client just returns clnt,
which happens to be a duplicate of a return immediately above.
Remove the label and instead of calling goto out_fail (once),
just return clnt.

Signed-Off-By: Horms <horms@verge.net.au>

 inode.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index a77ee95..367d62c 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -408,16 +408,13 @@ nfs_create_client(struct nfs_server *ser
 	if (IS_ERR(clnt)) {
 		dprintk("%s: cannot create RPC client. Error = %ld\n",
 				__FUNCTION__, PTR_ERR(xprt));
-		goto out_fail;
+		return clnt;
 	}
 
 	clnt->cl_intr     = 1;
 	clnt->cl_softrtry = 1;
 
 	return clnt;
-
-out_fail:
-	return clnt;
 }
 
 /*

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

* Re: [PATCH] NFS Client: remove supurflous goto from nfs_create_client()
  2006-03-09  9:23 [PATCH] NFS Client: remove supurflous goto from nfs_create_client() Horms
@ 2006-03-10  1:03 ` Sam Vilain
  2006-03-10  2:24   ` Horms
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Vilain @ 2006-03-10  1:03 UTC (permalink / raw)
  To: Horms; +Cc: linux-kernel, Trond Myklebust

Horms wrote:

>--- a/fs/nfs/inode.c
>+++ b/fs/nfs/inode.c
>@@ -408,16 +408,13 @@ nfs_create_client(struct nfs_server *ser
> 	if (IS_ERR(clnt)) {
> 		dprintk("%s: cannot create RPC client. Error = %ld\n",
> 				__FUNCTION__, PTR_ERR(xprt));
>-		goto out_fail;
>+		return clnt;
> 	}
> 
> 	clnt->cl_intr     = 1;
> 	clnt->cl_softrtry = 1;
> 
> 	return clnt;
>-
>-out_fail:
>-	return clnt;
> }
>  
>

Why not just move the label?

I think it is nicer if all of the exit points of a function are at the
end, I've observed this to be a common convention and its success has
actually made me jump off the 'goto=hell' bandwagon.

gcc might even be optimising those duplicate instructions to a single
one, so the duplication would be good documentation.

Sam.

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

* Re: [PATCH] NFS Client: remove supurflous goto from nfs_create_client()
  2006-03-10  1:03 ` Sam Vilain
@ 2006-03-10  2:24   ` Horms
  0 siblings, 0 replies; 3+ messages in thread
From: Horms @ 2006-03-10  2:24 UTC (permalink / raw)
  To: Sam Vilain; +Cc: linux-kernel, Trond Myklebust

On Fri, Mar 10, 2006 at 02:03:15PM +1300, Sam Vilain wrote:
> Why not just move the label?
> 
> I think it is nicer if all of the exit points of a function are at the
> end, I've observed this to be a common convention and its success has
> actually made me jump off the 'goto=hell' bandwagon.
> 
> gcc might even be optimising those duplicate instructions to a single
> one, so the duplication would be good documentation.

Sure, I thought of doing that as well, and I wasn't sure which was the
best option. I actually prefer not to have a label if its just going to
return. But I'm not religious about it. Here is an alternate patch that 
does what you suggest.

NFS Client: Remove duplicate return in nfs_create_client()

Signed-Off-By: Horms <horms@verge.net.au>

 inode.c |    2 --
 1 file changed, 2 deletions(-)

65263bbdd17ed4ca75ac1c38165e5bd50eed146c
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index a77ee95..14aa539 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -414,8 +414,6 @@ nfs_create_client(struct nfs_server *ser
 	clnt->cl_intr     = 1;
 	clnt->cl_softrtry = 1;
 
-	return clnt;
-
 out_fail:
 	return clnt;
 }

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

end of thread, other threads:[~2006-03-10  2:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-09  9:23 [PATCH] NFS Client: remove supurflous goto from nfs_create_client() Horms
2006-03-10  1:03 ` Sam Vilain
2006-03-10  2:24   ` Horms

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox