summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2015-07-22 19:57:03 +0200
committerMichal Schmidt <mschmidt@redhat.com>2015-07-22 19:57:03 +0200
commit42328446f42910f5890e46cc667041db9af9c413 (patch)
tree676a74a2fcf6d8b95eb09503abfa0fc683998ad0 /src
parentd21f001496a0d8233b39a5fbba6eef15fc72c288 (diff)
parent77247cba3e8f94a3f58d16ec338ae030eb9145af (diff)
Merge pull request #660 from michich/in-set
improve IN_SET macro
Diffstat (limited to 'src')
-rw-r--r--src/basic/macro.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h
index 5fa17ed208..ea01d701d2 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -406,12 +406,12 @@ do { \
#define IN_SET(x, y, ...) \
({ \
- const typeof(y) _y = (y); \
- const typeof(_y) _x = (x); \
+ static const typeof(y) _array[] = { (y), __VA_ARGS__ }; \
+ const typeof(y) _x = (x); \
unsigned _i; \
bool _found = false; \
- for (_i = 0; _i < 1 + sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \
- if (((const typeof(_x)[]) { _y, __VA_ARGS__ })[_i] == _x) { \
+ for (_i = 0; _i < ELEMENTSOF(_array); _i++) \
+ if (_array[_i] == _x) { \
_found = true; \
break; \
} \