linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Bob Liu <lliubbo@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, viro@zeniv.linux.org.uk, hch@lst.de,
	hughd@google.com, npiggin@kernel.dk, Bob Liu <lliubbo@gmail.com>
Subject: [PATCH] shmem: using goto to replace several return
Date: Tue, 8 Mar 2011 17:15:00 +0800	[thread overview]
Message-ID: <1299575700-6901-2-git-send-email-lliubbo@gmail.com> (raw)
In-Reply-To: <1299575700-6901-1-git-send-email-lliubbo@gmail.com>

Code clean, use goto to replace several return.

Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 mm/shmem.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 7c9cdc6..99f5915 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1847,17 +1847,13 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 						     &dentry->d_name, NULL,
 						     NULL, NULL);
 		if (error) {
-			if (error != -EOPNOTSUPP) {
-				iput(inode);
-				return error;
-			}
+			if (error != -EOPNOTSUPP)
+				goto failed_iput;
 		}
 #ifdef CONFIG_TMPFS_POSIX_ACL
 		error = generic_acl_init(inode, dir);
-		if (error) {
-			iput(inode);
-			return error;
-		}
+		if (error)
+			goto failed_iput;
 #else
 		error = 0;
 #endif
@@ -1866,6 +1862,9 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 		d_instantiate(dentry, inode);
 		dget(dentry); /* Extra count - pin the dentry in core */
 	}
+
+failed_iput:
+	iput(inode);
 	return error;
 }
 
@@ -1987,10 +1986,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 	error = security_inode_init_security(inode, dir, &dentry->d_name, NULL,
 					     NULL, NULL);
 	if (error) {
-		if (error != -EOPNOTSUPP) {
-			iput(inode);
-			return error;
-		}
+		if (error != -EOPNOTSUPP)
+			goto failed_iput;
 		error = 0;
 	}
 
@@ -2002,10 +1999,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 		inode->i_op = &shmem_symlink_inline_operations;
 	} else {
 		error = shmem_getpage(inode, 0, &page, SGP_WRITE, NULL);
-		if (error) {
-			iput(inode);
-			return error;
-		}
+		if (error)
+			goto failed_iput;
 		inode->i_mapping->a_ops = &shmem_aops;
 		inode->i_op = &shmem_symlink_inode_operations;
 		kaddr = kmap_atomic(page, KM_USER0);
@@ -2019,7 +2014,10 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	d_instantiate(dentry, inode);
 	dget(dentry);
-	return 0;
+
+failed_iput:
+	iput(inode);
+	return error;
 }
 
 static void *shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd)
-- 
1.6.3.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-03-08  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08  9:14 [PATCH] shmem: put inode if alloc_file failed Bob Liu
2011-03-08  9:15 ` Bob Liu [this message]
2011-03-09 23:01   ` [PATCH] shmem: using goto to replace several return Andrew Morton
2011-03-09 22:58 ` [PATCH] shmem: put inode if alloc_file failed Andrew Morton
2011-03-10  0:03   ` Al Viro
2011-03-11 10:12     ` Bob Liu
2011-03-11 10:20     ` Bob Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1299575700-6901-2-git-send-email-lliubbo@gmail.com \
    --to=lliubbo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@kernel.dk \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).