linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erez Zadok <ezk@cs.sunysb.edu>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	viro@ftp.linux.org.uk, hch@infradead.org,
	Erez Zadok <ezk@cs.sunysb.edu>
Subject: [PATCH 14/19] Unionfs: use braces in both branches of conditionals
Date: Mon,  1 Oct 2007 01:50:51 -0400	[thread overview]
Message-ID: <11912178623778-git-send-email-ezk@cs.sunysb.edu> (raw)
In-Reply-To: <1191217856647-git-send-email-ezk@cs.sunysb.edu>

As per CodingStyle, if one branch of an if-then-else has braces because it
has multiple statements, then the other branch should have braces too, even
if the other branch has only one statement in it.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
---
 fs/unionfs/commonfops.c |    6 ++++--
 fs/unionfs/dentry.c     |    8 ++++----
 fs/unionfs/dirfops.c    |    6 ++++--
 fs/unionfs/dirhelper.c  |    4 ++--
 fs/unionfs/inode.c      |    6 ++++--
 fs/unionfs/lookup.c     |    7 ++++---
 fs/unionfs/main.c       |    4 ++--
 fs/unionfs/rdstate.c    |    4 ++--
 fs/unionfs/rename.c     |   21 ++++++++++++---------
 fs/unionfs/unlink.c     |    9 +++++----
 10 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index b42a6f4..f7da687 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -182,8 +182,9 @@ static int open_all_files(struct file *file)
 		if (IS_ERR(lower_file)) {
 			err = PTR_ERR(lower_file);
 			goto out;
-		} else
+		} else {
 			unionfs_set_lower_file_idx(file, bindex, lower_file);
+		}
 	}
 out:
 	return err;
@@ -484,8 +485,9 @@ static int __open_file(struct inode *inode, struct file *file)
 					break;
 			}
 			return err;
-		} else
+		} else {
 			lower_flags &= ~(OPEN_WRITE_FLAGS);
+		}
 	}
 
 	dget(lower_dentry);
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 248c79d..8891c53 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -299,9 +299,9 @@ bool __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd,
 		 * always be valid, but its lower inode times don't have to
 		 * be, so sync up the times only.
 		 */
-		if (IS_ROOT(dtmp))
+		if (IS_ROOT(dtmp)) {
 			unionfs_copy_attr_times(dtmp->d_inode);
-		else {
+		} else {
 			/*
 			 * reset generation number to zero, guaranteed to be
 			 * "old"
@@ -376,9 +376,9 @@ out_this:
 
 	if (unlikely(is_newer_lower(dentry))) {
 		/* root dentry special case as aforementioned */
-		if (IS_ROOT(dentry))
+		if (IS_ROOT(dentry)) {
 			unionfs_copy_attr_times(dentry->d_inode);
-		else {
+		} else {
 			/*
 			 * reset generation number to zero, guaranteed to be
 			 * "old"
diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index da0fcdb..ed51540 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -174,8 +174,9 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir)
 		free_rdstate(uds);
 		UNIONFS_F(file)->rdstate = NULL;
 		file->f_pos = DIREOF;
-	} else
+	} else {
 		file->f_pos = rdstate2offset(uds);
+	}
 
 out:
 	unionfs_read_unlock(file->f_path.dentry->d_sb);
@@ -242,8 +243,9 @@ static loff_t unionfs_dir_llseek(struct file *file, loff_t offset, int origin)
 				if (rdstate) {
 					UNIONFS_F(file)->rdstate = rdstate;
 					err = rdstate->offset;
-				} else
+				} else {
 					err = -EINVAL;
+				}
 			}
 			break;
 		case SEEK_CUR:
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index f0e1fee..8f4a304 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -111,9 +111,9 @@ int delete_whiteouts(struct dentry *dentry, int bindex,
 	BUG_ON(!S_ISDIR(lower_dir->i_mode));
 
 	mutex_lock(&lower_dir->i_mutex);
-	if (!permission(lower_dir, MAY_WRITE | MAY_EXEC, NULL))
+	if (!permission(lower_dir, MAY_WRITE | MAY_EXEC, NULL)) {
 		err = do_delete_whiteouts(dentry, bindex, namelist);
-	else {
+	} else {
 		args.deletewh.namelist = namelist;
 		args.deletewh.dentry = dentry;
 		args.deletewh.bindex = bindex;
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 49b5baf..3b58277 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -571,8 +571,9 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
 			if (!IS_COPYUP_ERR(err))
 				goto out;
 			bstart--;
-		} else
+		} else {
 			whiteout_unlinked = 1;
+		}
 	}
 
 	for (bindex = bstart; bindex >= 0; bindex--) {
@@ -718,8 +719,9 @@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
 			if (!IS_COPYUP_ERR(err))
 				goto out;
 			bstart--;
-		} else
+		} else {
 			whiteout_unlinked = 1;
+		}
 	}
 
 	for (bindex = bstart; bindex >= 0; bindex--) {
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 929f15b..a2c046b 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -47,11 +47,11 @@ static noinline int is_opaque_dir(struct dentry *dentry, int bindex)
 
 	mutex_lock(&lower_inode->i_mutex);
 
-	if (!permission(lower_inode, MAY_EXEC, NULL))
+	if (!permission(lower_inode, MAY_EXEC, NULL)) {
 		wh_lower_dentry =
 			lookup_one_len(UNIONFS_DIR_OPAQUE, lower_dentry,
 				       sizeof(UNIONFS_DIR_OPAQUE) - 1);
-	else {
+	} else {
 		args.is_opaque.dentry = lower_dentry;
 		run_sioq(__is_opaque_dir, &args);
 		wh_lower_dentry = args.ret;
@@ -250,8 +250,9 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 				first_lower_mnt =
 					unionfs_mntget(parent_dentry, bindex);
 				first_dentry_offset = bindex;
-			} else
+			} else {
 				dput(lower_dentry);
+			}
 
 			continue;
 		}
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 25ac851..2fe6aaa 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -149,9 +149,9 @@ skip:
 		break;
 	case INTERPOSE_LOOKUP:
 		spliced = d_splice_alias(inode, dentry);
-		if (IS_ERR(spliced))
+		if (IS_ERR(spliced)) {
 			err = PTR_ERR(spliced);
-		else if (spliced && spliced != dentry) {
+		} else if (spliced && spliced != dentry) {
 			/*
 			 * d_splice can return a dentry if it was
 			 * disconnected and had to be moved.  We must ensure
diff --git a/fs/unionfs/rdstate.c b/fs/unionfs/rdstate.c
index 46cf2df..e96b6bc 100644
--- a/fs/unionfs/rdstate.c
+++ b/fs/unionfs/rdstate.c
@@ -260,9 +260,9 @@ int add_filldir_node(struct unionfs_dir_state *rdstate, const char *name,
 	new->bindex = bindex;
 	new->whiteout = whiteout;
 
-	if (namelen < DNAME_INLINE_LEN_MIN)
+	if (namelen < DNAME_INLINE_LEN_MIN) {
 		new->name = new->iname;
-	else {
+	} else {
 		new->name = kmalloc(namelen + 1, GFP_KERNEL);
 		if (unlikely(!new->name)) {
 			kmem_cache_free(unionfs_filldir_cachep, new);
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 81121f0..e6a2a3c 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -83,8 +83,9 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		unlock_dir(lower_wh_dir_dentry);
 		if (err)
 			goto out;
-	} else
+	} else {
 		dput(lower_wh_dentry);
+	}
 
 	dget(lower_old_dentry);
 	lower_old_dir_dentry = dget_parent(lower_old_dentry);
@@ -178,8 +179,9 @@ static int do_unionfs_rename(struct inode *old_dir,
 		if (!IS_COPYUP_ERR(err))
 			goto out;
 		do_copyup = old_bstart - 1;
-	} else
+	} else {
 		revert = 1;
+	}
 
 	/*
 	 * Unlink all instances of destination that exist to the left of
@@ -271,9 +273,9 @@ static int do_unionfs_rename(struct inode *old_dir,
 		local_err = vfs_create(lower_parent->d_inode, wh_old, S_IRUGO,
 				       &nd);
 		unlock_dir(lower_parent);
-		if (!local_err)
+		if (!local_err) {
 			set_dbopaque(old_dentry, bwh_old);
-		else {
+		} else {
 			/*
 			 * we can't fix anything now, so we cop-out and use
 			 * -EIO.
@@ -392,8 +394,9 @@ static int may_rename_dir(struct dentry *dentry)
 	if (err == -ENOTEMPTY) {
 		if (is_robranch(dentry))
 			return -EXDEV;
-	} else if (err)
+	} else if (err) {
 		return err;
+	}
 
 	bstart = dbstart(dentry);
 	if (dbend(dentry) == bstart || dbopaque(dentry) == bstart)
@@ -443,9 +446,9 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 * simply override it even if the whited-out dir is not empty.
 	 */
 	wh_dentry = lookup_whiteout(new_dentry);
-	if (!IS_ERR(wh_dentry))
+	if (!IS_ERR(wh_dentry)) {
 		dput(wh_dentry);
-	else if (new_dentry->d_inode) {
+	} else if (new_dentry->d_inode) {
 		if (S_ISDIR(old_dentry->d_inode->i_mode) !=
 		    S_ISDIR(new_dentry->d_inode->i_mode)) {
 			err = S_ISDIR(old_dentry->d_inode->i_mode) ?
@@ -473,10 +476,10 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	}
 	err = do_unionfs_rename(old_dir, old_dentry, new_dir, new_dentry);
 out:
-	if (err)
+	if (err) {
 		/* clear the new_dentry stuff created */
 		d_drop(new_dentry);
-	else {
+	} else {
 		/*
 		 * force re-lookup since the dir on ro branch is not renamed,
 		 * and lower dentries still indicate the un-renamed ones.
diff --git a/fs/unionfs/unlink.c b/fs/unionfs/unlink.c
index c5f6ed5..61a6fe1 100644
--- a/fs/unionfs/unlink.c
+++ b/fs/unionfs/unlink.c
@@ -55,11 +55,12 @@ static int unionfs_unlink_whiteout(struct inode *dir, struct dentry *dentry)
 		if (dbstart(dentry) == 0)
 			goto out;
 		err = create_whiteout(dentry, dbstart(dentry) - 1);
-	} else if (dbopaque(dentry) != -1)
+	} else if (dbopaque(dentry) != -1) {
 		/* There is a lower lower-priority file with the same name. */
 		err = create_whiteout(dentry, dbopaque(dentry));
-	else
+	} else {
 		err = create_whiteout(dentry, dbstart(dentry));
+	}
 
 out:
 	if (!err)
@@ -161,9 +162,9 @@ int unionfs_rmdir(struct inode *dir, struct dentry *dentry)
 
 	err = unionfs_rmdir_first(dir, dentry, namelist);
 	/* create whiteout */
-	if (!err)
+	if (!err) {
 		err = create_whiteout(dentry, dbstart(dentry));
-	else {
+	} else {
 		int new_err;
 
 		if (dbstart(dentry) == 0)
-- 
1.5.2.2


  parent reply	other threads:[~2007-10-01  5:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-01  5:50 [GIT PULL -mm] 00/19 Unionfs updates/cleanups/fixes Erez Zadok
2007-10-01  5:50 ` [PATCH 01/19] Unionfs: compile if debug is off Erez Zadok
2007-10-01  5:50 ` [PATCH 02/19] Unionfs: add un/likely on conditionals Erez Zadok
2007-10-01  5:50 ` [PATCH 03/19] Unionfs: minor comment cleanups Erez Zadok
2007-10-01  5:50 ` [PATCH 04/19] Unionfs: use consistent printk prefixes Erez Zadok
2007-10-01  5:50 ` [PATCH 05/19] Unionfs: use UNIONFS_NAME macro Erez Zadok
2007-10-01  5:50 ` [PATCH 06/19] Unionfs: properly indent static struct Erez Zadok
2007-10-01  5:50 ` [PATCH 07/19] Unionfs: remove unnecessary if condition Erez Zadok
2007-10-01  5:50 ` [PATCH 08/19] Unionfs: use page_offset() helper Erez Zadok
2007-10-01  5:50 ` [PATCH 09/19] Unionfs: use pr_debug() instead of custom dprintk() Erez Zadok
2007-10-01  5:50 ` [PATCH 10/19] Unionfs: convert all appropriate printk's to pr_debug calls Erez Zadok
2007-10-01  5:50 ` [PATCH 11/19] Unionfs: add missing newlines in printk's Erez Zadok
2007-10-01  5:50 ` [PATCH 12/19] Unionfs: update/assign a KERN_* level to all printk statements Erez Zadok
2007-10-01  5:50 ` [PATCH 13/19] Unionfs: remove periods from the end of printk strings Erez Zadok
2007-10-01  5:50 ` Erez Zadok [this message]
2007-10-01  5:50 ` [PATCH 15/19] Unionfs: coding style: proper spacing Erez Zadok
2007-10-01  5:50 ` [PATCH 16/19] Unionfs: coding style: take assignments out of "if" conditions Erez Zadok
2007-10-01  5:50 ` [PATCH 17/19] Unionfs: coding style: avoid multiple assignments on same line Erez Zadok
2007-10-01  5:50 ` [PATCH 18/19] Unionfs: coding style: miscellaneous fixes Erez Zadok
2007-10-01  5:50 ` [PATCH 19/19] Unionfs: coding style: avoid lines longer than 80 chars Erez Zadok

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=11912178623778-git-send-email-ezk@cs.sunysb.edu \
    --to=ezk@cs.sunysb.edu \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.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).