[clang-tidy] do not use else after return
Found with readability-else-after-return Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
bd89499e07
commit
042f62dfc5
|
@ -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)
|
||||
|
|
|
@ -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? */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -300,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;
|
||||
}
|
||||
|
@ -1355,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"),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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__)))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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."));
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -396,14 +396,18 @@ 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"));
|
||||
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
||||
if (rc == -MNT_ERR_LOCK) {
|
||||
if (buf)
|
||||
snprintf(buf, bufsz, _("locking failed"));
|
||||
return MNT_EX_FILEIO;
|
||||
} else if (rc == -MNT_ERR_NAMESPACE) {
|
||||
}
|
||||
|
||||
if (rc == -MNT_ERR_NAMESPACE) {
|
||||
if (buf)
|
||||
snprintf(buf, bufsz, _("failed to switch namespace"));
|
||||
return MNT_EX_SYSERR;
|
||||
|
@ -1265,7 +1269,7 @@ int mnt_context_get_umount_excode(
|
|||
return mnt_context_get_generic_excode(rc, buf, bufsz,
|
||||
_("umount failed: %m"));
|
||||
|
||||
} else if (mnt_context_get_syscall_errno(cxt) == 0) {
|
||||
} if (mnt_context_get_syscall_errno(cxt) == 0) {
|
||||
/*
|
||||
* umount(2) syscall success, but something else failed
|
||||
* (probably error in mtab processing).
|
||||
|
@ -1274,12 +1278,16 @@ int mnt_context_get_umount_excode(
|
|||
if (buf)
|
||||
snprintf(buf, bufsz, _("filesystem was unmounted, 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 unmounted, 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 unmounted, but any subsequent operation failed: %m"));
|
||||
|
||||
|
|
|
@ -474,25 +474,25 @@ static int lock_mtab(struct libmnt_lock *ml)
|
|||
/* proceed, since it was us who created the lockfile anyway */
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
/* Someone else made the link. Wait. */
|
||||
int err = mnt_wait_mtab_lock(ml, &flock, maxtime.tv_sec);
|
||||
|
||||
if (err == 1) {
|
||||
DBG(LOCKS, ul_debugobj(ml,
|
||||
"%s: can't create link: time out (perhaps "
|
||||
"there is a stale lock file?)", lockfile));
|
||||
rc = -ETIMEDOUT;
|
||||
goto failed;
|
||||
|
||||
} else if (err < 0) {
|
||||
rc = err;
|
||||
goto failed;
|
||||
}
|
||||
nanosleep(&waittime, NULL);
|
||||
close(ml->lockfile_fd);
|
||||
ml->lockfile_fd = -1;
|
||||
}
|
||||
|
||||
/* Someone else made the link. Wait. */
|
||||
int err = mnt_wait_mtab_lock(ml, &flock, maxtime.tv_sec);
|
||||
|
||||
if (err == 1) {
|
||||
DBG(LOCKS, ul_debugobj(ml,
|
||||
"%s: can't create link: time out (perhaps "
|
||||
"there is a stale lock file?)", lockfile));
|
||||
rc = -ETIMEDOUT;
|
||||
goto failed;
|
||||
|
||||
} else if (err < 0) {
|
||||
rc = err;
|
||||
goto failed;
|
||||
}
|
||||
nanosleep(&waittime, NULL);
|
||||
close(ml->lockfile_fd);
|
||||
ml->lockfile_fd = -1;
|
||||
}
|
||||
DBG(LOCKS, ul_debugobj(ml, "%s: (%d) successfully locked",
|
||||
lockfile, getpid()));
|
||||
|
|
|
@ -263,7 +263,9 @@ static int userspace_add_watch(struct monitor_entry *me, int *final, int *fd)
|
|||
if (fd)
|
||||
*fd = wd;
|
||||
break;
|
||||
} else if (errno != ENOENT) {
|
||||
}
|
||||
|
||||
if (errno != ENOENT) {
|
||||
rc = -errno;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ const struct libmnt_optmap *mnt_get_builtin_optmap(int id)
|
|||
|
||||
if (id == MNT_LINUX_MAP)
|
||||
return linux_flags_map;
|
||||
else if (id == MNT_USERSPACE_MAP)
|
||||
if (id == MNT_USERSPACE_MAP)
|
||||
return userspace_opts_map;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -983,7 +983,7 @@ int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
|
|||
(*(value + 7) == ',' || !*(value + 7)))
|
||||
return set_uint_value(optstr, getuid(), value, end, next);
|
||||
|
||||
else if (!isdigit(*value)) {
|
||||
if (!isdigit(*value)) {
|
||||
uid_t id;
|
||||
int rc;
|
||||
char *p = strndup(value, valsz);
|
||||
|
@ -1031,7 +1031,7 @@ int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
|
|||
(*(value + 7) == ',' || !*(value + 7)))
|
||||
return set_uint_value(optstr, getgid(), value, end, next);
|
||||
|
||||
else if (!isdigit(*value)) {
|
||||
if (!isdigit(*value)) {
|
||||
int rc;
|
||||
gid_t id;
|
||||
char *p = strndup(value, valsz);
|
||||
|
|
|
@ -701,28 +701,32 @@ static int try_write(const char *filename, const char *directory)
|
|||
if (eaccess(filename, R_OK|W_OK) == 0) {
|
||||
DBG(UTILS, ul_debug(" access OK"));
|
||||
return 0;
|
||||
} else if (errno != ENOENT) {
|
||||
}
|
||||
|
||||
if (errno != ENOENT) {
|
||||
DBG(UTILS, ul_debug(" access FAILED"));
|
||||
return -errno;
|
||||
} else if (directory) {
|
||||
}
|
||||
|
||||
if (directory) {
|
||||
/* file does not exist; try if directory is writable */
|
||||
if (eaccess(directory, R_OK|W_OK) != 0)
|
||||
rc = -errno;
|
||||
|
||||
DBG(UTILS, ul_debug(" access %s [%s]", rc ? "FAILED" : "OK", directory));
|
||||
return rc;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
DBG(UTILS, ul_debug(" doing open-write test"));
|
||||
|
||||
int fd = open(filename, O_RDWR|O_CREAT|O_CLOEXEC,
|
||||
S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
|
||||
if (fd < 0)
|
||||
rc = -errno;
|
||||
else
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBG(UTILS, ul_debug(" doing open-write test"));
|
||||
|
||||
int fd = open(filename, O_RDWR|O_CREAT|O_CLOEXEC,
|
||||
S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
|
||||
if (fd < 0)
|
||||
rc = -errno;
|
||||
else
|
||||
close(fd);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1214,7 @@ static int read_procfs_file(int fd, char **buf, size_t *bufsiz)
|
|||
}
|
||||
break;
|
||||
|
||||
} else if (ret > 0) {
|
||||
} if (ret > 0) {
|
||||
/* success -- verify no event during read */
|
||||
struct pollfd fds[] = {
|
||||
{ .fd = fd, .events = POLLPRI }
|
||||
|
|
|
@ -60,7 +60,7 @@ static int count_cell_width(struct libscols_table *tb,
|
|||
if (cl->is_extreme && cl->width_avg && len > cl->width_avg * 2)
|
||||
return 0;
|
||||
|
||||
else if (scols_column_is_noextremes(cl)) {
|
||||
if (scols_column_is_noextremes(cl)) {
|
||||
cl->extreme_sum += len;
|
||||
cl->extreme_count++;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ int scols_cell_get_alignment(const struct libscols_cell *ce)
|
|||
{
|
||||
if (ce->flags & SCOLS_CELL_FL_RIGHT)
|
||||
return SCOLS_CELL_FL_RIGHT;
|
||||
else if (ce->flags & SCOLS_CELL_FL_CENTER)
|
||||
if (ce->flags & SCOLS_CELL_FL_CENTER)
|
||||
return SCOLS_CELL_FL_CENTER;
|
||||
|
||||
return SCOLS_CELL_FL_LEFT; /* default */
|
||||
|
|
|
@ -62,8 +62,7 @@ int uuid_parse_range(const char *in_start, const char *in_end, uuid_t uu)
|
|||
(i == 23)) {
|
||||
if (*cp == '-')
|
||||
continue;
|
||||
else
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
if (i== 36)
|
||||
if (*cp == 0)
|
||||
|
|
|
@ -68,13 +68,16 @@ const uuid_t *uuid_get_template(const char *alias)
|
|||
|
||||
if (!strcmp(alias, "dns"))
|
||||
return &NameSpace_DNS;
|
||||
else if (!strcmp(alias, "url"))
|
||||
|
||||
if (!strcmp(alias, "url"))
|
||||
return &NameSpace_URL;
|
||||
else if (!strcmp(alias, "oid"))
|
||||
|
||||
if (!strcmp(alias, "oid"))
|
||||
return &NameSpace_OID;
|
||||
else if (!strcmp(alias, "x500") || !strcmp(alias, "x.500"))
|
||||
|
||||
if (!strcmp(alias, "x500") || !strcmp(alias, "x.500"))
|
||||
return &NameSpace_X500;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,12 +56,11 @@ static int is_local_in_file(const char *user, const char *filename)
|
|||
* but it is just an optimisation
|
||||
* anyway. */
|
||||
break;
|
||||
} else {
|
||||
/* we read a whole username, but it
|
||||
* is the wrong user. Skip to the
|
||||
* next line. */
|
||||
skip = 1;
|
||||
}
|
||||
/* we read a whole username, but it
|
||||
* is the wrong user. Skip to the
|
||||
* next line. */
|
||||
skip = 1;
|
||||
} else if ('\n' == chin) {
|
||||
/* This line contains no colon; it's
|
||||
* malformed. No skip since we are already
|
||||
|
@ -96,17 +95,17 @@ int main(int argc, char *argv[])
|
|||
fprintf(stderr, _("Usage: %s <passwordfile> <username>...\n"),
|
||||
argv[0]);
|
||||
return 1;
|
||||
} else {
|
||||
int i;
|
||||
for (i = 2; i < argc; i++) {
|
||||
const int rv = is_local_in_file(argv[i], argv[1]);
|
||||
if (rv < 0) {
|
||||
perror(argv[1]);
|
||||
return 2;
|
||||
}
|
||||
printf("%d:%s\n", rv, argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 2; i < argc; i++) {
|
||||
const int rv = is_local_in_file(argv[i], argv[1]);
|
||||
if (rv < 0) {
|
||||
perror(argv[1]);
|
||||
return 2;
|
||||
}
|
||||
printf("%d:%s\n", rv, argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -391,8 +391,9 @@ int get_hushlogin_status(struct passwd *pwd, int force_check)
|
|||
rc = effective_access(buf, O_RDONLY);
|
||||
if (rc == 0)
|
||||
return 1;
|
||||
else if (rc == -1 && errno == EACCES)
|
||||
return -1;
|
||||
|
||||
if (rc == -1 && errno == EACCES)
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -222,15 +222,14 @@ static FILE *dump(FILE *in, const char *filename, int follow, FILE *out)
|
|||
#ifdef HAVE_INOTIFY_INIT
|
||||
if (follow_by_inotify(in, filename, out) == 0)
|
||||
return NULL; /* file already closed */
|
||||
else
|
||||
#endif
|
||||
/* fallback for systems without inotify or with non-free
|
||||
* inotify instances */
|
||||
for (;;) {
|
||||
while (fread(&ut, sizeof(ut), 1, in) == 1)
|
||||
print_utline(&ut, out);
|
||||
sleep(1);
|
||||
}
|
||||
/* fallback for systems without inotify or with non-free
|
||||
* inotify instances */
|
||||
for (;;) {
|
||||
while (fread(&ut, sizeof(ut), 1, in) == 1)
|
||||
print_utline(&ut, out);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
|
|
@ -618,8 +618,8 @@ static int leap_year(const struct cal_control *ctl, int32_t year)
|
|||
{
|
||||
if (year <= ctl->reform_year)
|
||||
return !(year % 4);
|
||||
else
|
||||
return ( !(year % 4) && (year % 100) ) || !(year % 400);
|
||||
|
||||
return ( !(year % 4) && (year % 100) ) || !(year % 400);
|
||||
}
|
||||
|
||||
static void init_monthnames(struct cal_control *ctl)
|
||||
|
|
|
@ -407,7 +407,7 @@ static int verify_fstype(struct verify_context *vfy)
|
|||
&& mnt_fs_get_option(vfy->fs, "move", NULL, NULL) == 1)
|
||||
return verify_warn(vfy, _("\"none\" FS type is recommended for bind or move oprations only"));
|
||||
|
||||
else if (strcmp(type, "auto") == 0)
|
||||
if (strcmp(type, "auto") == 0)
|
||||
isauto = 1;
|
||||
else if (strcmp(type, "swap") == 0)
|
||||
isswap = 1;
|
||||
|
|
|
@ -392,8 +392,8 @@ int main(int argc, char *argv[])
|
|||
*/
|
||||
printf(" --\n");
|
||||
return EXIT_SUCCESS;
|
||||
} else
|
||||
parse_error(_("missing optstring argument"));
|
||||
}
|
||||
parse_error(_("missing optstring argument"));
|
||||
}
|
||||
|
||||
add_longopt(&ctl, NULL, 0); /* init */
|
||||
|
|
|
@ -505,7 +505,7 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
if (ct && nerrs == 0)
|
||||
return EXIT_SUCCESS; /* full success */
|
||||
else if (ct == nerrs)
|
||||
if (ct == nerrs)
|
||||
return EXIT_FAILURE; /* all failed */
|
||||
|
||||
return KILL_EXIT_SOMEOK; /* partial success */
|
||||
|
|
|
@ -96,8 +96,8 @@ static int ask(char *name)
|
|||
buf[1] = '\0';
|
||||
if (rpmatch(buf) == RPMATCH_YES)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
|
||||
|
|
|
@ -428,8 +428,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
|
|||
if (ns < 0) {
|
||||
if ((errno == EAGAIN) || (errno == EINTR))
|
||||
continue;
|
||||
else
|
||||
err(EXIT_FAILURE, "accept");
|
||||
err(EXIT_FAILURE, "accept");
|
||||
}
|
||||
len = read(ns, &op, 1);
|
||||
if (len != 1) {
|
||||
|
|
|
@ -298,13 +298,12 @@ static char *find_device(const char *name)
|
|||
|
||||
if ((*name == '.' || *name == '/') && access(name, F_OK) == 0)
|
||||
return xstrdup(name);
|
||||
else {
|
||||
char buf[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "/dev/%s", name);
|
||||
if (access(buf, F_OK) == 0)
|
||||
return xstrdup(buf);
|
||||
}
|
||||
char buf[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "/dev/%s", name);
|
||||
if (access(buf, F_OK) == 0)
|
||||
return xstrdup(buf);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -258,48 +258,48 @@ static int synchronize_to_clock_tick_rtc(const struct hwclock_control *ctl)
|
|||
if (rtc_fd == -1) {
|
||||
warn(_("cannot open rtc device"));
|
||||
return ret;
|
||||
} else {
|
||||
/* Turn on update interrupts (one per second) */
|
||||
int rc = ioctl(rtc_fd, RTC_UIE_ON, 0);
|
||||
}
|
||||
|
||||
if (rc != -1) {
|
||||
/*
|
||||
* Just reading rtc_fd fails on broken hardware: no
|
||||
* update interrupt comes and a bootscript with a
|
||||
* hwclock call hangs
|
||||
*/
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
/* Turn on update interrupts (one per second) */
|
||||
int rc = ioctl(rtc_fd, RTC_UIE_ON, 0);
|
||||
|
||||
/*
|
||||
* Wait up to ten seconds for the next update
|
||||
* interrupt
|
||||
*/
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(rtc_fd, &rfds);
|
||||
tv.tv_sec = 10;
|
||||
tv.tv_usec = 0;
|
||||
rc = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
|
||||
if (0 < rc)
|
||||
ret = 0;
|
||||
else if (rc == 0) {
|
||||
warnx(_("select() to %s to wait for clock tick timed out"),
|
||||
rtc_dev_name);
|
||||
} else
|
||||
warn(_("select() to %s to wait for clock tick failed"),
|
||||
rtc_dev_name);
|
||||
/* Turn off update interrupts */
|
||||
rc = ioctl(rtc_fd, RTC_UIE_OFF, 0);
|
||||
if (rc == -1)
|
||||
warn(_("ioctl() to %s to turn off update interrupts failed"),
|
||||
rtc_dev_name);
|
||||
if (rc != -1) {
|
||||
/*
|
||||
* Just reading rtc_fd fails on broken hardware: no
|
||||
* update interrupt comes and a bootscript with a
|
||||
* hwclock call hangs
|
||||
*/
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
/*
|
||||
* Wait up to ten seconds for the next update
|
||||
* interrupt
|
||||
*/
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(rtc_fd, &rfds);
|
||||
tv.tv_sec = 10;
|
||||
tv.tv_usec = 0;
|
||||
rc = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
|
||||
if (0 < rc)
|
||||
ret = 0;
|
||||
else if (rc == 0) {
|
||||
warnx(_("select() to %s to wait for clock tick timed out"),
|
||||
rtc_dev_name);
|
||||
} else
|
||||
warn(_("select() to %s to wait for clock tick failed"),
|
||||
rtc_dev_name);
|
||||
/* Turn off update interrupts */
|
||||
rc = ioctl(rtc_fd, RTC_UIE_OFF, 0);
|
||||
if (rc == -1)
|
||||
warn(_("ioctl() to %s to turn off update interrupts failed"),
|
||||
rtc_dev_name);
|
||||
} else if (errno == ENOTTY || errno == EINVAL) {
|
||||
/* rtc ioctl interrupts are unimplemented */
|
||||
ret = busywait_for_rtc_clock_tick(ctl, rtc_fd);
|
||||
} else
|
||||
warn(_("ioctl(%d, RTC_UIE_ON, 0) to %s failed"),
|
||||
rtc_fd, rtc_dev_name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -876,7 +876,9 @@ static int save_adjtime(const struct hwclock_control *ctl,
|
|||
if (fp == NULL) {
|
||||
warn(_("cannot open %s"), ctl->adj_file_name);
|
||||
return EXIT_FAILURE;
|
||||
} else if (fputs(content, fp) < 0 || close_stream(fp) != 0) {
|
||||
}
|
||||
|
||||
if (fputs(content, fp) < 0 || close_stream(fp) != 0) {
|
||||
warn(_("cannot update %s"), ctl->adj_file_name);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -1053,7 +1055,9 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
|
|||
}
|
||||
if (ctl->show || ctl->get) {
|
||||
return display_time(startup_hclocktime);
|
||||
} else if (ctl->set) {
|
||||
}
|
||||
|
||||
if (ctl->set) {
|
||||
set_hardware_clock_exact(ctl, set_time, startup_time);
|
||||
if (!ctl->noadjfile)
|
||||
adjust_drift_factor(ctl, adjtime, t2tv(set_time),
|
||||
|
|
|
@ -145,8 +145,8 @@ int ipc_shm_get_info(int id, struct shm_data **shmds)
|
|||
if (id == p->shm_perm.id) {
|
||||
i = 1;
|
||||
break;
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
p->next = xcalloc(1, sizeof(struct shm_data));
|
||||
|
@ -284,8 +284,8 @@ int ipc_sem_get_info(int id, struct sem_data **semds)
|
|||
get_sem_elements(p);
|
||||
i = 1;
|
||||
break;
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
p->next = xcalloc(1, sizeof(struct sem_data));
|
||||
|
@ -397,8 +397,8 @@ int ipc_msg_get_info(int id, struct msg_data **msgds)
|
|||
p->q_qbytes = msgseg.msg_qbytes;
|
||||
i = 1;
|
||||
break;
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
p->next = xcalloc(1, sizeof(struct msg_data));
|
||||
|
|
|
@ -221,12 +221,12 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|||
if (i > COL_CTIME) {
|
||||
if (i >= LOWER && i <= UPPER)
|
||||
return i;
|
||||
else {
|
||||
warnx(_("column %s does not apply to the specified IPC"), name);
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
return i;
|
||||
|
||||
warnx(_("column %s does not apply to the specified IPC"), name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
warnx(_("unknown column: %s"), name);
|
||||
|
|
|
@ -596,11 +596,10 @@ static int netnsid_xasputs(char **str, int netnsid)
|
|||
if (netnsid >= 0)
|
||||
return xasprintf(str, "%d", netnsid);
|
||||
#ifdef NETNSA_NSID_NOT_ASSIGNED
|
||||
else if (netnsid == NETNSA_NSID_NOT_ASSIGNED)
|
||||
if (netnsid == NETNSA_NSID_NOT_ASSIGNED)
|
||||
return xasprintf(str, "%s", "unassigned");
|
||||
#endif
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_namespaces(struct lsns *ls)
|
||||
|
|
|
@ -397,7 +397,9 @@ static int get_range(char *str, rlim_t *soft, rlim_t *hard, int *found)
|
|||
*found |= PRLIMIT_SOFT | PRLIMIT_HARD;
|
||||
return 0;
|
||||
|
||||
} else if (*str == ':') { /* <:hard> */
|
||||
}
|
||||
|
||||
if (*str == ':') { /* <:hard> */
|
||||
str++;
|
||||
|
||||
if (strcmp(str, INFINITY_STR) != 0) {
|
||||
|
|
|
@ -593,7 +593,7 @@ int main(int argc, char *argv[])
|
|||
err(EXIT_FAILURE, _("waitpid failed"));
|
||||
if (WIFEXITED(status))
|
||||
return WEXITSTATUS(status);
|
||||
else if (WIFSIGNALED(status))
|
||||
if (WIFSIGNALED(status))
|
||||
kill(getpid(), WTERMSIG(status));
|
||||
err(EXIT_FAILURE, _("child exit failed"));
|
||||
}
|
||||
|
|
|
@ -385,7 +385,9 @@ static char *get_mm_stat(struct zram *z, size_t idx, int bytes)
|
|||
ul_path_read_string(sysfs, &str, name);
|
||||
return str;
|
||||
|
||||
} else if (ul_path_read_u64(sysfs, &num, name) == 0)
|
||||
}
|
||||
|
||||
if (ul_path_read_u64(sysfs, &num, name) == 0)
|
||||
return size_to_human_string(SIZE_SUFFIX_1LETTER, num);
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -1701,7 +1701,9 @@ static int wait_for_term_input(int fd)
|
|||
if (FD_ISSET(fd, &rfds)) {
|
||||
return 1;
|
||||
|
||||
} else if (netlink_fd >= 0 && FD_ISSET(netlink_fd, &rfds)) {
|
||||
}
|
||||
|
||||
if (netlink_fd >= 0 && FD_ISSET(netlink_fd, &rfds)) {
|
||||
if (!process_netlink())
|
||||
continue;
|
||||
|
||||
|
|
|
@ -126,11 +126,11 @@ static int process_next_step(struct scriptlive *ss)
|
|||
|
||||
ul_pty_set_mainloop_time(ss->pty, &target);
|
||||
break;
|
||||
} else {
|
||||
/* no delay -- immediately write */
|
||||
rc = replay_emit_step_data(ss->setup, ss->step, fd);
|
||||
fdatasync(fd);
|
||||
}
|
||||
|
||||
/* no delay -- immediately write */
|
||||
rc = replay_emit_step_data(ss->setup, ss->step, fd);
|
||||
fdatasync(fd);
|
||||
} while (rc == 0);
|
||||
|
||||
return rc;
|
||||
|
|
|
@ -247,11 +247,11 @@ static char *find_optional_arg(char **av, char *oa, int *oi)
|
|||
char *arg;
|
||||
if (oa)
|
||||
return oa;
|
||||
else {
|
||||
arg = av[*oi];
|
||||
if (!arg || arg[0] == '-')
|
||||
return NULL;
|
||||
}
|
||||
|
||||
arg = av[*oi];
|
||||
if (!arg || arg[0] == '-')
|
||||
return NULL;
|
||||
|
||||
(*oi)++;
|
||||
return arg;
|
||||
}
|
||||
|
@ -265,29 +265,28 @@ static int parse_blank(char **av, char *oa, int *oi)
|
|||
return BLANKEDSCREEN;
|
||||
if (!strcmp(arg, "force"))
|
||||
return BLANKSCREEN;
|
||||
else if (!strcmp(arg, "poke"))
|
||||
if (!strcmp(arg, "poke"))
|
||||
return UNBLANKSCREEN;
|
||||
else {
|
||||
int ret;
|
||||
|
||||
ret = strtos32_or_err(arg, _("argument error"));
|
||||
if (ret < 0 || BLANK_MAX < ret)
|
||||
errx(EXIT_FAILURE, "%s: %s", _("argument error"), arg);
|
||||
return ret;
|
||||
}
|
||||
int ret;
|
||||
|
||||
ret = strtos32_or_err(arg, _("argument error"));
|
||||
if (ret < 0 || BLANK_MAX < ret)
|
||||
errx(EXIT_FAILURE, "%s: %s", _("argument error"), arg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int parse_powersave(const char *arg)
|
||||
{
|
||||
if (strcmp(arg, "on") == 0)
|
||||
return VESA_BLANK_MODE_SUSPENDV;
|
||||
else if (strcmp(arg, "vsync") == 0)
|
||||
if (strcmp(arg, "vsync") == 0)
|
||||
return VESA_BLANK_MODE_SUSPENDV;
|
||||
else if (strcmp(arg, "hsync") == 0)
|
||||
if (strcmp(arg, "hsync") == 0)
|
||||
return VESA_BLANK_MODE_SUSPENDH;
|
||||
else if (strcmp(arg, "powerdown") == 0)
|
||||
if (strcmp(arg, "powerdown") == 0)
|
||||
return VESA_BLANK_MODE_POWERDOWN;
|
||||
else if (strcmp(arg, "off") == 0)
|
||||
if (strcmp(arg, "off") == 0)
|
||||
return VESA_BLANK_MODE_OFF;
|
||||
errx(EXIT_FAILURE, "%s: %s", _("argument error"), arg);
|
||||
}
|
||||
|
|
|
@ -895,10 +895,9 @@ static void ttyin(struct more_control *ctl, char buf[], int nmax, char pchar)
|
|||
erase_one_column(ctl);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
if (!ctl->erase_line)
|
||||
ctl->prompt_len = maxlen;
|
||||
}
|
||||
if (!ctl->erase_line)
|
||||
ctl->prompt_len = maxlen;
|
||||
} else if (c == ctl->output_tty.c_cc[VKILL] && !slash) {
|
||||
if (ctl->hard_tty) {
|
||||
show(ctl, c);
|
||||
|
@ -1340,8 +1339,8 @@ static void search(struct more_control *ctl, char buf[], int n)
|
|||
puts(ctl->line_buf);
|
||||
}
|
||||
break;
|
||||
} else
|
||||
more_poll(ctl, 1);
|
||||
}
|
||||
more_poll(ctl, 1);
|
||||
}
|
||||
/* Move ctrl+c signal handling back to more_key_command(). */
|
||||
signal(SIGINT, SIG_DFL);
|
||||
|
|
|
@ -987,42 +987,43 @@ static void pgfile(FILE *f, const char *name)
|
|||
*b = '\0';
|
||||
dline = pagelen;
|
||||
break;
|
||||
} else {
|
||||
if (nobuf)
|
||||
fseeko(f, fpos, SEEK_SET);
|
||||
canjump = 1;
|
||||
p = fgets(b, READBUF, f);
|
||||
if (nobuf)
|
||||
if ((fpos = ftello(f)) == -1)
|
||||
warn("%s", name);
|
||||
canjump = 0;
|
||||
}
|
||||
|
||||
if (nobuf)
|
||||
fseeko(f, fpos, SEEK_SET);
|
||||
canjump = 1;
|
||||
p = fgets(b, READBUF, f);
|
||||
if (nobuf)
|
||||
if ((fpos = ftello(f)) == -1)
|
||||
warn("%s", name);
|
||||
canjump = 0;
|
||||
|
||||
if (p == NULL || *b == '\0') {
|
||||
if (ferror(f))
|
||||
warn("%s", name);
|
||||
eofline = fline;
|
||||
eof = 1;
|
||||
break;
|
||||
} else {
|
||||
if (!nobuf)
|
||||
fputs(b, fbuf);
|
||||
fwrite_all(&pos, sizeof pos, 1, find);
|
||||
if (!fflag) {
|
||||
oldpos = pos;
|
||||
p = b;
|
||||
while (*(p = endline(ttycols,
|
||||
p))
|
||||
!= '\0') {
|
||||
pos = oldpos + (p - b);
|
||||
fwrite_all(&pos,
|
||||
sizeof pos,
|
||||
1, find);
|
||||
fline++;
|
||||
bline++;
|
||||
}
|
||||
}
|
||||
fline++;
|
||||
}
|
||||
|
||||
if (!nobuf)
|
||||
fputs(b, fbuf);
|
||||
fwrite_all(&pos, sizeof pos, 1, find);
|
||||
if (!fflag) {
|
||||
oldpos = pos;
|
||||
p = b;
|
||||
while (*(p = endline(ttycols,
|
||||
p))
|
||||
!= '\0') {
|
||||
pos = oldpos + (p - b);
|
||||
fwrite_all(&pos,
|
||||
sizeof pos,
|
||||
1, find);
|
||||
fline++;
|
||||
bline++;
|
||||
}
|
||||
}
|
||||
fline++;
|
||||
} while (line > bline++);
|
||||
} else {
|
||||
/* eofline != 0 */
|
||||
|
@ -1057,7 +1058,9 @@ static void pgfile(FILE *f, const char *name)
|
|||
skip(1);
|
||||
}
|
||||
continue;
|
||||
} else if (eof) {
|
||||
}
|
||||
|
||||
if (eof) {
|
||||
/* We are not searching. */
|
||||
line = bline;
|
||||
} else if (*b != '\0') {
|
||||
|
|
|
@ -69,8 +69,8 @@ static int put1wc(int c)
|
|||
{
|
||||
if (putwchar(c) == WEOF)
|
||||
return EOF;
|
||||
else
|
||||
return c;
|
||||
|
||||
return c;
|
||||
}
|
||||
#define putwp(s) tputs(s, STDOUT_FILENO, put1wc)
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue