lua: use uci_foreach_element_safe in uci_lua_foreach() - patch by jow
[project/uci.git] / ucimap.c
index 52c920b..7c4fb02 100644 (file)
--- a/ucimap.c
+++ b/ucimap.c
@@ -59,23 +59,13 @@ struct ucimap_fixup {
 static inline bool
 ucimap_is_alloc(enum ucimap_type type)
 {
-       switch(type & UCIMAP_SUBTYPE) {
-       case UCIMAP_STRING:
-               return true;
-       default:
-               return false;
-       }
+       return (type & UCIMAP_SUBTYPE) == UCIMAP_STRING;
 }
 
 static inline bool
 ucimap_is_fixup(enum ucimap_type type)
 {
-       switch(type & UCIMAP_SUBTYPE) {
-       case UCIMAP_SECTION:
-               return true;
-       default:
-               return false;
-       }
+       return (type & UCIMAP_SUBTYPE) == UCIMAP_SECTION;
 }
 
 static inline bool
@@ -894,6 +884,7 @@ ucimap_parse(struct uci_map *map, struct uci_package *pkg)
                        } else {
                                sd = malloc(sm->alloc_len);
                                memset(sd, 0, sm->alloc_len);
+                               sd = ucimap_ptr_section(sm, sd);
                        }
                        if (!sd)
                                continue;