From d0cd0868cd5e071df9f560455542f6df041056ad Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 5 Feb 2008 02:09:25 +0100 Subject: [PATCH] allow merge-import, even if the config file does not exist yet --- cli.c | 5 ++++- err.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cli.c b/cli.c index 6be3372..9bdd553 100644 --- a/cli.c +++ b/cli.c @@ -171,6 +171,7 @@ static int uci_do_import(int argc, char **argv) struct uci_package *package = NULL; char *name = NULL; int ret = UCI_OK; + bool merge = false; if (argc > 2) return 255; @@ -184,10 +185,12 @@ static int uci_do_import(int argc, char **argv) if (flags & CLI_FLAG_MERGE) { if (uci_load(ctx, name, &package) != UCI_OK) package = NULL; + else + merge = true; } ret = uci_import(ctx, input, name, &package, (name != NULL)); if (ret == UCI_OK) { - if (flags & CLI_FLAG_MERGE) { + if (merge) { ret = uci_save(ctx, package); } else { struct uci_element *e; diff --git a/err.h b/err.h index 358cadf..686cde3 100644 --- a/err.h +++ b/err.h @@ -43,6 +43,7 @@ #define UCI_HANDLE_ERR(ctx) do { \ DPRINTF("ENTER: %s\n", __func__); \ int __val = 0; \ + ctx->errno = 0; \ if (!ctx) \ return UCI_ERR_INVAL; \ if (!ctx->internal) \ -- 2.11.0