chiark / gitweb /
tree-wide: use IN_SET macro (#6977)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 4 Oct 2017 14:01:32 +0000 (23:01 +0900)
committerSven Eden <yamakuzure@gmx.net>
Fri, 8 Dec 2017 06:27:34 +0000 (07:27 +0100)
24 files changed:
src/basic/cgroup-util.c
src/basic/env-util.c
src/basic/escape.c
src/basic/extract-word.c
src/basic/fs-util.c
src/basic/hashmap.c
src/basic/hostname-util.c
src/basic/mount-util.c
src/basic/parse-util.c
src/basic/process-util.c
src/basic/rm-rf.c
src/basic/socket-util.c
src/basic/string-util.c
src/basic/time-util.c
src/basic/unit-name.c
src/basic/user-util.c
src/basic/utf8.c
src/basic/xattr-util.c
src/core/cgroup.c
src/libelogind/sd-bus/bus-message.c
src/login/loginctl.c
src/login/logind-seat.c
src/login/logind-user.c
src/update-utmp/update-utmp.c

index 8136e62b4a23adb579eb763c8ba9ee898730cec1..a8de2424dd9f0ff78c93a6cb9a61323612e2fbf8 100644 (file)
@@ -376,7 +376,7 @@ int cg_kill_recursive(
 
         if (flags & CGROUP_REMOVE) {
                 r = cg_rmdir(controller, path);
-                if (r < 0 && ret >= 0 && r != -ENOENT && r != -EBUSY)
+                if (r < 0 && ret >= 0 && !IN_SET(r, -ENOENT, -EBUSY))
                         return r;
         }
 
@@ -515,7 +515,7 @@ int cg_migrate_recursive(
 
         if (flags & CGROUP_REMOVE) {
                 r = cg_rmdir(cfrom, pfrom);
-                if (r < 0 && ret >= 0 && r != -ENOENT && r != -EBUSY)
+                if (r < 0 && ret >= 0 && !IN_SET(r, -ENOENT, -EBUSY))
                         return r;
         }
 
@@ -1934,9 +1934,7 @@ char *cg_escape(const char *p) {
         /* The return value of this function (unlike cg_unescape())
          * needs free()! */
 
-        if (p[0] == 0 ||
-            p[0] == '_' ||
-            p[0] == '.' ||
+        if (IN_SET(p[0], 0, '_', '.') ||
             streq(p, "notify_on_release") ||
             streq(p, "release_agent") ||
             streq(p, "tasks") ||
@@ -2002,7 +2000,7 @@ bool cg_controller_is_valid(const char *p) {
         if (s)
                 p = s;
 
-        if (*p == 0 || *p == '_')
+        if (IN_SET(*p, 0, '_'))
                 return false;
 
         for (t = p; *t; t++)
@@ -2055,7 +2053,7 @@ int cg_slice_to_path(const char *unit, char **ret) {
                 char n[dash - p + sizeof(".slice")];
 
                 /* Don't allow trailing or double dashes */
-                if (dash[1] == 0 || dash[1] == '-')
+                if (IN_SET(dash[1], 0, '-'))
                         return -EINVAL;
 
                 strcpy(stpncpy(n, p, dash - p), ".slice");
index 1ddb5888f2934840937d97efcc3af30ce0efddde..f533b22ef0d1eda04742ef151e0f80cd9e0b5e78 100644 (file)
@@ -708,7 +708,7 @@ char **replace_env_argv(char **argv, char **env) {
         STRV_FOREACH(i, argv) {
 
                 /* If $FOO appears as single word, replace it by the split up variable */
-                if ((*i)[0] == '$' && (*i)[1] != '{' && (*i)[1] != '$') {
+                if ((*i)[0] == '$' && !IN_SET((*i)[1], '{', '$')) {
                         char *e;
                         char **w, **m = NULL;
                         unsigned q;
index 2587ca8d11cbf361e6769f3a7fbcf30cf5e7795a..466dadc7cb9049a62be1fb093bb02cbed51d1dd4 100644 (file)
@@ -427,7 +427,7 @@ char *octescape(const char *s, size_t len) {
 
         for (f = s, t = r; f < s + len; f++) {
 
-                if (*f < ' ' || *f >= 127 || *f == '\\' || *f == '"') {
+                if (*f < ' ' || *f >= 127 || IN_SET(*f, '\\', '"')) {
                         *(t++) = '\\';
                         *(t++) = '0' + (*f >> 6);
                         *(t++) = '0' + ((*f >> 3) & 8);
index 6f2959efdea9f71d9c32c9066a16b179f2962847..2a61a1e639ea429e1bde37876eaa28794b537299 100644 (file)
@@ -152,7 +152,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
                         for (;; (*p)++, c = **p) {
                                 if (c == 0)
                                         goto finish_force_terminate;
-                                else if ((c == '\'' || c == '"') && (flags & EXTRACT_QUOTES)) {
+                                else if (IN_SET(c, '\'', '"') && (flags & EXTRACT_QUOTES)) {
                                         quote = c;
                                         break;
                                 } else if (c == '\\' && !(flags & EXTRACT_RETAIN_ESCAPE)) {
index 9f18a42ff6dd4579018b21911750eace8ee81854..28b2dce33867498c7049c4d45c5b69b14711a496 100644 (file)
@@ -333,7 +333,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
                 mkdir_parents(path, 0755);
 
         fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY,
-                        (mode == 0 || mode == MODE_INVALID) ? 0644 : mode);
+                  IN_SET(mode, 0, MODE_INVALID) ? 0644 : mode);
         if (fd < 0)
                 return -errno;
 
index 0a8f48d82a63cfb88760caf3da7e14ebb33229aa..237826e81b75300d4eafda025018e12c6fd55d28 100644 (file)
@@ -34,7 +34,7 @@
 #include "strv.h"
 #include "util.h"
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
 #include <pthread.h>
 #include "list.h"
 #endif
@@ -142,7 +142,7 @@ typedef uint8_t dib_raw_t;
 
 #define DIB_FREE UINT_MAX
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
 struct hashmap_debug_info {
         LIST_FIELDS(struct hashmap_debug_info, debug_list);
         unsigned max_entries;  /* high watermark of n_entries */
@@ -499,7 +499,7 @@ static void base_remove_entry(HashmapBase *h, unsigned idx) {
         dibs = dib_raw_ptr(h);
         assert(dibs[idx] != DIB_RAW_FREE);
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         h->debug.rem_count++;
         h->debug.last_rem_idx = idx;
 #endif
@@ -508,7 +508,7 @@ static void base_remove_entry(HashmapBase *h, unsigned idx) {
         /* Find the stop bucket ("right"). It is either free or has DIB == 0. */
         for (right = next_idx(h, left); ; right = next_idx(h, right)) {
                 raw_dib = dibs[right];
-                if (raw_dib == 0 || raw_dib == DIB_RAW_FREE)
+                if (IN_SET(raw_dib, 0, DIB_RAW_FREE))
                         break;
 
                 /* The buckets are not supposed to be all occupied and with DIB > 0.
@@ -578,7 +578,7 @@ static unsigned hashmap_iterate_in_insertion_order(OrderedHashmap *h, Iterator *
                 assert(e->p.b.key == i->next_key);
         }
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         i->prev_idx = idx;
 #endif
 
@@ -635,7 +635,7 @@ static unsigned hashmap_iterate_in_internal_order(HashmapBase *h, Iterator *i) {
         }
 
         idx = i->idx;
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         i->prev_idx = idx;
 #endif
 
@@ -658,7 +658,7 @@ static unsigned hashmap_iterate_entry(HashmapBase *h, Iterator *i) {
                 return IDX_NIL;
         }
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         if (i->idx == IDX_FIRST) {
                 i->put_count = h->debug.put_count;
                 i->rem_count = h->debug.rem_count;
@@ -750,7 +750,7 @@ static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enu
                 shared_hash_key_initialized= true;
         }
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         h->debug.func = func;
         h->debug.file = file;
         h->debug.line = line;
@@ -807,7 +807,7 @@ static void hashmap_free_no_clear(HashmapBase *h) {
         assert(!h->has_indirect);
         assert(!h->n_direct_entries);
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         assert_se(pthread_mutex_lock(&hashmap_debug_list_mutex) == 0);
         LIST_REMOVE(debug_list, hashmap_debug_list, &h->debug);
         assert_se(pthread_mutex_unlock(&hashmap_debug_list_mutex) == 0);
@@ -919,7 +919,7 @@ static bool hashmap_put_robin_hood(HashmapBase *h, unsigned idx,
         dib_raw_t raw_dib, *dibs;
         unsigned dib, distance;
 
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         h->debug.put_count++;
 #endif
 
@@ -1012,7 +1012,7 @@ static int hashmap_base_put_boldly(HashmapBase *h, unsigned idx,
         assert_se(hashmap_put_robin_hood(h, idx, swap) == false);
 
         n_entries_inc(h);
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
         h->debug.max_entries = MAX(h->debug.max_entries, n_entries(h));
 #endif
 
@@ -1240,7 +1240,7 @@ int hashmap_replace(Hashmap *h, const void *key, void *value) {
         idx = bucket_scan(h, hash, key);
         if (idx != IDX_NIL) {
                 e = plain_bucket_at(h, idx);
-#if ENABLE_DEBUG_HASHMAP
+#ifdef ENABLE_DEBUG_HASHMAP
                 /* Although the key is equal, the key pointer may have changed,
                  * and this would break our assumption for iterating. So count
                  * this operation as incompatible with iteration. */
index 1add67de9af7bb368698a7952fbf4718ff53e9ea..5297b659d06608fdd9a54874941e1249c0db17e9 100644 (file)
@@ -98,9 +98,7 @@ static bool hostname_valid_char(char c) {
                 (c >= 'a' && c <= 'z') ||
                 (c >= 'A' && c <= 'Z') ||
                 (c >= '0' && c <= '9') ||
-                c == '-' ||
-                c == '_' ||
-                c == '.';
+                IN_SET(c, '-', '_', '.');
 }
 
 /**
@@ -246,7 +244,7 @@ int read_hostname_config(const char *path, char **hostname) {
         /* may have comments, ignore them */
         FOREACH_LINE(l, f, return -errno) {
                 truncate_nl(l);
-                if (l[0] != '\0' && l[0] != '#') {
+                if (!IN_SET(l[0], '\0', '#')) {
                         /* found line with value */
                         name = hostname_cleanup(l);
                         name = strdup(name);
index e65cd67dca6f77fe0e766a8c565490e8f4ffa0d9..d16f14bc8e413c78921c08f57e2a9d17bdccfb35 100644 (file)
@@ -473,14 +473,14 @@ int bind_remount_recursive_with_mountinfo(const char *prefix, bool ro, char **bl
                 while ((x = set_steal_first(todo))) {
 
                         r = set_consume(done, x);
-                        if (r == -EEXIST || r == 0)
+                        if (IN_SET(r, 0, -EEXIST))
                                 continue;
                         if (r < 0)
                                 return r;
 
                         /* Deal with mount points that are obstructed by a later mount */
                         r = path_is_mount_point(x, NULL, 0);
-                        if (r == -ENOENT || r == 0)
+                        if (IN_SET(r, 0, -ENOENT))
                                 continue;
                         if (r < 0)
                                 return r;
index c61c9e6374b7d7fc841bb1d1665d8de856aa328c..f47258edf17ce28dd0e194f8c23d4588c7ad870e 100644 (file)
@@ -155,7 +155,7 @@ int parse_size(const char *t, uint64_t base, uint64_t *size) {
         unsigned n_entries, start_pos = 0;
 
         assert(t);
-        assert(base == 1000 || base == 1024);
+        assert(IN_SET(base, 1000, 1024));
         assert(size);
 
         if (base == 1000) {
index 708b45aa0e55888a14ddf08d814331da0668796c..29eaa1e8e4c99776aca4bd0643afb05cd5e4b478 100644 (file)
@@ -34,7 +34,7 @@
 #include <sys/wait.h>
 #include <syslog.h>
 #include <unistd.h>
-#if HAVE_VALGRIND_VALGRIND_H
+#ifdef HAVE_VALGRIND_VALGRIND_H
 #include <valgrind/valgrind.h>
 #endif
 
@@ -394,7 +394,7 @@ int is_kernel_thread(pid_t pid) {
         bool eof;
         FILE *f;
 
-        if (pid == 0 || pid == 1 || pid == getpid_cached()) /* pid 1, and we ourselves certainly aren't a kernel thread */
+        if (IN_SET(pid, 0, 1) || pid == getpid_cached()) /* pid 1, and we ourselves certainly aren't a kernel thread */
                 return 0;
 
         assert(pid > 1);
@@ -825,7 +825,7 @@ bool pid_is_alive(pid_t pid) {
                 return true;
 
         r = get_process_state(pid);
-        if (r == -ESRCH || r == 'Z')
+        if (IN_SET(r, -ESRCH, 'Z'))
                 return false;
 
         return true;
@@ -956,7 +956,7 @@ int opinionated_personality(unsigned long *ret) {
 }
 
 void valgrind_summary_hack(void) {
-#if HAVE_VALGRIND_VALGRIND_H
+#ifdef HAVE_VALGRIND_VALGRIND_H
         if (getpid_cached() == 1 && RUNNING_ON_VALGRIND) {
                 pid_t pid;
                 pid = raw_clone(SIGCHLD);
index fea9242bed20921fdef3c04c4466755ef968684c..6b865ff93351bde3518fa4f20869b46fe81f7f4e 100644 (file)
@@ -133,7 +133,7 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
 
                                 r = btrfs_subvol_remove_fd(fd, de->d_name, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);
                                 if (r < 0) {
-                                        if (r != -ENOTTY && r != -EINVAL) {
+                                        if (!IN_SET(r, -ENOTTY, -EINVAL)) {
                                                 if (ret == 0)
                                                         ret = r;
 
@@ -196,7 +196,7 @@ int rm_rf(const char *path, RemoveFlags flags) {
                 if (r >= 0)
                         return r;
 
-                if (r != -ENOTTY && r != -EINVAL && r != -ENOTDIR)
+                if (!IN_SET(r, -ENOTTY, -EINVAL, -ENOTDIR))
                         return r;
 
                 /* Not btrfs or not a subvolume */
index ef3c59172dd1d4fd6d2054749778ce6ffca032c7..f71fb98f28f628dd43b1b6e3dac018b95567870c 100644 (file)
@@ -49,7 +49,7 @@
 #include "util.h"
 
 #if 0 /// UNNEEDED by elogind
-#if ENABLE_IDN
+#ifdef ENABLE_IDN
 #  define IDN_FLAGS (NI_IDN|NI_IDN_USE_STD3_ASCII_RULES)
 #else
 #  define IDN_FLAGS 0
@@ -895,7 +895,7 @@ bool ifname_valid(const char *p) {
                 if ((unsigned char) *p <= 32U)
                         return false;
 
-                if (*p == ':' || *p == '/')
+                if (IN_SET(*p, ':', '/'))
                         return false;
 
                 numeric = numeric && (*p >= '0' && *p <= '9');
index 9101d1daada7825e8b2d3824899bed0c7167e3cb..c3d7d208fae156c743fddd5287c06455ddc7edfc 100644 (file)
@@ -677,7 +677,7 @@ char *strip_tab_ansi(char **ibuf, size_t *_isz) {
                 case STATE_BRACKET:
 
                         if (i >= *ibuf + isz || /* EOT */
-                            (!(*i >= '0' && *i <= '9') && *i != ';' && *i != 'm')) {
+                            (!(*i >= '0' && *i <= '9') && !IN_SET(*i, ';', 'm'))) {
                                 fputc_unlocked('\x1B', f);
                                 fputc_unlocked('[', f);
                                 state = STATE_OTHER;
@@ -830,7 +830,7 @@ int free_and_strdup(char **p, const char *s) {
         return 1;
 }
 
-#if !HAVE_EXPLICIT_BZERO
+#if !HAVE_DECL_EXPLICIT_BZERO
 /*
  * Pointer to memset is volatile so that compiler must de-reference
  * the pointer and can't assume that it points to any function in
index 07fc5a4447737d579280b078b22d8f9a94904e11..0a0f806e8154af3cdb2e3e2958d83613a6654f0f 100644 (file)
@@ -1323,7 +1323,7 @@ bool timezone_is_valid(const char *name) {
                 if (!(*p >= '0' && *p <= '9') &&
                     !(*p >= 'a' && *p <= 'z') &&
                     !(*p >= 'A' && *p <= 'Z') &&
-                    !(*p == '-' || *p == '_' || *p == '+' || *p == '/'))
+                    !IN_SET(*p, '-', '_', '+', '/'))
                         return false;
 
                 if (*p == '/') {
index 4ccc456ef764b0588d1b96e0ec16f042162bbb86..2971b425dcdd01bea85cf5fceca38de1f42d8b38 100644 (file)
@@ -308,7 +308,7 @@ static char *do_escape(const char *f, char *t) {
         for (; *f; f++) {
                 if (*f == '/')
                         *(t++) = '-';
-                else if (*f == '-' || *f == '\\' || !strchr(VALID_CHARS, *f))
+                else if (IN_SET(*f, '-', '\\') || !strchr(VALID_CHARS, *f))
                         t = do_escape_char(*f, t);
                 else
                         *(t++) = *f;
index 332e1c6a9c7bc6a4b640208f70958a45004fa3c5..d9cc580d8d6056db9e75c156ed095588c04f91ff 100644 (file)
@@ -551,8 +551,7 @@ bool valid_user_group_name(const char *u) {
                 if (!(*i >= 'a' && *i <= 'z') &&
                     !(*i >= 'A' && *i <= 'Z') &&
                     !(*i >= '0' && *i <= '9') &&
-                    *i != '_' &&
-                    *i != '-')
+                    !IN_SET(*i, '_', '-'))
                         return false;
         }
 
index 6eae2b983d8dfd7943c479be9918d8539fd538fd..7a52fac62186ff17fc510a22f152a8dd42471486 100644 (file)
@@ -73,7 +73,7 @@ static bool unichar_is_control(char32_t ch) {
           '\t' is in C0 range, but more or less harmless and commonly used.
         */
 
-        return (ch < ' ' && ch != '\t' && ch != '\n') ||
+        return (ch < ' ' && !IN_SET(ch, '\t', '\n')) ||
                 (0x7F <= ch && ch <= 0x9F);
 }
 
index 6b5c5465316328c1d18ff467cdffd531ee3fccbc..f52d03457c896d3d06b27e79212b23a5de4cb5a9 100644 (file)
@@ -130,7 +130,7 @@ static int parse_crtime(le64_t le, usec_t *usec) {
         assert(usec);
 
         u = le64toh(le);
-        if (u == 0 || u == (uint64_t) -1)
+        if (IN_SET(u, 0, (uint64_t) -1))
                 return -EIO;
 
         *usec = (usec_t) u;
index 6e200ccb62cfc2eb17839d4b7474dd7b18eed71a..742c216691b4b0dcf63d3afd117fdf550206caee 100644 (file)
@@ -356,7 +356,7 @@ static int whitelist_major(const char *path, const char *name, char type, const
 
         assert(path);
         assert(acc);
-        assert(type == 'b' || type == 'c');
+        assert(IN_SET(type, 'b', 'c'));
 
         f = fopen("/proc/devices", "re");
         if (!f)
index 8923c5d685cb70e8556c5cd050f141c694f8c659..cfff484a84767f818ad8adbbaa08a301b4fb7ec0 100644 (file)
@@ -4233,8 +4233,7 @@ _public_ int sd_bus_message_peek_type(sd_bus_message *m, char *type, const char
                 return 1;
         }
 
-        if (c->signature[c->index] == SD_BUS_TYPE_STRUCT_BEGIN ||
-            c->signature[c->index] == SD_BUS_TYPE_DICT_ENTRY_BEGIN) {
+        if (IN_SET(c->signature[c->index], SD_BUS_TYPE_STRUCT_BEGIN, SD_BUS_TYPE_DICT_ENTRY_BEGIN)) {
 
                 if (contents) {
                         size_t l;
index dc39f8cdf14ee8d5f0beeacb69595abc66a30351..45daf54fb56db1889fe0834300a0ab7745386ccf 100644 (file)
@@ -425,7 +425,7 @@ static int prop_map_first_of_struct(sd_bus *bus, const char *member, sd_bus_mess
         if (r < 0)
                 return r;
 
-        if (contents[0] == 's' || contents[0] == 'o') {
+        if (IN_SET(contents[0], 's', 'o')) {
                 const char *s;
                 char **p = (char **) userdata;
 
index 1b6b4cdf2977df0daa855cacd073f744aeb858ae..eacea3c39d804b6b071136cd2d72e421a410fa4a 100644 (file)
@@ -669,8 +669,7 @@ static bool seat_name_valid_char(char c) {
                 (c >= 'a' && c <= 'z') ||
                 (c >= 'A' && c <= 'Z') ||
                 (c >= '0' && c <= '9') ||
-                c == '-' ||
-                c == '_';
+                IN_SET(c, '-', '_');
 }
 
 bool seat_name_is_valid(const char *name) {
index 485be84f6a948e823e7f17dce2f9e2fad61654cc..7824a1c8ef1b89b28fce5dbaf2b2523d895c87fc 100644 (file)
@@ -570,7 +570,7 @@ static int user_remove_runtime_path(User *u) {
          * quite possible, if we lacked the permissions to mount
          * something */
         r = umount2(u->runtime_path, MNT_DETACH);
-        if (r < 0 && errno != EINVAL && errno != ENOENT)
+        if (r < 0 && !IN_SET(errno, EINVAL, ENOENT))
                 log_error_errno(errno, "Failed to unmount user runtime directory %s: %m", u->runtime_path);
 
         r = rm_rf(u->runtime_path, REMOVE_ROOT);
index fc00845ab7ccaedef5a9dcabe39a817937464c42..d69a798eb5b196ff06cddf4bd26e7fcb0e5a0469 100644 (file)
@@ -21,7 +21,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
 #include <libaudit.h>
 #endif
 
@@ -46,7 +46,7 @@
 #include "update-utmp.h"
 typedef struct Context {
         sd_bus *bus;
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
         int audit_fd;
 #endif
 } Context;
@@ -131,7 +131,7 @@ static int on_reboot(Context *c) {
         /* We finished start-up, so let's write the utmp
          * record and send the audit msg */
 
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
         if (c->audit_fd >= 0)
                 if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
                     errno != EPERM) {
@@ -164,7 +164,7 @@ static int on_shutdown(Context *c) {
         /* We started shut-down, so let's write the utmp
          * record and send the audit msg */
 
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
         if (c->audit_fd >= 0)
                 if (audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_SHUTDOWN, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
                     errno != EPERM) {
@@ -194,7 +194,7 @@ static int on_runlevel(Context *c) {
         q = utmp_get_runlevel(&previous, NULL);
 
         if (q < 0) {
-                if (q != -ESRCH && q != -ENOENT)
+                if (!IN_SET(q, -ESRCH, -ENOENT))
                         return log_error_errno(q, "Failed to get current runlevel: %m");
 
                 previous = 0;
@@ -209,7 +209,7 @@ static int on_runlevel(Context *c) {
         if (previous == runlevel)
                 return 0;
 
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
         if (c->audit_fd >= 0) {
                 _cleanup_free_ char *s = NULL;
 
@@ -224,7 +224,7 @@ static int on_runlevel(Context *c) {
 #endif
 
         q = utmp_put_runlevel(runlevel, previous);
-        if (q < 0 && q != -ESRCH && q != -ENOENT) {
+        if (q < 0 && !IN_SET(q, -ESRCH, -ENOENT)) {
                 log_error_errno(q, "Failed to write utmp record: %m");
                 r = q;
         }
@@ -239,7 +239,7 @@ int main(int argc, char *argv[]) {
 void update_utmp(int argc, char* argv[], sd_bus *bus) {
 #endif // 0
         Context c = {
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
                 .audit_fd = -1
 #endif
         };
@@ -267,11 +267,11 @@ void update_utmp(int argc, char* argv[], sd_bus *bus) {
         assert(bus);
 #endif // 0
 
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
         /* If the kernel lacks netlink or audit support,
          * don't worry about it. */
         c.audit_fd = audit_open();
-        if (c.audit_fd < 0 && errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
+        if (c.audit_fd < 0 && !IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT))
                 log_error_errno(errno, "Failed to connect to audit log: %m");
 #endif
 #if 0 /// UNNEEDED by elogind
@@ -305,7 +305,7 @@ finish:
         else if (streq(argv[1], "shutdown"))
                 (void)on_shutdown(&c);
 #endif // 0
-#if HAVE_AUDIT
+#ifdef HAVE_AUDIT
         if (c.audit_fd >= 0)
                 audit_close(c.audit_fd);
 #endif