All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>
Subject: [PATCH 02/13] switch_root: simplify code and reduce indentation [oclint]
Date: Sun, 17 Jul 2016 14:00:04 +0100	[thread overview]
Message-ID: <20160717130015.31760-3-kerolasa@iki.fi> (raw)
In-Reply-To: <20160717130015.31760-1-kerolasa@iki.fi>

The if statement in line 162 already ensures value of cfd to be 0 or
greater, so the later if is not needed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/switch_root.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index dc55a6d..6f5468f 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -176,22 +176,21 @@ static int switchroot(const char *newroot)
 		return -1;
 	}
 
-	if (cfd >= 0) {
-		pid = fork();
-		if (pid <= 0) {
-			struct statfs stfs;
-			if (fstatfs(cfd, &stfs) == 0 &&
-			    (F_TYPE_EQUAL(stfs.f_type, STATFS_RAMFS_MAGIC) ||
-			     F_TYPE_EQUAL(stfs.f_type, STATFS_TMPFS_MAGIC)))
-				recursiveRemove(cfd);
-			else
-				warn(_("old root filesystem is not an initramfs"));
-
-			if (pid == 0)
-				exit(EXIT_SUCCESS);
-		}
-		close(cfd);
+	pid = fork();
+	if (pid <= 0) {
+		struct statfs stfs;
+
+		if (fstatfs(cfd, &stfs) == 0 &&
+		    (F_TYPE_EQUAL(stfs.f_type, STATFS_RAMFS_MAGIC) ||
+		     F_TYPE_EQUAL(stfs.f_type, STATFS_TMPFS_MAGIC)))
+			recursiveRemove(cfd);
+		else
+			warn(_("old root filesystem is not an initramfs"));
+		if (pid == 0)
+			exit(EXIT_SUCCESS);
 	}
+
+	close(cfd);
 	return 0;
 }
 
-- 
2.9.0


  parent reply	other threads:[~2016-07-17 13:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17 13:00 [PATCH 00/13] pull: OCLint static code analysis changes Sami Kerola
2016-07-17 13:00 ` [PATCH 01/13] misc: simplify if clauses [oclint] Sami Kerola
2016-07-17 13:00 ` Sami Kerola [this message]
2016-07-17 13:00 ` [PATCH 03/13] libfdisk: collapse indentation [oclint] Sami Kerola
2016-07-19  8:48   ` Karel Zak
2016-07-21 20:20     ` Sami Kerola
2016-07-17 13:00 ` [PATCH 04/13] lslogins: simplify if clause and move definition and comments [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 05/13] libblkid: simplify if clause [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 06/13] logger: " Sami Kerola
2016-07-17 13:00 ` [PATCH 07/13] syspriv: flip inverted logic [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 08/13] libmount, look: remove dead code [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 09/13] dmesg: drop core at impossible case in read_buffer() [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 10/13] misc: fix declarations shadowing variables in the global scope [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 11/13] setterm: " Sami Kerola
2016-07-17 13:00 ` [PATCH 12/13] agetty: move unreachable code to pre-processor #else segment [oclint] Sami Kerola
2016-07-17 13:00 ` [PATCH 13/13] libblkid: fix debugging macro [oclint] Sami Kerola
2016-08-02 13:44 ` [PATCH 00/13] pull: OCLint static code analysis changes Karel Zak

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=20160717130015.31760-3-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.