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


Groups > linux.kernel > #1306417

[RESEND PATCH 2/3] vfs: show_mountinfo: cleanup error code checks

From "Dmitry V. Levin" <ldv@altlinux.org>
Newsgroups linux.kernel
Subject [RESEND PATCH 2/3] vfs: show_mountinfo: cleanup error code checks
Date 2016-01-11 16:40 +0100
Message-ID <qPMJA-4ee-3@gated-at.bofh.it> (permalink)
References <p5GXU-3Mt-7@gated-at.bofh.it> <qwfbs-6aN-13@gated-at.bofh.it> <qwfl8-6tM-15@gated-at.bofh.it> <qwiVI-ms-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Date: Wed Nov 18 21:08:33 2015 +0000

Check err variable right after each assignment.  This change makes
initialization of err redundant, so remove the initialization.

Suggested-by: Mateusz Guzik <mguzik@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 fs/proc_namespace.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index cbc9c27..7a6b2f3 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -131,16 +131,17 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
 	struct mount *r = real_mount(mnt);
 	struct super_block *sb = mnt->mnt_sb;
 	struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
-	int err = 0;
+	int err;
 
 	seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
 		   MAJOR(sb->s_dev), MINOR(sb->s_dev));
-	if (sb->s_op->show_path)
+	if (sb->s_op->show_path) {
 		err = sb->s_op->show_path(m, mnt->mnt_root);
-	else
+		if (err)
+			goto out;
+	} else {
 		seq_dentry(m, mnt->mnt_root, " \t\n\\");
-	if (err)
-		goto out;
+	}
 	seq_putc(m, ' ');
 
 	/* mountpoints outside of chroot jail will give SEQ_SKIP on this */
@@ -168,12 +169,13 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
 	seq_puts(m, " - ");
 	show_type(m, sb);
 	seq_putc(m, ' ');
-	if (sb->s_op->show_devname)
+	if (sb->s_op->show_devname) {
 		err = sb->s_op->show_devname(m, mnt->mnt_root);
-	else
+		if (err)
+			goto out;
+	} else {
 		mangle(m, r->mnt_devname ? r->mnt_devname : "none");
-	if (err)
-		goto out;
+	}
 	seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw");
 	err = show_sb_opts(m, sb);
 	if (err)

-- 
ldv

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RESEND PATCH 2/3] vfs: show_mountinfo: cleanup error code checks "Dmitry V. Levin" <ldv@altlinux.org> - 2016-01-11 16:40 +0100

csiph-web