From patchwork Mon May 14 08:53:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Oberhollenzer X-Patchwork-Id: 912753 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sigma-star.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ErTy60Bi"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40kvdP3mqFz9ryk for ; Mon, 14 May 2018 18:54:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fpncGo1XCEX3xNcI9/SDRkzAL+tbFkysCEE6+rgDs7s=; b=ErTy60Bi3sSB3lwB19sfAQLiy7 Dywsuxt9JFyiii6VHPFllgbd866UE83ZybSSyh7RzqFZcOKUCOSyGFOlsfS6cha63fQyUeq0cFk1J I6nc5DHSkgJEXnkXBz6m4GwjN4bMJfiloDidF+8NHzklrHA7I2XCVj2bMnXOzAemqNPInqyNt/UNs i13Ulj5jmN/vUa0V51S/zXS23AuiEC5GkoHJSk29lFIwXpjHzAUUf4l6h4wN+k1HMduI8yGVrtbZG zq3BpDTsbPb500ZIeuMfo7kWYpCKxi0b5034gNDS9W+ocY3zhnvB+n1em19cq47Pxi9eIpbc8gbPL +OIrnpzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fI9FC-0007Sm-3q; Mon, 14 May 2018 08:54:10 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fI9Ey-0006Lr-Ag for linux-mtd@lists.infradead.org; Mon, 14 May 2018 08:54:07 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id C3274181A2F0B; Mon, 14 May 2018 10:53:42 +0200 (CEST) From: David Oberhollenzer To: linux-mtd@lists.infradead.org Subject: [PATCH 1/3] ubiformat: process command line arguments first Date: Mon, 14 May 2018 10:53:23 +0200 Message-Id: <20180514085325.6793-2-david.oberhollenzer@sigma-star.at> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514085325.6793-1-david.oberhollenzer@sigma-star.at> References: <20180514085325.6793-1-david.oberhollenzer@sigma-star.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180514_015356_551300_A54A84FC X-CRM114-Status: GOOD ( 12.08 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard@nod.at, David Oberhollenzer MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If libmtd_open fails, the program always exists with failure status and prints "MTD subsystem is not present". Even `ubiformat --help` produces the same result, which is definitely undesired. This patch moves command line option processing first to get the desired behavior. Signed-off-by: David Oberhollenzer --- ubi-utils/ubiformat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c index c38b9b4..694ab4c 100644 --- a/ubi-utils/ubiformat.c +++ b/ubi-utils/ubiformat.c @@ -692,13 +692,14 @@ int main(int argc, char * const argv[]) struct ubigen_info ui; struct ubi_scan_info *si; - libmtd = libmtd_open(); - if (!libmtd) - return errmsg("MTD subsystem is not present"); err = parse_opt(argc, argv); if (err) - goto out_close_mtd; + return -1; + + libmtd = libmtd_open(); + if (!libmtd) + return errmsg("MTD subsystem is not present"); err = mtd_get_info(libmtd, &mtd_info); if (err) {