From patchwork Thu Aug 11 16:19:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 109649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C51FBB70C5 for ; Fri, 12 Aug 2011 02:20:18 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QrXzM-0001VN-R8; Thu, 11 Aug 2011 16:20:09 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QrXzM-0002Fl-BT; Thu, 11 Aug 2011 16:20:08 +0000 Received: from mms1.broadcom.com ([216.31.210.17]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QrXzI-0002F9-Vw for linux-mtd@lists.infradead.org; Thu, 11 Aug 2011 16:20:05 +0000 Received: from [10.9.200.133] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Thu, 11 Aug 2011 09:25:35 -0700 X-Server-Uuid: 02CED230-5797-4B57-9875-D5D2FEE4708A Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Thu, 11 Aug 2011 09:19:30 -0700 Received: from localhost.localdomain (ld-irv-0074 [10.12.160.50]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id D527B74D03; Thu, 11 Aug 2011 09:19:46 -0700 (PDT) From: "Brian Norris" To: "Artem Bityutskiy" Subject: [PATCH v3 5/5] mtdinfo: consolidate help as display_help() Date: Thu, 11 Aug 2011 09:19:40 -0700 Message-ID: <1313079580-22144-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: MIME-Version: 1.0 X-WSS-ID: 625ADDF53DK10162752-01-01 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110811_122005_284581_BA7B3D16 X-CRM114-Status: GOOD ( 14.96 ) X-Spam-Score: 1.2 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: brian.foster@maxim-ic.com, Brian Norris , linux-mtd@lists.infradead.org, Mike Frysinger X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The help message for mtdinfo is unnecessarily disjointed. It is split into three strings which reuse the PROGRAM_NAME string inefficiently and don't have a consistent style. This fixup should provide a cleaner look with aligned columns and easier-to-read source code. Signed-off-by: Brian Norris Acked-by: Mike Frysinger --- v3: indented help message properly ubi-utils/mtdinfo.c | 52 ++++++++++++++++++++++++++------------------------ 1 files changed, 27 insertions(+), 25 deletions(-) diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c index 1c3a46f..2d47bd7 100644 --- a/ubi-utils/mtdinfo.c +++ b/ubi-utils/mtdinfo.c @@ -50,28 +50,32 @@ static struct args args = { .node = NULL, }; -static const char doc[] = PROGRAM_NAME " version " VERSION - " - a tool to print MTD information."; - -static const char optionsstr[] = -"-u, --ubi-info print what would UBI layout be if it was put\n" -" on this MTD device\n" -"-M, --map print eraseblock map\n" -"-a, --all print information about all MTD devices\n" -" Note: `--all' may give less info per device\n" -" than, e.g., `mtdinfo /dev/mtdX'\n" -"-h, --help print help message\n" -"-V, --version print program version"; - -static const char usage[] = -"Usage: " PROGRAM_NAME " [--map | -M] [--ubi-info | -u]\n" -" " PROGRAM_NAME " --all [--ubi-info | -u]\n" -" " PROGRAM_NAME " [--help | --version]\n" -"\n" -"Example 1: " PROGRAM_NAME " /dev/mtd0 print information MTD device /dev/mtd0\n" -"Example 2: " PROGRAM_NAME " /dev/mtd0 -u print information MTD device /dev/mtd0\n" -"\t\t\t\t and include UBI layout information\n" -"Example 3: " PROGRAM_NAME " -a print information about all MTD devices\n"; +static void display_help(void) +{ + printf( + "%1$s version %2$s - a tool to print MTD information.\n" + "\n" + "Usage: %1$s [--map | -M] [--ubi-info | -u]\n" + " %1$s --all [--ubi-info | -u]\n" + " %1$s [--help | --version]\n" + "\n" + "Options:\n" + "-u, --ubi-info print what would UBI layout be if it was put\n" + " on this MTD device\n" + "-M, --map print eraseblock map\n" + "-a, --all print information about all MTD devices\n" + " Note: `--all' may give less info per device\n" + " than, e.g., `mtdinfo /dev/mtdX'\n" + "-h, --help print help message\n" + "-V, --version print program version\n" + "\n" + "Examples:\n" + " %1$s /dev/mtd0 print information MTD device /dev/mtd0\n" + " %1$s /dev/mtd0 -u print information MTD device /dev/mtd0\n" + "\t\t\t\tand include UBI layout information\n" + " %1$s -a print information about all MTD devices\n", + PROGRAM_NAME, VERSION); +} static const struct option long_options[] = { { .name = "ubi-info", .has_arg = 0, .flag = NULL, .val = 'u' }, @@ -105,9 +109,7 @@ static int parse_opt(int argc, char * const argv[]) break; case 'h': - printf("%s\n\n", doc); - printf("%s\n\n", usage); - printf("%s\n", optionsstr); + display_help(); exit(EXIT_SUCCESS); case 'V':