mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] FAT: simple error handling cleanup (2/4)
Date: Sun, 02 May 2004 22:09:31 +0900	[thread overview]
Message-ID: <871xm3t1pw.fsf@devron.myhome.or.jp> (raw)

Hi,

    From: René Scharfe <l.s.r@web.de>

the following patch converts the error handling paths in VFAT fs to use
goto, making it more consistent with other filesystem code. Shrinks the
resulting binary by 144 bytes in my build.

Please apply.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>




 fs/vfat/namei.c |   53 +++++++++++++++++++++++------------------------------
 1 files changed, 23 insertions(+), 30 deletions(-)

diff -puN fs/vfat/namei.c~vfat_cleanup1 fs/vfat/namei.c
--- linux-2.6.6-rc3/fs/vfat/namei.c~vfat_cleanup1	2004-05-02 19:15:38.000000000 +0900
+++ linux-2.6.6-rc3-hirofumi/fs/vfat/namei.c	2004-05-02 19:15:39.000000000 +0900
@@ -866,24 +866,22 @@ int vfat_create(struct inode *dir,struct
 
 	lock_kernel();
 	res = vfat_add_entry(dir, &dentry->d_name, 0, &sinfo, &bh, &de);
-	if (res < 0) {
-		unlock_kernel();
-		return res;
-	}
+	if (res < 0)
+		goto out;
 	inode = fat_build_inode(sb, de, sinfo.i_pos, &res);
 	brelse(bh);
-	if (!inode) {
-		unlock_kernel();
-		return res;
-	}
+	if (!inode)
+		goto out;
+	res = 0;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
 	mark_inode_dirty(inode);
 	inode->i_version++;
 	dir->i_version++;
 	dentry->d_time = dentry->d_parent->d_inode->i_version;
 	d_instantiate(dentry,inode);
+out:
 	unlock_kernel();
-	return 0;
+	return res;
 }
 
 static void vfat_remove_entry(struct inode *dir,struct vfat_slot_info *sinfo,
@@ -919,16 +917,13 @@ int vfat_rmdir(struct inode *dir,struct 
 
 	lock_kernel();
 	res = fat_dir_empty(dentry->d_inode);
-	if (res) {
-		unlock_kernel();
-		return res;
-	}
+	if (res)
+		goto out;
 
 	res = vfat_find(dir,&dentry->d_name,&sinfo, &bh, &de);
-	if (res<0) {
-		unlock_kernel();
-		return res;
-	}
+	if (res < 0)
+		goto out;
+	res = 0;
 	dentry->d_inode->i_nlink = 0;
 	dentry->d_inode->i_mtime = dentry->d_inode->i_atime = CURRENT_TIME;
 	fat_detach(dentry->d_inode);
@@ -936,8 +931,9 @@ int vfat_rmdir(struct inode *dir,struct 
 	/* releases bh */
 	vfat_remove_entry(dir,&sinfo,bh,de);
 	dir->i_nlink--;
+out:
 	unlock_kernel();
-	return 0;
+	return res;
 }
 
 int vfat_unlink(struct inode *dir, struct dentry* dentry)
@@ -949,16 +945,15 @@ int vfat_unlink(struct inode *dir, struc
 
 	lock_kernel();
 	res = vfat_find(dir,&dentry->d_name,&sinfo,&bh,&de);
-	if (res < 0) {
-		unlock_kernel();
-		return res;
-	}
+	if (res < 0)
+		goto out;
 	dentry->d_inode->i_nlink = 0;
 	dentry->d_inode->i_mtime = dentry->d_inode->i_atime = CURRENT_TIME;
 	fat_detach(dentry->d_inode);
 	mark_inode_dirty(dentry->d_inode);
 	/* releases bh */
 	vfat_remove_entry(dir,&sinfo,bh,de);
+out:
 	unlock_kernel();
 
 	return res;
@@ -976,13 +971,11 @@ int vfat_mkdir(struct inode *dir,struct 
 
 	lock_kernel();
 	res = vfat_add_entry(dir, &dentry->d_name, 1, &sinfo, &bh, &de);
-	if (res < 0) {
-		unlock_kernel();
-		return res;
-	}
+	if (res < 0)
+		goto out;
 	inode = fat_build_inode(sb, de, sinfo.i_pos, &res);
 	if (!inode)
-		goto out;
+		goto out_brelse;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
 	mark_inode_dirty(inode);
 	inode->i_version++;
@@ -994,8 +987,9 @@ int vfat_mkdir(struct inode *dir,struct 
 		goto mkdir_failed;
 	dentry->d_time = dentry->d_parent->d_inode->i_version;
 	d_instantiate(dentry,inode);
-out:
+out_brelse:
 	brelse(bh);
+out:
 	unlock_kernel();
 	return res;
 
@@ -1008,8 +1002,7 @@ mkdir_failed:
 	vfat_remove_entry(dir,&sinfo,bh,de);
 	iput(inode);
 	dir->i_nlink--;
-	unlock_kernel();
-	return res;
+	goto out;
 }
  
 int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,

_

                 reply	other threads:[~2004-05-02 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=871xm3t1pw.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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

all inboxes | Powered by JetHome®