From patchwork Wed Dec 21 12:05:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horst Kronstorfer X-Patchwork-Id: 132624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 87105B70EE for ; Wed, 21 Dec 2011 23:30:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA811280F6; Wed, 21 Dec 2011 13:30:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FyojogNd7AH6; Wed, 21 Dec 2011 13:30:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7D549280E9; Wed, 21 Dec 2011 13:30:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EC8B6280E9 for ; Wed, 21 Dec 2011 13:30:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sN-i-XqYPc3W for ; Wed, 21 Dec 2011 13:30:38 +0100 (CET) X-Greylist: delayed 1475 seconds by postgrey-1.27 at theia; Wed, 21 Dec 2011 13:30:36 CET X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from m3f4.kronos.net (194-166-33-214.adsl.highway.telekom.at [194.166.33.214]) by theia.denx.de (Postfix) with ESMTPS id 229D0280D8 for ; Wed, 21 Dec 2011 13:30:36 +0100 (CET) Received: from m3f4.kronos.net (m3f4.kronos.net [127.0.0.1]) by m3f4.kronos.net (8.14.5/8.14.5) with ESMTP id pBLC5xOn018079; Wed, 21 Dec 2011 13:05:59 +0100 Received: (from mabuze@localhost) by m3f4.kronos.net (8.14.5/8.14.5/Submit) id pBLC5xvj018078; Wed, 21 Dec 2011 13:05:59 +0100 From: Horst Kronstorfer To: u-boot@lists.denx.de Date: Wed, 21 Dec 2011 13:05:57 +0100 Message-Id: <1324469157-18032-1-git-send-email-hkronsto@frequentis.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1323082526-2125-3-git-send-email-hkronsto@frequentis.com> References: <1323082526-2125-3-git-send-email-hkronsto@frequentis.com> Subject: [U-Boot] [PATCH v2] Print program basename instead of whole path in usage() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Horst Kronstorfer --- Changes for v2: - Use the GNU version of basename(). - Rebased against branch 'next.' tools/mkenvimage.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 753d9e6..6a6a392 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -25,6 +25,9 @@ * MA 02111-1307 USA */ +/* We want the GNU version of basename() */ +#define _GNU_SOURCE + #include #include #include @@ -81,6 +84,9 @@ int main(int argc, char **argv) struct stat txt_file_stat; int fp, ep; + const char *prg; + + prg = basename(argv[0]); /* Turn off getopt()'s internal error message */ opterr = 0; @@ -109,7 +115,7 @@ int main(int argc, char **argv) padbyte = strtol(optarg, NULL, 0); break; case 'h': - usage(argv[0]); + usage(prg); return EXIT_SUCCESS; case 'V': printf("%s version %s\n", prg, PLAIN_VERSION); @@ -117,11 +123,11 @@ int main(int argc, char **argv) case ':': fprintf(stderr, "Missing argument for option -%c\n", optopt); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; default: fprintf(stderr, "Wrong option -%c\n", optopt); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; } } @@ -131,7 +137,7 @@ int main(int argc, char **argv) fprintf(stderr, "Please specify the size of the environment " "partition.\n"); - usage(argv[0]); + usage(prg); return EXIT_FAILURE; }