]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use IN_SET where possible
authorAndreas Rammhold <andreas@rammhold.de>
Thu, 28 Sep 2017 22:37:23 +0000 (00:37 +0200)
committerAndreas Rammhold <andreas@rammhold.de>
Mon, 2 Oct 2017 11:09:54 +0000 (13:09 +0200)
In addition to the changes from #6933 this handles cases that could be
matched with the included cocci file.

58 files changed:
coccinelle/in_set.cocci [new file with mode: 0644]
src/basic/barrier.c
src/basic/barrier.h
src/basic/hashmap.c
src/basic/in-addr-util.h
src/basic/journal-importer.c
src/basic/process-util.c
src/basic/signal-util.c
src/basic/socket-util.c
src/basic/terminal-util.c
src/basic/util.c
src/core/automount.c
src/core/dbus-unit.c
src/core/dynamic-user.c
src/core/job.c
src/core/manager.c
src/core/path.c
src/core/scope.c
src/core/service.c
src/core/socket.c
src/core/timer.c
src/core/transaction.c
src/core/unit.c
src/core/unit.h
src/cryptsetup/cryptsetup.c
src/fsck/fsck.c
src/import/importd.c
src/import/pull-job.c
src/journal/journal-file.c
src/journal/journalctl.c
src/journal/journald-audit.c
src/journal/journald-kmsg.c
src/journal/journald-server.c
src/journal/journald-syslog.c
src/journal/sd-journal.c
src/libsystemd-network/dhcp-packet.c
src/libsystemd-network/icmp6-util.c
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-ipv4acd.c
src/network/networkd-util.c
src/nspawn/nspawn.c
src/resolve/resolved-dns-stub.c
src/resolve/resolved-dns-synthesize.c
src/resolve/resolved-dns-transaction.c
src/resolve/resolved-link.c
src/resolve/resolved-llmnr.c
src/shared/ask-password-api.c
src/shared/clean-ipc.c
src/shared/ptyfwd.c
src/shared/utmp-wtmp.c
src/sysv-generator/sysv-generator.c
src/tmpfiles/tmpfiles.c
src/tty-ask-password-agent/tty-ask-password-agent.c
src/udev/collect/collect.c
src/udev/scsi_id/scsi_serial.c
src/udev/udevadm-monitor.c
src/udev/udevd.c
src/veritysetup/veritysetup.c

diff --git a/coccinelle/in_set.cocci b/coccinelle/in_set.cocci
new file mode 100644 (file)
index 0000000..f5ddd3d
--- /dev/null
@@ -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)
index 2da633b31188a305ad95186ce2f314e8bb6ddfd0..0c44e47b12ce921fda12ec476c00696e84c97cfe 100644 (file)
@@ -171,7 +171,7 @@ void barrier_set_role(Barrier *b, unsigned int role) {
         int fd;
 
         assert(b);
-        assert(role == BARRIER_PARENT || role == BARRIER_CHILD);
+        assert(IN_SET(role, BARRIER_PARENT, BARRIER_CHILD));
         /* make sure this is only called once */
         assert(b->pipe[0] >= 0 && b->pipe[1] >= 0);
 
index 6347fddc4d7cf01df6b8896d0cfe0002c66718af..1e54c824252664b153765d6856df13add41fb816 100644 (file)
@@ -70,11 +70,11 @@ bool barrier_sync_next(Barrier *b);
 bool barrier_sync(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) {
-        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) {
@@ -82,7 +82,8 @@ static inline bool barrier_we_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) {
index 50fefb0b54fe5604d92d436ca92bed4d3d8c244b..6ef1b0ba3583678e8df63ed7ff75227854749313 100644 (file)
@@ -927,7 +927,7 @@ static bool hashmap_put_robin_hood(HashmapBase *h, unsigned idx,
 
         for (distance = 0; ; distance++) {
                 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)
                                 bucket_move_entry(h, swap, idx, IDX_TMP);
 
index d129bf5585483c339227f7655b54ac905881edc8..59f8eb7edf25d39bd95f266fdb92cdcce6e6f82b 100644 (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);
 
 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;
 }
 
index 38ac8deaf34828d3dbb1de225d7e79d8489d04f5..e750101165890087edcb575b7005075c6d4f9c6c 100644 (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) {
 
         assert(imp);
-        assert(imp->state == IMPORTER_STATE_DATA_START ||
-               imp->state == IMPORTER_STATE_DATA ||
-               imp->state == IMPORTER_STATE_DATA_FINISH);
+        assert(IN_SET(imp->state, IMPORTER_STATE_DATA_START, IMPORTER_STATE_DATA, IMPORTER_STATE_DATA_FINISH));
         assert(size <= DATA_SIZE_MAX);
         assert(imp->offset <= imp->filled);
         assert(imp->filled <= imp->size);
index b77d83c99f639bbbd0598953a3ff3cabebd02c96..ab661a8f1632c322965345508a4ce3023b2228c0 100644 (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);
 
                 return status.si_status;
-        } else if (status.si_code == CLD_KILLED ||
-                   status.si_code == CLD_DUMPED) {
+        } else if (IN_SET(status.si_code, CLD_KILLED, CLD_DUMPED)) {
 
                 log_warning("%s terminated by signal %s.", name, signal_to_string(status.si_status));
                 return -EPROTO;
index 280b5c3251ecc53f84baf906be816522e3f7a72c..df6b742fde9f9f608048f6dd30d15aa1bc6ba64f 100644 (file)
@@ -38,7 +38,7 @@ int reset_all_signal_handlers(void) {
         for (sig = 1; sig < _NSIG; sig++) {
 
                 /* These two cannot be caught... */
-                if (sig == SIGKILL || sig == SIGSTOP)
+                if (IN_SET(sig, SIGKILL, SIGSTOP))
                         continue;
 
                 /* On Linux the first two RT signals are reserved by
index f1b2256b2178cc06b90b3310f43b92e899444328..c2f795b4d8bf8cbd0d8cf4d2cbc32be4c474dc59 100644 (file)
@@ -364,8 +364,7 @@ bool socket_address_can_accept(const SocketAddress *a) {
         assert(a);
 
         return
-                a->type == SOCK_STREAM ||
-                a->type == SOCK_SEQPACKET;
+                IN_SET(a->type, SOCK_STREAM, SOCK_SEQPACKET);
 }
 
 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);
         if (l < 0) {
-                if (errno == EOPNOTSUPP || errno == EFAULT)
+                if (IN_SET(errno, EOPNOTSUPP, EFAULT))
                         goto fallback;
 
                 return -errno;
index 64745e80632c7a6b9b68843280032df2962c5107..28c8c35fe0f64d20acba2ad5fdc64779b81fbd25 100644 (file)
@@ -476,7 +476,7 @@ int acquire_terminal(
 
                         l = read(notify, &buffer, sizeof(buffer));
                         if (l < 0) {
-                                if (errno == EINTR || errno == EAGAIN)
+                                if (IN_SET(errno, EINTR, EAGAIN))
                                         continue;
 
                                 r = -errno;
index daaee99284ce9894ea433e63c1792864398e818c..687de40993052ddab3f64252fe66b98240a39cee 100644 (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);
                 if (device < 0) {
-                        if (errno == ENOENT || errno == ENOTDIR)
+                        if (IN_SET(errno, ENOENT, ENOTDIR))
                                 continue;
 
                         return -errno;
index 0c9261657549a7aaec72537c144ec3f2ac3ac085..ecaa916ce3470e0bb4d3fe350c8f7be9b1190401 100644 (file)
@@ -804,7 +804,7 @@ static int automount_start(Unit *u) {
         int r;
 
         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) {
                 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);
 
         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);
         return 1;
index 8d2ae964d819b7ce72f522779c25dcc26e929880..791649e5b5f2d0b2de19bf70427480b10fe3d076 100644 (file)
@@ -1253,13 +1253,13 @@ int bus_unit_queue_job(
         }
 
         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)
                 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) ||
             (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))
                 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);
 
index 9b0dbaf248f8f8dccd26eed342b7f25908c3d492..6358fcba0231a1a768610197df44859926c76fa0 100644 (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 */
                         if (r < 0) {
-                                if (errno == EBUSY || errno == EAGAIN)
+                                if (IN_SET(errno, EBUSY, EAGAIN))
                                         goto next; /* already in use */
 
                                 return -errno;
index f04c8a21683e43b167cd922ca2eaa0783777b400..f962881a12710ffffca63dbfe17e33423b0b0b29 100644 (file)
@@ -368,19 +368,13 @@ bool job_type_is_redundant(JobType a, UnitActiveState b) {
         switch (a) {
 
         case JOB_START:
-                return
-                        b == UNIT_ACTIVE ||
-                        b == UNIT_RELOADING;
+                return IN_SET(b, UNIT_ACTIVE, UNIT_RELOADING);
 
         case JOB_STOP:
-                return
-                        b == UNIT_INACTIVE ||
-                        b == UNIT_FAILED;
+                return IN_SET(b, UNIT_INACTIVE, UNIT_FAILED);
 
         case JOB_VERIFY_ACTIVE:
-                return
-                        b == UNIT_ACTIVE ||
-                        b == UNIT_RELOADING;
+                return IN_SET(b, UNIT_ACTIVE, UNIT_RELOADING);
 
         case JOB_RELOAD:
                 return
@@ -888,7 +882,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr
                 goto finish;
         }
 
-        if (result == JOB_FAILED || result == JOB_INVALID)
+        if (IN_SET(result, JOB_FAILED, JOB_INVALID))
                 j->manager->n_failed_jobs++;
 
         job_uninstall(j);
index 8ebea8d66bf0dd3cb84d602061ecf2b877d1486b..519473599a4d408cec224e2ed7dc08c3e442056e 100644 (file)
@@ -1442,7 +1442,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, sd_bus_e
                 return -ENOMEM;
 
         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);
         if (r < 0)
                 goto tr_abort;
@@ -1985,7 +1985,7 @@ static int manager_dispatch_sigchld(Manager *m) {
                 if (si.si_pid <= 0)
                         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;
                         Unit *u1, *u2, *u3;
 
index 7092ed13bac56477d1d8267e6cf10bdafd044137..bbf891c462b01c93a60f5ef0b4d2563b4bf81984 100644 (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);
                 if (r < 0) {
-                        if (errno == EACCES || errno == ENOENT) {
+                        if (IN_SET(errno, EACCES, ENOENT)) {
                                 if (cut)
                                         *cut = tmp;
                                 break;
@@ -168,14 +168,14 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
 
         l = read(s->inotify_fd, &buffer, sizeof(buffer));
         if (l < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 return log_error_errno(errno, "Failed to read inotify event: %m");
         }
 
         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)
                         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) {
         int r;
 
-        if (s->type == PATH_EXISTS || s->type == PATH_EXISTS_GLOB)
+        if (IN_SET(s->type, PATH_EXISTS, PATH_EXISTS_GLOB))
                 return;
 
         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 == PATH_WAITING ||
-                    p->deserialized_state == PATH_RUNNING)
+                if (IN_SET(p->deserialized_state, PATH_WAITING, PATH_RUNNING))
                         path_enter_waiting(p, true, true);
                 else
                         path_set_state(p, p->deserialized_state);
@@ -566,7 +565,7 @@ static int path_start(Unit *u) {
         int r;
 
         assert(p);
-        assert(p->state == PATH_DEAD || p->state == PATH_FAILED);
+        assert(IN_SET(p->state, PATH_DEAD, PATH_FAILED));
 
         trigger = UNIT_TRIGGER(u);
         if (!trigger || trigger->load_state != UNIT_LOADED) {
@@ -596,7 +595,7 @@ static int path_stop(Unit *u) {
         Path *p = PATH(u);
 
         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);
         return 1;
index 9670228694891e799930bf3533fef6d929e8c94c..4cd5e3dd2a6cb1fdae9d58dcd2dc6d8962de8f55 100644 (file)
@@ -322,8 +322,7 @@ static int scope_start(Unit *u) {
                 return -EPERM;
 
         /* We can't fulfill this right now, please try again later */
-        if (s->state == SCOPE_STOP_SIGTERM ||
-            s->state == SCOPE_STOP_SIGKILL)
+        if (IN_SET(s->state, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL))
                 return -EAGAIN;
 
         assert(s->state == SCOPE_DEAD);
@@ -357,12 +356,10 @@ static int scope_stop(Unit *u) {
 
         assert(s);
 
-        if (s->state == SCOPE_STOP_SIGTERM ||
-            s->state == SCOPE_STOP_SIGKILL)
+        if (IN_SET(s->state, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL))
                 return 0;
 
-        assert(s->state == SCOPE_RUNNING ||
-               s->state == SCOPE_ABANDONED);
+        assert(IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED));
 
         scope_enter_signal(s, SCOPE_STOP_SIGTERM, SCOPE_SUCCESS);
         return 1;
index 1a4455bd2282b4863c2b74b263710f7f06b95689..fb8a970a27c78a9d5b269619549064bd503e0dce 100644 (file)
@@ -529,7 +529,7 @@ static int service_verify(Service *s) {
         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.");
 
-        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.");
                 return -EINVAL;
         }
@@ -2224,7 +2224,7 @@ static int service_reload(Unit *u) {
 
         assert(s);
 
-        assert(s->state == SERVICE_RUNNING || s->state == SERVICE_EXITED);
+        assert(IN_SET(s->state, SERVICE_RUNNING, SERVICE_EXITED));
 
         service_enter_reload(s);
         return 1;
@@ -2755,7 +2755,7 @@ static int service_retry_pid_file(Service *s) {
         int r;
 
         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);
         if (r < 0)
@@ -2826,7 +2826,7 @@ static int service_dispatch_io(sd_event_source *source, int fd, uint32_t events,
 
         assert(s);
         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(path_spec_owns_inotify_fd(s->pid_file_pathspec, fd));
 
index e05daaa1dc07a03d20c1640bd5958c60b9c5897c..d579f341fb69588be2cb44395a6543a1aef25fea 100644 (file)
@@ -2083,7 +2083,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
 fail:
         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);
         else
                 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);
         if (r < 0) {
@@ -2500,7 +2500,7 @@ static int socket_stop(Unit *u) {
                 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);
         return 1;
index a34bc7b14eb26a60e8d4efa54e8cf6527aea3630..9ea5f322d8fd0c44e6cf5da2dd3c40b29e346856 100644 (file)
@@ -589,7 +589,7 @@ static int timer_start(Unit *u) {
         int r;
 
         assert(t);
-        assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED);
+        assert(IN_SET(t->state, TIMER_DEAD, TIMER_FAILED));
 
         trigger = UNIT_TRIGGER(u);
         if (!trigger || trigger->load_state != UNIT_LOADED) {
@@ -649,7 +649,7 @@ static int timer_stop(Unit *u) {
         Timer *t = TIMER(u);
 
         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);
         return 1;
@@ -754,8 +754,7 @@ static void timer_trigger_notify(Unit *u, Unit *other) {
 
         /* Reenable all timers that depend on unit state */
         LIST_FOREACH(value, v, t->values)
-                if (v->base == TIMER_UNIT_ACTIVE ||
-                    v->base == TIMER_UNIT_INACTIVE)
+                if (IN_SET(v->base, TIMER_UNIT_ACTIVE, TIMER_UNIT_INACTIVE))
                         v->disabled = false;
 
         switch (t->state) {
index 1af4ed910061fdf6ef1fd56450db0b543a4cebae..46c2fa452e2d869bfcf501265e41f07f9fd8090c 100644 (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 */
 
-        if (mode == JOB_ISOLATE || mode == JOB_FLUSH) {
+        if (IN_SET(mode, JOB_ISOLATE, JOB_FLUSH)) {
 
                 /* When isolating first kill all installed jobs which
                  * aren't part of the new transaction */
@@ -968,7 +968,7 @@ int transaction_add_job_and_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) {
                                 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
                                 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[] = {
                                 UNIT_REQUIRED_BY,
                                 UNIT_REQUISITE_OF,
index 60cf30ea3a4941c344597da57d146ff49e381e7c..0ef6fcfab595848f9e83c283c9939e1c8625829f 100644 (file)
@@ -3552,9 +3552,7 @@ bool unit_active_or_pending(Unit *u) {
                 return true;
 
         if (u->job &&
-            (u->job->type == JOB_START ||
-             u->job->type == JOB_RELOAD_OR_START ||
-             u->job->type == JOB_RESTART))
+            IN_SET(u->job->type, JOB_START, JOB_RELOAD_OR_START, JOB_RESTART))
                 return true;
 
         return false;
index 7c6fef27b38127d67d0d819f7ba4dc9054e224cf..02090ed67d6f9fd965fb2498c11b7ae31b73c336 100644 (file)
@@ -46,19 +46,19 @@ typedef enum KillOperation {
 } KillOperation;
 
 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) {
-        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) {
-        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) {
-        return t == UNIT_INACTIVE || t == UNIT_FAILED;
+        return IN_SET(t, UNIT_INACTIVE, UNIT_FAILED);
 }
 
 #include "job.h"
index e1e1a9675ede4157d787b336cd8996ac4e18c6e3..8fc35ad999e279aa150d0dbfc4118e03525662a2 100644 (file)
@@ -660,7 +660,7 @@ int main(int argc, char *argv[]) {
                 crypt_set_log_callback(cd, log_glue, NULL);
 
                 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]);
                         r = 0;
                         goto finish;
index 2100681e1773b0b9387c0648f1c36940d2a5cd82..434321f806aaf733ea675085dfe5f7ebf50d1deb 100644 (file)
@@ -269,7 +269,7 @@ static int fsck_progress_socket(void) {
                 return log_warning_errno(errno, "socket(): %m");
 
         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);
                 safe_close(fd);
                 return r;
index 3d379d6de9ea3de2a5015f3784b37e403996ab1c..bdb9910010bf28632f2401c4e2573f33744097ed 100644 (file)
@@ -321,8 +321,7 @@ static int transfer_on_pid(sd_event_source *s, const siginfo_t *si, void *userda
                         success = true;
                 }
 
-        } else if (si->si_code == CLD_KILLED ||
-                   si->si_code == CLD_DUMPED)
+        } else if (IN_SET(si->si_code, CLD_KILLED, CLD_DUMPED))
 
                 log_error("Import process terminated by signal %s.", signal_to_string(si->si_status));
         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);
         if (n < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 return -errno;
index 320c21305addd68b27962252521fb551edb40c46..3e20905d79647162d32e231e06f511bc0d8f04fb 100644 (file)
@@ -58,8 +58,7 @@ PullJob* pull_job_unref(PullJob *j) {
 static void pull_job_finish(PullJob *j, int ret) {
         assert(j);
 
-        if (j->state == PULL_JOB_DONE ||
-            j->state == PULL_JOB_FAILED)
+        if (IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED))
                 return;
 
         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(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;
                 goto fail;
         }
index 5c33c435e2dde157340d6b13129f4a770e17a842..94f0559d64ccde45d99b6ef4cc5b953747e12b6f 100644 (file)
@@ -322,8 +322,7 @@ bool journal_file_is_offlining(JournalFile *f) {
 
         __sync_synchronize();
 
-        if (f->offline_state == OFFLINE_DONE ||
-            f->offline_state == OFFLINE_JOINED)
+        if (IN_SET(f->offline_state, OFFLINE_DONE, OFFLINE_JOINED))
                 return false;
 
         return true;
index 1bb4d891594234d8071e4283a059069f1e417c80..3dcfb0e97a9fa9437fee4dfc66e4a64ecbd2d8bc 100644 (file)
@@ -477,11 +477,7 @@ static int parse_argv(int argc, char *argv[]) {
                                 return -EINVAL;
                         }
 
-                        if (arg_output == OUTPUT_EXPORT ||
-                            arg_output == OUTPUT_JSON ||
-                            arg_output == OUTPUT_JSON_PRETTY ||
-                            arg_output == OUTPUT_JSON_SSE ||
-                            arg_output == OUTPUT_CAT)
+                        if (IN_SET(arg_output, OUTPUT_EXPORT, OUTPUT_JSON, OUTPUT_JSON_PRETTY, OUTPUT_JSON_SSE, OUTPUT_CAT))
                                 arg_quiet = true;
 
                         break;
index 869c996aefe5616b74ec6b9b575588efc9d7218f..b20e7ab12973c4aee58ac2d178c05d0b5045ddca 100644 (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);
                 if (s->audit_fd < 0) {
-                        if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)
+                        if (IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT))
                                 log_debug("Audit not supported in the kernel.");
                         else
                                 log_warning_errno(errno, "Failed to create audit socket, ignoring: %m");
index 1bad7cb2eeb191093b33f78adaf07ae23ae89492..36f16a1ec8da05ac41ed3989ec8619b1f27c7f8a 100644 (file)
@@ -335,7 +335,7 @@ static int server_read_dev_kmsg(Server *s) {
                         return 0;
                 }
 
-                if (errno == EAGAIN || errno == EINTR || errno == EPIPE)
+                if (IN_SET(errno, EAGAIN, EINTR, EPIPE))
                         return 0;
 
                 return log_error_errno(errno, "Failed to read from kernel: %m");
index 2d51be7c89ec0cdd48e4c8eda12329ce26a68eaa..de643c91494c305cbb6ba9248f86aa422dfbdfe3 100644 (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);
         if (n < 0) {
-                if (errno == EINTR || errno == EAGAIN)
+                if (IN_SET(errno, EINTR, EAGAIN))
                         return 0;
 
                 return log_error_errno(errno, "recvmsg() failed: %m");
index fa597e47a234bc7d9ef39378eedbe83c4391d4fe..7d040de893976255478a9bbae7b6ddde47c1ce83 100644 (file)
@@ -91,7 +91,7 @@ static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned
                 return;
         }
 
-        if (ucred && (errno == ESRCH || errno == EPERM)) {
+        if (ucred && IN_SET(errno, ESRCH, EPERM)) {
                 struct ucred u;
 
                 /* Hmm, presumably the sender process vanished
index 22054835baab03c9095f91f6f91814abb7f7b5af..fb7269e510093a0e2a4be7edd1f1ebdc75f74a01 100644 (file)
@@ -136,7 +136,7 @@ static void reset_location(sd_journal *j) {
 
 static void init_location(Location *l, LocationType type, JournalFile *f, Object *o) {
         assert(l);
-        assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
+        assert(IN_SET(type, LOCATION_DISCRETE, LOCATION_SEEK));
         assert(f);
         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));
                 if (l < 0) {
-                        if (errno == EAGAIN || errno == EINTR)
+                        if (IN_SET(errno, EAGAIN, EINTR))
                                 return got_something ? determine_change(j) : SD_JOURNAL_NOP;
 
                         return -errno;
index 40442b3636c3a50f2763e0fc5b02cd6dfe2004c6..475c5729a00583f82bd114af392576550ae10ed5 100644 (file)
@@ -34,8 +34,8 @@ int dhcp_message_init(DHCPMessage *message, uint8_t op, uint32_t xid,
         size_t offset = 0;
         int r;
 
-        assert(op == BOOTREQUEST || op == BOOTREPLY);
-        assert(arp_type == ARPHRD_ETHER || arp_type == ARPHRD_INFINIBAND);
+        assert(IN_SET(op, BOOTREQUEST, BOOTREPLY));
+        assert(IN_SET(arp_type, ARPHRD_ETHER, ARPHRD_INFINIBAND));
 
         message->op = op;
         message->htype = arp_type;
index 7fbebd6f2757385f044ae2581f0843eefb1932af..cf69044d6df988ea8cc7b79347f0de49f6a40c3f 100644 (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);
         if (len < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 return -errno;
index 8426f602a997bc047ab7f02872f23dfbbdd1def5..25cff849e547a31d4888ac021eaf280d5dff39ed 100644 (file)
@@ -1164,7 +1164,7 @@ static int client_start_delayed(sd_dhcp_client *client) {
         }
         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());
 
         return client_initialize_events(client, client_receive_message_raw);
index 2ebc00f247d966eed98fa4a797bcac3c51b2b49b..909b4702513776710563368fbf9580bda883db17 100644 (file)
@@ -354,7 +354,7 @@ static int ipv4acd_on_packet(
 
         n = recv(fd, &packet, sizeof(struct ether_arp), 0);
         if (n < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 log_ipv4acd_errno(acd, errno, "Failed to read ARP packet: %m");
index 555a7c68a19f4acd60b4ba6fd27912f743afb7e8..8856e762690574f32a6de64cefdeb7a264cf82d4 100644 (file)
@@ -25,8 +25,7 @@
 #include "util.h"
 
 const char *address_family_boolean_to_string(AddressFamilyBoolean b) {
-        if (b == ADDRESS_FAMILY_YES ||
-            b == ADDRESS_FAMILY_NO)
+        if (IN_SET(b, ADDRESS_FAMILY_YES, ADDRESS_FAMILY_NO))
                 return yes_no(b == ADDRESS_FAMILY_YES);
 
         if (b == ADDRESS_FAMILY_IPV4)
index 5ba09a994a96114c81c91e7887d3bd63959a734d..82fd0bd5f4a5aec940af7cb199e13cef09f16a88 100644 (file)
@@ -1766,8 +1766,7 @@ static int setup_journal(const char *directory) {
 
         r = readlink_and_make_absolute(p, &d);
         if (r >= 0) {
-                if ((arg_link_journal == LINK_GUEST ||
-                     arg_link_journal == LINK_AUTO) &&
+                if (IN_SET(arg_link_journal, LINK_GUEST, LINK_AUTO) &&
                     path_equal(d, q)) {
 
                         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);
         if (n < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 return log_warning_errno(errno, "Couldn't read notification socket: %m");
index 6f7b5ab9e874e4b2cbd964617f5bf66bdcf6e585..292e94daa3de637a0468ea26522f1a3a612241d8 100644 (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);
         if (cfd < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 return -errno;
index c454f6404962fda38991b9c878741ac932f67ba8..25d2322453b8086a3a778dc6f5967967e1f01c4b 100644 (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
                          * 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) {
                                         .family = AF_INET,
                                         .ifindex = dns_synthesize_ifindex(ifindex),
                                         .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) {
                                         .family = AF_INET6,
                                         .ifindex = dns_synthesize_ifindex(ifindex),
                                         .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);
                 }
         }
 
index 3075f62b5e26fe09009cb23bbfefaaa2a09bd25e..8b231323392975bf625f4083920633c7e9ebb9dd 100644 (file)
@@ -1528,8 +1528,7 @@ int dns_transaction_go(DnsTransaction *t) {
                   af_to_name_short(t->scope->family));
 
         if (!t->initial_jitter_scheduled &&
-            (t->scope->protocol == DNS_PROTOCOL_LLMNR ||
-             t->scope->protocol == DNS_PROTOCOL_MDNS)) {
+            IN_SET(t->scope->protocol, DNS_PROTOCOL_LLMNR, DNS_PROTOCOL_MDNS)) {
                 usec_t jitter, accuracy;
 
                 /* RFC 4795 Section 2.7 suggests all queries should be
index ea3b0618770ec974158c70129d4af7f196959ac3..95795e4d242201b78eb3b1aa9be9dca047600291 100644 (file)
@@ -314,7 +314,7 @@ void link_set_dnssec_mode(Link *l, DnssecMode mode) {
         assert(l);
 
 #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.");
         return;
 #endif
index 29396e997356149728a3c30552a24f5ed7f8fa9b..0cf45835720d22271fe1d72ee222317adeb7a9b5 100644 (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);
         if (cfd < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 0;
 
                 return -errno;
index 0ce8e54573b9ecbf55c042aa1078c03e216dadf7..de3847adfda5ef5ce2ab47998c77da7220898f7a 100644 (file)
@@ -320,7 +320,7 @@ int ask_password_tty(
 
                 n = read(ttyfd >= 0 ? ttyfd : STDIN_FILENO, &c, 1);
                 if (n < 0) {
-                        if (errno == EINTR || errno == EAGAIN)
+                        if (IN_SET(errno, EINTR, EAGAIN))
                                 continue;
 
                         r = -errno;
@@ -613,8 +613,7 @@ int ask_password_agent(
 
                 n = recvmsg(socket_fd, &msghdr, 0);
                 if (n < 0) {
-                        if (errno == EAGAIN ||
-                            errno == EINTR)
+                        if (IN_SET(errno, EAGAIN, EINTR))
                                 continue;
 
                         r = -errno;
index f59f6f23ae15eb7ca5f4d798828baa4768722fbf..3e246a1dcad0823aabfda2d0ebbd8e6859080b5b 100644 (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) {
 
                         /* Ignore entries that are already deleted */
-                        if (errno == EIDRM || errno == EINVAL)
+                        if (IN_SET(errno, EIDRM, EINVAL))
                                 continue;
 
                         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) {
 
                         /* Ignore entries that are already deleted */
-                        if (errno == EIDRM || errno == EINVAL)
+                        if (IN_SET(errno, EIDRM, EINVAL))
                                 continue;
 
                         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) {
 
                         /* Ignore entries that are already deleted */
-                        if (errno == EIDRM || errno == EINVAL)
+                        if (IN_SET(errno, EIDRM, EINVAL))
                                 continue;
 
                         ret = log_warning_errno(errno,
index 59b541d51926041239afd10d5d99370f82c82ac9..0c92184ba51f0f13dfe594169a07da5d122e5000 100644 (file)
@@ -187,7 +187,7 @@ static int shovel(PTYForward *f) {
 
                                 if (errno == EAGAIN)
                                         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_hangup = true;
 
@@ -217,9 +217,9 @@ static int shovel(PTYForward *f) {
                         k = write(f->master, f->in_buffer, f->in_buffer_full);
                         if (k < 0) {
 
-                                if (errno == EAGAIN || errno == EIO)
+                                if (IN_SET(errno, EAGAIN, EIO))
                                         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_hangup = true;
 
@@ -249,7 +249,7 @@ static int shovel(PTYForward *f) {
 
                                 if (errno == EAGAIN || (errno == EIO && ignore_vhangup(f)))
                                         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_hangup = true;
 
@@ -271,7 +271,7 @@ static int shovel(PTYForward *f) {
 
                                 if (errno == EAGAIN)
                                         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_hangup = true;
                                         f->stdout_event_source = sd_event_source_unref(f->stdout_event_source);
index 9750dcd81722f0ba25843e520784b7374f61d398..fc8548c5b3d6cf2641a6efee6b784882d9a6e4f5 100644 (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)
                 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;
                 r = write_entry_both(&store);
                 if (r < 0)
index 3f3237d9b3822c26f8b129fce8c3aa7ca7580c46..195f7a0604e6d3a46731aac3054ddc5886a0a44f 100644 (file)
@@ -480,7 +480,7 @@ static int load_sysv(SysvStub *s) {
                         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;
                         continue;
                 }
@@ -554,7 +554,7 @@ static int load_sysv(SysvStub *s) {
                                 chkconfig_description = d;
                         }
 
-                } else if (state == LSB || state == LSB_DESCRIPTION) {
+                } else if (IN_SET(state, LSB, LSB_DESCRIPTION)) {
 
                         if (startswith_no_case(t, "Provides:")) {
                                 state = LSB;
index 3d3967f2719f3c62f5cc55fba8021633b9d25de1..3f5c1e62ee66f631382c4abe1eb2bdfd9d4a0a06 100644 (file)
@@ -931,7 +931,7 @@ static int parse_attribute_from_arg(Item *item) {
 
                 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;
         }
index a17c006d57bd2b5f8fe04d5fa8ace844cf24a430..3ea8dae7a9caed4bc9bce051e4f978b8a9c3e752 100644 (file)
@@ -165,7 +165,7 @@ static int ask_password_plymouth(
 
                 k = read(fd, buffer + p, sizeof(buffer) - p);
                 if (k < 0) {
-                        if (errno == EINTR || errno == EAGAIN)
+                        if (IN_SET(errno, EINTR, EAGAIN))
                                 continue;
 
                         r = -errno;
@@ -346,8 +346,7 @@ static int parse_password(const char *filename, char **wall) {
         } else {
                 _cleanup_strv_free_erase_ char **passwords = NULL;
 
-                assert(arg_action == ACTION_QUERY ||
-                       arg_action == ACTION_WATCH);
+                assert(IN_SET(arg_action, ACTION_QUERY, ACTION_WATCH));
 
                 if (access(socket_name, W_OK) < 0) {
                         if (arg_action == ACTION_QUERY)
index 57dfb016f9bbc7fc62b57ea25b783432d47b46c0..52229d82b58ef837fcccb7926db9d69dcfa49c8a 100644 (file)
@@ -102,7 +102,7 @@ static int prepare(char *dir, char *filename)
         if (lockf(fd,F_TLOCK,0) < 0) {
                 if (debug)
                         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);
                         lockf(fd, F_LOCK, 0);
                         if (debug)
index e079e286986e1a0eac443ed22fd301e83d43520c..f007cc6001b8a1c03cace1d7aa93a80baed6d52c 100644 (file)
@@ -358,7 +358,7 @@ resend:
 
         retval = ioctl(fd, SG_IO, io_buf);
         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;
                         goto resend;
                 }
index 94a59186ed83f34f6e2bfe0c08ab8211ea310504..77ae3a9732dbcae549ad8c1e14fa22f335fb0996 100644 (file)
@@ -33,7 +33,7 @@
 static bool udev_exit;
 
 static void sig_handler(int signum) {
-        if (signum == SIGINT || signum == SIGTERM)
+        if (IN_SET(signum, SIGINT, SIGTERM))
                 udev_exit = true;
 }
 
index 0e49e62688d6746cfe2cd7255253fedb333513b3..83f846fbc81952cecc1216d3176e177325c55cc8 100644 (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));
         if (l < 0) {
-                if (errno == EAGAIN || errno == EINTR)
+                if (IN_SET(errno, EAGAIN, EINTR))
                         return 1;
 
                 return log_error_errno(errno, "Failed to read inotify fd: %m");
index f809d51638715b94b0a60291ab5d881e44de5eb7..c6a79541f74b14ae1f31e726e84b649edadf4e74 100644 (file)
@@ -91,7 +91,7 @@ int main(int argc, char *argv[]) {
                 crypt_set_log_callback(cd, log_glue, NULL);
 
                 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]);
                         r = 0;
                         goto finish;