mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
tree-wide: use IN_SET macro (#6977)
This commit is contained in:
parent
6d0aa4db7b
commit
4c70109600
@ -421,11 +421,7 @@ static int parse_weekdays(const char **p, CalendarSpec *c) {
|
||||
|
||||
skip = strlen(day_nr[i].name);
|
||||
|
||||
if ((*p)[skip] != '-' &&
|
||||
(*p)[skip] != '.' &&
|
||||
(*p)[skip] != ',' &&
|
||||
(*p)[skip] != ' ' &&
|
||||
(*p)[skip] != 0)
|
||||
if (!IN_SET((*p)[skip], 0, '-', '.', ',', ' '))
|
||||
return -EINVAL;
|
||||
|
||||
c->weekdays_bits |= 1 << day_nr[i].nr;
|
||||
@ -484,7 +480,7 @@ static int parse_weekdays(const char **p, CalendarSpec *c) {
|
||||
}
|
||||
|
||||
/* Allow a trailing comma but not an open range */
|
||||
if (**p == 0 || **p == ' ') {
|
||||
if (IN_SET(**p, 0, ' ')) {
|
||||
*p += strspn(*p, " ");
|
||||
return l < 0 ? 0 : -EINVAL;
|
||||
}
|
||||
@ -644,7 +640,7 @@ static int prepend_component(const char **p, bool usec, CalendarComponent **c) {
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
if (*e != 0 && *e != ' ' && *e != ',' && *e != '-' && *e != '~' && *e != ':')
|
||||
if (!IN_SET(*e, 0, ' ', ',', '-', '~', ':'))
|
||||
return -EINVAL;
|
||||
|
||||
cc = new0(CalendarComponent, 1);
|
||||
@ -741,7 +737,7 @@ static int parse_date(const char **p, CalendarSpec *c) {
|
||||
return r;
|
||||
|
||||
/* Already the end? A ':' as separator? In that case this was a time, not a date */
|
||||
if (*t == 0 || *t == ':') {
|
||||
if (IN_SET(*t, 0, ':')) {
|
||||
free_chain(first);
|
||||
return 0;
|
||||
}
|
||||
@ -761,7 +757,7 @@ static int parse_date(const char **p, CalendarSpec *c) {
|
||||
}
|
||||
|
||||
/* Got two parts, hence it's month and day */
|
||||
if (*t == ' ' || *t == 0) {
|
||||
if (IN_SET(*t, 0, ' ')) {
|
||||
*p = t + strspn(t, " ");
|
||||
c->month = first;
|
||||
c->day = second;
|
||||
@ -789,7 +785,7 @@ static int parse_date(const char **p, CalendarSpec *c) {
|
||||
}
|
||||
|
||||
/* Got three parts, hence it is year, month and day */
|
||||
if (*t == ' ' || *t == 0) {
|
||||
if (IN_SET(*t, 0, ' ')) {
|
||||
*p = t + strspn(t, " ");
|
||||
c->year = first;
|
||||
c->month = second;
|
||||
|
@ -374,7 +374,7 @@ int cg_kill_recursive(
|
||||
|
||||
if (flags & CGROUP_REMOVE) {
|
||||
r = cg_rmdir(controller, path);
|
||||
if (r < 0 && ret >= 0 && r != -ENOENT && r != -EBUSY)
|
||||
if (r < 0 && ret >= 0 && !IN_SET(r, -ENOENT, -EBUSY))
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ int cg_migrate_recursive(
|
||||
|
||||
if (flags & CGROUP_REMOVE) {
|
||||
r = cg_rmdir(cfrom, pfrom);
|
||||
if (r < 0 && ret >= 0 && r != -ENOENT && r != -EBUSY)
|
||||
if (r < 0 && ret >= 0 && !IN_SET(r, -ENOENT, -EBUSY))
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -1883,9 +1883,7 @@ char *cg_escape(const char *p) {
|
||||
/* The return value of this function (unlike cg_unescape())
|
||||
* needs free()! */
|
||||
|
||||
if (p[0] == 0 ||
|
||||
p[0] == '_' ||
|
||||
p[0] == '.' ||
|
||||
if (IN_SET(p[0], 0, '_', '.') ||
|
||||
streq(p, "notify_on_release") ||
|
||||
streq(p, "release_agent") ||
|
||||
streq(p, "tasks") ||
|
||||
@ -1951,7 +1949,7 @@ bool cg_controller_is_valid(const char *p) {
|
||||
if (s)
|
||||
p = s;
|
||||
|
||||
if (*p == 0 || *p == '_')
|
||||
if (IN_SET(*p, 0, '_'))
|
||||
return false;
|
||||
|
||||
for (t = p; *t; t++)
|
||||
@ -2003,7 +2001,7 @@ int cg_slice_to_path(const char *unit, char **ret) {
|
||||
char n[dash - p + sizeof(".slice")];
|
||||
|
||||
/* Don't allow trailing or double dashes */
|
||||
if (dash[1] == 0 || dash[1] == '-')
|
||||
if (IN_SET(dash[1], 0, '-'))
|
||||
return -EINVAL;
|
||||
|
||||
strcpy(stpncpy(n, p, dash - p), ".slice");
|
||||
|
@ -707,7 +707,7 @@ char **replace_env_argv(char **argv, char **env) {
|
||||
STRV_FOREACH(i, argv) {
|
||||
|
||||
/* If $FOO appears as single word, replace it by the split up variable */
|
||||
if ((*i)[0] == '$' && (*i)[1] != '{' && (*i)[1] != '$') {
|
||||
if ((*i)[0] == '$' && !IN_SET((*i)[1], '{', '$')) {
|
||||
char *e;
|
||||
char **w, **m = NULL;
|
||||
unsigned q;
|
||||
|
@ -426,7 +426,7 @@ char *octescape(const char *s, size_t len) {
|
||||
|
||||
for (f = s, t = r; f < s + len; f++) {
|
||||
|
||||
if (*f < ' ' || *f >= 127 || *f == '\\' || *f == '"') {
|
||||
if (*f < ' ' || *f >= 127 || IN_SET(*f, '\\', '"')) {
|
||||
*(t++) = '\\';
|
||||
*(t++) = '0' + (*f >> 6);
|
||||
*(t++) = '0' + ((*f >> 3) & 8);
|
||||
|
@ -152,7 +152,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
|
||||
for (;; (*p)++, c = **p) {
|
||||
if (c == 0)
|
||||
goto finish_force_terminate;
|
||||
else if ((c == '\'' || c == '"') && (flags & EXTRACT_QUOTES)) {
|
||||
else if (IN_SET(c, '\'', '"') && (flags & EXTRACT_QUOTES)) {
|
||||
quote = c;
|
||||
break;
|
||||
} else if (c == '\\' && !(flags & EXTRACT_RETAIN_ESCAPE)) {
|
||||
|
@ -324,7 +324,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
|
||||
mkdir_parents(path, 0755);
|
||||
|
||||
fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY,
|
||||
(mode == 0 || mode == MODE_INVALID) ? 0644 : mode);
|
||||
IN_SET(mode, 0, MODE_INVALID) ? 0644 : mode);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -508,7 +508,7 @@ static void base_remove_entry(HashmapBase *h, unsigned idx) {
|
||||
/* Find the stop bucket ("right"). It is either free or has DIB == 0. */
|
||||
for (right = next_idx(h, left); ; right = next_idx(h, right)) {
|
||||
raw_dib = dibs[right];
|
||||
if (raw_dib == 0 || raw_dib == DIB_RAW_FREE)
|
||||
if (IN_SET(raw_dib, 0, DIB_RAW_FREE))
|
||||
break;
|
||||
|
||||
/* The buckets are not supposed to be all occupied and with DIB > 0.
|
||||
|
@ -90,9 +90,7 @@ static bool hostname_valid_char(char c) {
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') ||
|
||||
c == '-' ||
|
||||
c == '_' ||
|
||||
c == '.';
|
||||
IN_SET(c, '-', '_', '.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +233,7 @@ int read_hostname_config(const char *path, char **hostname) {
|
||||
/* may have comments, ignore them */
|
||||
FOREACH_LINE(l, f, return -errno) {
|
||||
truncate_nl(l);
|
||||
if (l[0] != '\0' && l[0] != '#') {
|
||||
if (!IN_SET(l[0], '\0', '#')) {
|
||||
/* found line with value */
|
||||
name = hostname_cleanup(l);
|
||||
name = strdup(name);
|
||||
|
@ -472,14 +472,14 @@ int bind_remount_recursive_with_mountinfo(const char *prefix, bool ro, char **bl
|
||||
while ((x = set_steal_first(todo))) {
|
||||
|
||||
r = set_consume(done, x);
|
||||
if (r == -EEXIST || r == 0)
|
||||
if (IN_SET(r, 0, -EEXIST))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Deal with mount points that are obstructed by a later mount */
|
||||
r = path_is_mount_point(x, NULL, 0);
|
||||
if (r == -ENOENT || r == 0)
|
||||
if (IN_SET(r, 0, -ENOENT))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -152,7 +152,7 @@ int parse_size(const char *t, uint64_t base, uint64_t *size) {
|
||||
unsigned n_entries, start_pos = 0;
|
||||
|
||||
assert(t);
|
||||
assert(base == 1000 || base == 1024);
|
||||
assert(IN_SET(base, 1000, 1024));
|
||||
assert(size);
|
||||
|
||||
if (base == 1000) {
|
||||
|
@ -392,7 +392,7 @@ int is_kernel_thread(pid_t pid) {
|
||||
bool eof;
|
||||
FILE *f;
|
||||
|
||||
if (pid == 0 || pid == 1 || pid == getpid_cached()) /* pid 1, and we ourselves certainly aren't a kernel thread */
|
||||
if (IN_SET(pid, 0, 1) || pid == getpid_cached()) /* pid 1, and we ourselves certainly aren't a kernel thread */
|
||||
return 0;
|
||||
|
||||
assert(pid > 1);
|
||||
@ -817,7 +817,7 @@ bool pid_is_alive(pid_t pid) {
|
||||
return true;
|
||||
|
||||
r = get_process_state(pid);
|
||||
if (r == -ESRCH || r == 'Z')
|
||||
if (IN_SET(r, -ESRCH, 'Z'))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -132,7 +132,7 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
|
||||
|
||||
r = btrfs_subvol_remove_fd(fd, de->d_name, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);
|
||||
if (r < 0) {
|
||||
if (r != -ENOTTY && r != -EINVAL) {
|
||||
if (!IN_SET(r, -ENOTTY, -EINVAL)) {
|
||||
if (ret == 0)
|
||||
ret = r;
|
||||
|
||||
@ -193,7 +193,7 @@ int rm_rf(const char *path, RemoveFlags flags) {
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
if (r != -ENOTTY && r != -EINVAL && r != -ENOTDIR)
|
||||
if (!IN_SET(r, -ENOTTY, -EINVAL, -ENOTDIR))
|
||||
return r;
|
||||
|
||||
/* Not btrfs or not a subvolume */
|
||||
|
@ -892,7 +892,7 @@ bool ifname_valid(const char *p) {
|
||||
if ((unsigned char) *p <= 32U)
|
||||
return false;
|
||||
|
||||
if (*p == ':' || *p == '/')
|
||||
if (IN_SET(*p, ':', '/'))
|
||||
return false;
|
||||
|
||||
numeric = numeric && (*p >= '0' && *p <= '9');
|
||||
|
@ -673,7 +673,7 @@ char *strip_tab_ansi(char **ibuf, size_t *_isz) {
|
||||
case STATE_BRACKET:
|
||||
|
||||
if (i >= *ibuf + isz || /* EOT */
|
||||
(!(*i >= '0' && *i <= '9') && *i != ';' && *i != 'm')) {
|
||||
(!(*i >= '0' && *i <= '9') && !IN_SET(*i, ';', 'm'))) {
|
||||
fputc_unlocked('\x1B', f);
|
||||
fputc_unlocked('[', f);
|
||||
state = STATE_OTHER;
|
||||
|
@ -1308,7 +1308,7 @@ bool timezone_is_valid(const char *name) {
|
||||
if (!(*p >= '0' && *p <= '9') &&
|
||||
!(*p >= 'a' && *p <= 'z') &&
|
||||
!(*p >= 'A' && *p <= 'Z') &&
|
||||
!(*p == '-' || *p == '_' || *p == '+' || *p == '/'))
|
||||
!IN_SET(*p, '-', '_', '+', '/'))
|
||||
return false;
|
||||
|
||||
if (*p == '/') {
|
||||
|
@ -305,7 +305,7 @@ static char *do_escape(const char *f, char *t) {
|
||||
for (; *f; f++) {
|
||||
if (*f == '/')
|
||||
*(t++) = '-';
|
||||
else if (*f == '-' || *f == '\\' || !strchr(VALID_CHARS, *f))
|
||||
else if (IN_SET(*f, '-', '\\') || !strchr(VALID_CHARS, *f))
|
||||
t = do_escape_char(*f, t);
|
||||
else
|
||||
*(t++) = *f;
|
||||
|
@ -543,8 +543,7 @@ bool valid_user_group_name(const char *u) {
|
||||
if (!(*i >= 'a' && *i <= 'z') &&
|
||||
!(*i >= 'A' && *i <= 'Z') &&
|
||||
!(*i >= '0' && *i <= '9') &&
|
||||
*i != '_' &&
|
||||
*i != '-')
|
||||
!IN_SET(*i, '_', '-'))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ static bool unichar_is_control(char32_t ch) {
|
||||
'\t' is in C0 range, but more or less harmless and commonly used.
|
||||
*/
|
||||
|
||||
return (ch < ' ' && ch != '\t' && ch != '\n') ||
|
||||
return (ch < ' ' && !IN_SET(ch, '\t', '\n')) ||
|
||||
(0x7F <= ch && ch <= 0x9F);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ static int parse_crtime(le64_t le, usec_t *usec) {
|
||||
assert(usec);
|
||||
|
||||
u = le64toh(le);
|
||||
if (u == 0 || u == (uint64_t) -1)
|
||||
if (IN_SET(u, 0, (uint64_t) -1))
|
||||
return -EIO;
|
||||
|
||||
*usec = (usec_t) u;
|
||||
|
@ -208,7 +208,7 @@ int xml_tokenize(const char **p, char **name, void **state, unsigned *line) {
|
||||
if (*c == '=') {
|
||||
c++;
|
||||
|
||||
if (*c == '\'' || *c == '\"') {
|
||||
if (IN_SET(*c, '\'', '\"')) {
|
||||
/* Tag with a quoted value */
|
||||
|
||||
e = strchr(c+1, *c);
|
||||
|
@ -355,7 +355,7 @@ static int whitelist_major(const char *path, const char *name, char type, const
|
||||
|
||||
assert(path);
|
||||
assert(acc);
|
||||
assert(type == 'b' || type == 'c');
|
||||
assert(IN_SET(type, 'b', 'c'));
|
||||
|
||||
f = fopen("/proc/devices", "re");
|
||||
if (!f)
|
||||
|
@ -917,7 +917,7 @@ static int append_process(sd_bus_message *reply, const char *p, pid_t pid, Set *
|
||||
assert(pid > 0);
|
||||
|
||||
r = set_put(pids, PID_TO_PTR(pid));
|
||||
if (r == -EEXIST || r == 0)
|
||||
if (IN_SET(r, 0, -EEXIST))
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -2062,7 +2062,7 @@ static int setup_smack(
|
||||
_cleanup_free_ char *exec_label = NULL;
|
||||
|
||||
r = mac_smack_read(command->path, SMACK_ATTR_EXEC, &exec_label);
|
||||
if (r < 0 && r != -ENODATA && r != -EOPNOTSUPP)
|
||||
if (r < 0 && !IN_SET(r, -ENODATA, -EOPNOTSUPP))
|
||||
return r;
|
||||
|
||||
r = mac_smack_apply_pid(0, exec_label ? : SMACK_DEFAULT_PROCESS_LABEL);
|
||||
|
@ -681,7 +681,7 @@ _pure_ static const char *job_get_status_message_format(Unit *u, JobType t, JobR
|
||||
/* Return generic strings */
|
||||
if (t == JOB_START)
|
||||
return generic_finished_start_job[result];
|
||||
else if (t == JOB_STOP || t == JOB_RESTART)
|
||||
else if (IN_SET(t, JOB_STOP, JOB_RESTART))
|
||||
return generic_finished_stop_job[result];
|
||||
else if (t == JOB_RELOAD)
|
||||
return generic_finished_reload_job[result];
|
||||
|
@ -1672,7 +1672,7 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (arg_action == ACTION_TEST || arg_action == ACTION_HELP) {
|
||||
if (IN_SET(arg_action, ACTION_TEST, ACTION_HELP)) {
|
||||
pager_open(arg_no_pager, false);
|
||||
skip_setup = true;
|
||||
}
|
||||
@ -1696,7 +1696,7 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
assert_se(arg_action == ACTION_RUN || arg_action == ACTION_TEST);
|
||||
assert_se(IN_SET(arg_action, ACTION_RUN, ACTION_TEST));
|
||||
|
||||
/* Close logging fds, in order not to confuse fdset below */
|
||||
log_close();
|
||||
@ -1892,7 +1892,7 @@ int main(int argc, char *argv[]) {
|
||||
r = manager_load_unit(m, arg_default_unit, NULL, &error, &target);
|
||||
if (r < 0)
|
||||
log_error("Failed to load default target: %s", bus_error_message(&error, r));
|
||||
else if (target->load_state == UNIT_ERROR || target->load_state == UNIT_NOT_FOUND)
|
||||
else if (IN_SET(target->load_state, UNIT_ERROR, UNIT_NOT_FOUND))
|
||||
log_error_errno(target->load_error, "Failed to load default target: %m");
|
||||
else if (target->load_state == UNIT_MASKED)
|
||||
log_error("Default target masked.");
|
||||
@ -1905,7 +1905,7 @@ int main(int argc, char *argv[]) {
|
||||
log_emergency("Failed to load rescue target: %s", bus_error_message(&error, r));
|
||||
error_message = "Failed to load rescue target";
|
||||
goto finish;
|
||||
} else if (target->load_state == UNIT_ERROR || target->load_state == UNIT_NOT_FOUND) {
|
||||
} else if (IN_SET(target->load_state, UNIT_ERROR, UNIT_NOT_FOUND)) {
|
||||
log_emergency_errno(target->load_error, "Failed to load rescue target: %m");
|
||||
error_message = "Failed to load rescue target";
|
||||
goto finish;
|
||||
|
@ -396,7 +396,7 @@ static int enable_special_signals(Manager *m) {
|
||||
/* Enable that we get SIGINT on control-alt-del. In containers
|
||||
* this will fail with EPERM (older) or EINVAL (newer), so
|
||||
* ignore that. */
|
||||
if (reboot(RB_DISABLE_CAD) < 0 && errno != EPERM && errno != EINVAL)
|
||||
if (reboot(RB_DISABLE_CAD) < 0 && !IN_SET(errno, EPERM, EINVAL))
|
||||
log_warning_errno(errno, "Failed to enable ctrl-alt-del handling: %m");
|
||||
|
||||
fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC);
|
||||
@ -985,10 +985,8 @@ static void unit_gc_sweep(Unit *u, unsigned gc_marker) {
|
||||
|
||||
assert(u);
|
||||
|
||||
if (u->gc_marker == gc_marker + GC_OFFSET_GOOD ||
|
||||
u->gc_marker == gc_marker + GC_OFFSET_BAD ||
|
||||
u->gc_marker == gc_marker + GC_OFFSET_UNSURE ||
|
||||
u->gc_marker == gc_marker + GC_OFFSET_IN_PATH)
|
||||
if (IN_SET(u->gc_marker - gc_marker,
|
||||
GC_OFFSET_GOOD, GC_OFFSET_BAD, GC_OFFSET_UNSURE, GC_OFFSET_IN_PATH))
|
||||
return;
|
||||
|
||||
if (u->in_cleanup_queue)
|
||||
@ -1055,8 +1053,8 @@ static unsigned manager_dispatch_gc_unit_queue(Manager *m) {
|
||||
|
||||
n++;
|
||||
|
||||
if (u->gc_marker == gc_marker + GC_OFFSET_BAD ||
|
||||
u->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
|
||||
if (IN_SET(u->gc_marker - gc_marker,
|
||||
GC_OFFSET_BAD, GC_OFFSET_UNSURE)) {
|
||||
if (u->id)
|
||||
log_unit_debug(u, "Collecting.");
|
||||
u->gc_marker = gc_marker + GC_OFFSET_BAD;
|
||||
@ -3747,7 +3745,7 @@ int manager_dispatch_user_lookup_fd(sd_event_source *source, int fd, uint32_t re
|
||||
|
||||
l = recv(fd, &buffer, sizeof(buffer), MSG_DONTWAIT);
|
||||
if (l < 0) {
|
||||
if (errno == EINTR || errno == EAGAIN)
|
||||
if (IN_SET(errno, EINTR, EAGAIN))
|
||||
return 0;
|
||||
|
||||
return log_error_errno(errno, "Failed to read from user lookup fd: %m");
|
||||
|
@ -218,7 +218,7 @@ static void service_start_watchdog(Service *s) {
|
||||
assert(s);
|
||||
|
||||
watchdog_usec = service_get_watchdog_usec(s);
|
||||
if (watchdog_usec == 0 || watchdog_usec == USEC_INFINITY)
|
||||
if (IN_SET(watchdog_usec, 0, USEC_INFINITY))
|
||||
return;
|
||||
|
||||
if (s->watchdog_event_source) {
|
||||
|
@ -1444,7 +1444,7 @@ static int socket_determine_selinux_label(Socket *s, char **ret) {
|
||||
goto no_label;
|
||||
|
||||
r = mac_selinux_get_create_label_from_exe(c->path, ret);
|
||||
if (r == -EPERM || r == -EOPNOTSUPP)
|
||||
if (IN_SET(r, -EPERM, -EOPNOTSUPP))
|
||||
goto no_label;
|
||||
}
|
||||
|
||||
|
@ -3647,7 +3647,7 @@ int unit_kill_common(
|
||||
return -ENOMEM;
|
||||
|
||||
q = cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, signo, 0, pid_set, NULL, NULL);
|
||||
if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
|
||||
if (q < 0 && !IN_SET(q, -EAGAIN, -ESRCH, -ENOENT))
|
||||
r = q;
|
||||
else
|
||||
killed = true;
|
||||
@ -4179,7 +4179,7 @@ int unit_kill_context(
|
||||
pid_set,
|
||||
log_func, u);
|
||||
if (r < 0) {
|
||||
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
|
||||
if (!IN_SET(r, -EAGAIN, -ESRCH, -ENOENT))
|
||||
log_unit_warning_errno(u, r, "Failed to kill control group %s, ignoring: %m", u->cgroup_path);
|
||||
|
||||
} else if (r > 0) {
|
||||
|
@ -378,7 +378,7 @@ static int add_crypttab_devices(void) {
|
||||
crypttab_line++;
|
||||
|
||||
l = strstrip(line);
|
||||
if (*l == '#' || *l == 0)
|
||||
if (IN_SET(*l, 0, '#'))
|
||||
continue;
|
||||
|
||||
k = sscanf(l, "%ms %ms %ms %ms", &name, &device, &keyfile, &options);
|
||||
|
@ -462,7 +462,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (status.si_code != CLD_EXITED || (status.si_status & ~1)) {
|
||||
|
||||
if (status.si_code == CLD_KILLED || status.si_code == CLD_DUMPED)
|
||||
if (IN_SET(status.si_code, CLD_KILLED, CLD_DUMPED))
|
||||
log_error("fsck terminated by signal %s.", signal_to_string(status.si_status));
|
||||
else if (status.si_code == CLD_EXITED)
|
||||
log_error("fsck failed with error code %i.", status.si_status);
|
||||
|
@ -37,7 +37,7 @@ int import_make_read_only_fd(int fd) {
|
||||
/* First, let's make this a read-only subvolume if it refers
|
||||
* to a subvolume */
|
||||
r = btrfs_subvol_set_read_only_fd(fd, true);
|
||||
if (r == -ENOTTY || r == -ENOTDIR || r == -EINVAL) {
|
||||
if (IN_SET(r, -ENOTTY, -ENOTDIR, -EINVAL)) {
|
||||
struct stat st;
|
||||
|
||||
/* This doesn't refer to a subvolume, or the file
|
||||
|
@ -250,7 +250,7 @@ static void transfer_send_logs(Transfer *t, bool flush) {
|
||||
n = strndup(t->log_message, e - t->log_message);
|
||||
|
||||
/* Skip over NUL and newlines */
|
||||
while ((e < t->log_message + t->log_message_size) && (*e == 0 || *e == '\n'))
|
||||
while ((e < t->log_message + t->log_message_size) && IN_SET(*e, 0, '\n'))
|
||||
e++;
|
||||
|
||||
memmove(t->log_message, e, t->log_message + sizeof(t->log_message) - e);
|
||||
|
@ -108,7 +108,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
|
||||
if (curl_easy_getinfo(curl, CURLINFO_PRIVATE, (char **)&j) != CURLE_OK)
|
||||
return;
|
||||
|
||||
if (!j || j->state == PULL_JOB_DONE || j->state == PULL_JOB_FAILED)
|
||||
if (!j || IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED))
|
||||
return;
|
||||
|
||||
if (result != CURLE_OK) {
|
||||
|
@ -213,8 +213,7 @@ static int verify_header(const Header *header) {
|
||||
if (HEADER_MAGIC(header) != QCOW2_MAGIC)
|
||||
return -EBADMSG;
|
||||
|
||||
if (HEADER_VERSION(header) != 2 &&
|
||||
HEADER_VERSION(header) != 3)
|
||||
if (!IN_SET(HEADER_VERSION(header), 2, 3))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (HEADER_CRYPT_METHOD(header) != 0)
|
||||
|
@ -216,7 +216,7 @@ int catalog_file_lang(const char* filename, char **lang) {
|
||||
return 0;
|
||||
|
||||
beg = end - 1;
|
||||
while (beg > filename && *beg != '.' && *beg != '/' && end - beg < 32)
|
||||
while (beg > filename && !IN_SET(*beg, '.', '/') && end - beg < 32)
|
||||
beg--;
|
||||
|
||||
if (*beg != '.' || end <= beg + 1)
|
||||
@ -312,7 +312,7 @@ int catalog_import_file(Hashmap *h, const char *path) {
|
||||
line[0] == '-' &&
|
||||
line[1] == '-' &&
|
||||
line[2] == ' ' &&
|
||||
(line[2+1+32] == ' ' || line[2+1+32] == '\0')) {
|
||||
IN_SET(line[2+1+32], ' ', '\0')) {
|
||||
|
||||
bool with_language;
|
||||
sd_id128_t jd;
|
||||
|
@ -280,7 +280,7 @@ int decompress_startswith_xz(const void *src, uint64_t src_size,
|
||||
for (;;) {
|
||||
ret = lzma_code(&s, LZMA_FINISH);
|
||||
|
||||
if (ret != LZMA_STREAM_END && ret != LZMA_OK)
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END))
|
||||
return -EBADMSG;
|
||||
|
||||
if (*buffer_size - s.avail_out >= prefix_len + 1)
|
||||
@ -417,7 +417,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
}
|
||||
|
||||
ret = lzma_code(&s, action);
|
||||
if (ret != LZMA_OK && ret != LZMA_STREAM_END) {
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) {
|
||||
log_error("Compression failed: code %u", ret);
|
||||
return -EBADMSG;
|
||||
}
|
||||
@ -579,7 +579,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
}
|
||||
|
||||
ret = lzma_code(&s, action);
|
||||
if (ret != LZMA_OK && ret != LZMA_STREAM_END) {
|
||||
if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) {
|
||||
log_debug("Decompression failed: code %u", ret);
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ static int parse_boot_descriptor(const char *x, sd_id128_t *boot_id, int *offset
|
||||
if (r >= 0)
|
||||
x += 32;
|
||||
|
||||
if (*x != '-' && *x != '+' && *x != 0)
|
||||
if (!IN_SET(*x, 0, '-', '+'))
|
||||
return -EINVAL;
|
||||
|
||||
if (*x != 0) {
|
||||
@ -1572,7 +1572,7 @@ static int setup_keys(void) {
|
||||
struct stat st;
|
||||
|
||||
r = stat("/var/log/journal", &st);
|
||||
if (r < 0 && errno != ENOENT && errno != ENOTDIR)
|
||||
if (r < 0 && !IN_SET(errno, ENOENT, ENOTDIR))
|
||||
return log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal");
|
||||
|
||||
if (r < 0 || !S_ISDIR(st.st_mode)) {
|
||||
|
@ -49,7 +49,7 @@ static int map_simple_field(const char *field, const char **p, struct iovec **io
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(c, field, l);
|
||||
for (e = *p; *e != ' ' && *e != 0; e++) {
|
||||
for (e = *p; !IN_SET(*e, 0, ' '); e++) {
|
||||
if (!GREEDY_REALLOC(c, allocated, l+2))
|
||||
return -ENOMEM;
|
||||
|
||||
@ -110,7 +110,7 @@ static int map_string_field_internal(const char *field, const char **p, struct i
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(c, field, l);
|
||||
for (e = *p; *e != ' ' && *e != 0; e += 2) {
|
||||
for (e = *p; !IN_SET(*e, 0, ' '); e += 2) {
|
||||
int a, b;
|
||||
uint8_t x;
|
||||
|
||||
@ -167,7 +167,7 @@ static int map_generic_field(const char *prefix, const char **p, struct iovec **
|
||||
|
||||
for (e = *p; e < *p + 16; e++) {
|
||||
|
||||
if (*e == 0 || *e == ' ')
|
||||
if (IN_SET(*e, 0, ' '))
|
||||
return 0;
|
||||
|
||||
if (*e == '=')
|
||||
@ -176,7 +176,7 @@ static int map_generic_field(const char *prefix, const char **p, struct iovec **
|
||||
if (!((*e >= 'a' && *e <= 'z') ||
|
||||
(*e >= 'A' && *e <= 'Z') ||
|
||||
(*e >= '0' && *e <= '9') ||
|
||||
*e == '_' || *e == '-'))
|
||||
IN_SET(*e, '_', '-')))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ static int server_process_entry(
|
||||
break;
|
||||
}
|
||||
|
||||
if (*p == '.' || *p == '#') {
|
||||
if (IN_SET(*p, '.', '#')) {
|
||||
/* Ignore control commands for now, and
|
||||
* comments too. */
|
||||
*remaining -= (e - p) + 1;
|
||||
|
@ -317,7 +317,7 @@ static int system_journal_open(Server *s, bool flush_requested) {
|
||||
(void) cache_space_refresh(s, &s->system_storage);
|
||||
patch_min_use(&s->system_storage);
|
||||
} else if (r < 0) {
|
||||
if (r != -ENOENT && r != -EROFS)
|
||||
if (!IN_SET(r, -ENOENT, -EROFS))
|
||||
log_warning_errno(r, "Failed to open system journal: %m");
|
||||
|
||||
r = 0;
|
||||
@ -1620,7 +1620,7 @@ static int server_connect_notify(Server *s) {
|
||||
if (!e)
|
||||
return 0;
|
||||
|
||||
if ((e[0] != '@' && e[0] != '/') || e[1] == 0) {
|
||||
if (!IN_SET(e[0], '@', '/') || e[1] == 0) {
|
||||
log_error("NOTIFY_SOCKET set to an invalid value: %s", e);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ _pure_ static int compare_with_location(JournalFile *f, Location *l) {
|
||||
assert(f);
|
||||
assert(l);
|
||||
assert(f->location_type == LOCATION_SEEK);
|
||||
assert(l->type == LOCATION_DISCRETE || l->type == LOCATION_SEEK);
|
||||
assert(IN_SET(l->type, LOCATION_DISCRETE, LOCATION_SEEK));
|
||||
|
||||
if (l->monotonic_set &&
|
||||
sd_id128_equal(f->current_boot_id, l->boot_id) &&
|
||||
|
@ -194,7 +194,7 @@ static void test_compress_stream(int compression,
|
||||
|
||||
assert_se(lseek(dst, 1, SEEK_SET) == 1);
|
||||
r = decompress(dst, dst2, st.st_size);
|
||||
assert_se(r == -EBADMSG || r == 0);
|
||||
assert_se(IN_SET(r, 0, -EBADMSG));
|
||||
|
||||
assert_se(lseek(dst, 0, SEEK_SET) == 0);
|
||||
assert_se(lseek(dst2, 0, SEEK_SET) == 0);
|
||||
|
@ -528,7 +528,7 @@ static int client_message_init(
|
||||
assert(ret);
|
||||
assert(_optlen);
|
||||
assert(_optoffset);
|
||||
assert(type == DHCP_DISCOVER || type == DHCP_REQUEST);
|
||||
assert(IN_SET(type, DHCP_DISCOVER, DHCP_REQUEST));
|
||||
|
||||
optlen = DHCP_MIN_OPTIONS_SIZE;
|
||||
size = sizeof(DHCPPacket) + optlen;
|
||||
@ -707,8 +707,7 @@ static int client_send_discover(sd_dhcp_client *client) {
|
||||
int r;
|
||||
|
||||
assert(client);
|
||||
assert(client->state == DHCP_STATE_INIT ||
|
||||
client->state == DHCP_STATE_SELECTING);
|
||||
assert(IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_SELECTING));
|
||||
|
||||
r = client_message_init(client, &discover, DHCP_DISCOVER,
|
||||
&optlen, &optoffset);
|
||||
@ -1688,7 +1687,7 @@ static int client_receive_message_udp(
|
||||
|
||||
len = recv(fd, message, buflen, 0);
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return log_dhcp_client_errno(client, errno,
|
||||
@ -1782,7 +1781,7 @@ static int client_receive_message_raw(
|
||||
|
||||
len = recvmsg(fd, &msg, 0);
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return log_dhcp_client_errno(client, errno,
|
||||
|
@ -993,7 +993,7 @@ static int server_receive_message(sd_event_source *s, int fd,
|
||||
|
||||
len = recvmsg(fd, &msg, 0);
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
|
@ -940,7 +940,7 @@ static int client_receive_message(
|
||||
|
||||
len = recv(fd, message, buflen, 0);
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return log_dhcp6_client_errno(client, errno, "Could not receive message from UDP socket: %m");
|
||||
|
@ -218,7 +218,7 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
|
||||
|
||||
length = recv(fd, LLDP_NEIGHBOR_RAW(n), n->raw_size, MSG_DONTWAIT);
|
||||
if (length < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return log_lldp_errno(errno, "Failed to read LLDP datagram: %m");
|
||||
|
@ -294,7 +294,7 @@ static void test_discover_message(sd_event *e) {
|
||||
|
||||
res = sd_dhcp_client_start(client);
|
||||
|
||||
assert_se(res == 0 || res == -EINPROGRESS);
|
||||
assert_se(IN_SET(res, 0, -EINPROGRESS));
|
||||
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
|
||||
@ -513,7 +513,7 @@ static void test_addr_acq(sd_event *e) {
|
||||
test_dhcp_hangcheck, NULL) >= 0);
|
||||
|
||||
res = sd_dhcp_client_start(client);
|
||||
assert_se(res == 0 || res == -EINPROGRESS);
|
||||
assert_se(IN_SET(res, 0, -EINPROGRESS));
|
||||
|
||||
assert_se(sd_event_loop(e) >= 0);
|
||||
|
||||
|
@ -4219,8 +4219,7 @@ _public_ int sd_bus_message_peek_type(sd_bus_message *m, char *type, const char
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (c->signature[c->index] == SD_BUS_TYPE_STRUCT_BEGIN ||
|
||||
c->signature[c->index] == SD_BUS_TYPE_DICT_ENTRY_BEGIN) {
|
||||
if (IN_SET(c->signature[c->index], SD_BUS_TYPE_STRUCT_BEGIN, SD_BUS_TYPE_DICT_ENTRY_BEGIN)) {
|
||||
|
||||
if (contents) {
|
||||
size_t l;
|
||||
|
@ -39,7 +39,7 @@ static bool startswith_comma(const char *s, const char *prefix) {
|
||||
if (!s)
|
||||
return false;
|
||||
|
||||
return *s == ',' || *s == '\0';
|
||||
return IN_SET(*s, ',', '\0');
|
||||
}
|
||||
|
||||
static const char* strnulldash(const char *s) {
|
||||
@ -177,7 +177,7 @@ static int x11_read_data(Context *c) {
|
||||
char_array_0(line);
|
||||
l = strstrip(line);
|
||||
|
||||
if (l[0] == 0 || l[0] == '#')
|
||||
if (IN_SET(l[0], 0, '#'))
|
||||
continue;
|
||||
|
||||
if (in_section && first_word(l, "Option")) {
|
||||
@ -425,7 +425,7 @@ static int read_next_mapping(const char* filename,
|
||||
(*n)++;
|
||||
|
||||
l = strstrip(line);
|
||||
if (l[0] == 0 || l[0] == '#')
|
||||
if (IN_SET(l[0], 0, '#'))
|
||||
continue;
|
||||
|
||||
r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_QUOTES);
|
||||
|
@ -407,7 +407,7 @@ static int prop_map_first_of_struct(sd_bus *bus, const char *member, sd_bus_mess
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (contents[0] == 's' || contents[0] == 'o') {
|
||||
if (IN_SET(contents[0], 's', 'o')) {
|
||||
const char *s;
|
||||
char **p = (char **) userdata;
|
||||
|
||||
|
@ -663,8 +663,7 @@ static bool seat_name_valid_char(char c) {
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') ||
|
||||
c == '-' ||
|
||||
c == '_';
|
||||
IN_SET(c, '-', '_');
|
||||
}
|
||||
|
||||
bool seat_name_is_valid(const char *name) {
|
||||
|
@ -547,7 +547,7 @@ static int user_remove_runtime_path(User *u) {
|
||||
* quite possible, if we lacked the permissions to mount
|
||||
* something */
|
||||
r = umount2(u->runtime_path, MNT_DETACH);
|
||||
if (r < 0 && errno != EINVAL && errno != ENOENT)
|
||||
if (r < 0 && !IN_SET(errno, EINVAL, ENOENT))
|
||||
log_error_errno(errno, "Failed to unmount user runtime directory %s: %m", u->runtime_path);
|
||||
|
||||
r = rm_rf(u->runtime_path, REMOVE_ROOT);
|
||||
|
@ -1458,8 +1458,7 @@ static int login_machine(int argc, char *argv[], void *userdata) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL &&
|
||||
arg_transport != BUS_TRANSPORT_MACHINE) {
|
||||
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE)) {
|
||||
log_error("Login only supported on local machines.");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@ -1521,8 +1520,7 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
if (arg_transport != BUS_TRANSPORT_LOCAL &&
|
||||
arg_transport != BUS_TRANSPORT_MACHINE) {
|
||||
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE)) {
|
||||
log_error("Shell only supported on local machines.");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ static int get_gateway_description(
|
||||
|
||||
assert(rtnl);
|
||||
assert(ifindex >= 0);
|
||||
assert(family == AF_INET || family == AF_INET6);
|
||||
assert(IN_SET(family, AF_INET, AF_INET6));
|
||||
assert(gateway);
|
||||
assert(gateway_description);
|
||||
|
||||
|
@ -453,7 +453,7 @@ int address_remove(
|
||||
int r;
|
||||
|
||||
assert(address);
|
||||
assert(address->family == AF_INET || address->family == AF_INET6);
|
||||
assert(IN_SET(address->family, AF_INET, AF_INET6));
|
||||
assert(link);
|
||||
assert(link->ifindex > 0);
|
||||
assert(link->manager);
|
||||
@ -553,7 +553,7 @@ int address_configure(
|
||||
int r;
|
||||
|
||||
assert(address);
|
||||
assert(address->family == AF_INET || address->family == AF_INET6);
|
||||
assert(IN_SET(address->family, AF_INET, AF_INET6));
|
||||
assert(link);
|
||||
assert(link->ifindex > 0);
|
||||
assert(link->manager);
|
||||
|
@ -87,7 +87,7 @@ int config_parse_duid_rawdata(
|
||||
}
|
||||
|
||||
len = strlen(cbyte);
|
||||
if (len != 1 && len != 2) {
|
||||
if (!IN_SET(len, 1, 2)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid length - DUID byte: %s, ignoring assignment: %s.", cbyte, rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ int route_remove(Route *route, Link *link,
|
||||
assert(link->manager);
|
||||
assert(link->manager->rtnl);
|
||||
assert(link->ifindex > 0);
|
||||
assert(route->family == AF_INET || route->family == AF_INET6);
|
||||
assert(IN_SET(route->family, AF_INET, AF_INET6));
|
||||
|
||||
r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
|
||||
RTM_DELROUTE, route->family,
|
||||
@ -528,7 +528,7 @@ int route_configure(
|
||||
assert(link->manager);
|
||||
assert(link->manager->rtnl);
|
||||
assert(link->ifindex > 0);
|
||||
assert(route->family == AF_INET || route->family == AF_INET6);
|
||||
assert(IN_SET(route->family, AF_INET, AF_INET6));
|
||||
|
||||
if (route_get(link, route->family, &route->dst, route->dst_prefixlen, route->tos, route->priority, route->table, NULL) <= 0 &&
|
||||
set_size(link->routes) >= routes_max())
|
||||
|
@ -307,7 +307,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
|
||||
if (af == AF_UNSPEC)
|
||||
af = AF_INET;
|
||||
|
||||
if (af != AF_INET && af != AF_INET6) {
|
||||
if (!IN_SET(af, AF_INET, AF_INET6)) {
|
||||
r = -EAFNOSUPPORT;
|
||||
goto fail;
|
||||
}
|
||||
|
@ -1247,10 +1247,10 @@ static int nsec3_is_good(DnsResourceRecord *rr, DnsResourceRecord *nsec3) {
|
||||
|
||||
/* Ignore NSEC3 RRs generated from wildcards. If these NSEC3 RRs weren't correctly signed we can't make this
|
||||
* check (since rr->n_skip_labels_source is -1), but that's OK, as we won't trust them anyway in that case. */
|
||||
if (rr->n_skip_labels_source != 0 && rr->n_skip_labels_source != (unsigned) -1)
|
||||
if (!IN_SET(rr->n_skip_labels_source, 0, (unsigned) -1))
|
||||
return 0;
|
||||
/* Ignore NSEC3 RRs that are located anywhere else than one label below the zone */
|
||||
if (rr->n_skip_labels_signer != 1 && rr->n_skip_labels_signer != (unsigned) -1)
|
||||
if (!IN_SET(rr->n_skip_labels_signer, 1, (unsigned) -1))
|
||||
return 0;
|
||||
|
||||
if (!nsec3)
|
||||
|
@ -904,7 +904,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
|
||||
* messages, not all of them. That should be enough to
|
||||
* indicate where there might be a conflict */
|
||||
r = ordered_hashmap_put(scope->conflict_queue, rr->key, rr);
|
||||
if (r == -EEXIST || r == 0)
|
||||
if (IN_SET(r, 0, -EEXIST))
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to queue conflicting RR: %m");
|
||||
|
@ -383,8 +383,7 @@ int dns_synthesize_answer(
|
||||
const char *name;
|
||||
int af;
|
||||
|
||||
if (key->class != DNS_CLASS_IN &&
|
||||
key->class != DNS_CLASS_ANY)
|
||||
if (!IN_SET(key->class, DNS_CLASS_IN, DNS_CLASS_ANY))
|
||||
continue;
|
||||
|
||||
name = dns_resource_key_name(key);
|
||||
|
@ -190,7 +190,7 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* We only support the IN class */
|
||||
if (key->class != DNS_CLASS_IN && key->class != DNS_CLASS_ANY)
|
||||
if (!IN_SET(key->class, DNS_CLASS_IN, DNS_CLASS_ANY))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (hashmap_size(s->manager->dns_transactions) >= TRANSACTIONS_MAX)
|
||||
@ -1593,7 +1593,7 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
log_debug("Sending query via TCP since it is too large.");
|
||||
else if (r == -EAGAIN)
|
||||
log_debug("Sending query via TCP since server doesn't support UDP.");
|
||||
if (r == -EMSGSIZE || r == -EAGAIN)
|
||||
if (IN_SET(r, -EMSGSIZE, -EAGAIN))
|
||||
r = dns_transaction_open_tcp(t);
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||
if (l == 0)
|
||||
return 0;
|
||||
if (l < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
if (IN_SET(errno, EAGAIN, EINTR))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
|
@ -87,7 +87,7 @@ int manager_read_resolv_conf(Manager *m) {
|
||||
char *l;
|
||||
|
||||
l = strstrip(line);
|
||||
if (*l == '#' || *l == ';')
|
||||
if (IN_SET(*l, '#', ';'))
|
||||
continue;
|
||||
|
||||
a = first_word(l, "nameserver");
|
||||
|
@ -337,7 +337,7 @@ int ask_password_tty(
|
||||
backspace_chars(ttyfd, p);
|
||||
p = 0;
|
||||
|
||||
} else if (c == '\b' || c == 127) {
|
||||
} else if (IN_SET(c, '\b', 127)) {
|
||||
|
||||
if (p > 0) {
|
||||
|
||||
|
@ -131,7 +131,7 @@ static int condition_test_kernel_command_line(Condition *c) {
|
||||
const char *f;
|
||||
|
||||
f = startswith(word, c->parameter);
|
||||
found = f && (*f == '=' || *f == 0);
|
||||
found = f && IN_SET(*f, 0, '=');
|
||||
}
|
||||
|
||||
if (found)
|
||||
|
@ -57,7 +57,7 @@ _unused_ static int probe_filesystem(const char *node, char **ret_fstype) {
|
||||
|
||||
errno = 0;
|
||||
r = blkid_do_safeprobe(b);
|
||||
if (r == -2 || r == 1) {
|
||||
if (IN_SET(r, -2, 1)) {
|
||||
log_debug("Failed to identify any partition type on partition %s", node);
|
||||
goto not_found;
|
||||
}
|
||||
@ -156,7 +156,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI
|
||||
|
||||
errno = 0;
|
||||
r = blkid_do_safeprobe(b);
|
||||
if (r == -2 || r == 1) {
|
||||
if (IN_SET(r, -2, 1)) {
|
||||
log_debug("Failed to identify any partition table.");
|
||||
return -ENOPKG;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
|
||||
/* Ending NUL */
|
||||
return -EINVAL;
|
||||
|
||||
else if (*n == '\\' || *n == '.') {
|
||||
else if (IN_SET(*n, '\\', '.')) {
|
||||
/* Escaped backslash or dot */
|
||||
|
||||
if (d)
|
||||
@ -164,7 +164,7 @@ int dns_label_unescape_suffix(const char *name, const char **label_terminal, cha
|
||||
}
|
||||
|
||||
terminal = *label_terminal;
|
||||
assert(*terminal == '.' || *terminal == 0);
|
||||
assert(IN_SET(*terminal, 0, '.'));
|
||||
|
||||
/* Skip current terminal character (and accept domain names ending it ".") */
|
||||
if (*terminal == 0)
|
||||
@ -228,7 +228,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) {
|
||||
q = dest;
|
||||
while (l > 0) {
|
||||
|
||||
if (*p == '.' || *p == '\\') {
|
||||
if (IN_SET(*p, '.', '\\')) {
|
||||
|
||||
/* Dot or backslash */
|
||||
|
||||
@ -240,8 +240,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) {
|
||||
|
||||
sz -= 2;
|
||||
|
||||
} else if (*p == '_' ||
|
||||
*p == '-' ||
|
||||
} else if (IN_SET(*p, '_', '-') ||
|
||||
(*p >= '0' && *p <= '9') ||
|
||||
(*p >= 'a' && *p <= 'z') ||
|
||||
(*p >= 'A' && *p <= 'Z')) {
|
||||
|
@ -110,7 +110,7 @@ int fw_add_masquerade(
|
||||
if (af != AF_INET)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (protocol != 0 && protocol != IPPROTO_TCP && protocol != IPPROTO_UDP)
|
||||
if (!IN_SET(protocol, 0, IPPROTO_TCP, IPPROTO_UDP))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
h = iptc_init("nat");
|
||||
@ -194,7 +194,7 @@ int fw_add_local_dnat(
|
||||
if (af != AF_INET)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP)
|
||||
if (!IN_SET(protocol, IPPROTO_TCP, IPPROTO_UDP))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (local_port <= 0)
|
||||
|
@ -683,7 +683,7 @@ void json_escape(
|
||||
fputc('\"', f);
|
||||
|
||||
while (l > 0) {
|
||||
if (*p == '"' || *p == '\\') {
|
||||
if (IN_SET(*p, '"', '\\')) {
|
||||
fputc('\\', f);
|
||||
fputc(*p, f);
|
||||
} else if (*p == '\n')
|
||||
|
@ -313,7 +313,7 @@ int image_find(const char *name, Image **ret) {
|
||||
}
|
||||
|
||||
r = image_make(NULL, dirfd(d), path, name, ret);
|
||||
if (r == 0 || r == -ENOENT) {
|
||||
if (IN_SET(r, 0, -ENOENT)) {
|
||||
_cleanup_free_ char *raw = NULL;
|
||||
|
||||
raw = strappend(name, ".raw");
|
||||
@ -321,7 +321,7 @@ int image_find(const char *name, Image **ret) {
|
||||
return -ENOMEM;
|
||||
|
||||
r = image_make(NULL, dirfd(d), path, raw, ret);
|
||||
if (r == 0 || r == -ENOENT)
|
||||
if (IN_SET(r, 0, -ENOENT))
|
||||
continue;
|
||||
}
|
||||
if (r < 0)
|
||||
@ -364,7 +364,7 @@ int image_discover(Hashmap *h) {
|
||||
continue;
|
||||
|
||||
r = image_make(NULL, dirfd(d), path, de->d_name, &image);
|
||||
if (r == 0 || r == -ENOENT)
|
||||
if (IN_SET(r, 0, -ENOENT))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -514,13 +514,13 @@ int lookup_paths_init(
|
||||
/* Note: if XDG_RUNTIME_DIR is not set, this will fail completely with ENXIO */
|
||||
r = acquire_generator_dirs(scope, tempdir,
|
||||
&generator, &generator_early, &generator_late);
|
||||
if (r < 0 && r != -EOPNOTSUPP && r != -ENXIO)
|
||||
if (r < 0 && !IN_SET(r, -EOPNOTSUPP, -ENXIO))
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Note: if XDG_RUNTIME_DIR is not set, this will fail completely with ENXIO */
|
||||
r = acquire_transient_dir(scope, tempdir, &transient);
|
||||
if (r < 0 && r != -EOPNOTSUPP && r != -ENXIO)
|
||||
if (r < 0 && !IN_SET(r, -EOPNOTSUPP, -ENXIO))
|
||||
return r;
|
||||
|
||||
/* Note: when XDG_RUNTIME_DIR is not set this will not return -ENXIO, but simply set runtime_control to NULL */
|
||||
|
@ -164,7 +164,7 @@ static int connection_shovel(
|
||||
if (z > 0) {
|
||||
*full += z;
|
||||
shoveled = true;
|
||||
} else if (z == 0 || errno == EPIPE || errno == ECONNRESET) {
|
||||
} else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {
|
||||
*from_source = sd_event_source_unref(*from_source);
|
||||
*from = safe_close(*from);
|
||||
} else if (!IN_SET(errno, EAGAIN, EINTR))
|
||||
@ -176,7 +176,7 @@ static int connection_shovel(
|
||||
if (z > 0) {
|
||||
*full -= z;
|
||||
shoveled = true;
|
||||
} else if (z == 0 || errno == EPIPE || errno == ECONNRESET) {
|
||||
} else if (z == 0 || IN_SET(errno, EPIPE, ECONNRESET)) {
|
||||
*to_source = sd_event_source_unref(*to_source);
|
||||
*to = safe_close(*to);
|
||||
} else if (!IN_SET(errno, EAGAIN, EINTR))
|
||||
|
@ -7815,7 +7815,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
|
||||
assert(argv);
|
||||
|
||||
if (utmp_get_runlevel(&runlevel, NULL) >= 0)
|
||||
if (runlevel == '0' || runlevel == '6')
|
||||
if (IN_SET(runlevel, '0', '6'))
|
||||
arg_force = 2;
|
||||
|
||||
while ((c = getopt_long(argc, argv, "pfwdnih", options, NULL)) >= 0)
|
||||
|
@ -1669,7 +1669,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
|
||||
v++;
|
||||
|
||||
l = strstrip(line);
|
||||
if (*l == '#' || *l == 0)
|
||||
if (IN_SET(*l, 0, '#'))
|
||||
continue;
|
||||
|
||||
k = parse_line(fn, v, l);
|
||||
|
@ -26,7 +26,7 @@ int main(int argc, char *argv[]) {
|
||||
int a, v;
|
||||
|
||||
v = detect_virtualization();
|
||||
if (v == -EPERM || v == -EACCES)
|
||||
if (IN_SET(v, -EPERM, -EACCES))
|
||||
return EXIT_TEST_SKIP;
|
||||
|
||||
assert_se(v >= 0);
|
||||
|
@ -40,7 +40,7 @@ static int test_cgroup_mask(void) {
|
||||
assert_se(set_unit_path(get_testdata_dir("")) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m);
|
||||
if (r == -EPERM || r == -EACCES) {
|
||||
if (IN_SET(r, -EPERM, -EACCES)) {
|
||||
puts("manager_new: Permission denied. Skipping test.");
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ static void test_clock_is_localtime_system(void) {
|
||||
log_info("/etc/adjtime exists, clock_is_localtime() == %i", r);
|
||||
/* if /etc/adjtime exists we expect some answer, no error or
|
||||
* crash */
|
||||
assert_se(r == 0 || r == 1);
|
||||
assert_se(IN_SET(r, 0, 1));
|
||||
} else
|
||||
/* default is UTC if there is no /etc/adjtime */
|
||||
assert_se(r == 0);
|
||||
|
@ -393,7 +393,7 @@ static void test_capeff(void) {
|
||||
r = get_process_capeff(0, &capeff);
|
||||
log_info("capeff: '%s' (r=%d)", capeff, r);
|
||||
|
||||
if (r == -ENOENT || r == -EPERM)
|
||||
if (IN_SET(r, -ENOENT, -EPERM))
|
||||
return;
|
||||
|
||||
assert_se(r == 0);
|
||||
@ -479,15 +479,15 @@ static void test_write_string_file_verify(void) {
|
||||
assert_se((buf2 = strjoin(buf, "\n")));
|
||||
|
||||
r = write_string_file("/proc/cmdline", buf, 0);
|
||||
assert_se(r == -EACCES || r == -EIO);
|
||||
assert_se(IN_SET(r, -EACCES, -EIO));
|
||||
r = write_string_file("/proc/cmdline", buf2, 0);
|
||||
assert_se(r == -EACCES || r == -EIO);
|
||||
assert_se(IN_SET(r, -EACCES, -EIO));
|
||||
|
||||
assert_se(write_string_file("/proc/cmdline", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
|
||||
assert_se(write_string_file("/proc/cmdline", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE) == 0);
|
||||
|
||||
r = write_string_file("/proc/cmdline", buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE);
|
||||
assert_se(r == -EACCES || r == -EIO);
|
||||
assert_se(IN_SET(r, -EACCES, -EIO));
|
||||
assert_se(write_string_file("/proc/cmdline", buf2, WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_AVOID_NEWLINE) == 0);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ static int print_gaih_addrtuples(const struct gaih_addrtuple *tuples) {
|
||||
|
||||
memcpy(&u, it->addr, 16);
|
||||
r = in_addr_to_string(it->family, &u, &a);
|
||||
assert_se(r == 0 || r == -EAFNOSUPPORT);
|
||||
assert_se(IN_SET(r, 0, -EAFNOSUPPORT));
|
||||
if (r == -EAFNOSUPPORT)
|
||||
assert_se((a = hexmem(it->addr, 16)));
|
||||
|
||||
|
@ -55,7 +55,7 @@ static int test_unit_file_get_set(void) {
|
||||
|
||||
r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h, NULL, NULL);
|
||||
|
||||
if (r == -EPERM || r == -EACCES) {
|
||||
if (IN_SET(r, -EPERM, -EACCES)) {
|
||||
log_notice_errno(r, "Skipping test: unit_file_get_list: %m");
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ static int dir_is_mount_point(DIR *d, const char *subdir) {
|
||||
|
||||
/* got only one handle; assume different mount points if one
|
||||
* of both queries was not supported by the filesystem */
|
||||
if (r_p == -ENOSYS || r_p == -EOPNOTSUPP || r == -ENOSYS || r == -EOPNOTSUPP)
|
||||
if (IN_SET(r_p, -ENOSYS, -EOPNOTSUPP) || IN_SET(r, -ENOSYS, -EOPNOTSUPP))
|
||||
return true;
|
||||
|
||||
/* return error */
|
||||
@ -501,7 +501,7 @@ static int dir_cleanup(
|
||||
|
||||
log_debug("Removing directory \"%s\".", sub_path);
|
||||
if (unlinkat(dirfd(d), dent->d_name, AT_REMOVEDIR) < 0)
|
||||
if (errno != ENOENT && errno != ENOTEMPTY) {
|
||||
if (!IN_SET(errno, ENOENT, ENOTEMPTY)) {
|
||||
log_error_errno(errno, "rmdir(%s): %m", sub_path);
|
||||
r = -errno;
|
||||
}
|
||||
@ -984,7 +984,7 @@ static int path_set_attribute(Item *item, const char *path) {
|
||||
|
||||
r = chattr_fd(fd, f, item->attribute_mask);
|
||||
if (r < 0)
|
||||
log_full_errno(r == -ENOTTY || r == -EOPNOTSUPP ? LOG_DEBUG : LOG_WARNING,
|
||||
log_full_errno(IN_SET(r, -ENOTTY, -EOPNOTSUPP) ? LOG_DEBUG : LOG_WARNING,
|
||||
r,
|
||||
"Cannot set file attribute for '%s', value=0x%08x, mask=0x%08x: %m",
|
||||
path, item->attribute_value, item->attribute_mask);
|
||||
@ -1075,7 +1075,7 @@ static int item_do_children(Item *i, const char *path, action_t action) {
|
||||
|
||||
d = opendir_nomod(path);
|
||||
if (!d)
|
||||
return errno == ENOENT || errno == ENOTDIR ? 0 : -errno;
|
||||
return IN_SET(errno, ENOENT, ENOTDIR) ? 0 : -errno;
|
||||
|
||||
FOREACH_DIRENT_ALL(de, d, r = -errno) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
@ -1253,7 +1253,7 @@ static int create_item(Item *i) {
|
||||
if (r < 0) {
|
||||
int k;
|
||||
|
||||
if (r != -EEXIST && r != -EROFS)
|
||||
if (!IN_SET(r, -EEXIST, -EROFS))
|
||||
return log_error_errno(r, "Failed to create directory or subvolume \"%s\": %m", i->path);
|
||||
|
||||
k = is_dir(i->path, false);
|
||||
@ -2215,7 +2215,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
|
||||
v++;
|
||||
|
||||
l = strstrip(line);
|
||||
if (*l == '#' || *l == 0)
|
||||
if (IN_SET(*l, 0, '#'))
|
||||
continue;
|
||||
|
||||
k = parse_line(fn, v, l);
|
||||
|
@ -206,7 +206,7 @@ static int ask_password_plymouth(
|
||||
r = -ENOENT;
|
||||
goto finish;
|
||||
|
||||
} else if (buffer[0] == 2 || buffer[0] == 9) {
|
||||
} else if (IN_SET(buffer[0], 2, 9)) {
|
||||
uint32_t size;
|
||||
char **l;
|
||||
|
||||
|
@ -617,7 +617,7 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
|
||||
word = identify.wyde[76];
|
||||
if (word != 0x0000 && word != 0xffff) {
|
||||
if (!IN_SET(word, 0x0000, 0xffff)) {
|
||||
printf("ID_ATA_SATA=1\n");
|
||||
/*
|
||||
* If bit 2 of word 76 is set to one, then the device supports the Gen2
|
||||
@ -661,8 +661,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* from Linux's include/linux/ata.h */
|
||||
if (identify.wyde[0] == 0x848a ||
|
||||
identify.wyde[0] == 0x844a ||
|
||||
if (IN_SET(identify.wyde[0], 0x848a, 0x844a) ||
|
||||
(identify.wyde[83] & 0xc004) == 0x4004)
|
||||
printf("ID_ATA_CFA=1\n");
|
||||
} else {
|
||||
|
@ -544,7 +544,7 @@ static int cd_profiles(struct udev *udev, int fd)
|
||||
if ((err != 0)) {
|
||||
info_scsi_cmd_err(udev, "GET CONFIGURATION", err);
|
||||
/* handle pre-MMC2 drives which do not support GET CONFIGURATION */
|
||||
if (SK(err) == 0x5 && (ASC(err) == 0x20 || ASC(err) == 0x24)) {
|
||||
if (SK(err) == 0x5 && IN_SET(ASC(err), 0x20, 0x24)) {
|
||||
log_debug("drive is pre-MMC2 and does not support 46h get configuration command");
|
||||
log_debug("trying to work around the problem");
|
||||
ret = cd_profiles_old_mmc(udev, fd);
|
||||
|
@ -115,9 +115,8 @@ static int sg_err_category_new(struct udev *udev,
|
||||
if (!scsi_status && !host_status && !driver_status)
|
||||
return SG_ERR_CAT_CLEAN;
|
||||
|
||||
if ((scsi_status == SCSI_CHECK_CONDITION) ||
|
||||
(scsi_status == SCSI_COMMAND_TERMINATED) ||
|
||||
((driver_status & 0xf) == DRIVER_SENSE)) {
|
||||
if (IN_SET(scsi_status, SCSI_CHECK_CONDITION, SCSI_COMMAND_TERMINATED) ||
|
||||
(driver_status & 0xf) == DRIVER_SENSE) {
|
||||
if (sense_buffer && (sb_len > 2)) {
|
||||
int sense_key;
|
||||
unsigned char asc;
|
||||
@ -143,9 +142,7 @@ static int sg_err_category_new(struct udev *udev,
|
||||
return SG_ERR_CAT_SENSE;
|
||||
}
|
||||
if (host_status) {
|
||||
if ((host_status == DID_NO_CONNECT) ||
|
||||
(host_status == DID_BUS_BUSY) ||
|
||||
(host_status == DID_TIME_OUT))
|
||||
if (IN_SET(host_status, DID_NO_CONNECT, DID_BUS_BUSY, DID_TIME_OUT))
|
||||
return SG_ERR_CAT_TIMEOUT;
|
||||
}
|
||||
if (driver_status) {
|
||||
@ -215,7 +212,7 @@ static int scsi_dump_sense(struct udev *udev,
|
||||
dev_scsi->kernel, sb_len, s - sb_len);
|
||||
return -1;
|
||||
}
|
||||
if ((code == 0x0) || (code == 0x1)) {
|
||||
if (IN_SET(code, 0x0, 0x1)) {
|
||||
sense_key = sense_buffer[2] & 0xf;
|
||||
if (s < 14) {
|
||||
/*
|
||||
@ -227,7 +224,7 @@ static int scsi_dump_sense(struct udev *udev,
|
||||
}
|
||||
asc = sense_buffer[12];
|
||||
ascq = sense_buffer[13];
|
||||
} else if ((code == 0x2) || (code == 0x3)) {
|
||||
} else if (IN_SET(code, 0x2, 0x3)) {
|
||||
sense_key = sense_buffer[1] & 0xf;
|
||||
asc = sense_buffer[2];
|
||||
ascq = sense_buffer[3];
|
||||
|
@ -47,7 +47,7 @@ static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool
|
||||
seat = "seat0";
|
||||
|
||||
r = sd_seat_get_active(seat, NULL, &uid);
|
||||
if (r == -ENXIO || r == -ENODATA) {
|
||||
if (IN_SET(r, -ENXIO, -ENODATA)) {
|
||||
/* No active session on this seat */
|
||||
r = 0;
|
||||
goto finish;
|
||||
|
@ -307,7 +307,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||
dev_if_packed_info(dev_usb, packed_if_str, sizeof(packed_if_str));
|
||||
|
||||
/* mass storage : SCSI or ATAPI */
|
||||
if (protocol == 6 || protocol == 2) {
|
||||
if (IN_SET(protocol, 6, 2)) {
|
||||
struct udev_device *dev_scsi;
|
||||
const char *scsi_model, *scsi_vendor, *scsi_type, *scsi_rev;
|
||||
int host, bus, target, lun;
|
||||
|
@ -87,7 +87,7 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s
|
||||
log_debug("creating symlink '%s' to '%s'", slink, target);
|
||||
do {
|
||||
err = mkdir_parents_label(slink, 0755);
|
||||
if (err != 0 && err != -ENOENT)
|
||||
if (!IN_SET(err, 0, -ENOENT))
|
||||
break;
|
||||
mac_selinux_create_file_prepare(slink, S_IFLNK);
|
||||
err = symlink(target, slink);
|
||||
@ -104,7 +104,7 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s
|
||||
unlink(slink_tmp);
|
||||
do {
|
||||
err = mkdir_parents_label(slink_tmp, 0755);
|
||||
if (err != 0 && err != -ENOENT)
|
||||
if (!IN_SET(err, 0, -ENOENT))
|
||||
break;
|
||||
mac_selinux_create_file_prepare(slink_tmp, S_IFLNK);
|
||||
err = symlink(target, slink_tmp);
|
||||
@ -209,7 +209,7 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) {
|
||||
int fd;
|
||||
|
||||
err = mkdir_parents(filename, 0755);
|
||||
if (err != 0 && err != -ENOENT)
|
||||
if (!IN_SET(err, 0, -ENOENT))
|
||||
break;
|
||||
fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
|
||||
if (fd >= 0)
|
||||
|
@ -579,7 +579,7 @@ static int import_property_from_string(struct udev_device *dev, char *line) {
|
||||
key++;
|
||||
|
||||
/* comment or empty line */
|
||||
if (key[0] == '#' || key[0] == '\0')
|
||||
if (IN_SET(key[0], '#', '\0'))
|
||||
return -1;
|
||||
|
||||
/* split key/value */
|
||||
@ -613,7 +613,7 @@ static int import_property_from_string(struct udev_device *dev, char *line) {
|
||||
return -1;
|
||||
|
||||
/* unquote */
|
||||
if (val[0] == '"' || val[0] == '\'') {
|
||||
if (IN_SET(val[0], '"', '\'')) {
|
||||
if (len == 1 || val[len-1] != val[0]) {
|
||||
log_debug("inconsistent quoting: '%s', skip", line);
|
||||
return -1;
|
||||
@ -741,7 +741,7 @@ static int get_key(struct udev *udev, char **line, char **key, enum operation_ty
|
||||
break;
|
||||
if (linepos[0] == '=')
|
||||
break;
|
||||
if ((linepos[0] == '+') || (linepos[0] == '-') || (linepos[0] == '!') || (linepos[0] == ':'))
|
||||
if (IN_SET(linepos[0], '+', '-', '!', ':'))
|
||||
if (linepos[1] == '=')
|
||||
break;
|
||||
}
|
||||
@ -1968,7 +1968,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
int count;
|
||||
|
||||
util_remove_trailing_chars(result, '\n');
|
||||
if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) {
|
||||
if (IN_SET(esc, ESCAPE_UNSET, ESCAPE_REPLACE)) {
|
||||
count = util_replace_chars(result, UDEV_ALLOWED_CHARS_INPUT);
|
||||
if (count > 0)
|
||||
log_debug("%i character(s) replaced" , count);
|
||||
@ -2219,7 +2219,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
else
|
||||
label = rules_str(rules, cur->key.value_off);
|
||||
|
||||
if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
|
||||
if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL))
|
||||
udev_list_cleanup(&event->seclabel_list);
|
||||
udev_list_entry_add(&event->seclabel_list, name, label);
|
||||
log_debug("SECLABEL{%s}='%s' %s:%u",
|
||||
@ -2260,13 +2260,13 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
const char *p;
|
||||
|
||||
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), tag, sizeof(tag), false);
|
||||
if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
|
||||
if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL))
|
||||
udev_device_cleanup_tags_list(event->dev);
|
||||
for (p = tag; *p != '\0'; p++) {
|
||||
if ((*p >= 'a' && *p <= 'z') ||
|
||||
(*p >= 'A' && *p <= 'Z') ||
|
||||
(*p >= '0' && *p <= '9') ||
|
||||
*p == '-' || *p == '_')
|
||||
IN_SET(*p, '-', '_'))
|
||||
continue;
|
||||
log_error("ignoring invalid tag name '%s'", tag);
|
||||
break;
|
||||
@ -2288,7 +2288,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
if (cur->key.op == OP_ASSIGN_FINAL)
|
||||
event->name_final = true;
|
||||
udev_event_apply_format(event, name, name_str, sizeof(name_str), false);
|
||||
if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) {
|
||||
if (IN_SET(esc, ESCAPE_UNSET, ESCAPE_REPLACE)) {
|
||||
count = util_replace_chars(name_str, "/");
|
||||
if (count > 0)
|
||||
log_debug("%i character(s) replaced", count);
|
||||
@ -2323,7 +2323,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
break;
|
||||
if (cur->key.op == OP_ASSIGN_FINAL)
|
||||
event->devlink_final = true;
|
||||
if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
|
||||
if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL))
|
||||
udev_device_cleanup_devlinks_list(event->dev);
|
||||
|
||||
/* allow multiple symlinks separated by spaces */
|
||||
@ -2396,7 +2396,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
case TK_A_RUN_PROGRAM: {
|
||||
struct udev_list_entry *entry;
|
||||
|
||||
if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
|
||||
if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL))
|
||||
udev_list_cleanup(&event->run_list);
|
||||
log_debug("RUN '%s' %s:%u",
|
||||
rules_str(rules, cur->key.value_off),
|
||||
|
@ -183,7 +183,7 @@ static int on_runlevel(Context *c) {
|
||||
q = utmp_get_runlevel(&previous, NULL);
|
||||
|
||||
if (q < 0) {
|
||||
if (q != -ESRCH && q != -ENOENT)
|
||||
if (!IN_SET(q, -ESRCH, -ENOENT))
|
||||
return log_error_errno(q, "Failed to get current runlevel: %m");
|
||||
|
||||
previous = 0;
|
||||
@ -213,7 +213,7 @@ static int on_runlevel(Context *c) {
|
||||
#endif
|
||||
|
||||
q = utmp_put_runlevel(runlevel, previous);
|
||||
if (q < 0 && q != -ESRCH && q != -ENOENT) {
|
||||
if (q < 0 && !IN_SET(q, -ESRCH, -ENOENT)) {
|
||||
log_error_errno(q, "Failed to write utmp record: %m");
|
||||
r = q;
|
||||
}
|
||||
@ -249,7 +249,7 @@ int main(int argc, char *argv[]) {
|
||||
/* If the kernel lacks netlink or audit support,
|
||||
* don't worry about it. */
|
||||
c.audit_fd = audit_open();
|
||||
if (c.audit_fd < 0 && errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
|
||||
if (c.audit_fd < 0 && !IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT))
|
||||
log_error_errno(errno, "Failed to connect to audit log: %m");
|
||||
#endif
|
||||
r = bus_connect_system_systemd(&c.bus);
|
||||
|
Loading…
x
Reference in New Issue
Block a user