From patchwork Mon Jun 12 10:50:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 774518 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3wmV904RqPz9s71 for ; Mon, 12 Jun 2017 20:52:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UqyNM2et"; dkim-atps=neutral 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=rsK/qtZ79j0307BpLRMqvXG5HcN86UAzkx2tON60Cvc=; b=UqyNM2etbw8Nyxb0Rnc9hFnB6Z Kkj+6v1Kg5tx+yym1GzTw/vkpZoon6llWN8xlteW57OSVEmxzBi/E3sAJrMdeLsStqhXEozsKbtY0 66DAY6TUy9ZyCUdEDrJF3tDCNWlK+X/ssCR+wGhSlUU2rdUZHf0rNyW15bjoxXjiHVeTQ2B6VeLXu u0hEld6Rk7MUTNltD47OkcQV38CG9EaW2Wd4BfRNteBndaS4RiO8ppZ12J0IQvFC1GFxpv6NRBTVd 6/VS47Y6VZ6ymoY2nlrhdOe/GvNCfcK0kUZ71WXLzY2+b21vV0Rq1qrj2/Ex0DGD7yqK1yEcBerTK jRh5NLkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dKMxR-0004Zm-CI; Mon, 12 Jun 2017 10:52:29 +0000 Received: from lizzard.sbs.de ([194.138.37.39]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dKMwX-0003K6-QQ for linux-mtd@lists.infradead.org; Mon, 12 Jun 2017 10:51:37 +0000 Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id v5CAp8cr020012 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 12 Jun 2017 12:51:08 +0200 Received: from localhost ([139.25.0.78]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id v5CAp8s4003203; Mon, 12 Jun 2017 12:51:08 +0200 From: Daniel Wagner To: linux-mtd@lists.infradead.org Subject: [PATCH v0 11/20] nor-utils: rfddump: Return error code if command line option is unknown Date: Mon, 12 Jun 2017 12:50:52 +0200 Message-Id: <20170612105101.18223-12-daniel.wagner@siemens.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170612105101.18223-1-daniel.wagner@siemens.com> References: <20170612105101.18223-1-daniel.wagner@siemens.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170612_035134_281599_BF280CF6 X-CRM114-Status: UNSURE ( 8.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [194.138.37.39 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [194.138.37.39 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: Daniel Wagner MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The tool will quit with an exit code 0 if the command line option was not recognized. By returning an error code a calling script has the possibility to distinguish between a real success and an invalid invocation. Signed-off-by: Daniel Wagner --- nor-utils/rfddump.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nor-utils/rfddump.c b/nor-utils/rfddump.c index 048f58ca4ec9..5141ea37b926 100644 --- a/nor-utils/rfddump.c +++ b/nor-utils/rfddump.c @@ -55,7 +55,7 @@ struct rfd { int verbose; }; -void display_help(void) +void display_help(int status) { printf("Usage: %s [OPTIONS] MTD-device filename\n" "Dumps the contents of a resident flash disk\n" @@ -65,7 +65,7 @@ void display_help(void) "-v --verbose Be verbose\n" "-b size --blocksize Block size (defaults to erase unit)\n", PROGRAM_NAME); - exit(0); + exit(status); } void display_version(void) @@ -101,7 +101,7 @@ void process_options(int argc, char *argv[], struct rfd *rfd) switch (c) { case 'h': - display_help(); + display_help(EXIT_SUCCESS); break; case 'V': display_version(); @@ -119,7 +119,7 @@ void process_options(int argc, char *argv[], struct rfd *rfd) } if ((argc - optind) != 2 || error) - display_help(); + display_help(EXIT_FAILURE); rfd->mtd_filename = argv[optind]; rfd->out_filename = argv[optind + 1];