summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-22 12:12:29 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-22 12:21:12 +0100
commit63c691c6481e7cdcac87eee5c88608240ede5351 (patch)
tree420d1ff73ae5e1ffd2922bd965b5944245007520 /src/basic
parent8238423095ca54c48d9408a5da13e0325b31e6f6 (diff)
downloadsystemd-63c691c6481e7cdcac87eee5c88608240ede5351.tar.gz
string-table: use string_table_lookup() in our own macros everywhere
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/string-table.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/basic/string-table.h b/src/basic/string-table.h
index 228c12ad00..42fe4f4315 100644
--- a/src/basic/string-table.h
+++ b/src/basic/string-table.h
@@ -59,13 +59,13 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(name,type,max,scope) \
scope type name##_from_string(const char *s) { \
- type i; \
unsigned u = 0; \
+ type i; \
if (!s) \
return (type) -1; \
- for (i = 0; i < (type) ELEMENTSOF(name##_table); i++) \
- if (streq_ptr(name##_table[i], s)) \
- return i; \
+ i = (type) string_table_lookup(name##_table, ELEMENTSOF(name##_table), s); \
+ if (i >= 0) \
+ return i; \
if (safe_atou(s, &u) >= 0 && u <= max) \
return (type) u; \
return (type) -1; \