Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1455979 > unrolled thread

[patch] nfsd: remove some dead code in nfsd_create_locked()

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-08-03 21:10 +0200
Last post2016-08-03 23:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] nfsd: remove some dead code in nfsd_create_locked() Dan Carpenter <dan.carpenter@oracle.com> - 2016-08-03 21:10 +0200
    Re: [patch] nfsd: remove some dead code in nfsd_create_locked() "J. Bruce Fields" <bfields@fieldses.org> - 2016-08-03 23:00 +0200

#1455979 — [patch] nfsd: remove some dead code in nfsd_create_locked()

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-08-03 21:10 +0200
Subject[patch] nfsd: remove some dead code in nfsd_create_locked()
Message-ID<s29Ie-6D8-33@gated-at.bofh.it>
We changed this around in f13058a93484 ('nfsd: reorganize nfsd_create')
so "dchild" can't be an error pointer any more.  Also we don't need to
test if dchild is NULL because dput has a check built-in.  Can it even
be NULL?

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index c844fd6..cd628ce 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1141,7 +1141,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
 		char *fname, int flen, struct iattr *iap,
 		int type, dev_t rdev, struct svc_fh *resfhp)
 {
-	struct dentry	*dentry, *dchild = NULL;
+	struct dentry	*dentry, *dchild;
 	struct inode	*dirp;
 	__be32		err;
 	__be32		err2;
@@ -1208,8 +1208,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	if (!err)
 		err = fh_update(resfhp);
 out:
-	if (dchild && !IS_ERR(dchild))
-		dput(dchild);
+	dput(dchild);
 	return err;
 
 out_nfserr:

[toc] | [next] | [standalone]


#1456025

From"J. Bruce Fields" <bfields@fieldses.org>
Date2016-08-03 23:00 +0200
Message-ID<s2bqF-7Bn-13@gated-at.bofh.it>
In reply to#1455979
On Wed, Aug 03, 2016 at 10:05:00PM +0300, Dan Carpenter wrote:
> We changed this around in f13058a93484 ('nfsd: reorganize nfsd_create')
> so "dchild" can't be an error pointer any more.  Also we don't need to
> test if dchild is NULL because dput has a check built-in.

Thanks!

> Can it even be NULL?

It was returned from a caller's lookup_one_len, which can only return
pointers or errors, I believe.  (And looks like callers also do
fh_verify and would already oops if it was null.)

Anyway, added a brief comment to that effect, fixed up the referenced
commitid (I rewrote some history there, apologies) and committed, will
push out after a few tests....

--b.

> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index c844fd6..cd628ce 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1141,7 +1141,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
>  		char *fname, int flen, struct iattr *iap,
>  		int type, dev_t rdev, struct svc_fh *resfhp)
>  {
> -	struct dentry	*dentry, *dchild = NULL;
> +	struct dentry	*dentry, *dchild;
>  	struct inode	*dirp;
>  	__be32		err;
>  	__be32		err2;
> @@ -1208,8 +1208,7 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
>  	if (!err)
>  		err = fh_update(resfhp);
>  out:
> -	if (dchild && !IS_ERR(dchild))
> -		dput(dchild);
> +	dput(dchild);
>  	return err;
>  
>  out_nfserr:

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web