summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorSami Kerola2016-07-04 23:09:10 +0200
committerSami Kerola2016-07-21 22:14:33 +0200
commit74ce680a3ef90503b26da0a34f04cf725f6c5beb (patch)
tree307baa695e1c36c7a7855718468d9913ddf96bc1 /disk-utils
parentagetty: call uname() only when necessary (diff)
downloadkernel-qcow2-util-linux-74ce680a3ef90503b26da0a34f04cf725f6c5beb.tar.gz
kernel-qcow2-util-linux-74ce680a3ef90503b26da0a34f04cf725f6c5beb.tar.xz
kernel-qcow2-util-linux-74ce680a3ef90503b26da0a34f04cf725f6c5beb.zip
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/fsck.c31
-rw-r--r--disk-utils/fsck.cramfs.c11
-rw-r--r--disk-utils/fsck.minix.c7
-rw-r--r--disk-utils/mkfs.cramfs.c15
-rw-r--r--disk-utils/mkfs.minix.c8
5 files changed, 30 insertions, 42 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index eede03810..dd8952703 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -632,22 +632,21 @@ static int execute(const char *progname, const char *progpath,
for (i=0; i <num_args; i++)
argv[argc++] = xstrdup(args[i]);
- if (progress) {
- if ((strcmp(type, "ext2") == 0) ||
- (strcmp(type, "ext3") == 0) ||
- (strcmp(type, "ext4") == 0) ||
- (strcmp(type, "ext4dev") == 0)) {
- char tmp[80];
-
- tmp[0] = 0;
- if (!progress_active()) {
- snprintf(tmp, 80, "-C%d", progress_fd);
- inst->flags |= FLAG_PROGRESS;
- } else if (progress_fd)
- snprintf(tmp, 80, "-C%d", progress_fd * -1);
- if (tmp[0])
- argv[argc++] = xstrdup(tmp);
- }
+ if (progress &&
+ ((strcmp(type, "ext2") == 0) ||
+ (strcmp(type, "ext3") == 0) ||
+ (strcmp(type, "ext4") == 0) ||
+ (strcmp(type, "ext4dev") == 0))) {
+
+ char tmp[80];
+ tmp[0] = 0;
+ if (!progress_active()) {
+ snprintf(tmp, 80, "-C%d", progress_fd);
+ inst->flags |= FLAG_PROGRESS;
+ } else if (progress_fd)
+ snprintf(tmp, 80, "-C%d", progress_fd * -1);
+ if (tmp[0])
+ argv[argc++] = xstrdup(tmp);
}
argv[argc++] = xstrdup(fs_get_device(fs));
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index ef311c103..d904037d3 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -403,10 +403,8 @@ static void do_uncompress(char *path, int outfd, unsigned long offset,
size);
}
size -= out;
- if (*extract_dir != '\0')
- if (write(outfd, outbuffer, out) < 0)
- err(FSCK_EX_ERROR, _("write failed: %s"),
- path);
+ if (*extract_dir != '\0' && write(outfd, outbuffer, out) < 0)
+ err(FSCK_EX_ERROR, _("write failed: %s"), path);
curr = next;
} while (size);
}
@@ -629,9 +627,8 @@ static void test_fs(int start)
_("directory data end (%lu) != file data start (%lu)"),
end_dir, start_data);
}
- if (super.flags & CRAMFS_FLAG_FSID_VERSION_2)
- if (end_data > super.size)
- errx(FSCK_EX_UNCORRECTED, _("invalid file data offset"));
+ if (super.flags & CRAMFS_FLAG_FSID_VERSION_2 && end_data > super.size)
+ errx(FSCK_EX_UNCORRECTED, _("invalid file data offset"));
iput(root); /* free(root) */
}
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index 726f5daaf..97e558b76 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -1333,10 +1333,9 @@ main(int argc, char **argv) {
usage(stderr);
check_mount(); /* trying to check a mounted filesystem? */
- if (repair && !automatic) {
- if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
- die(_("need terminal for interactive repairs"));
- }
+ if (repair && !automatic && (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)))
+ die(_("need terminal for interactive repairs"));
+
device_fd = open(device_name, repair ? O_RDWR : O_RDONLY);
if (device_fd < 0)
die(_("cannot open %s: %s"), device_name, strerror(errno));
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 65ad356b0..bb1e4d04c 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -313,10 +313,9 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
if (dirent->d_name[0] == '.') {
if (dirent->d_name[1] == '\0')
continue;
- if (dirent->d_name[1] == '.') {
- if (dirent->d_name[2] == '\0')
- continue;
- }
+ if (dirent->d_name[1] == '.' &&
+ dirent->d_name[2] == '\0')
+ continue;
}
namelen = strlen(dirent->d_name);
if (namelen > MAX_INPUT_NAMELEN) {
@@ -352,11 +351,9 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
entry->size = parse_directory(root_entry, path, &entry->child, fslen_ub);
} else if (S_ISREG(st.st_mode)) {
entry->path = xstrdup(path);
- if (entry->size) {
- if (entry->size >= (1 << CRAMFS_SIZE_WIDTH)) {
- warn_size = 1;
- entry->size = (1 << CRAMFS_SIZE_WIDTH) - 1;
- }
+ if (entry->size && entry->size >= (1 << CRAMFS_SIZE_WIDTH)) {
+ warn_size = 1;
+ entry->size = (1 << CRAMFS_SIZE_WIDTH) - 1;
}
} else if (S_ISLNK(st.st_mode)) {
entry->path = xstrdup(path);
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index d4a576f83..0e26966e5 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -669,15 +669,11 @@ static int find_super_magic(const struct fs_control *ctl)
case 1:
if (ctl->fs_namelen == 14)
return MINIX_SUPER_MAGIC;
- else
- return MINIX_SUPER_MAGIC2;
- break;
+ return MINIX_SUPER_MAGIC2;
case 2:
if (ctl->fs_namelen == 14)
return MINIX2_SUPER_MAGIC;
- else
- return MINIX2_SUPER_MAGIC2;
- break;
+ return MINIX2_SUPER_MAGIC2;
case 3:
return MINIX3_SUPER_MAGIC;
default: