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 --- nor-utils/rfdformat.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'nor-utils/rfdformat.c') diff --git a/nor-utils/rfdformat.c b/nor-utils/rfdformat.c index a8a44a9..d393975 100644 --- a/nor-utils/rfdformat.c +++ b/nor-utils/rfdformat.c @@ -13,7 +13,6 @@ */ #define PROGRAM_NAME "rfdformat" -#define PROGRAM_VERSION "$Revision 1.0 $" #define _XOPEN_SOURCE 500 /* For pread/pwrite */ @@ -29,6 +28,8 @@ #include #include +#include "common.h" + void display_help(void) { printf("Usage: %s [OPTIONS] MTD-device\n" @@ -42,12 +43,9 @@ void display_help(void) void display_version(void) { - printf("%s " PROGRAM_VERSION "\n" - "\n" - "This is free software; see the source for copying conditions. There is NO\n" - "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", - PROGRAM_NAME); - + common_print_version(); + printf("This is free software; see the source for copying conditions. There is NO\n" + "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); exit(0); } -- cgit v1.2.3