From 5b65a773c10cdab7e9f36312dd4f7cabea3d9bf5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 4 Oct 2017 23:01:32 +0900 Subject: tree-wide: use IN_SET macro (#6977) --- src/basic/cgroup-util.c | 12 +++++------- src/basic/env-util.c | 2 +- src/basic/escape.c | 2 +- src/basic/extract-word.c | 2 +- src/basic/fs-util.c | 2 +- src/basic/hashmap.c | 24 ++++++++++++------------ src/basic/hostname-util.c | 6 ++---- src/basic/mount-util.c | 4 ++-- src/basic/parse-util.c | 2 +- src/basic/process-util.c | 8 ++++---- src/basic/rm-rf.c | 4 ++-- src/basic/socket-util.c | 4 ++-- src/basic/string-util.c | 4 ++-- src/basic/time-util.c | 2 +- src/basic/unit-name.c | 2 +- src/basic/user-util.c | 3 +-- src/basic/utf8.c | 2 +- src/basic/xattr-util.c | 2 +- src/core/cgroup.c | 2 +- src/libelogind/sd-bus/bus-message.c | 3 +-- src/login/loginctl.c | 2 +- src/login/logind-seat.c | 3 +-- src/login/logind-user.c | 2 +- src/update-utmp/update-utmp.c | 22 +++++++++++----------- 24 files changed, 57 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 8136e62b4..a8de2424d 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -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"); diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 1ddb5888f..f533b22ef 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -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; diff --git a/src/basic/escape.c b/src/basic/escape.c index 2587ca8d1..466dadc7c 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -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); diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c index 6f2959efd..2a61a1e63 100644 --- a/src/basic/extract-word.c +++ b/src/basic/extract-word.c @@ -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)) { diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 9f18a42ff..28b2dce33 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -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; diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 0a8f48d82..237826e81 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -34,7 +34,7 @@ #include "strv.h" #include "util.h" -#if ENABLE_DEBUG_HASHMAP +#ifdef ENABLE_DEBUG_HASHMAP #include #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. */ diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 1add67de9..5297b659d 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -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); diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index e65cd67dc..d16f14bc8 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -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; diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index c61c9e637..f47258edf 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -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) { diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 708b45aa0..29eaa1e8e 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -34,7 +34,7 @@ #include #include #include -#if HAVE_VALGRIND_VALGRIND_H +#ifdef HAVE_VALGRIND_VALGRIND_H #include #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); diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index fea9242be..6b865ff93 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -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 */ diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index ef3c59172..f71fb98f2 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -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'); diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 9101d1daa..c3d7d208f 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -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 diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 07fc5a444..0a0f806e8 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -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 == '/') { diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index 4ccc456ef..2971b425d 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -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; diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 332e1c6a9..d9cc580d8 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -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; } diff --git a/src/basic/utf8.c b/src/basic/utf8.c index 6eae2b983..7a52fac62 100644 --- a/src/basic/utf8.c +++ b/src/basic/utf8.c @@ -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); } diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index 6b5c54653..f52d03457 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -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; diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 6e200ccb6..742c21669 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -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) diff --git a/src/libelogind/sd-bus/bus-message.c b/src/libelogind/sd-bus/bus-message.c index 8923c5d68..cfff484a8 100644 --- a/src/libelogind/sd-bus/bus-message.c +++ b/src/libelogind/sd-bus/bus-message.c @@ -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; diff --git a/src/login/loginctl.c b/src/login/loginctl.c index dc39f8cdf..45daf54fb 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -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; diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 1b6b4cdf2..eacea3c39 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -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) { diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 485be84f6..7824a1c8e 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -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); diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index fc00845ab..d69a798eb 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -21,7 +21,7 @@ #include #include -#if HAVE_AUDIT +#ifdef HAVE_AUDIT #include #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 -- cgit v1.2.3