fix const related compile error with newer gcc
[project/uci.git] / list.c
diff --git a/list.c b/list.c
index fe2e6ec225940b488b9bdbae771499f953ee7bb4..9486ffba17d1f9b871d3709921fb8e499bfd9dfe 100644 (file)
--- a/list.c
+++ b/list.c
@@ -322,7 +322,7 @@ uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr)
 
        if (!*name)
                name = NULL;
-       else if (!uci_validate_str(name, false))
+       else if (!uci_validate_type(name))
                goto error;
 
        /* if the given index is negative, it specifies the section number from 
@@ -527,6 +527,9 @@ int uci_rename(struct uci_context *ctx, struct uci_ptr *ptr)
                free(e->name);
        e->name = n;
 
+       if (e->type == UCI_TYPE_SECTION)
+               uci_to_section(e)->anonymous = false;
+
        return 0;
 }
 
@@ -564,6 +567,12 @@ int uci_delete(struct uci_context *ctx, struct uci_ptr *ptr)
                uci_add_history(ctx, &p->history, UCI_CMD_REMOVE, ptr->section, ptr->option, NULL);
 
        uci_free_any(&e);
+
+       if (ptr->option)
+               ptr->o = NULL;
+       else if (ptr->section)
+               ptr->s = NULL;
+
        return 0;
 }
 
@@ -618,7 +627,7 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr)
        UCI_ASSERT(ctx, ptr->value);
        UCI_ASSERT(ctx, ptr->s || (!ptr->option && ptr->section));
        if (!ptr->option) {
-               UCI_ASSERT(ctx, uci_validate_str(ptr->value, false));
+               UCI_ASSERT(ctx, uci_validate_type(ptr->value));
        }
 
        if (!ptr->o && ptr->s && ptr->option) {