diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 0937e58a152..3b920418b09 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -1249,7 +1249,7 @@ typedef enum EndOfLineMarker { static EndOfLineMarker categorize_eol(char c, ReadLineFlags flags) { - if (!IN_SET(flags, READ_LINE_ONLY_NUL)) { + if (!FLAGS_SET(flags, READ_LINE_ONLY_NUL)) { if (c == '\n') return EOL_TEN; if (c == '\r') diff --git a/src/core/timer.c b/src/core/timer.c index b6810c8599b..371e42e0aa0 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -864,7 +864,7 @@ static int timer_clean(Unit *u, ExecCleanMask mask) { if (t->state != TIMER_DEAD) return -EBUSY; - if (!IN_SET(mask, EXEC_CLEAN_STATE)) + if (mask != EXEC_CLEAN_STATE) return -EUNATCH; r = timer_setup_persistent(t); diff --git a/src/core/unit.c b/src/core/unit.c index 3b27e6e6d4c..0e66cae4341 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -5793,7 +5793,7 @@ int unit_clean(Unit *u, ExecCleanMask mask) { return -EBUSY; state = unit_active_state(u); - if (!IN_SET(state, UNIT_INACTIVE)) + if (state != UNIT_INACTIVE) return -EBUSY; return UNIT_VTABLE(u)->clean(u, mask); diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index db778c76099..9400c389ca9 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -278,15 +278,15 @@ CASE_F_10,CASE_F_9,CASE_F_8,CASE_F_7,CASE_F_6,CASE_F_5,CASE_F_4,CASE_F_3,CASE_F_2,CASE_F_1) \ (__VA_ARGS__) -#define IN_SET(x, ...) \ +#define IN_SET(x, first, ...) \ ({ \ bool _found = false; \ /* If the build breaks in the line below, you need to extend the case macros. We use typeof(+x) \ * here to widen the type of x if it is a bit-field as this would otherwise be illegal. */ \ - static const typeof(+x) __assert_in_set[] _unused_ = { __VA_ARGS__ }; \ + static const typeof(+x) __assert_in_set[] _unused_ = { first, __VA_ARGS__ }; \ assert_cc(ELEMENTSOF(__assert_in_set) <= 20); \ switch (x) { \ - FOR_EACH_MAKE_CASE(__VA_ARGS__) \ + FOR_EACH_MAKE_CASE(first, __VA_ARGS__) \ _found = true; \ break; \ default: \ diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h index d558842c0e3..024cfb87447 100644 --- a/src/resolve/resolved-dns-rr.h +++ b/src/resolve/resolved-dns-rr.h @@ -320,7 +320,7 @@ ssize_t dns_resource_record_payload(DnsResourceRecord *rr, void **out); DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref); static inline bool dns_key_is_shared(const DnsResourceKey *key) { - return IN_SET(key->type, DNS_TYPE_PTR); + return key->type == DNS_TYPE_PTR; } bool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b); diff --git a/src/shared/varlink.c b/src/shared/varlink.c index 80820fcad21..8244f599a9a 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -423,7 +423,7 @@ static int varlink_test_disconnect(Varlink *v) { /* Similar, if are a client that hasn't written anything yet but the write side is dead, also * disconnect. We also explicitly check for POLLHUP here since we likely won't notice the write side * being down if we never wrote anything. */ - if (IN_SET(v->state, VARLINK_IDLE_CLIENT) && (v->write_disconnected || v->got_pollhup)) + if (v->state == VARLINK_IDLE_CLIENT && (v->write_disconnected || v->got_pollhup)) goto disconnect; /* We are on the server side and still want to send out more replies, but we saw POLLHUP already, and @@ -1473,7 +1473,7 @@ int varlink_call( if (v->state == VARLINK_DISCONNECTED) return varlink_log_errno(v, SYNTHETIC_ERRNO(ENOTCONN), "Not connected."); - if (!IN_SET(v->state, VARLINK_IDLE_CLIENT)) + if (v->state != VARLINK_IDLE_CLIENT) return varlink_log_errno(v, SYNTHETIC_ERRNO(EBUSY), "Connection busy."); assert(v->n_pending == 0); /* n_pending can't be > 0 if we are in VARLINK_IDLE_CLIENT state */ diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c index edc907c832d..fdf2cdfd051 100644 --- a/src/systemctl/systemctl-start-special.c +++ b/src/systemctl/systemctl-start-special.c @@ -216,7 +216,7 @@ int verb_start_special(int argc, char *argv[], void *userdata) { arg_no_block = true; - } else if (IN_SET(a, ACTION_EXIT)) + } else if (a == ACTION_EXIT) /* Since exit is so close in behaviour to power-off/reboot, let's also make * it asynchronous, in order to not confuse the user needlessly with unexpected * behaviour. */ diff --git a/src/test/test-macro.c b/src/test/test-macro.c index d4f32496b7e..aec1f1ecd42 100644 --- a/src/test/test-macro.c +++ b/src/test/test-macro.c @@ -202,22 +202,22 @@ TEST(ptr_to_int) { } TEST(in_set) { - assert_se(IN_SET(1, 1)); + assert_se(IN_SET(1, 1, 2)); assert_se(IN_SET(1, 1, 2, 3, 4)); assert_se(IN_SET(2, 1, 2, 3, 4)); assert_se(IN_SET(3, 1, 2, 3, 4)); assert_se(IN_SET(4, 1, 2, 3, 4)); - assert_se(!IN_SET(0, 1)); + assert_se(!IN_SET(0, 1, 2)); assert_se(!IN_SET(0, 1, 2, 3, 4)); struct { unsigned x:3; } t = { 1 }; - assert_se(IN_SET(t.x, 1)); + assert_se(IN_SET(t.x, 1, 2)); assert_se(IN_SET(t.x, 1, 2, 3, 4)); assert_se(IN_SET(t.x, 2, 3, 4, 1)); - assert_se(!IN_SET(t.x, 0)); + assert_se(!IN_SET(t.x, 0, 2)); assert_se(!IN_SET(t.x, 2, 3, 4)); } diff --git a/src/tmpfiles/offline-passwd.c b/src/tmpfiles/offline-passwd.c index f712099b0b6..4ffed1c1023 100644 --- a/src/tmpfiles/offline-passwd.c +++ b/src/tmpfiles/offline-passwd.c @@ -62,7 +62,7 @@ static int populate_uid_cache(const char *root, Hashmap **ret) { return -ENOMEM; r = hashmap_put(cache, n, UID_TO_PTR(pw->pw_uid)); - if (IN_SET(r, 0 -EEXIST)) + if (IN_SET(r, 0, -EEXIST)) continue; if (r < 0) return r;