summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-03 16:41:06 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-03 16:41:15 +0100
commit059d9fbb5a691ced7428cff5ff1da5681cacf6da (patch)
treefbe7c675b3775f1aad612f4851cc7beaabf84d1e /src
parent89fbb95e03dbaf6762a8d83c7dd544b387e9314e (diff)
macro: better make IN_SET() macro use const arrays
Diffstat (limited to 'src')
-rw-r--r--src/shared/macro.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 54b641be23..4198095011 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -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; \
})