From 7dd42c510dc8ab10f52dcc2d20dc8af412be0744 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 19 Jul 2016 15:06:58 +0200 Subject: Unify version string printing When a program does sophisticated enough command line processing (i.e. getopt), make sure it responds to -V and --version. When a program prints a version string, make sure it uses the common_print_version macro to print out its name, that it is part of mtd-utils and the mtd-utils version from the build system in a fashion similar to common program packages like the GNU coreutils. When a program responds to -V/--version or -h/--help, make sure it reports success exit status. Signed-off-by: David Oberhollenzer Signed-off-by: Richard Weinberger --- jffsX-utils/sumtool.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'jffsX-utils/sumtool.c') diff --git a/jffsX-utils/sumtool.c b/jffsX-utils/sumtool.c index 886b545..0958615 100644 --- a/jffsX-utils/sumtool.c +++ b/jffsX-utils/sumtool.c @@ -113,8 +113,6 @@ static const char helptext[] = " eraseblock\n\n"; -static const char revtext[] = "$Revision: 1.9 $"; - static unsigned char ffbuf[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff @@ -159,14 +157,15 @@ void process_options (int argc, char **argv) break; case 'h': case '?': - errmsg_die("%s", helptext); + puts(helptext); + exit(EXIT_SUCCESS); case 'v': verbose = 1; break; case 'V': - errmsg_die("revision %.*s\n", - (int) strlen(revtext) - 13, revtext + 11); + common_print_version(); + exit(EXIT_SUCCESS); case 'e': { char *next; -- cgit v1.2.3