aboutsummaryrefslogtreecommitdiff
path: root/nand-utils/nandtest.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/nandtest.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/nandtest.c')
-rw-r--r--nand-utils/nandtest.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/nand-utils/nandtest.c b/nand-utils/nandtest.c
index 2ef7cc8..5676733 100644
--- a/nand-utils/nandtest.c
+++ b/nand-utils/nandtest.c
@@ -22,6 +22,7 @@ void usage(int status)
fprintf(status ? stderr : stdout,
"usage: %s [OPTIONS] <device>\n\n"
" -h, --help Display this help output\n"
+ " -V, --version Display version information and exit\n"
" -m, --markbad Mark blocks bad if they appear so\n"
" -s, --seed Supply random seed\n"
" -p, --passes Number of passes\n"
@@ -160,9 +161,10 @@ int main(int argc, char **argv)
seed = time(NULL);
for (;;) {
- static const char short_options[] = "hkl:mo:p:r:s:";
+ static const char short_options[] = "hkl:mo:p:r:s:V";
static const struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
{ "markbad", no_argument, 0, 'm' },
{ "seed", required_argument, 0, 's' },
{ "passes", required_argument, 0, 'p' },
@@ -181,7 +183,10 @@ int main(int argc, char **argv)
case 'h':
usage(0);
break;
-
+ case 'V':
+ common_print_version();
+ exit(EXIT_SUCCESS);
+ break;
case '?':
usage(1);
break;