tree-wide: use IN_SET where possible

In addition to the changes from #6933 this handles cases that could be
matched with the included cocci file.
This commit is contained in:
Andreas Rammhold 2017-09-29 00:37:23 +02:00
parent 01a65d4180
commit 3742095b27
No known key found for this signature in database
GPG key ID: E432E410B5E48C86
58 changed files with 140 additions and 131 deletions

35
coccinelle/in_set.cocci Normal file
View file

@ -0,0 +1,35 @@
@@
expression e;
identifier n1, n2, n3, n4, n5, n6;
statement s;
@@
- e == n1 || e == n2 || e == n3 || e == n4 || e == n5 || e == n6
+ IN_SET(e, n1, n2, n3, n4, n5, n6)
@@
expression e;
identifier n1, n2, n3, n4, n5;
statement s;
@@
- e == n1 || e == n2 || e == n3 || e == n4 || e == n5
+ IN_SET(e, n1, n2, n3, n4, n5)
@@
expression e;
identifier n1, n2, n3, n4;
statement s;
@@
- e == n1 || e == n2 || e == n3 || e == n4
+ IN_SET(e, n1, n2, n3, n4)
@@
expression e;
identifier n1, n2, n3;
statement s;
@@
- e == n1 || e == n2 || e == n3
+ IN_SET(e, n1, n2, n3)
@@
expression e;
identifier n, p;
statement s;
@@
- e == n || e == p
+ IN_SET(e, n, p)

View file

@ -171,7 +171,7 @@ void barrier_set_role(Barrier *b, unsigned int role) {
int fd; int fd;
assert(b); assert(b);
assert(role == BARRIER_PARENT || role == BARRIER_CHILD); assert(IN_SET(role, BARRIER_PARENT, BARRIER_CHILD));
/* make sure this is only called once */ /* make sure this is only called once */
assert(b->pipe[0] >= 0 && b->pipe[1] >= 0); assert(b->pipe[0] >= 0 && b->pipe[1] >= 0);

View file

@ -70,11 +70,11 @@ bool barrier_sync_next(Barrier *b);
bool barrier_sync(Barrier *b); bool barrier_sync(Barrier *b);
static inline bool barrier_i_aborted(Barrier *b) { static inline bool barrier_i_aborted(Barrier *b) {
return b->barriers == BARRIER_I_ABORTED || b->barriers == BARRIER_WE_ABORTED; return IN_SET(b->barriers, BARRIER_I_ABORTED, BARRIER_WE_ABORTED);
} }
static inline bool barrier_they_aborted(Barrier *b) { static inline bool barrier_they_aborted(Barrier *b) {
return b->barriers == BARRIER_THEY_ABORTED || b->barriers == BARRIER_WE_ABORTED; return IN_SET(b->barriers, BARRIER_THEY_ABORTED, BARRIER_WE_ABORTED);
} }
static inline bool barrier_we_aborted(Barrier *b) { static inline bool barrier_we_aborted(Barrier *b) {
@ -82,7 +82,8 @@ static inline bool barrier_we_aborted(Barrier *b) {
} }
static inline bool barrier_is_aborted(Barrier *b) { static inline bool barrier_is_aborted(Barrier *b) {
return b->barriers == BARRIER_I_ABORTED || b->barriers == BARRIER_THEY_ABORTED || b->barriers == BARRIER_WE_ABORTED; return IN_SET(b->barriers, BARRIER_I_ABORTED, BARRIER_THEY_ABORTED,
BARRIER_WE_ABORTED);
} }
static inline bool barrier_place_and_sync(Barrier *b) { static inline bool barrier_place_and_sync(Barrier *b) {

View file

@ -927,7 +927,7 @@ static bool hashmap_put_robin_hood(HashmapBase *h, unsigned idx,
for (distance = 0; ; distance++) { for (distance = 0; ; distance++) {
raw_dib = dibs[idx]; raw_dib = dibs[idx];
if (raw_dib == DIB_RAW_FREE || raw_dib == DIB_RAW_REHASH) { if (IN_SET(raw_dib, DIB_RAW_FREE, DIB_RAW_REHASH)) {
if (raw_dib == DIB_RAW_REHASH) if (raw_dib == DIB_RAW_REHASH)
bucket_move_entry(h, swap, idx, IDX_TMP); bucket_move_entry(h, swap, idx, IDX_TMP);

View file

@ -66,7 +66,7 @@ int in_addr_prefix_from_string(const char *p, int family, union in_addr_union *r
int in_addr_prefix_from_string_auto(const char *p, int *ret_family, union in_addr_union *ret_prefix, unsigned char *ret_prefixlen); int in_addr_prefix_from_string_auto(const char *p, int *ret_family, union in_addr_union *ret_prefix, unsigned char *ret_prefixlen);
static inline size_t FAMILY_ADDRESS_SIZE(int family) { static inline size_t FAMILY_ADDRESS_SIZE(int family) {
assert(family == AF_INET || family == AF_INET6); assert(IN_SET(family, AF_INET, AF_INET6));
return family == AF_INET6 ? 16 : 4; return family == AF_INET6 ? 16 : 4;
} }

View file

@ -154,9 +154,7 @@ static int get_line(JournalImporter *imp, char **line, size_t *size) {
static int fill_fixed_size(JournalImporter *imp, void **data, size_t size) { static int fill_fixed_size(JournalImporter *imp, void **data, size_t size) {
assert(imp); assert(imp);
assert(imp->state == IMPORTER_STATE_DATA_START || assert(IN_SET(imp->state, IMPORTER_STATE_DATA_START, IMPORTER_STATE_DATA, IMPORTER_STATE_DATA_FINISH));
imp->state == IMPORTER_STATE_DATA ||
imp->state == IMPORTER_STATE_DATA_FINISH);
assert(size <= DATA_SIZE_MAX); assert(size <= DATA_SIZE_MAX);
assert(imp->offset <= imp->filled); assert(imp->offset <= imp->filled);
assert(imp->filled <= imp->size); assert(imp->filled <= imp->size);

View file

@ -688,8 +688,7 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_cod
log_debug("%s succeeded.", name); log_debug("%s succeeded.", name);
return status.si_status; return status.si_status;
} else if (status.si_code == CLD_KILLED || } else if (IN_SET(status.si_code, CLD_KILLED, CLD_DUMPED)) {
status.si_code == CLD_DUMPED) {
log_warning("%s terminated by signal %s.", name, signal_to_string(status.si_status)); log_warning("%s terminated by signal %s.", name, signal_to_string(status.si_status));
return -EPROTO; return -EPROTO;

View file

@ -38,7 +38,7 @@ int reset_all_signal_handlers(void) {
for (sig = 1; sig < _NSIG; sig++) { for (sig = 1; sig < _NSIG; sig++) {
/* These two cannot be caught... */ /* These two cannot be caught... */
if (sig == SIGKILL || sig == SIGSTOP) if (IN_SET(sig, SIGKILL, SIGSTOP))
continue; continue;
/* On Linux the first two RT signals are reserved by /* On Linux the first two RT signals are reserved by

View file

@ -364,8 +364,7 @@ bool socket_address_can_accept(const SocketAddress *a) {
assert(a); assert(a);
return return
a->type == SOCK_STREAM || IN_SET(a->type, SOCK_STREAM, SOCK_SEQPACKET);
a->type == SOCK_SEQPACKET;
} }
bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) { bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) {
@ -1081,7 +1080,7 @@ ssize_t next_datagram_size_fd(int fd) {
l = recv(fd, NULL, 0, MSG_PEEK|MSG_TRUNC); l = recv(fd, NULL, 0, MSG_PEEK|MSG_TRUNC);
if (l < 0) { if (l < 0) {
if (errno == EOPNOTSUPP || errno == EFAULT) if (IN_SET(errno, EOPNOTSUPP, EFAULT))
goto fallback; goto fallback;
return -errno; return -errno;

View file

@ -476,7 +476,7 @@ int acquire_terminal(
l = read(notify, &buffer, sizeof(buffer)); l = read(notify, &buffer, sizeof(buffer));
if (l < 0) { if (l < 0) {
if (errno == EINTR || errno == EAGAIN) if (IN_SET(errno, EINTR, EAGAIN))
continue; continue;
r = -errno; r = -errno;

View file

@ -378,7 +378,7 @@ int on_ac_power(void) {
device = openat(dirfd(d), de->d_name, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_NOCTTY); device = openat(dirfd(d), de->d_name, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (device < 0) { if (device < 0) {
if (errno == ENOENT || errno == ENOTDIR) if (IN_SET(errno, ENOENT, ENOTDIR))
continue; continue;
return -errno; return -errno;

View file

@ -804,7 +804,7 @@ static int automount_start(Unit *u) {
int r; int r;
assert(a); assert(a);
assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED); assert(IN_SET(a->state, AUTOMOUNT_DEAD, AUTOMOUNT_FAILED));
if (path_is_mount_point(a->where, NULL, 0) > 0) { if (path_is_mount_point(a->where, NULL, 0) > 0) {
log_unit_error(u, "Path %s is already a mount point, refusing start.", a->where); log_unit_error(u, "Path %s is already a mount point, refusing start.", a->where);
@ -836,7 +836,7 @@ static int automount_stop(Unit *u) {
Automount *a = AUTOMOUNT(u); Automount *a = AUTOMOUNT(u);
assert(a); assert(a);
assert(a->state == AUTOMOUNT_WAITING || a->state == AUTOMOUNT_RUNNING); assert(IN_SET(a->state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING));
automount_enter_dead(a, AUTOMOUNT_SUCCESS); automount_enter_dead(a, AUTOMOUNT_SUCCESS);
return 1; return 1;

View file

@ -1253,13 +1253,13 @@ int bus_unit_queue_job(
} }
if (type == JOB_STOP && if (type == JOB_STOP &&
(u->load_state == UNIT_NOT_FOUND || u->load_state == UNIT_ERROR) && (IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_ERROR)) &&
unit_active_state(u) == UNIT_INACTIVE) unit_active_state(u) == UNIT_INACTIVE)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", u->id); return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", u->id);
if ((type == JOB_START && u->refuse_manual_start) || if ((type == JOB_START && u->refuse_manual_start) ||
(type == JOB_STOP && u->refuse_manual_stop) || (type == JOB_STOP && u->refuse_manual_stop) ||
((type == JOB_RESTART || type == JOB_TRY_RESTART) && (u->refuse_manual_start || u->refuse_manual_stop)) || (IN_SET(type, JOB_RESTART, JOB_TRY_RESTART) && (u->refuse_manual_start || u->refuse_manual_stop)) ||
(type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start)) (type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start))
return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id); return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id);

View file

@ -221,7 +221,7 @@ static int pick_uid(const char *name, uid_t *ret_uid) {
r = flock(lock_fd, LOCK_EX|LOCK_NB); /* Try to get a BSD file lock on the UID lock file */ r = flock(lock_fd, LOCK_EX|LOCK_NB); /* Try to get a BSD file lock on the UID lock file */
if (r < 0) { if (r < 0) {
if (errno == EBUSY || errno == EAGAIN) if (IN_SET(errno, EBUSY, EAGAIN))
goto next; /* already in use */ goto next; /* already in use */
return -errno; return -errno;

View file

@ -368,19 +368,13 @@ bool job_type_is_redundant(JobType a, UnitActiveState b) {
switch (a) { switch (a) {
case JOB_START: case JOB_START:
return return IN_SET(b, UNIT_ACTIVE, UNIT_RELOADING);
b == UNIT_ACTIVE ||
b == UNIT_RELOADING;
case JOB_STOP: case JOB_STOP:
return return IN_SET(b, UNIT_INACTIVE, UNIT_FAILED);
b == UNIT_INACTIVE ||
b == UNIT_FAILED;
case JOB_VERIFY_ACTIVE: case JOB_VERIFY_ACTIVE:
return return IN_SET(b, UNIT_ACTIVE, UNIT_RELOADING);
b == UNIT_ACTIVE ||
b == UNIT_RELOADING;
case JOB_RELOAD: case JOB_RELOAD:
return return
@ -888,7 +882,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr
goto finish; goto finish;
} }
if (result == JOB_FAILED || result == JOB_INVALID) if (IN_SET(result, JOB_FAILED, JOB_INVALID))
j->manager->n_failed_jobs++; j->manager->n_failed_jobs++;
job_uninstall(j); job_uninstall(j);

View file

@ -1442,7 +1442,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_e
return -ENOMEM; return -ENOMEM;
r = transaction_add_job_and_dependencies(tr, type, unit, NULL, true, false, r = transaction_add_job_and_dependencies(tr, type, unit, NULL, true, false,
mode == JOB_IGNORE_DEPENDENCIES || mode == JOB_IGNORE_REQUIREMENTS, IN_SET(mode, JOB_IGNORE_DEPENDENCIES, JOB_IGNORE_REQUIREMENTS),
mode == JOB_IGNORE_DEPENDENCIES, e); mode == JOB_IGNORE_DEPENDENCIES, e);
if (r < 0) if (r < 0)
goto tr_abort; goto tr_abort;
@ -1985,7 +1985,7 @@ static int manager_dispatch_sigchld(Manager *m) {
if (si.si_pid <= 0) if (si.si_pid <= 0)
break; break;
if (si.si_code == CLD_EXITED || si.si_code == CLD_KILLED || si.si_code == CLD_DUMPED) { if (IN_SET(si.si_code, CLD_EXITED, CLD_KILLED, CLD_DUMPED)) {
_cleanup_free_ char *name = NULL; _cleanup_free_ char *name = NULL;
Unit *u1, *u2, *u3; Unit *u1, *u2, *u3;

View file

@ -97,7 +97,7 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) {
r = inotify_add_watch(s->inotify_fd, s->path, flags); r = inotify_add_watch(s->inotify_fd, s->path, flags);
if (r < 0) { if (r < 0) {
if (errno == EACCES || errno == ENOENT) { if (IN_SET(errno, EACCES, ENOENT)) {
if (cut) if (cut)
*cut = tmp; *cut = tmp;
break; break;
@ -168,14 +168,14 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
l = read(s->inotify_fd, &buffer, sizeof(buffer)); l = read(s->inotify_fd, &buffer, sizeof(buffer));
if (l < 0) { if (l < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
return log_error_errno(errno, "Failed to read inotify event: %m"); return log_error_errno(errno, "Failed to read inotify event: %m");
} }
FOREACH_INOTIFY_EVENT(e, buffer, l) { FOREACH_INOTIFY_EVENT(e, buffer, l) {
if ((s->type == PATH_CHANGED || s->type == PATH_MODIFIED) && if (IN_SET(s->type, PATH_CHANGED, PATH_MODIFIED) &&
s->primary_wd == e->wd) s->primary_wd == e->wd)
r = 1; r = 1;
} }
@ -224,7 +224,7 @@ static bool path_spec_check_good(PathSpec *s, bool initial) {
static void path_spec_mkdir(PathSpec *s, mode_t mode) { static void path_spec_mkdir(PathSpec *s, mode_t mode) {
int r; int r;
if (s->type == PATH_EXISTS || s->type == PATH_EXISTS_GLOB) if (IN_SET(s->type, PATH_EXISTS, PATH_EXISTS_GLOB))
return; return;
r = mkdir_p_label(s->path, mode); r = mkdir_p_label(s->path, mode);
@ -441,8 +441,7 @@ static int path_coldplug(Unit *u) {
if (p->deserialized_state != p->state) { if (p->deserialized_state != p->state) {
if (p->deserialized_state == PATH_WAITING || if (IN_SET(p->deserialized_state, PATH_WAITING, PATH_RUNNING))
p->deserialized_state == PATH_RUNNING)
path_enter_waiting(p, true, true); path_enter_waiting(p, true, true);
else else
path_set_state(p, p->deserialized_state); path_set_state(p, p->deserialized_state);
@ -566,7 +565,7 @@ static int path_start(Unit *u) {
int r; int r;
assert(p); assert(p);
assert(p->state == PATH_DEAD || p->state == PATH_FAILED); assert(IN_SET(p->state, PATH_DEAD, PATH_FAILED));
trigger = UNIT_TRIGGER(u); trigger = UNIT_TRIGGER(u);
if (!trigger || trigger->load_state != UNIT_LOADED) { if (!trigger || trigger->load_state != UNIT_LOADED) {
@ -596,7 +595,7 @@ static int path_stop(Unit *u) {
Path *p = PATH(u); Path *p = PATH(u);
assert(p); assert(p);
assert(p->state == PATH_WAITING || p->state == PATH_RUNNING); assert(IN_SET(p->state, PATH_WAITING, PATH_RUNNING));
path_enter_dead(p, PATH_SUCCESS); path_enter_dead(p, PATH_SUCCESS);
return 1; return 1;

View file

@ -322,8 +322,7 @@ static int scope_start(Unit *u) {
return -EPERM; return -EPERM;
/* We can't fulfill this right now, please try again later */ /* We can't fulfill this right now, please try again later */
if (s->state == SCOPE_STOP_SIGTERM || if (IN_SET(s->state, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL))
s->state == SCOPE_STOP_SIGKILL)
return -EAGAIN; return -EAGAIN;
assert(s->state == SCOPE_DEAD); assert(s->state == SCOPE_DEAD);
@ -357,12 +356,10 @@ static int scope_stop(Unit *u) {
assert(s); assert(s);
if (s->state == SCOPE_STOP_SIGTERM || if (IN_SET(s->state, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL))
s->state == SCOPE_STOP_SIGKILL)
return 0; return 0;
assert(s->state == SCOPE_RUNNING || assert(IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED));
s->state == SCOPE_ABANDONED);
scope_enter_signal(s, SCOPE_STOP_SIGTERM, SCOPE_SUCCESS); scope_enter_signal(s, SCOPE_STOP_SIGTERM, SCOPE_SUCCESS);
return 1; return 1;

View file

@ -529,7 +529,7 @@ static int service_verify(Service *s) {
if (s->bus_name && s->type != SERVICE_DBUS) if (s->bus_name && s->type != SERVICE_DBUS)
log_unit_warning(UNIT(s), "Service has a D-Bus service name specified, but is not of type dbus. Ignoring."); log_unit_warning(UNIT(s), "Service has a D-Bus service name specified, but is not of type dbus. Ignoring.");
if (s->exec_context.pam_name && !(s->kill_context.kill_mode == KILL_CONTROL_GROUP || s->kill_context.kill_mode == KILL_MIXED)) { if (s->exec_context.pam_name && !IN_SET(s->kill_context.kill_mode, KILL_CONTROL_GROUP, KILL_MIXED)) {
log_unit_error(UNIT(s), "Service has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing."); log_unit_error(UNIT(s), "Service has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing.");
return -EINVAL; return -EINVAL;
} }
@ -2224,7 +2224,7 @@ static int service_reload(Unit *u) {
assert(s); assert(s);
assert(s->state == SERVICE_RUNNING || s->state == SERVICE_EXITED); assert(IN_SET(s->state, SERVICE_RUNNING, SERVICE_EXITED));
service_enter_reload(s); service_enter_reload(s);
return 1; return 1;
@ -2755,7 +2755,7 @@ static int service_retry_pid_file(Service *s) {
int r; int r;
assert(s->pid_file); assert(s->pid_file);
assert(s->state == SERVICE_START || s->state == SERVICE_START_POST); assert(IN_SET(s->state, SERVICE_START, SERVICE_START_POST));
r = service_load_pid_file(s, false); r = service_load_pid_file(s, false);
if (r < 0) if (r < 0)
@ -2826,7 +2826,7 @@ static int service_dispatch_io(sd_event_source *source, int fd, uint32_t events,
assert(s); assert(s);
assert(fd >= 0); assert(fd >= 0);
assert(s->state == SERVICE_START || s->state == SERVICE_START_POST); assert(IN_SET(s->state, SERVICE_START, SERVICE_START_POST));
assert(s->pid_file_pathspec); assert(s->pid_file_pathspec);
assert(path_spec_owns_inotify_fd(s->pid_file_pathspec, fd)); assert(path_spec_owns_inotify_fd(s->pid_file_pathspec, fd));

View file

@ -2083,7 +2083,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
fail: fail:
log_unit_warning_errno(UNIT(s), r, "Failed to kill processes: %m"); log_unit_warning_errno(UNIT(s), r, "Failed to kill processes: %m");
if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL) if (IN_SET(state, SOCKET_STOP_PRE_SIGTERM, SOCKET_STOP_PRE_SIGKILL))
socket_enter_stop_post(s, SOCKET_FAILURE_RESOURCES); socket_enter_stop_post(s, SOCKET_FAILURE_RESOURCES);
else else
socket_enter_dead(s, SOCKET_FAILURE_RESOURCES); socket_enter_dead(s, SOCKET_FAILURE_RESOURCES);
@ -2456,7 +2456,7 @@ static int socket_start(Unit *u) {
} }
} }
assert(s->state == SOCKET_DEAD || s->state == SOCKET_FAILED); assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED));
r = unit_start_limit_test(u); r = unit_start_limit_test(u);
if (r < 0) { if (r < 0) {
@ -2500,7 +2500,7 @@ static int socket_stop(Unit *u) {
return -EAGAIN; return -EAGAIN;
} }
assert(s->state == SOCKET_LISTENING || s->state == SOCKET_RUNNING); assert(IN_SET(s->state, SOCKET_LISTENING, SOCKET_RUNNING));
socket_enter_stop_pre(s, SOCKET_SUCCESS); socket_enter_stop_pre(s, SOCKET_SUCCESS);
return 1; return 1;

View file

@ -589,7 +589,7 @@ static int timer_start(Unit *u) {
int r; int r;
assert(t); assert(t);
assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED); assert(IN_SET(t->state, TIMER_DEAD, TIMER_FAILED));
trigger = UNIT_TRIGGER(u); trigger = UNIT_TRIGGER(u);
if (!trigger || trigger->load_state != UNIT_LOADED) { if (!trigger || trigger->load_state != UNIT_LOADED) {
@ -649,7 +649,7 @@ static int timer_stop(Unit *u) {
Timer *t = TIMER(u); Timer *t = TIMER(u);
assert(t); assert(t);
assert(t->state == TIMER_WAITING || t->state == TIMER_RUNNING || t->state == TIMER_ELAPSED); assert(IN_SET(t->state, TIMER_WAITING, TIMER_RUNNING, TIMER_ELAPSED));
timer_enter_dead(t, TIMER_SUCCESS); timer_enter_dead(t, TIMER_SUCCESS);
return 1; return 1;
@ -754,8 +754,7 @@ static void timer_trigger_notify(Unit *u, Unit *other) {
/* Reenable all timers that depend on unit state */ /* Reenable all timers that depend on unit state */
LIST_FOREACH(value, v, t->values) LIST_FOREACH(value, v, t->values)
if (v->base == TIMER_UNIT_ACTIVE || if (IN_SET(v->base, TIMER_UNIT_ACTIVE, TIMER_UNIT_INACTIVE))
v->base == TIMER_UNIT_INACTIVE)
v->disabled = false; v->disabled = false;
switch (t->state) { switch (t->state) {

View file

@ -609,7 +609,7 @@ static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) {
/* Moves the transaction jobs to the set of active jobs */ /* Moves the transaction jobs to the set of active jobs */
if (mode == JOB_ISOLATE || mode == JOB_FLUSH) { if (IN_SET(mode, JOB_ISOLATE, JOB_FLUSH)) {
/* When isolating first kill all installed jobs which /* When isolating first kill all installed jobs which
* aren't part of the new transaction */ * aren't part of the new transaction */
@ -968,7 +968,7 @@ int transaction_add_job_and_dependencies(
} }
/* Finally, recursively add in all dependencies. */ /* Finally, recursively add in all dependencies. */
if (type == JOB_START || type == JOB_RESTART) { if (IN_SET(type, JOB_START, JOB_RESTART)) {
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) { SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) {
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e); r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
if (r < 0) { if (r < 0) {
@ -1033,7 +1033,7 @@ int transaction_add_job_and_dependencies(
} }
if (type == JOB_STOP || type == JOB_RESTART) { if (IN_SET(type, JOB_STOP, JOB_RESTART)) {
static const UnitDependency propagate_deps[] = { static const UnitDependency propagate_deps[] = {
UNIT_REQUIRED_BY, UNIT_REQUIRED_BY,
UNIT_REQUISITE_OF, UNIT_REQUISITE_OF,

View file

@ -3552,9 +3552,7 @@ bool unit_active_or_pending(Unit *u) {
return true; return true;
if (u->job && if (u->job &&
(u->job->type == JOB_START || IN_SET(u->job->type, JOB_START, JOB_RELOAD_OR_START, JOB_RESTART))
u->job->type == JOB_RELOAD_OR_START ||
u->job->type == JOB_RESTART))
return true; return true;
return false; return false;

View file

@ -46,19 +46,19 @@ typedef enum KillOperation {
} KillOperation; } KillOperation;
static inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) { static inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {
return t == UNIT_ACTIVE || t == UNIT_RELOADING; return IN_SET(t, UNIT_ACTIVE, UNIT_RELOADING);
} }
static inline bool UNIT_IS_ACTIVE_OR_ACTIVATING(UnitActiveState t) { static inline bool UNIT_IS_ACTIVE_OR_ACTIVATING(UnitActiveState t) {
return t == UNIT_ACTIVE || t == UNIT_ACTIVATING || t == UNIT_RELOADING; return IN_SET(t, UNIT_ACTIVE, UNIT_ACTIVATING, UNIT_RELOADING);
} }
static inline bool UNIT_IS_INACTIVE_OR_DEACTIVATING(UnitActiveState t) { static inline bool UNIT_IS_INACTIVE_OR_DEACTIVATING(UnitActiveState t) {
return t == UNIT_INACTIVE || t == UNIT_FAILED || t == UNIT_DEACTIVATING; return IN_SET(t, UNIT_INACTIVE, UNIT_FAILED, UNIT_DEACTIVATING);
} }
static inline bool UNIT_IS_INACTIVE_OR_FAILED(UnitActiveState t) { static inline bool UNIT_IS_INACTIVE_OR_FAILED(UnitActiveState t) {
return t == UNIT_INACTIVE || t == UNIT_FAILED; return IN_SET(t, UNIT_INACTIVE, UNIT_FAILED);
} }
#include "job.h" #include "job.h"

View file

@ -660,7 +660,7 @@ int main(int argc, char *argv[]) {
crypt_set_log_callback(cd, log_glue, NULL); crypt_set_log_callback(cd, log_glue, NULL);
status = crypt_status(cd, argv[2]); status = crypt_status(cd, argv[2]);
if (status == CRYPT_ACTIVE || status == CRYPT_BUSY) { if (IN_SET(status, CRYPT_ACTIVE, CRYPT_BUSY)) {
log_info("Volume %s already active.", argv[2]); log_info("Volume %s already active.", argv[2]);
r = 0; r = 0;
goto finish; goto finish;

View file

@ -269,7 +269,7 @@ static int fsck_progress_socket(void) {
return log_warning_errno(errno, "socket(): %m"); return log_warning_errno(errno, "socket(): %m");
if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) { if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) {
r = log_full_errno(errno == ECONNREFUSED || errno == ENOENT ? LOG_DEBUG : LOG_WARNING, r = log_full_errno(IN_SET(errno, ECONNREFUSED, ENOENT) ? LOG_DEBUG : LOG_WARNING,
errno, "Failed to connect to progress socket %s, ignoring: %m", sa.un.sun_path); errno, "Failed to connect to progress socket %s, ignoring: %m", sa.un.sun_path);
safe_close(fd); safe_close(fd);
return r; return r;

View file

@ -321,8 +321,7 @@ static int transfer_on_pid(sd_event_source *s, const siginfo_t *si, void *userda
success = true; success = true;
} }
} else if (si->si_code == CLD_KILLED || } else if (IN_SET(si->si_code, CLD_KILLED, CLD_DUMPED))
si->si_code == CLD_DUMPED)
log_error("Import process terminated by signal %s.", signal_to_string(si->si_status)); log_error("Import process terminated by signal %s.", signal_to_string(si->si_status));
else else
@ -585,7 +584,7 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC); n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (n < 0) { if (n < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
return -errno; return -errno;

View file

@ -58,8 +58,7 @@ PullJob* pull_job_unref(PullJob *j) {
static void pull_job_finish(PullJob *j, int ret) { static void pull_job_finish(PullJob *j, int ret) {
assert(j); assert(j);
if (j->state == PULL_JOB_DONE || if (IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED))
j->state == PULL_JOB_FAILED)
return; return;
if (ret == 0) { if (ret == 0) {
@ -442,7 +441,7 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
assert(contents); assert(contents);
assert(j); assert(j);
if (j->state == PULL_JOB_DONE || j->state == PULL_JOB_FAILED) { if (IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED)) {
r = -ESTALE; r = -ESTALE;
goto fail; goto fail;
} }

View file

@ -322,8 +322,7 @@ bool journal_file_is_offlining(JournalFile *f) {
__sync_synchronize(); __sync_synchronize();
if (f->offline_state == OFFLINE_DONE || if (IN_SET(f->offline_state, OFFLINE_DONE, OFFLINE_JOINED))
f->offline_state == OFFLINE_JOINED)
return false; return false;
return true; return true;

View file

@ -477,11 +477,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL; return -EINVAL;
} }
if (arg_output == OUTPUT_EXPORT || if (IN_SET(arg_output, OUTPUT_EXPORT, OUTPUT_JSON, OUTPUT_JSON_PRETTY, OUTPUT_JSON_SSE, OUTPUT_CAT))
arg_output == OUTPUT_JSON ||
arg_output == OUTPUT_JSON_PRETTY ||
arg_output == OUTPUT_JSON_SSE ||
arg_output == OUTPUT_CAT)
arg_quiet = true; arg_quiet = true;
break; break;

View file

@ -528,7 +528,7 @@ int server_open_audit(Server *s) {
s->audit_fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT); s->audit_fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT);
if (s->audit_fd < 0) { if (s->audit_fd < 0) {
if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) if (IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT))
log_debug("Audit not supported in the kernel."); log_debug("Audit not supported in the kernel.");
else else
log_warning_errno(errno, "Failed to create audit socket, ignoring: %m"); log_warning_errno(errno, "Failed to create audit socket, ignoring: %m");

View file

@ -335,7 +335,7 @@ static int server_read_dev_kmsg(Server *s) {
return 0; return 0;
} }
if (errno == EAGAIN || errno == EINTR || errno == EPIPE) if (IN_SET(errno, EAGAIN, EINTR, EPIPE))
return 0; return 0;
return log_error_errno(errno, "Failed to read from kernel: %m"); return log_error_errno(errno, "Failed to read from kernel: %m");

View file

@ -1111,7 +1111,7 @@ int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC); n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (n < 0) { if (n < 0) {
if (errno == EINTR || errno == EAGAIN) if (IN_SET(errno, EINTR, EAGAIN))
return 0; return 0;
return log_error_errno(errno, "recvmsg() failed: %m"); return log_error_errno(errno, "recvmsg() failed: %m");

View file

@ -91,7 +91,7 @@ static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned
return; return;
} }
if (ucred && (errno == ESRCH || errno == EPERM)) { if (ucred && IN_SET(errno, ESRCH, EPERM)) {
struct ucred u; struct ucred u;
/* Hmm, presumably the sender process vanished /* Hmm, presumably the sender process vanished

View file

@ -136,7 +136,7 @@ static void reset_location(sd_journal *j) {
static void init_location(Location *l, LocationType type, JournalFile *f, Object *o) { static void init_location(Location *l, LocationType type, JournalFile *f, Object *o) {
assert(l); assert(l);
assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK); assert(IN_SET(type, LOCATION_DISCRETE, LOCATION_SEEK));
assert(f); assert(f);
assert(o->object.type == OBJECT_ENTRY); assert(o->object.type == OBJECT_ENTRY);
@ -2436,7 +2436,7 @@ _public_ int sd_journal_process(sd_journal *j) {
l = read(j->inotify_fd, &buffer, sizeof(buffer)); l = read(j->inotify_fd, &buffer, sizeof(buffer));
if (l < 0) { if (l < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return got_something ? determine_change(j) : SD_JOURNAL_NOP; return got_something ? determine_change(j) : SD_JOURNAL_NOP;
return -errno; return -errno;

View file

@ -34,8 +34,8 @@ int dhcp_message_init(DHCPMessage *message, uint8_t op, uint32_t xid,
size_t offset = 0; size_t offset = 0;
int r; int r;
assert(op == BOOTREQUEST || op == BOOTREPLY); assert(IN_SET(op, BOOTREQUEST, BOOTREPLY));
assert(arp_type == ARPHRD_ETHER || arp_type == ARPHRD_INFINIBAND); assert(IN_SET(arp_type, ARPHRD_ETHER, ARPHRD_INFINIBAND));
message->op = op; message->op = op;
message->htype = arp_type; message->htype = arp_type;

View file

@ -191,7 +191,7 @@ int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst,
len = recvmsg(fd, &msg, MSG_DONTWAIT); len = recvmsg(fd, &msg, MSG_DONTWAIT);
if (len < 0) { if (len < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
return -errno; return -errno;

View file

@ -1164,7 +1164,7 @@ static int client_start_delayed(sd_dhcp_client *client) {
} }
client->fd = r; client->fd = r;
if (client->state == DHCP_STATE_INIT || client->state == DHCP_STATE_INIT_REBOOT) if (IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_INIT_REBOOT))
client->start_time = now(clock_boottime_or_monotonic()); client->start_time = now(clock_boottime_or_monotonic());
return client_initialize_events(client, client_receive_message_raw); return client_initialize_events(client, client_receive_message_raw);

View file

@ -354,7 +354,7 @@ static int ipv4acd_on_packet(
n = recv(fd, &packet, sizeof(struct ether_arp), 0); n = recv(fd, &packet, sizeof(struct ether_arp), 0);
if (n < 0) { if (n < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
log_ipv4acd_errno(acd, errno, "Failed to read ARP packet: %m"); log_ipv4acd_errno(acd, errno, "Failed to read ARP packet: %m");

View file

@ -25,8 +25,7 @@
#include "util.h" #include "util.h"
const char *address_family_boolean_to_string(AddressFamilyBoolean b) { const char *address_family_boolean_to_string(AddressFamilyBoolean b) {
if (b == ADDRESS_FAMILY_YES || if (IN_SET(b, ADDRESS_FAMILY_YES, ADDRESS_FAMILY_NO))
b == ADDRESS_FAMILY_NO)
return yes_no(b == ADDRESS_FAMILY_YES); return yes_no(b == ADDRESS_FAMILY_YES);
if (b == ADDRESS_FAMILY_IPV4) if (b == ADDRESS_FAMILY_IPV4)

View file

@ -1766,8 +1766,7 @@ static int setup_journal(const char *directory) {
r = readlink_and_make_absolute(p, &d); r = readlink_and_make_absolute(p, &d);
if (r >= 0) { if (r >= 0) {
if ((arg_link_journal == LINK_GUEST || if (IN_SET(arg_link_journal, LINK_GUEST, LINK_AUTO) &&
arg_link_journal == LINK_AUTO) &&
path_equal(d, q)) { path_equal(d, q)) {
r = userns_mkdir(directory, p, 0755, 0, 0); r = userns_mkdir(directory, p, 0755, 0, 0);
@ -2882,7 +2881,7 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC); n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (n < 0) { if (n < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
return log_warning_errno(errno, "Couldn't read notification socket: %m"); return log_warning_errno(errno, "Couldn't read notification socket: %m");

View file

@ -467,7 +467,7 @@ static int on_dns_stub_stream(sd_event_source *s, int fd, uint32_t revents, void
cfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC); cfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (cfd < 0) { if (cfd < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
return -errno; return -errno;

View file

@ -240,21 +240,23 @@ static int synthesize_system_hostname_rr(Manager *m, const DnsResourceKey *key,
/* If we have no local addresses then use ::1 /* If we have no local addresses then use ::1
* and 127.0.0.2 as local ones. */ * and 127.0.0.2 as local ones. */
if (af == AF_INET || af == AF_UNSPEC) if (IN_SET(af, AF_INET, AF_UNSPEC))
buffer[n++] = (struct local_address) { buffer[n++] = (struct local_address) {
.family = AF_INET, .family = AF_INET,
.ifindex = dns_synthesize_ifindex(ifindex), .ifindex = dns_synthesize_ifindex(ifindex),
.address.in.s_addr = htobe32(0x7F000002), .address.in.s_addr = htobe32(0x7F000002),
}; };
if (af == AF_INET6 || af == AF_UNSPEC) if (IN_SET(af, AF_INET6, AF_UNSPEC))
buffer[n++] = (struct local_address) { buffer[n++] = (struct local_address) {
.family = AF_INET6, .family = AF_INET6,
.ifindex = dns_synthesize_ifindex(ifindex), .ifindex = dns_synthesize_ifindex(ifindex),
.address.in6 = in6addr_loopback, .address.in6 = in6addr_loopback,
}; };
return answer_add_addresses_rr(answer, dns_resource_key_name(key), buffer, n); return answer_add_addresses_rr(answer,
dns_resource_key_name(key),
buffer, n);
} }
} }

View file

@ -1528,8 +1528,7 @@ int dns_transaction_go(DnsTransaction *t) {
af_to_name_short(t->scope->family)); af_to_name_short(t->scope->family));
if (!t->initial_jitter_scheduled && if (!t->initial_jitter_scheduled &&
(t->scope->protocol == DNS_PROTOCOL_LLMNR || IN_SET(t->scope->protocol, DNS_PROTOCOL_LLMNR, DNS_PROTOCOL_MDNS)) {
t->scope->protocol == DNS_PROTOCOL_MDNS)) {
usec_t jitter, accuracy; usec_t jitter, accuracy;
/* RFC 4795 Section 2.7 suggests all queries should be /* RFC 4795 Section 2.7 suggests all queries should be

View file

@ -314,7 +314,7 @@ void link_set_dnssec_mode(Link *l, DnssecMode mode) {
assert(l); assert(l);
#ifndef HAVE_GCRYPT #ifndef HAVE_GCRYPT
if (mode == DNSSEC_YES || mode == DNSSEC_ALLOW_DOWNGRADE) if (IN_SET(mode, DNSSEC_YES, DNSSEC_ALLOW_DOWNGRADE))
log_warning("DNSSEC option for the link cannot be enabled or set to allow-downgrade when systemd-resolved is built without gcrypt support. Turning off DNSSEC support."); log_warning("DNSSEC option for the link cannot be enabled or set to allow-downgrade when systemd-resolved is built without gcrypt support. Turning off DNSSEC support.");
return; return;
#endif #endif

View file

@ -345,7 +345,7 @@ static int on_llmnr_stream(sd_event_source *s, int fd, uint32_t revents, void *u
cfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC); cfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (cfd < 0) { if (cfd < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 0; return 0;
return -errno; return -errno;

View file

@ -320,7 +320,7 @@ int ask_password_tty(
n = read(ttyfd >= 0 ? ttyfd : STDIN_FILENO, &c, 1); n = read(ttyfd >= 0 ? ttyfd : STDIN_FILENO, &c, 1);
if (n < 0) { if (n < 0) {
if (errno == EINTR || errno == EAGAIN) if (IN_SET(errno, EINTR, EAGAIN))
continue; continue;
r = -errno; r = -errno;
@ -613,8 +613,7 @@ int ask_password_agent(
n = recvmsg(socket_fd, &msghdr, 0); n = recvmsg(socket_fd, &msghdr, 0);
if (n < 0) { if (n < 0) {
if (errno == EAGAIN || if (IN_SET(errno, EAGAIN, EINTR))
errno == EINTR)
continue; continue;
r = -errno; r = -errno;

View file

@ -95,7 +95,7 @@ static int clean_sysvipc_shm(uid_t delete_uid, gid_t delete_gid) {
if (shmctl(shmid, IPC_RMID, NULL) < 0) { if (shmctl(shmid, IPC_RMID, NULL) < 0) {
/* Ignore entries that are already deleted */ /* Ignore entries that are already deleted */
if (errno == EIDRM || errno == EINVAL) if (IN_SET(errno, EIDRM, EINVAL))
continue; continue;
ret = log_warning_errno(errno, ret = log_warning_errno(errno,
@ -147,7 +147,7 @@ static int clean_sysvipc_sem(uid_t delete_uid, gid_t delete_gid) {
if (semctl(semid, 0, IPC_RMID) < 0) { if (semctl(semid, 0, IPC_RMID) < 0) {
/* Ignore entries that are already deleted */ /* Ignore entries that are already deleted */
if (errno == EIDRM || errno == EINVAL) if (IN_SET(errno, EIDRM, EINVAL))
continue; continue;
ret = log_warning_errno(errno, ret = log_warning_errno(errno,
@ -200,7 +200,7 @@ static int clean_sysvipc_msg(uid_t delete_uid, gid_t delete_gid) {
if (msgctl(msgid, IPC_RMID, NULL) < 0) { if (msgctl(msgid, IPC_RMID, NULL) < 0) {
/* Ignore entries that are already deleted */ /* Ignore entries that are already deleted */
if (errno == EIDRM || errno == EINVAL) if (IN_SET(errno, EIDRM, EINVAL))
continue; continue;
ret = log_warning_errno(errno, ret = log_warning_errno(errno,

View file

@ -187,7 +187,7 @@ static int shovel(PTYForward *f) {
if (errno == EAGAIN) if (errno == EAGAIN)
f->stdin_readable = false; f->stdin_readable = false;
else if (errno == EIO || errno == EPIPE || errno == ECONNRESET) { else if (IN_SET(errno, EIO, EPIPE, ECONNRESET)) {
f->stdin_readable = false; f->stdin_readable = false;
f->stdin_hangup = true; f->stdin_hangup = true;
@ -217,9 +217,9 @@ static int shovel(PTYForward *f) {
k = write(f->master, f->in_buffer, f->in_buffer_full); k = write(f->master, f->in_buffer, f->in_buffer_full);
if (k < 0) { if (k < 0) {
if (errno == EAGAIN || errno == EIO) if (IN_SET(errno, EAGAIN, EIO))
f->master_writable = false; f->master_writable = false;
else if (errno == EPIPE || errno == ECONNRESET) { else if (IN_SET(errno, EPIPE, ECONNRESET)) {
f->master_writable = f->master_readable = false; f->master_writable = f->master_readable = false;
f->master_hangup = true; f->master_hangup = true;
@ -249,7 +249,7 @@ static int shovel(PTYForward *f) {
if (errno == EAGAIN || (errno == EIO && ignore_vhangup(f))) if (errno == EAGAIN || (errno == EIO && ignore_vhangup(f)))
f->master_readable = false; f->master_readable = false;
else if (errno == EPIPE || errno == ECONNRESET || errno == EIO) { else if (IN_SET(errno, EPIPE, ECONNRESET, EIO)) {
f->master_readable = f->master_writable = false; f->master_readable = f->master_writable = false;
f->master_hangup = true; f->master_hangup = true;
@ -271,7 +271,7 @@ static int shovel(PTYForward *f) {
if (errno == EAGAIN) if (errno == EAGAIN)
f->stdout_writable = false; f->stdout_writable = false;
else if (errno == EIO || errno == EPIPE || errno == ECONNRESET) { else if (IN_SET(errno, EIO, EPIPE, ECONNRESET)) {
f->stdout_writable = false; f->stdout_writable = false;
f->stdout_hangup = true; f->stdout_hangup = true;
f->stdout_event_source = sd_event_source_unref(f->stdout_event_source); f->stdout_event_source = sd_event_source_unref(f->stdout_event_source);

View file

@ -234,7 +234,7 @@ int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line
if (r < 0) if (r < 0)
return r; return r;
if (ut_type == LOGIN_PROCESS || ut_type == USER_PROCESS) { if (IN_SET(ut_type, LOGIN_PROCESS, USER_PROCESS)) {
store.ut_type = LOGIN_PROCESS; store.ut_type = LOGIN_PROCESS;
r = write_entry_both(&store); r = write_entry_both(&store);
if (r < 0) if (r < 0)

View file

@ -480,7 +480,7 @@ static int load_sysv(SysvStub *s) {
continue; continue;
} }
if ((state == LSB_DESCRIPTION || state == LSB) && streq(t, "### END INIT INFO")) { if (IN_SET(state, LSB_DESCRIPTION, LSB) && streq(t, "### END INIT INFO")) {
state = NORMAL; state = NORMAL;
continue; continue;
} }
@ -554,7 +554,7 @@ static int load_sysv(SysvStub *s) {
chkconfig_description = d; chkconfig_description = d;
} }
} else if (state == LSB || state == LSB_DESCRIPTION) { } else if (IN_SET(state, LSB, LSB_DESCRIPTION)) {
if (startswith_no_case(t, "Provides:")) { if (startswith_no_case(t, "Provides:")) {
state = LSB; state = LSB;

View file

@ -931,7 +931,7 @@ static int parse_attribute_from_arg(Item *item) {
v = attributes[i].value; v = attributes[i].value;
SET_FLAG(value, v, (mode == MODE_ADD || mode == MODE_SET)); SET_FLAG(value, v, IN_SET(mode, MODE_ADD, MODE_SET));
mask |= v; mask |= v;
} }

View file

@ -165,7 +165,7 @@ static int ask_password_plymouth(
k = read(fd, buffer + p, sizeof(buffer) - p); k = read(fd, buffer + p, sizeof(buffer) - p);
if (k < 0) { if (k < 0) {
if (errno == EINTR || errno == EAGAIN) if (IN_SET(errno, EINTR, EAGAIN))
continue; continue;
r = -errno; r = -errno;
@ -346,8 +346,7 @@ static int parse_password(const char *filename, char **wall) {
} else { } else {
_cleanup_strv_free_erase_ char **passwords = NULL; _cleanup_strv_free_erase_ char **passwords = NULL;
assert(arg_action == ACTION_QUERY || assert(IN_SET(arg_action, ACTION_QUERY, ACTION_WATCH));
arg_action == ACTION_WATCH);
if (access(socket_name, W_OK) < 0) { if (access(socket_name, W_OK) < 0) {
if (arg_action == ACTION_QUERY) if (arg_action == ACTION_QUERY)

View file

@ -102,7 +102,7 @@ static int prepare(char *dir, char *filename)
if (lockf(fd,F_TLOCK,0) < 0) { if (lockf(fd,F_TLOCK,0) < 0) {
if (debug) if (debug)
fprintf(stderr, "Lock taken, wait for %d seconds\n", UDEV_ALARM_TIMEOUT); fprintf(stderr, "Lock taken, wait for %d seconds\n", UDEV_ALARM_TIMEOUT);
if (errno == EAGAIN || errno == EACCES) { if (IN_SET(errno, EAGAIN, EACCES)) {
alarm(UDEV_ALARM_TIMEOUT); alarm(UDEV_ALARM_TIMEOUT);
lockf(fd, F_LOCK, 0); lockf(fd, F_LOCK, 0);
if (debug) if (debug)

View file

@ -358,7 +358,7 @@ resend:
retval = ioctl(fd, SG_IO, io_buf); retval = ioctl(fd, SG_IO, io_buf);
if (retval < 0) { if (retval < 0) {
if ((errno == EINVAL || errno == ENOSYS) && dev_scsi->use_sg == 4) { if (IN_SET(errno, EINVAL, ENOSYS) && dev_scsi->use_sg == 4) {
dev_scsi->use_sg = 3; dev_scsi->use_sg = 3;
goto resend; goto resend;
} }

View file

@ -33,7 +33,7 @@
static bool udev_exit; static bool udev_exit;
static void sig_handler(int signum) { static void sig_handler(int signum) {
if (signum == SIGINT || signum == SIGTERM) if (IN_SET(signum, SIGINT, SIGTERM))
udev_exit = true; udev_exit = true;
} }

View file

@ -1134,7 +1134,7 @@ static int on_inotify(sd_event_source *s, int fd, uint32_t revents, void *userda
l = read(fd, &buffer, sizeof(buffer)); l = read(fd, &buffer, sizeof(buffer));
if (l < 0) { if (l < 0) {
if (errno == EAGAIN || errno == EINTR) if (IN_SET(errno, EAGAIN, EINTR))
return 1; return 1;
return log_error_errno(errno, "Failed to read inotify fd: %m"); return log_error_errno(errno, "Failed to read inotify fd: %m");

View file

@ -91,7 +91,7 @@ int main(int argc, char *argv[]) {
crypt_set_log_callback(cd, log_glue, NULL); crypt_set_log_callback(cd, log_glue, NULL);
status = crypt_status(cd, argv[2]); status = crypt_status(cd, argv[2]);
if (status == CRYPT_ACTIVE || status == CRYPT_BUSY) { if (IN_SET(status, CRYPT_ACTIVE, CRYPT_BUSY)) {
log_info("Volume %s already active.", argv[2]); log_info("Volume %s already active.", argv[2]);
r = 0; r = 0;
goto finish; goto finish;