diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-01-02 15:22:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-01-02 17:16:50 +0100 |
commit | 4f06325ce97a072be84130c6ca8d29c52dcf9d0d (patch) | |
tree | 0660c2a964a2729f6c7487ecbabcbcb2804bb05d /src/fundamental | |
parent | efa75d702290c0a758dd30a2052fddaf8b7aa073 (diff) | |
download | systemd-4f06325ce97a072be84130c6ca8d29c52dcf9d0d.tar.gz |
fundamental: rework IN_SET() to require at least three arguments
If less than three parameters are passed a simple comparison is the
better choice.
Lo and behold this found two pretty bad typos.
Diffstat (limited to 'src/fundamental')
-rw-r--r-- | src/fundamental/macro-fundamental.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index db778c7609..9400c389ca 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: \ |