diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2017-09-29 09:58:22 +0200 |
---|---|---|
committer | Andreas Rammhold <andreas@rammhold.de> | 2017-10-02 13:09:56 +0200 |
commit | ec2ce0c5d7623c83dabf50c98253f5b0c0fb1359 (patch) | |
tree | 2be64c5b07a1c2cde8c2244a78b5e4c5e125e4b9 /src/core | |
parent | 3742095b27f8df4b195d530b52d15bc5fea70bf1 (diff) | |
download | systemd-ec2ce0c5d7623c83dabf50c98253f5b0c0fb1359.tar.gz |
tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`
The included cocci was used to generate the changes.
Thanks to @flo-wer for pointing this case out.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/audit-fd.c | 2 | ||||
-rw-r--r-- | src/core/automount.c | 3 | ||||
-rw-r--r-- | src/core/killall.c | 3 | ||||
-rw-r--r-- | src/core/manager.c | 4 | ||||
-rw-r--r-- | src/core/path.c | 3 | ||||
-rw-r--r-- | src/core/socket.c | 6 | ||||
-rw-r--r-- | src/core/unit.c | 5 |
7 files changed, 9 insertions, 17 deletions
diff --git a/src/core/audit-fd.c b/src/core/audit-fd.c index a91906b626..bc421a4343 100644 --- a/src/core/audit-fd.c +++ b/src/core/audit-fd.c @@ -48,7 +48,7 @@ int get_audit_fd(void) { audit_fd = audit_open(); if (audit_fd < 0) { - if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT) + if (!IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT)) log_error_errno(errno, "Failed to connect to audit log: %m"); audit_fd = errno ? -errno : -EINVAL; diff --git a/src/core/automount.c b/src/core/automount.c index ecaa916ce3..9b0d1ca429 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -251,8 +251,7 @@ static void automount_set_state(Automount *a, AutomountState state) { if (state != AUTOMOUNT_RUNNING) automount_stop_expire(a); - if (state != AUTOMOUNT_WAITING && - state != AUTOMOUNT_RUNNING) + if (!IN_SET(state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING)) unmount_autofs(a); if (state != old_state) diff --git a/src/core/killall.c b/src/core/killall.c index 3fe9fa2ed0..5e914e478d 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -174,8 +174,7 @@ static int killall(int sig, Set *pids, bool send_sighup) { pid_t pid; int r; - if (d->d_type != DT_DIR && - d->d_type != DT_UNKNOWN) + if (!IN_SET(d->d_type, DT_DIR, DT_UNKNOWN)) continue; if (parse_pid(d->d_name, &pid) < 0) diff --git a/src/core/manager.c b/src/core/manager.c index 519473599a..da673c7ae2 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2513,9 +2513,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) { if (detect_container() > 0) return; - if (u->type != UNIT_SERVICE && - u->type != UNIT_MOUNT && - u->type != UNIT_SWAP) + if (!IN_SET(u->type, UNIT_SERVICE, UNIT_MOUNT, UNIT_SWAP)) return; /* We set SOCK_NONBLOCK here so that we rather drop the diff --git a/src/core/path.c b/src/core/path.c index bbf891c462..44831f5803 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -669,8 +669,7 @@ static int path_dispatch_io(sd_event_source *source, int fd, uint32_t revents, v p = PATH(s->unit); - if (p->state != PATH_WAITING && - p->state != PATH_RUNNING) + if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING)) return 0; /* log_debug("inotify wakeup on %s.", u->id); */ diff --git a/src/core/socket.c b/src/core/socket.c index d579f341fb..06ceb46eca 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -2055,7 +2055,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) { r = unit_kill_context( UNIT(s), &s->kill_context, - (state != SOCKET_STOP_PRE_SIGTERM && state != SOCKET_FINAL_SIGTERM) ? + !IN_SET(state, SOCKET_STOP_PRE_SIGTERM, SOCKET_FINAL_SIGTERM) ? KILL_KILL : KILL_TERMINATE, -1, s->control_pid, @@ -2448,9 +2448,7 @@ static int socket_start(Unit *u) { /* If the service is already active we cannot start the * socket */ - if (service->state != SERVICE_DEAD && - service->state != SERVICE_FAILED && - service->state != SERVICE_AUTO_RESTART) { + if (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED, SERVICE_AUTO_RESTART)) { log_unit_error(u, "Socket service %s already active, refusing.", UNIT(service)->id); return -EBUSY; } diff --git a/src/core/unit.c b/src/core/unit.c index 0ef6fcfab5..90112a8b15 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -778,8 +778,7 @@ int unit_merge(Unit *u, Unit *other) { if (!unit_type_may_alias(u->type)) /* Merging only applies to unit names that support aliases */ return -EEXIST; - if (other->load_state != UNIT_STUB && - other->load_state != UNIT_NOT_FOUND) + if (!IN_SET(other->load_state, UNIT_STUB, UNIT_NOT_FOUND)) return -EEXIST; if (other->job) @@ -2221,7 +2220,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su if (u->job->state == JOB_RUNNING) { if (ns == UNIT_ACTIVE) job_finish_and_invalidate(u->job, reload_success ? JOB_DONE : JOB_FAILED, true, false); - else if (ns != UNIT_ACTIVATING && ns != UNIT_RELOADING) { + else if (!IN_SET(ns, UNIT_ACTIVATING, UNIT_RELOADING)) { unexpected = true; if (UNIT_IS_INACTIVE_OR_FAILED(ns)) |