diff options
author | Daniel Wagner <daniel.wagner@siemens.com> | 2017-06-12 12:50:54 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2017-06-14 11:00:30 +0200 |
commit | 76e27a79eddb6279bbbc0ec840d66b753a9ba0f3 (patch) | |
tree | 50650ace637991c5845b15a7800e67f7cdece62b | |
parent | b8e785a96f907022466bd383ec6afaa201e5f759 (diff) |
ubi-utils: Return error code if command line option is unknown
The tools in question will quit with an exit code 0 if the command
line option was not recognized. By returning an error code a calling
script has the possibility to distinguish between a real success and
an invalid invocation.
We need to return -1 instead of EXIT_FAILURE to be consistent with the
other exit code places.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | tests/fs-tests/integrity/integck.c | 5 | ||||
-rw-r--r-- | ubi-utils/ubiblock.c | 6 | ||||
-rw-r--r-- | ubi-utils/ubiformat.c | 6 | ||||
-rw-r--r-- | ubi-utils/ubimkvol.c | 7 | ||||
-rw-r--r-- | ubi-utils/ubirmvol.c | 7 | ||||
-rw-r--r-- | ubi-utils/ubirsvol.c | 7 | ||||
-rw-r--r-- | ubi-utils/ubiupdatevol.c | 7 | ||||
-rw-r--r-- | ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 |
8 files changed, 42 insertions, 9 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 7cb5305..827adc5 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -3080,10 +3080,13 @@ static int parse_opts(int argc, char * const argv[]) exit(EXIT_SUCCESS); case 'h': - case '?': fprintf(stderr, "%s\n\n", doc); fprintf(stderr, "%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + fprintf(stderr, "%s\n\n", doc); + fprintf(stderr, "%s\n", optionsstr); + exit(-1); case ':': return errmsg("parameter is missing"); diff --git a/ubi-utils/ubiblock.c b/ubi-utils/ubiblock.c index 1e12be8..8e36678 100644 --- a/ubi-utils/ubiblock.c +++ b/ubi-utils/ubiblock.c @@ -78,11 +78,15 @@ static int parse_opt(int argc, char * const argv[]) args.node = optarg; break; case 'h': - case '?': printf("%s\n\n", doc); printf("%s\n\n", usage); printf("%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + printf("%s\n\n", doc); + printf("%s\n\n", usage); + printf("%s\n", optionsstr); + return -1; case 'V': common_print_version(); diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c index 896fe20..ef0378a 100644 --- a/ubi-utils/ubiformat.c +++ b/ubi-utils/ubiformat.c @@ -209,11 +209,15 @@ static int parse_opt(int argc, char * const argv[]) exit(EXIT_SUCCESS); case 'h': - case '?': printf("%s\n\n", doc); printf("%s\n\n", usage); printf("%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + printf("%s\n\n", doc); + printf("%s\n\n", usage); + printf("%s\n", optionsstr); + return -1; case ':': return errmsg("parameter is missing"); diff --git a/ubi-utils/ubimkvol.c b/ubi-utils/ubimkvol.c index fdbc67f..b81fc99 100644 --- a/ubi-utils/ubimkvol.c +++ b/ubi-utils/ubimkvol.c @@ -164,12 +164,17 @@ static int parse_opt(int argc, char * const argv[]) break; case 'h': - case '?': printf("%s\n\n", doc); printf("%s\n\n", usage); printf("%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + printf("%s\n\n", doc); + printf("%s\n\n", usage); + printf("%s\n", optionsstr); + return -1; + case 'V': common_print_version(); exit(EXIT_SUCCESS); diff --git a/ubi-utils/ubirmvol.c b/ubi-utils/ubirmvol.c index 3370aff..049e70d 100644 --- a/ubi-utils/ubirmvol.c +++ b/ubi-utils/ubirmvol.c @@ -109,12 +109,17 @@ static int parse_opt(int argc, char * const argv[]) break; case 'h': - case '?': printf("%s\n\n", doc); printf("%s\n\n", usage); printf("%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + printf("%s\n\n", doc); + printf("%s\n\n", usage); + printf("%s\n", optionsstr); + return -1; + case 'V': common_print_version(); exit(EXIT_SUCCESS); diff --git a/ubi-utils/ubirsvol.c b/ubi-utils/ubirsvol.c index 69a4ea1..0854abc 100644 --- a/ubi-utils/ubirsvol.c +++ b/ubi-utils/ubirsvol.c @@ -137,12 +137,17 @@ static int parse_opt(int argc, char * const argv[]) break; case 'h': - case '?': printf("%s\n\n", doc); printf("%s\n\n", usage); printf("%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + printf("%s\n\n", doc); + printf("%s\n\n", usage); + printf("%s\n", optionsstr); + return -1; + case 'V': common_print_version(); exit(EXIT_SUCCESS); diff --git a/ubi-utils/ubiupdatevol.c b/ubi-utils/ubiupdatevol.c index 5096791..bdcc091 100644 --- a/ubi-utils/ubiupdatevol.c +++ b/ubi-utils/ubiupdatevol.c @@ -109,12 +109,17 @@ static int parse_opt(int argc, char * const argv[]) break; case 'h': - case '?': printf("%s\n\n", doc); printf("%s\n\n", usage); printf("%s\n", optionsstr); exit(EXIT_SUCCESS); + case '?': + printf("%s\n\n", doc); + printf("%s\n\n", usage); + printf("%s\n", optionsstr); + return -1; + case 'V': common_print_version(); exit(EXIT_SUCCESS); diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index a60052d..9e69a4f 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -548,15 +548,17 @@ static int get_options(int argc, char**argv) yes = 1; break; case 'h': + printf("%s", helptext); + exit(EXIT_SUCCESS); case '?': printf("%s", helptext); - exit(0); + exit(-1); case 'v': verbose = 1; break; case 'V': common_print_version(); - exit(0); + exit(EXIT_SUCCESS); case 'g': debug_level = strtol(optarg, &endp, 0); if (*endp != '\0' || endp == optarg || |