* 'clang' of https://github.com/neheb/util-linux:
  [clang-tidy] fix misleading identation
  [clang-tidy] use ceil
  [clang-tidy] fix wrong *cmp usage
  [clang-tidy] do not use else after return
  [clang-tidy] do not return in void functions
  [clang-tidy] fix mismatching declarations
pull/1016/head
Karel Zak 2020-04-22 10:07:51 +02:00
commit 69fe4f4ba6
101 changed files with 440 additions and 402 deletions

View File

@ -986,7 +986,9 @@ static size_t menuitem_get_line(struct cfdisk *cf, size_t idx)
if (!m->page_sz) /* small menu */
return (ui_lines - (cf->menu->nitems + 1)) / 2 + idx;
return (idx % m->page_sz) + 1;
} else {
}
{
size_t len = MENU_H_ITEMWIDTH(m) + MENU_H_BETWEEN; /** item width */
size_t items = ui_cols / len; /* items per line */
@ -1003,7 +1005,9 @@ static int menuitem_get_column(struct cfdisk *cf, size_t idx)
if ((size_t) ui_cols <= nc)
return 0;
return (ui_cols - nc) / 2;
} else {
}
{
size_t len = MENU_H_ITEMWIDTH(cf->menu) + MENU_H_BETWEEN; /* item width */
size_t items = ui_cols / len; /* items per line */
size_t extra = items < cf->menu->nitems ? /* extra space on line */
@ -1877,7 +1881,7 @@ static int ui_get_size(struct cfdisk *cf, /* context */
if (rc == 0) {
ui_warnx(_("Please, specify size."));
continue; /* nothing specified */
} else if (rc == -CFDISK_ERR_ESC)
} if (rc == -CFDISK_ERR_ESC)
break; /* cancel dialog */
if (strcmp(buf, dflt) == 0)

View File

@ -201,9 +201,10 @@ void list_disklabel(struct fdisk_context *cxt)
if (fdisk_partition_has_wipe(cxt, pa)) {
if (!post)
fdisk_info(cxt, ""); /* line break */
fdisk_info(cxt, _("Filesystem/RAID signature on partition %zu will be wiped."),
fdisk_partition_get_partno(pa) + 1);
post++;
fdisk_info(cxt, _("Filesystem/RAID signature on partition %zu will be wiped."),
fdisk_partition_get_partno(pa) + 1);
post++;
}
}

View File

@ -172,8 +172,8 @@ static int string_to_int(const char *s)
l = strtol(s, &p, 0);
if (*p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
return -1;
else
return (int) l;
return (int) l;
}
/* Do we really really want to check this fs? */
@ -398,7 +398,6 @@ done:
inst->lockpath = NULL;
}
free(diskpath);
return;
}
static void unlock_disk(struct fsck_instance *inst)
@ -425,7 +424,6 @@ static void free_instance(struct fsck_instance *i)
free(i->lockpath);
mnt_unref_fs(i->fs);
free(i);
return;
}
static struct libmnt_fs *add_dummy_fs(const char *device)
@ -821,10 +819,10 @@ static struct fsck_instance *wait_one(int flags)
for (inst2 = instance_list; inst2; inst2 = inst2->next) {
if (inst2->flags & FLAG_DONE)
continue;
if (strcmp(inst2->type, "ext2") &&
if (strcmp(inst2->type, "ext2") != 0 &&
strcmp(inst2->type, "ext3") &&
strcmp(inst2->type, "ext4") &&
strcmp(inst2->type, "ext4dev"))
strcmp(inst2->type, "ext4") != 0 &&
strcmp(inst2->type, "ext4dev") != 0)
continue;
/*
* If we've just started the fsck, wait a tiny
@ -905,8 +903,8 @@ static int fsck_device(struct libmnt_fs *fs, int interactive)
if (type && strcmp(type, "auto") != 0)
;
else if (fstype && strncmp(fstype, "no", 2) &&
strncmp(fstype, "opts=", 5) && strncmp(fstype, "loop", 4) &&
else if (fstype && strncmp(fstype, "no", 2) != 0 &&
strncmp(fstype, "opts=", 5) != 0 && strncmp(fstype, "loop", 4) != 0 &&
!strchr(fstype, ','))
type = fstype;
else

View File

@ -131,12 +131,15 @@ static int get_superblock_endianness(uint32_t magic)
if (magic == CRAMFS_MAGIC) {
cramfs_is_big_endian = HOST_IS_BIG_ENDIAN;
return 0;
} else if (magic ==
}
if (magic ==
u32_toggle_endianness(!HOST_IS_BIG_ENDIAN, CRAMFS_MAGIC)) {
cramfs_is_big_endian = !HOST_IS_BIG_ENDIAN;
return 0;
} else
return -1;
}
return -1;
}
static void test_super(int *start, size_t * length)

View File

@ -293,7 +293,6 @@ check_mount(void) {
printf(_("check aborted.\n"));
exit(FSCK_EX_OK);
}
return;
}
@ -301,7 +300,7 @@ static int is_valid_zone_nr(unsigned short nr)
{
if (nr < get_first_zone())
return 0;
else if (nr >= get_nzones())
if (nr >= get_nzones())
return 0;
return 1;
}
@ -511,7 +510,6 @@ write_super_block(void) {
die(_("seek failed in write_super_block"));
if (MINIX_BLOCK_SIZE != write(device_fd, super_block_buffer, MINIX_BLOCK_SIZE))
die(_("unable to write super-block"));
return;
}
static void
@ -978,7 +976,7 @@ check_file(struct minix_inode *dir, unsigned int offset) {
inode = get_inode(ino);
name_depth--;
if (!offset) {
if (!inode || strcmp(".", name)) {
if (!inode || strcmp(".", name) != 0) {
get_current_name();
printf(_("%s: bad directory: '.' isn't first\n"),
current_name);
@ -987,7 +985,7 @@ check_file(struct minix_inode *dir, unsigned int offset) {
return;
}
if (offset == dirsize) {
if (!inode || strcmp("..", name)) {
if (!inode || strcmp("..", name) != 0) {
get_current_name();
printf(_("%s: bad directory: '..' isn't second\n"),
current_name);
@ -1017,7 +1015,6 @@ check_file(struct minix_inode *dir, unsigned int offset) {
if (inode && S_ISDIR(inode->i_mode))
recursive_check(ino);
name_depth--;
return;
}
static void
@ -1052,7 +1049,7 @@ check_file2(struct minix2_inode *dir, unsigned int offset) {
inode = get_inode2(ino);
name_depth--;
if (!offset) {
if (!inode || strcmp(".", name)) {
if (!inode || strcmp(".", name) != 0) {
get_current_name();
printf(_("%s: bad directory: '.' isn't first\n"),
current_name);
@ -1061,7 +1058,7 @@ check_file2(struct minix2_inode *dir, unsigned int offset) {
return;
}
if (offset == dirsize) {
if (!inode || strcmp("..", name)) {
if (!inode || strcmp("..", name) != 0) {
get_current_name();
printf(_("%s: bad directory: '..' isn't second\n"),
current_name);
@ -1087,7 +1084,6 @@ check_file2(struct minix2_inode *dir, unsigned int offset) {
if (inode && S_ISDIR(inode->i_mode))
recursive_check2(ino);
name_depth--;
return;
}
static void
@ -1359,7 +1355,9 @@ main(int argc, char **argv) {
if (repair)
printf(_("%s is clean, no check.\n"), device_name);
return retcode;
} else if (force)
}
if (force)
printf(_("Forcing filesystem check on %s.\n"), device_name);
else if (repair)
printf(_("Filesystem on %s is dirty, needs checking.\n"),

View File

@ -547,9 +547,9 @@ static int is_zero(unsigned char const *begin, unsigned len)
(len-- == 0 ||
(begin[3] == '\0' &&
memcmp(begin, begin + 4, len) == 0))))))));
else
/* Never create holes. */
return 0;
/* Never create holes. */
return 0;
}
/*

View File

@ -245,7 +245,7 @@ static int get_max_partno(const char *disk, dev_t devno)
if (d->d_type != DT_DIR && d->d_type != DT_UNKNOWN)
continue;
#endif
if (strncmp(parent, d->d_name, strlen(parent)))
if (strncmp(parent, d->d_name, strlen(parent)) != 0)
continue;
snprintf(path, sizeof(path), "%s/partition", d->d_name);
@ -332,7 +332,9 @@ static int del_parts(int fd, const char *device, dev_t devno,
if (verbose)
printf(_("%s: partition #%d removed\n"), device, i);
continue;
} else if (errno == ENXIO) {
}
if (errno == ENXIO) {
if (verbose)
printf(_("%s: partition #%d doesn't exist\n"), device, i);
continue;

View File

@ -1869,14 +1869,18 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
buf[sizeof(buf) - 1] = '\0';
fdisk_warnx(sf->cxt, _("Unknown script header '%s' -- ignore."), buf);
continue;
} else if (rc < 0) {
}
if (rc < 0) {
DBG(PARSE, ul_debug("script parsing failed, trying sfdisk specific commands"));
buf[sizeof(buf) - 1] = '\0';
rc = loop_control_commands(sf, dp, buf);
if (rc)
break;
continue;
} else if (rc == 1) {
}
if (rc == 1) {
rc = SFDISK_DONE_EOF;
if (!sf->quiet)
fputs(_("Done.\n"), stdout);
@ -1910,7 +1914,9 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
rc = fdisk_set_partition(sf->cxt, partno, pa);
rc = rc == 0 ? SFDISK_DONE_ASK : SFDISK_DONE_ABORT;
break;
} else if (!rc) { /* add partition */
}
if (!rc) { /* add partition */
if (!sf->interactive && !sf->quiet &&
(!sf->prompt || startswith(sf->prompt, SFDISK_PROMPT))) {
refresh_prompt_buffer(sf, devname, next_partno, created);

View File

@ -11,9 +11,9 @@ struct UL_MD5Context {
unsigned char in[64];
};
void ul_MD5Init(struct UL_MD5Context *context);
void ul_MD5Update(struct UL_MD5Context *context, unsigned char const *buf, unsigned len);
void ul_MD5Final(unsigned char digest[UL_MD5LENGTH], struct UL_MD5Context *context);
void ul_MD5Init(struct UL_MD5Context *ctx);
void ul_MD5Update(struct UL_MD5Context *ctx, unsigned char const *buf, unsigned len);
void ul_MD5Final(unsigned char digest[UL_MD5LENGTH], struct UL_MD5Context *ctx);
void ul_MD5Transform(uint32_t buf[4], uint32_t const in[16]);
/*

View File

@ -281,8 +281,8 @@ int blkdev_is_cdrom(int fd)
if ((ret = ioctl(fd, CDROM_GET_CAPABILITY, NULL)) < 0)
return 0;
else
return ret;
return ret;
}
#else
int blkdev_is_cdrom(int fd __attribute__((__unused__)))

View File

@ -48,7 +48,9 @@ size_t ul_encode_to_utf8(int enc, unsigned char *dest, size_t len,
if (c == 0) {
dest[j] = '\0';
break;
} else if (c < 0x80) {
}
if (c < 0x80) {
if (j+1 >= len)
break;
dest[j++] = (uint8_t) c;

View File

@ -93,7 +93,6 @@ static void add_id(struct idcache *ic, char *name, unsigned long int id)
if (w <= 0)
w = ent->name ? strlen(ent->name) : 0;
ic->width = ic->width < w ? w : ic->width;
return;
}
void add_uid(struct idcache *cache, unsigned long int id)

View File

@ -272,7 +272,7 @@ static int is_swap_device(const char *file)
/* Skip the first line */
if (!fgets(buf, sizeof(buf), f))
goto leave;
if (*buf && strncmp(buf, "Filename\t", 9))
if (*buf && strncmp(buf, "Filename\t", 9) != 0)
/* Linux <=2.6.19 contained a bug in the /proc/swaps
* code where the header would not be displayed
*/

View File

@ -1074,8 +1074,8 @@ found:
uint64_t sz = 0;
return loopcxt_get_sizelimit(lc, &sz) == 0 && sz == sizelimit;
} else
return rc;
}
return rc;
}
return 1;
}
@ -1806,7 +1806,7 @@ int loopdev_count_by_backing_file(const char *filename, char **loopdev)
while(loopcxt_next(&lc) == 0) {
char *backing = loopcxt_get_backing_file(&lc);
if (!backing || strcmp(backing, filename)) {
if (!backing || strcmp(backing, filename) != 0) {
free(backing);
continue;
}

View File

@ -177,7 +177,6 @@ void random_get_bytes(void *buf, size_t nbytes)
sizeof(ul_jrand_seed)-sizeof(unsigned short));
}
#endif
return;
}

View File

@ -255,7 +255,9 @@ int parse_switch(const char *arg, const char *errmesg, ...)
if (strcmp(arg, a) == 0) {
va_end(ap);
return 1;
} else if (strcmp(arg, b) == 0) {
}
if (strcmp(arg, b) == 0) {
va_end(ap);
return 0;
}
@ -1110,19 +1112,16 @@ int main(int argc, char *argv[])
if (argc == 3 && strcmp(argv[1], "--size") == 0)
return test_strutils_sizes(argc - 1, argv + 1);
else if (argc == 4 && strcmp(argv[1], "--cmp-paths") == 0)
if (argc == 4 && strcmp(argv[1], "--cmp-paths") == 0)
return test_strutils_cmp_paths(argc - 1, argv + 1);
else if (argc == 4 && strcmp(argv[1], "--strdup-member") == 0)
if (argc == 4 && strcmp(argv[1], "--strdup-member") == 0)
return test_strdup_to_member(argc - 1, argv + 1);
else {
fprintf(stderr, "usage: %1$s --size <number>[suffix]\n"
" %1$s --cmp-paths <path> <path>\n"
" %1$s --strdup-member <str> <str>\n",
argv[0]);
exit(EXIT_FAILURE);
}
fprintf(stderr, "usage: %1$s --size <number>[suffix]\n"
" %1$s --cmp-paths <path> <path>\n"
" %1$s --strdup-member <str> <str>\n",
argv[0]);
return EXIT_FAILURE;
}

View File

@ -37,7 +37,7 @@ blkid_probe get_swap_prober(const char *devname)
/* Only the SWAPSPACE2 is supported. */
if (blkid_probe_lookup_value(pr, "VERSION", &version, NULL) == 0
&& version
&& strcmp(version, stringify_value(SWAP_VERSION)))
&& strcmp(version, stringify_value(SWAP_VERSION)) != 0)
warnx(_("%s: unsupported swap version '%s'"),
devname, version);
else

View File

@ -869,7 +869,7 @@ dev_t __sysfs_devname_to_devno(const char *prefix, const char *name, const char
goto done;
sysfs_devname_dev_to_sys(_name);
if (parent && strncmp("dm-", name, 3)) {
if (parent && strncmp("dm-", name, 3) != 0) {
/*
* Create path to /sys/block/<parent>/<name>/dev
*/

View File

@ -355,7 +355,7 @@ int parse_timestamp(const char *t, usec_t *usec)
int get_gmtoff(const struct tm *tp)
{
if (tp->tm_isdst < 0)
return 0;
return 0;
#if HAVE_TM_GMTOFF
return tp->tm_gmtoff;

View File

@ -73,9 +73,9 @@ int get_terminal_stdfd(void)
{
if (isatty(STDIN_FILENO))
return STDIN_FILENO;
else if (isatty(STDOUT_FILENO))
if (isatty(STDOUT_FILENO))
return STDOUT_FILENO;
else if (isatty(STDERR_FILENO))
if (isatty(STDERR_FILENO))
return STDERR_FILENO;
return -EINVAL;

View File

@ -350,7 +350,7 @@ struct dir_list {
};
extern void blkid__scan_dir(char *, dev_t, struct dir_list **, char **)
__attribute__((nonnull(1,4)));
extern int blkid_driver_has_major(const char *drvname, int major)
extern int blkid_driver_has_major(const char *drvname, int drvmaj)
__attribute__((warn_unused_result));
/* lseek.c */

View File

@ -58,7 +58,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
/* search by name */
list_for_each(p, &cache->bic_devs) {
tmp = list_entry(p, struct blkid_struct_dev, bid_devs);
if (strcmp(tmp->bid_name, devname))
if (strcmp(tmp->bid_name, devname) != 0)
continue;
dev = tmp;
break;
@ -70,7 +70,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
DBG(DEVNAME, ul_debug("search canonical %s", cn));
list_for_each(p, &cache->bic_devs) {
tmp = list_entry(p, struct blkid_struct_dev, bid_devs);
if (strcmp(tmp->bid_name, cn))
if (strcmp(tmp->bid_name, cn) != 0)
continue;
dev = tmp;
@ -120,13 +120,13 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
if (dev2->bid_flags & BLKID_BID_FL_VERIFIED)
continue;
if (!dev->bid_type || !dev2->bid_type ||
strcmp(dev->bid_type, dev2->bid_type))
strcmp(dev->bid_type, dev2->bid_type) != 0)
continue;
if (dev->bid_label && dev2->bid_label &&
strcmp(dev->bid_label, dev2->bid_label))
strcmp(dev->bid_label, dev2->bid_label) != 0)
continue;
if (dev->bid_uuid && dev2->bid_uuid &&
strcmp(dev->bid_uuid, dev2->bid_uuid))
strcmp(dev->bid_uuid, dev2->bid_uuid) != 0)
continue;
if ((dev->bid_label && !dev2->bid_label) ||
(!dev->bid_label && dev2->bid_label) ||
@ -160,7 +160,7 @@ static int is_dm_leaf(const char *devname)
while ((de = readdir(dir)) != NULL) {
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..") ||
!strcmp(de->d_name, devname) ||
strncmp(de->d_name, "dm-", 3) ||
strncmp(de->d_name, "dm-", 3) != 0 ||
strlen(de->d_name) > sizeof(path)-32)
continue;
sprintf(path, "/sys/block/%s/slaves", de->d_name);
@ -267,7 +267,6 @@ set_pri:
if (removable)
dev->bid_flags |= BLKID_BID_FL_REMOVABLE;
}
return;
}
#define PROC_PARTITIONS "/proc/partitions"
@ -545,7 +544,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
* dev, and the device's base name has changed,
* check last as well.
*/
if (lens[last] && strncmp(ptnames[last], ptname, lens[last])) {
if (lens[last] && strncmp(ptnames[last], ptname, lens[last]) != 0) {
DBG(DEVNAME, ul_debug(" whole dev %s, devno 0x%04X",
ptnames[last], (unsigned int) devs[last]));
probe_one(cache, ptnames[last], devs[last], 0,

View File

@ -161,7 +161,6 @@ void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list,
add_to_dirlist(dirname, dp->d_name, list);
}
closedir(dir);
return;
}
/* Directories where we will try to search for device numbers */

View File

@ -164,7 +164,7 @@ static int parse_extended(blkid_probe pr, blkid_partlist ls,
if (!IS_ACTIVE(xrs->part[i+1]))
break;
if (memcmp(xrs->part[i+1].id, "XGM", 3))
if (memcmp(xrs->part[i+1].id, "XGM", 3) != 0)
return 0;
xstart = x0start + be32_to_cpu(xrs->part[i+1].start);

View File

@ -321,7 +321,7 @@ static int probe_gpt_pt(blkid_probe pr,
ret = is_pmbr_valid(pr, NULL);
if (ret < 0)
return ret;
else if (ret == 0)
if (ret == 0)
goto nothing;
errno = 0;

View File

@ -1245,7 +1245,9 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
return blkid_probe_step_back(pr);
} else if (dryrun) {
}
if (dryrun) {
/* wipe in memory only */
blkid_probe_hide_range(pr, magoff, len);
return blkid_probe_step_back(pr);
@ -1998,7 +2000,6 @@ void blkid_probe_set_wiper(blkid_probe pr, uint64_t off, uint64_t size)
chn->driver->name,
chn->driver->idinfos[chn->idx]->name,
pr->wipe_off, pr->wipe_size));
return;
}
/*

View File

@ -420,7 +420,6 @@ void blkid_read_cache(blkid_cache cache)
return;
errout:
close(fd);
return;
}
#ifdef TEST_PROGRAM

View File

@ -169,8 +169,7 @@ static unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_bloc
return get_custom_block_run(pr, bs,
&ds->direct[i],
start, length, fs_le);
else
start -= br_len;
start -= br_len;
}
} else if (start < (int64_t) FS64_TO_CPU(ds->max_indirect_range, fs_le)) {
struct block_run *br;
@ -192,8 +191,7 @@ static unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_bloc
if (start < br_len)
return get_custom_block_run(pr, bs, &br[i],
start, length, fs_le);
else
start -= br_len;
start -= br_len;
}
} else if (start < (int64_t) FS64_TO_CPU(ds->max_double_indirect_range, fs_le)) {
struct block_run *br;
@ -333,8 +331,8 @@ static int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs,
if ((int64_t) FS64_TO_CPU(bn->overflow_link, fs_le)
== BPLUSTREE_NULL)
return FS64_TO_CPU(values[last], fs_le);
else
node_pointer = FS64_TO_CPU(values[last], fs_le);
node_pointer = FS64_TO_CPU(values[last], fs_le);
} else if (cmp < 0)
node_pointer = FS64_TO_CPU(bn->overflow_link, fs_le);
else {
@ -352,9 +350,10 @@ static int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs,
fs_le) == BPLUSTREE_NULL)
return FS64_TO_CPU(values[mid],
fs_le);
else
break;
} else if (cmp < 0)
break;
}
if (cmp < 0)
first = mid + 1;
else
last = mid - 1;
@ -411,7 +410,9 @@ static int get_uuid(blkid_probe pr, const struct befs_super_block *bs,
sizeof(uint64_t));
break;
} else if (FS32_TO_CPU(sd->type, fs_le) == 0
}
if (FS32_TO_CPU(sd->type, fs_le) == 0
&& FS16_TO_CPU(sd->name_size, fs_le) == 0
&& FS16_TO_CPU(sd->data_size, fs_le) == 0)
break;
@ -437,7 +438,7 @@ static int get_uuid(blkid_probe pr, const struct befs_super_block *bs,
if (value < 0)
return value == -ENOENT ? BLKID_PROBE_NONE : value;
else if (value > 0) {
if (value > 0) {
bi = (struct befs_inode *) blkid_probe_get_buffer(pr,
value << FS32_TO_CPU(bs->block_shift, fs_le),
FS32_TO_CPU(bs->block_size, fs_le));

View File

@ -108,18 +108,18 @@ static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag __attribute_
if (!memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L)) {
/* LUKS primary header was found. */
return luks_attributes(pr, header, 0);
} else {
/* No primary header, scan for known offsets of LUKS2 secondary header. */
for (i = 0; i < ARRAY_SIZE(secondary_offsets); i++) {
header = (struct luks2_phdr *) blkid_probe_get_buffer(pr,
secondary_offsets[i], sizeof(struct luks2_phdr));
}
if (!header)
return errno ? -errno : BLKID_PROBE_NONE;
/* No primary header, scan for known offsets of LUKS2 secondary header. */
for (i = 0; i < ARRAY_SIZE(secondary_offsets); i++) {
header = (struct luks2_phdr *) blkid_probe_get_buffer(pr,
secondary_offsets[i], sizeof(struct luks2_phdr));
if (!memcmp(header->magic, LUKS_MAGIC_2, LUKS_MAGIC_L))
return luks_attributes(pr, header, secondary_offsets[i]);
}
if (!header)
return errno ? -errno : BLKID_PROBE_NONE;
if (!memcmp(header->magic, LUKS_MAGIC_2, LUKS_MAGIC_L))
return luks_attributes(pr, header, secondary_offsets[i]);
}
return BLKID_PROBE_NONE;

View File

@ -143,7 +143,8 @@ static int probe_minix(blkid_probe pr,
ext = blkid_probe_get_buffer(pr, 0x400 + 0x38, 2);
if (!ext)
return errno ? -errno : 1;
else if (memcmp(ext, "\123\357", 2) == 0)
if (memcmp(ext, "\123\357", 2) == 0)
return 1;
blkid_probe_sprintf_version(pr, "%d", version);

View File

@ -162,7 +162,7 @@ static int __probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag, int save_
if (!buf_mft)
return errno ? -errno : 1;
if (memcmp(buf_mft, "FILE", 4))
if (memcmp(buf_mft, "FILE", 4) != 0)
return 1;
off += MFT_RECORD_VOLUME * mft_record_size;
@ -171,7 +171,7 @@ static int __probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag, int save_
if (!buf_mft)
return errno ? -errno : 1;
if (memcmp(buf_mft, "FILE", 4))
if (memcmp(buf_mft, "FILE", 4) != 0)
return 1;
/* return if caller does not care about UUID and LABEL */

View File

@ -91,7 +91,9 @@ static int probe_swap(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_version(pr, "0");
return 0;
} else if (!memcmp(mag->magic, "SWAPSPACE2", mag->len))
}
if (!memcmp(mag->magic, "SWAPSPACE2", mag->len))
return swap_set_info(pr, "1");
return 1;

View File

@ -217,7 +217,7 @@ static int probe_udf(blkid_probe pr,
if (vsd_len == 2048) {
if (vsd_2048_valid == 0)
continue;
else if (vsd_2048_valid == 1)
if (vsd_2048_valid == 1)
goto anchor;
}

View File

@ -425,7 +425,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
}
}
if (boot_label && memcmp(boot_label, no_name, 11))
if (boot_label && memcmp(boot_label, no_name, 11) != 0)
blkid_probe_set_id_label(pr, "LABEL_FATBOOT", boot_label, 11);
if (vol_label)

View File

@ -73,7 +73,7 @@ int blkid_dev_has_tag(blkid_dev dev, const char *type,
tag = blkid_find_tag_dev(dev, type);
if (!value)
return (tag != NULL);
if (!tag || strcmp(tag->bit_val, value))
if (!tag || strcmp(tag->bit_val, value) != 0)
return 0;
return 1;
}

View File

@ -226,7 +226,8 @@ struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name)
if (!name)
return cxt->label;
else if (strcasecmp(name, "mbr") == 0)
if (strcasecmp(name, "mbr") == 0)
name = "dos";
for (i = 0; i < cxt->nlabels; i++)
@ -818,17 +819,16 @@ int fdisk_reread_partition_table(struct fdisk_context *cxt)
if (!S_ISBLK(cxt->dev_st.st_mode))
return 0;
else {
DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl"));
sync();
DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl"));
sync();
#ifdef BLKRRPART
fdisk_info(cxt, _("Calling ioctl() to re-read partition table."));
i = ioctl(cxt->dev_fd, BLKRRPART);
fdisk_info(cxt, _("Calling ioctl() to re-read partition table."));
i = ioctl(cxt->dev_fd, BLKRRPART);
#else
errno = ENOSYS;
i = 1;
errno = ENOSYS;
i = 1;
#endif
}
if (i) {
fdisk_warn(cxt, _("Re-reading the partition table failed."));

View File

@ -1715,7 +1715,9 @@ static int dos_add_partition(struct fdisk_context *cxt,
if (!ext_pe) {
fdisk_warnx(cxt, _("Extended partition does not exists. Failed to add logical partition."));
return -EINVAL;
} else if (fdisk_partition_has_start(pa)
}
if (fdisk_partition_has_start(pa)
&& pa->start < l->ext_offset
&& pa->start > get_abs_partition_end(ext_pe)) {
DBG(LABEL, ul_debug("DOS: pa template specifies partno>=4, but start out of extended"));
@ -1775,8 +1777,8 @@ static int dos_add_partition(struct fdisk_context *cxt,
if (pa && fdisk_partition_has_start(pa)) {
fdisk_warnx(cxt, msg);
return -EINVAL;
} else
fdisk_info(cxt, msg);
}
fdisk_info(cxt, msg);
}
rc = add_logical(cxt, pa, &res);
} else {

View File

@ -753,7 +753,9 @@ int fdisk_partition_next_partno(
}
return -ERANGE;
} else if (pa && fdisk_partition_has_partno(pa)) {
}
if (pa && fdisk_partition_has_partno(pa)) {
DBG(PART, ul_debugobj(pa, "next partno (specified=%zu)", pa->partno));
@ -763,7 +765,9 @@ int fdisk_partition_next_partno(
*n = pa->partno;
return 0;
} else if (fdisk_has_dialogs(cxt))
}
if (fdisk_has_dialogs(cxt))
return fdisk_ask_partnum(cxt, n, 1);
return -EINVAL;

View File

@ -396,20 +396,24 @@ static int sgi_check_bootfile(struct fdisk_context *cxt, const char *name)
"e.g. \"/unix\" or \"/unix.save\"."));
return -EINVAL;
} else if (sz > sizeof(sgilabel->boot_file)) {
}
if (sz > sizeof(sgilabel->boot_file)) {
fdisk_warnx(cxt, P_("Name of bootfile is too long: %zu byte maximum.",
"Name of bootfile is too long: %zu bytes maximum.",
sizeof(sgilabel->boot_file)),
sizeof(sgilabel->boot_file));
return -EINVAL;
} else if (*name != '/') {
}
if (*name != '/') {
fdisk_warnx(cxt, _("Bootfile must have a fully qualified pathname."));
return -EINVAL;
}
if (strncmp(name, (char *) sgilabel->boot_file,
sizeof(sgilabel->boot_file))) {
sizeof(sgilabel->boot_file)) != 0) {
fdisk_warnx(cxt, _("Be aware that the bootfile is not checked "
"for existence. SGI's default is \"/unix\", "
"and for backup \"/unix.save\"."));

View File

@ -34,12 +34,12 @@ static PyObject *Context_set_tables_errcb(ContextObjext *self, PyObject *func,
if (!PyCallable_Check(func))
return NULL;
else {
PyObject *tmp = self->table_errcb;
Py_INCREF(func);
self->table_errcb = func;
Py_XDECREF(tmp);
}
PyObject *tmp = self->table_errcb;
Py_INCREF(func);
self->table_errcb = func;
Py_XDECREF(tmp);
return UL_IncRef(self);
}
@ -570,7 +570,7 @@ static int Context_set_optsmode(ContextObjext *self, PyObject *value, void *clos
PyErr_SetString(PyExc_TypeError, NODEL_ATTR);
return -1;
}
else if (!PyLong_Check(value)) {
if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return -1;
}
@ -586,7 +586,7 @@ static int Context_set_syscall_status(ContextObjext *self, PyObject *value, void
PyErr_SetString(PyExc_TypeError, NODEL_ATTR);
return -1;
}
else if (!PyLong_Check(value)) {
if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return -1;
}
@ -602,7 +602,7 @@ static int Context_set_user_mflags(ContextObjext *self, PyObject *value, void *c
PyErr_SetString(PyExc_TypeError, NODEL_ATTR);
return -1;
}
else if (!PyLong_Check(value)) {
if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return -1;
}
@ -619,7 +619,7 @@ static int Context_set_mflags(ContextObjext *self, PyObject *value, void *closur
PyErr_SetString(PyExc_TypeError, NODEL_ATTR);
return -1;
}
else if (!PyLong_Check(value)) {
if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return -1;
}

View File

@ -370,7 +370,9 @@ static int Fs_set_freq(FsObject *self, PyObject *value,
PyErr_SetString(PyExc_TypeError, NODEL_ATTR);
return -1;
} else if (!PyLong_Check(value)) {
}
if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return -1;
}
@ -395,7 +397,9 @@ static int Fs_set_passno(FsObject *self, PyObject *value, void *closure __attrib
if (!value) {
PyErr_SetString(PyExc_TypeError, NODEL_ATTR);
return -1;
} else if (!PyLong_Check(value)) {
}
if (!PyLong_Check(value)) {
PyErr_SetString(PyExc_TypeError, ARG_ERR);
return -1;
}
@ -810,7 +814,9 @@ static PyObject *Fs_copy_fs(FsObject *self, PyObject *args, PyObject *kwds)
DBG(FS, pymnt_debug_h(dest, "copy data"));
return (PyObject *)dest;
} else if (dest == Py_None) { /* create new object */
}
if (dest == Py_None) { /* create new object */
FsObject *result = PyObject_New(FsObject, &FsType);
DBG(FS, pymnt_debug_h(result, "new copy"));

View File

@ -492,7 +492,9 @@ static PyObject *Table_next_fs(TableObject *self)
if (rc == 1) {
mnt_reset_iter(self->iter, MNT_ITER_FORWARD);
Py_RETURN_NONE;
} else if (rc)
}
if (rc)
return UL_RaiseExc(-rc);
return PyObjectResultFs(fs);

View File

@ -578,7 +578,8 @@ char *mnt_resolve_target(const char *path, struct libmnt_cache *cache)
p = (char *) cache_find_path(cache, path);
if (p)
return p;
else {
{
struct libmnt_iter itr;
struct libmnt_fs *fs = NULL;
@ -586,8 +587,8 @@ char *mnt_resolve_target(const char *path, struct libmnt_cache *cache)
while (mnt_table_next_fs(cache->mtab, &itr, &fs) == 0) {
if (!mnt_fs_is_kernel(fs)
|| mnt_fs_is_swaparea(fs)
|| !mnt_fs_streq_target(fs, path))
|| mnt_fs_is_swaparea(fs)
|| !mnt_fs_streq_target(fs, path))
continue;
p = strdup(path);

View File

@ -1808,7 +1808,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
* Source is PATH (canonicalize)
*/
path = mnt_resolve_path(src, cache);
if (path && strcmp(path, src))
if (path && strcmp(path, src) != 0)
rc = mnt_fs_set_source(cxt->fs, path);
}
@ -2864,7 +2864,9 @@ int mnt_context_is_fs_mounted(struct libmnt_context *cxt,
}
*mounted = 0;
return 0; /* /proc not mounted */
} else if (rc)
}
if (rc)
return rc;
*mounted = __mnt_table_is_fs_mounted(mtab, fs,

View File

@ -1733,12 +1733,16 @@ int mnt_context_get_mount_excode(
if (buf)
snprintf(buf, bufsz, _("filesystem was mounted, but failed to update userspace mount table"));
return MNT_EX_FILEIO;
} else if (rc == -MNT_ERR_NAMESPACE) {
}
if (rc == -MNT_ERR_NAMESPACE) {
if (buf)
snprintf(buf, bufsz, _("filesystem was mounted, but failed to switch namespace back"));
return MNT_EX_SYSERR;
} else if (rc < 0)
}
if (rc < 0)
return mnt_context_get_generic_excode(rc, buf, bufsz,
_("filesystem was mounted, but any subsequent operation failed: %m"));

View File

@ -388,7 +388,7 @@ static int is_associated_fs(const char *devname, struct libmnt_fs *fs)
int flags = 0;
/* check if it begins with /dev/loop */
if (strncmp(devname, _PATH_DEV_LOOP, sizeof(_PATH_DEV_LOOP) - 1))
if (strncmp(devname, _PATH_DEV_LOOP, sizeof(_PATH_DEV_LOOP) - 1) != 0)
return 0;
src = mnt_fs_get_srcpath(fs);
@ -1253,11 +1253,15 @@ int mnt_context_get_umount_excode(
if (buf)
snprintf(buf, bufsz, _("not mounted"));
return MNT_EX_USAGE;
} else if (rc == -MNT_ERR_LOCK) {
}