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>
This commit is contained in:
parent
74ce680a3e
commit
341154da28
|
@ -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"));
|
||||
pid = fork();
|
||||
if (pid <= 0) {
|
||||
struct statfs stfs;
|
||||
|
||||
if (pid == 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
close(cfd);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue