diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-01-22 17:49:28 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-01-22 17:50:50 +0100 |
commit | b9a5f8588facd64fcff0f75fa91e3f80730b93f2 (patch) | |
tree | f31b2431533fd90c240f49f6e1801fd3b7adb426 | |
parent | aa9bd4992ff0240f6ceecb70ec364d5d9c7574f4 (diff) |
import: only define the _to_string() enum mapping function, thus making gcc shut up
-rw-r--r-- | src/import/importd.c | 2 | ||||
-rw-r--r-- | src/shared/util.h | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/import/importd.c b/src/import/importd.c index 92ad801306..3e417b1749 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -86,7 +86,7 @@ static const char* const transfer_type_table[_TRANSFER_TYPE_MAX] = { [TRANSFER_DKR] = "dkr", }; -DEFINE_PRIVATE_STRING_TABLE_LOOKUP(transfer_type, TransferType); +DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(transfer_type, TransferType); static Transfer *transfer_unref(Transfer *t) { if (!t) diff --git a/src/shared/util.h b/src/shared/util.h index bfa56335cd..ca0c2e5e3d 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -348,12 +348,14 @@ static inline uint32_t random_u32(void) { } /* For basic lookup tables with strictly enumerated entries */ -#define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \ +#define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \ scope const char *name##_to_string(type i) { \ if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \ return NULL; \ return name##_table[i]; \ - } \ + } + +#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \ scope type name##_from_string(const char *s) { \ type i; \ if (!s) \ @@ -363,11 +365,17 @@ static inline uint32_t random_u32(void) { streq(name##_table[i], s)) \ return i; \ return (type) -1; \ - } \ + } + +#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \ + _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \ + _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \ struct __useless_struct_to_allow_trailing_semicolon__ -#define DEFINE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,) -#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,static) +#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,) +#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static) +#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static) +#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static) /* For string conversions where numbers are also acceptable */ #define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \ |