This makes it clear uci_fixup_section only needs to be called in
uci_add_section when an unnamed section is added.
Before it was a bit misleading when walking through the code seeing
uci_fixup_section being called in uci_parse_config and uci_import.
When uci config is parsed via these functions uci_add_section is
eventually called which in the end constructs a name for an unnamed
section.
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
- uci_fixup_section(ctx, ctx->pctx->section);
if (!ctx->pctx->package) {
if (!ctx->pctx->name)
uci_parse_error(ctx, "attempting to import a file without a package name");
if (!ctx->pctx->package) {
if (!ctx->pctx->name)
uci_parse_error(ctx, "attempting to import a file without a package name");
UCI_THROW(ctx, ctx->err);
}
UCI_THROW(ctx, ctx->err);
}
- uci_fixup_section(ctx, ctx->pctx->section);
if (!pctx->package && name)
uci_switch_config(ctx);
if (package)
if (!pctx->package && name)
uci_switch_config(ctx);
if (package)
}
/* fix up an unnamed section, e.g. after adding options to it */
}
/* fix up an unnamed section, e.g. after adding options to it */
-__private void uci_fixup_section(struct uci_context *ctx, struct uci_section *s)
+static void uci_fixup_section(struct uci_context *ctx, struct uci_section *s)
{
unsigned int hash = ~0;
struct uci_element *e;
{
unsigned int hash = ~0;
struct uci_element *e;
UCI_HANDLE_ERR(ctx);
UCI_ASSERT(ctx, p != NULL);
s = uci_alloc_section(p, type, NULL);
UCI_HANDLE_ERR(ctx);
UCI_ASSERT(ctx, p != NULL);
s = uci_alloc_section(p, type, NULL);
- uci_fixup_section(ctx, s);
+ if (s && s->anonymous)
+ uci_fixup_section(ctx, s);
*res = s;
if (!internal && p->has_delta)
uci_add_delta(ctx, &p->delta, UCI_CMD_ADD, s->e.name, NULL, type);
*res = s;
if (!internal && p->has_delta)
uci_add_delta(ctx, &p->delta, UCI_CMD_ADD, s->e.name, NULL, type);
__private void uci_cleanup(struct uci_context *ctx);
__private struct uci_element *uci_lookup_list(struct uci_list *list, const char *name);
__private void uci_cleanup(struct uci_context *ctx);
__private struct uci_element *uci_lookup_list(struct uci_list *list, const char *name);
-__private void uci_fixup_section(struct uci_context *ctx, struct uci_section *s);
__private void uci_free_package(struct uci_package **package);
__private struct uci_element *uci_alloc_generic(struct uci_context *ctx, int type, const char *name, int size);
__private void uci_free_element(struct uci_element *e);
__private void uci_free_package(struct uci_package **package);
__private struct uci_element *uci_alloc_generic(struct uci_context *ctx, int type, const char *name, int size);
__private void uci_free_element(struct uci_element *e);