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:
Sami Kerola 2016-07-03 12:30:46 +01:00
parent 74ce680a3e
commit 341154da28
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
1 changed files with 13 additions and 14 deletions

View File

@ -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;
}