DEFINE_STRING_TABLE_LOOKUP: return _INVALID_* rather than assert on NULL string
authorTom Gundersen <teg@jklm.no>
Tue, 21 Jan 2014 23:14:04 +0000 (00:14 +0100)
committerTom Gundersen <teg@jklm.no>
Wed, 22 Jan 2014 16:56:49 +0000 (17:56 +0100)
src/shared/util.h

index ebc765d..d6d746b 100644 (file)
@@ -295,7 +295,8 @@ static inline uint32_t random_u32(void) {
         }                                                               \
         scope type name##_from_string(const char *s) {                  \
                 type i;                                                 \
-                assert(s);                                              \
+                if (!s)                                                 \
+                        return (type) -1;                               \
                 for (i = 0; i < (type)ELEMENTSOF(name##_table); i++)    \
                         if (name##_table[i] &&                          \
                             streq(name##_table[i], s))                  \