summaryrefslogtreecommitdiff
path: root/nand-utils/nanddump.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2016-07-19 15:06:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2016-11-17 11:36:55 +0100
commit7dd42c510dc8ab10f52dcc2d20dc8af412be0744 (patch)
treefa45022d4754db6a72285d7e9f9284e877ce06c5 /nand-utils/nanddump.c
parent8a00021b2ab5529640e5acaca30a27cdaca04178 (diff)
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 <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'nand-utils/nanddump.c')
-rw-r--r--nand-utils/nanddump.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c
index ec17314..a8ad334 100644
--- a/nand-utils/nanddump.c
+++ b/nand-utils/nanddump.c
@@ -63,9 +63,8 @@ static void display_help(int status)
static void display_version(void)
{
- printf("%1$s " VERSION "\n"
- "\n"
- "%1$s comes with NO WARRANTY\n"
+ common_print_version();
+ printf("%1$s comes with NO WARRANTY\n"
"to the extent permitted by law.\n"
"\n"
"You may redistribute copies of %1$s\n"
@@ -101,9 +100,9 @@ static void process_options(int argc, char * const argv[])
for (;;) {
int option_index = 0;
- static const char short_options[] = "hs:f:l:opqnca";
+ static const char short_options[] = "hs:f:l:opqncaV";
static const struct option long_options[] = {
- {"version", no_argument, 0, 0},
+ {"version", no_argument, 0, 'V'},
{"bb", required_argument, 0, 0},
{"omitoob", no_argument, 0, 0},
{"help", no_argument, 0, 'h'},
@@ -128,9 +127,6 @@ static void process_options(int argc, char * const argv[])
switch (c) {
case 0:
switch (option_index) {
- case 0:
- display_version();
- break;
case 1:
/* Handle --bb=METHOD */
if (!strcmp(optarg, "padbad"))
@@ -152,6 +148,9 @@ static void process_options(int argc, char * const argv[])
break;
}
break;
+ case 'V':
+ display_version();
+ break;
case 's':
start_addr = simple_strtoll(optarg, &error);
break;