diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2015-01-24 23:07:51 +0800 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-01-24 20:46:19 +0100 |
commit | 446e774d0e39aeb08d9df4a80453e1334805a606 (patch) | |
tree | dc18ac7b3affcaeea488980ef3c21f35c6b73099 | |
parent | 37930de695fbf183cd9eef8b33e428921efa7cc8 (diff) | |
download | uci-446e774d0e39aeb08d9df4a80453e1334805a606.tar.gz |
cli: properly unload package before quit.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r-- | cli.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -286,7 +286,7 @@ static int package_cmd(int cmd, char *tuple) { struct uci_element *e = NULL; struct uci_ptr ptr; - int ret = 0; + int ret = 1; if (uci_lookup_ptr(ctx, &ptr, tuple, true) != UCI_OK) { cli_perror(); @@ -299,11 +299,12 @@ static int package_cmd(int cmd, char *tuple) uci_show_changes(ptr.p); break; case CMD_COMMIT: - if (flags & CLI_FLAG_NOCOMMIT) - return 0; + if (flags & CLI_FLAG_NOCOMMIT) { + ret = 0; + goto out; + } if (uci_commit(ctx, &ptr.p, false) != UCI_OK) { cli_perror(); - ret = 1; } break; case CMD_EXPORT: @@ -313,7 +314,6 @@ static int package_cmd(int cmd, char *tuple) if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) { ctx->err = UCI_ERR_NOTFOUND; cli_perror(); - ret = 1; } switch(e->type) { case UCI_TYPE_PACKAGE: @@ -327,11 +327,12 @@ static int package_cmd(int cmd, char *tuple) break; default: /* should not happen */ - return 1; + goto out; } break; } +out: if (ptr.p) uci_unload(ctx, ptr.p); return ret; |