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 */
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 */
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)
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? */
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)
{
if (nr < get_first_zone())
return 0;
- else if (nr >= get_nzones())
+ if (nr >= get_nzones())
return 0;
return 1;
}
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"),
(len-- == 0 ||
(begin[3] == '\0' &&
memcmp(begin, begin + 4, len) == 0))))))));
- else
- /* Never create holes. */
- return 0;
+
+ /* Never create holes. */
+ return 0;
}
/*
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;
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);
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);
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__)))
if (c == 0) {
dest[j] = '\0';
break;
- } else if (c < 0x80) {
+ }
+
+ if (c < 0x80) {
if (j+1 >= len)
break;
dest[j++] = (uint8_t) c;
uint64_t sz = 0;
return loopcxt_get_sizelimit(lc, &sz) == 0 && sz == sizelimit;
- } else
- return rc;
+ }
+ return rc;
}
return 1;
}
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;
}
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;
}
{
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;
ret = is_pmbr_valid(pr, NULL);
if (ret < 0)
return ret;
- else if (ret == 0)
+ if (ret == 0)
goto nothing;
errno = 0;
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);
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;
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;
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 {
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;
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;
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));
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;
-
- if (!memcmp(header->magic, LUKS_MAGIC_2, LUKS_MAGIC_L))
- return luks_attributes(pr, header, secondary_offsets[i]);
- }
+ }
+
+ /* 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;
+
+ if (!memcmp(header->magic, LUKS_MAGIC_2, LUKS_MAGIC_L))
+ return luks_attributes(pr, header, secondary_offsets[i]);
}
return BLKID_PROBE_NONE;
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);
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;
if (vsd_len == 2048) {
if (vsd_2048_valid == 0)
continue;
- else if (vsd_2048_valid == 1)
+ if (vsd_2048_valid == 1)
goto anchor;
}
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++)
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."));
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"));
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 {
}
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));
*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;
"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 (!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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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"));
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);
p = (char *) cache_find_path(cache, path);
if (p)
return p;
- else {
+
+ {
struct libmnt_iter itr;
struct libmnt_fs *fs = NULL;
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);
}
*mounted = 0;
return 0; /* /proc not mounted */
- } else if (rc)
+ }
+
+ if (rc)
return rc;
*mounted = __mnt_table_is_fs_mounted(mtab, fs,
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"));
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;
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).
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"));
/* 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()));
if (fd)
*fd = wd;
break;
- } else if (errno != ENOENT) {
+ }
+
+ if (errno != ENOENT) {
rc = -errno;
break;
}
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;
}
(*(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);
(*(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);
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);
- }
+ 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;
}
}
break;
- } else if (ret > 0) {
+ } if (ret > 0) {
/* success -- verify no event during read */
struct pollfd fds[] = {
{ .fd = fd, .events = POLLPRI }
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++;
}
{
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 */
(i == 23)) {
if (*cp == '-')
continue;
- else
- return -1;
+ return -1;
}
if (i== 36)
if (*cp == 0)
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;
}
* 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
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]);
+ }
+
+ 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;
}
- return 0;
+ printf("%d:%s\n", rv, argv[i]);
}
+ return 0;
}
#endif
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;
}
}
#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;
}
{
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)
&& 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;
*/
printf(" --\n");
return EXIT_SUCCESS;
- } else
- parse_error(_("missing optstring argument"));
+ }
+ parse_error(_("missing optstring argument"));
}
add_longopt(&ctl, NULL, 0); /* init */
#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 */
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,
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) {
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;
}
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;
-
- /*
- * 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);
+ }
+
+ /* 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;
+
+ /*
+ * 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;
}
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;
}
}
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),
if (id == p->shm_perm.id) {
i = 1;
break;
- } else
- continue;
+ }
+ continue;
}
p->next = xcalloc(1, sizeof(struct shm_data));
get_sem_elements(p);
i = 1;
break;
- } else
- continue;
+ }
+ continue;
}
p->next = xcalloc(1, sizeof(struct sem_data));
p->q_qbytes = msgseg.msg_qbytes;
i = 1;
break;
- } else
- continue;
+ }
+ continue;
}
p->next = xcalloc(1, sizeof(struct msg_data));
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);
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)
*found |= PRLIMIT_SOFT | PRLIMIT_HARD;
return 0;
- } else if (*str == ':') { /* <:hard> */
+ }
+
+ if (*str == ':') { /* <:hard> */
str++;
if (strcmp(str, INFINITY_STR) != 0) {
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"));
}
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;
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;
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;
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;
}
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);
}
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);
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);
*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++;
- }
+ }
+
+ 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++;
}
+ fline++;
} while (line > bline++);
} else {
/* eofline != 0 */
skip(1);
}
continue;
- } else if (eof) {
+ }
+
+ if (eof) {
/* We are not searching. */
line = bline;
} else if (*b != '\0') {
{
if (putwchar(c) == WEOF)
return EOF;
- else
- return c;
+
+ return c;
}
#define putwp(s) tputs(s, STDOUT_FILENO, put1wc)
#else