From patchwork Wed Mar 18 04:44:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 451221 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8CDE3140119 for ; Wed, 18 Mar 2015 15:54:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=rfyzc5sX; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 81BAB28C631; Wed, 18 Mar 2015 05:52:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 2A52328C627 for ; Wed, 18 Mar 2015 05:52:14 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 18 Mar 2015 05:52:09 +0100 (CET) Received: by pabyw6 with SMTP id yw6so30769673pab.2 for ; Tue, 17 Mar 2015 21:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LjL5HEJ3I++DQiMOSpVLWudXu7MwDcwgRvApXbgBTEo=; b=rfyzc5sXkloNPy3Bw+p7QxOJ4ZnHHvj0RW5QDje6pVKwLjnOLh7ec9++6TIgbnvVt4 UtE1rPQfO2OkW+hrqiHGGobcYNPa+oVRQVeLNTS4GjbYsty4X11MSbt3uy7NjAzy3906 t5ka+RdLYI1MpkVHdHuhpoWHolm2lnQY0Xstnud6677BHniJ8qw0gxDRC1RQScmTY6lF B1HdNmWCXaktHBeEY/STKNGx4OSl/Mlgu21BUQ5nRhE/WkqyW1mT1DNf+AkDiuxCZf3I fSpSctSfA7yApTnjg0Tsv3f+Qty3TPSj5wIlsGUxQWj9ElBJOeiWiq1zwjq4as/SI2j5 sbOQ== X-Received: by 10.66.253.101 with SMTP id zz5mr128573982pac.143.1426654351058; Tue, 17 Mar 2015 21:52:31 -0700 (PDT) Received: from debian.corp.sankuai.com ([103.29.140.56]) by mx.google.com with ESMTPSA id v7sm25048051pds.72.2015.03.17.21.52.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Mar 2015 21:52:30 -0700 (PDT) From: Yousong Zhou To: nbd@openwrt.org Date: Wed, 18 Mar 2015 12:44:44 +0800 Message-Id: <1426653885-23455-3-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1426653885-23455-1-git-send-email-yszhou4tech@gmail.com> References: <1426653885-23455-1-git-send-email-yszhou4tech@gmail.com> Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH v2 2/3] cli: fix return value of package_cmd(). X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" It's a bug revealed by commit 446e774 "cli: properly unload package before quit". The current code would exit with value 1 even if uci_export() succceeded. Signed-off-by: Yousong Zhou --- cli.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli.c b/cli.c index b647f77..557472e 100644 --- a/cli.c +++ b/cli.c @@ -305,10 +305,13 @@ static int package_cmd(int cmd, char *tuple) } if (uci_commit(ctx, &ptr.p, false) != UCI_OK) { cli_perror(); + goto out; } break; case CMD_EXPORT: - uci_export(ctx, stdout, ptr.p, true); + if (uci_export(ctx, stdout, ptr.p, true) != UCI_OK) { + goto out; + } break; case CMD_SHOW: if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) { @@ -333,6 +336,8 @@ static int package_cmd(int cmd, char *tuple) break; } + ret = 0; + out: if (ptr.p) uci_unload(ctx, ptr.p);