X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=ucimap.c;h=0ffab944d3d354c3d7c561973e3674a76bd054e2;hb=HEAD;hp=99b8829e194dab82a470a7f4f1badf49a5901394;hpb=c434442c9e5467fa428f888591f238d0d2d0908c;p=uci.git diff --git a/ucimap.c b/ucimap.c index 99b8829..0ffab94 100644 --- 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 @@ -229,7 +219,7 @@ ucimap_handle_fixup(struct uci_map *map, struct ucimap_fixup *f) break; case UCIMAP_LIST: list = f->data->list; - data = ucimap_list_append(f->data->list); + data = ucimap_list_append(list); if (!data) return false; @@ -404,11 +394,10 @@ ucimap_add_value(union ucimap_data *data, struct uci_optmap *om, struct ucimap_s ucimap_add_fixup(sd, data, om, str); return; case UCIMAP_CUSTOM: - tdata.s = (char *) data; break; } if (om->parse) { - if (om->parse(ucimap_section_ptr(sd), om, &tdata, str) < 0) + if (om->parse(ucimap_section_ptr(sd), om, data, str) < 0) return; if (ucimap_is_custom(om->type) && om->free) { if (tdata.ptr != data->ptr) @@ -795,13 +784,6 @@ ucimap_data_to_string(struct ucimap_section_data *sd, struct uci_optmap *om, uni } if (om->format) { - union ucimap_data tdata; - - if (ucimap_is_custom(om->type)) { - tdata.s = (char *)data; - data = &tdata; - } - if (om->format(ucimap_section_ptr(sd), om, data, &str) < 0) return NULL; @@ -902,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;