[systemd-commits] src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Dec 3 07:41:28 PST 2013
src/shared/macro.h | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
New commits:
commit 059d9fbb5a691ced7428cff5ff1da5681cacf6da
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Dec 3 16:41:06 2013 +0100
macro: better make IN_SET() macro use const arrays
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 54b641b..4198095 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; \
})
More information about the systemd-commits
mailing list