summaryrefslogtreecommitdiffstats
path: root/sys-utils/switch_root.c
diff options
context:
space:
mode:
authorSami Kerola2016-07-03 13:30:46 +0200
committerSami Kerola2016-07-21 22:14:33 +0200
commit341154da281916a0cc04ec0d4712296bc3e7e69a (patch)
tree29ddb3e30b39ebe7d04eac8c11925a9e78971b61 /sys-utils/switch_root.c
parentmisc: simplify if clauses [oclint] (diff)
downloadkernel-qcow2-util-linux-341154da281916a0cc04ec0d4712296bc3e7e69a.tar.gz
kernel-qcow2-util-linux-341154da281916a0cc04ec0d4712296bc3e7e69a.tar.xz
kernel-qcow2-util-linux-341154da281916a0cc04ec0d4712296bc3e7e69a.zip
switch_root: simplify code and reduce indentation [oclint]
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>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r--sys-utils/switch_root.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index dc55a6d08..6f5468fca 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;
}