mirror of
https://github.com/systemd/systemd.git
synced 2025-09-09 17:44:49 +03:00
macro: better make IN_SET() macro use const arrays
This commit is contained in:
@@ -285,16 +285,17 @@ do { \
|
|||||||
#define SET_FLAG(v, flag, b) \
|
#define SET_FLAG(v, flag, b) \
|
||||||
(v) = (b) ? ((v) | (flag)) : ((v) & ~(flag))
|
(v) = (b) ? ((v) | (flag)) : ((v) & ~(flag))
|
||||||
|
|
||||||
#define IN_SET(x, ...) ({ \
|
#define IN_SET(x, ...) \
|
||||||
typeof(x) _x = (x); \
|
({ \
|
||||||
unsigned _i; \
|
const typeof(x) _x = (x); \
|
||||||
bool _found = false; \
|
unsigned _i; \
|
||||||
for (_i = 0; _i < sizeof((typeof(_x)[]) { __VA_ARGS__ })/sizeof(typeof(_x)); _i++) \
|
bool _found = false; \
|
||||||
if (((typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \
|
for (_i = 0; _i < sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \
|
||||||
_found = true; \
|
if (((const typeof(_x)[]) { __VA_ARGS__ })[_i] == _x) { \
|
||||||
break; \
|
_found = true; \
|
||||||
} \
|
break; \
|
||||||
_found; \
|
} \
|
||||||
|
_found; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user