1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

macro: better make IN_SET() macro use const arrays

This commit is contained in:
Lennart Poettering 2013-12-03 16:41:06 +01:00
parent 89fbb95e03
commit 059d9fbb5a

View File

@ -285,16 +285,17 @@ do { \
#define SET_FLAG(v, flag, b) \
(v) = (b) ? ((v) | (flag)) : ((v) & ~(flag))
#define IN_SET(x, ...) ({ \
typeof(x) _x = (x); \
unsigned _i; \
bool _found = false; \
for (_i = 0; _i < sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) \
if (((typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \
_found = true; \
break; \
} \
_found; \
#define IN_SET(x, ...) \
({ \
const typeof(x) _x = (x); \
unsigned _i; \
bool _found = false; \
for (_i = 0; _i < sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \
if (((const typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \
_found = true; \
break; \
} \
_found; \
})