X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=list.c;h=00fca3f074a5075ac4c81abe0b3c8d556b68af7c;hp=0b3dd947049cd2ea9c8c30e47e231afd6bc68283;hb=6e141df7e2a603fcfced2f020e8964492c34a307;hpb=bc7b118f0a40709c985b54c96d826e9057c9f0dd diff --git a/list.c b/list.c index 0b3dd94..00fca3f 100644 --- a/list.c +++ b/list.c @@ -104,13 +104,16 @@ static struct uci_section *uci_add_section(struct uci_config *cfg, const char *t struct uci_context *ctx = cfg->ctx; UCI_TRAP_SAVE(ctx, error); + cfg->n_section++; section = (struct uci_section *) uci_malloc(ctx, sizeof(struct uci_section)); section->config = cfg; uci_list_init(§ion->list); uci_list_init(§ion->options); section->type = uci_strdup(ctx, type); - if (name) + if (name && name[0]) section->name = uci_strdup(ctx, name); + else + asprintf(§ion->name, "cfg%d", cfg->n_section); uci_list_add(&cfg->sections, §ion->list); UCI_TRAP_RESTORE(ctx);