]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: Return error code if command line option is unknown
authorDaniel Wagner <daniel.wagner@siemens.com>
Mon, 12 Jun 2017 10:50:54 +0000 (12:50 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Wed, 14 Jun 2017 09:00:30 +0000 (11:00 +0200)
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>
tests/fs-tests/integrity/integck.c
ubi-utils/ubiblock.c
ubi-utils/ubiformat.c
ubi-utils/ubimkvol.c
ubi-utils/ubirmvol.c
ubi-utils/ubirsvol.c
ubi-utils/ubiupdatevol.c
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c

index 7cb530515d42185f979b755f47281ae2b509b0c5..827adc5205bf12626d83902f94dd80897be92762 100644 (file)
@@ -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");
 
index 1e12be8fb978060c9372da619805500098ffd76d..8e366789a88cbd44bc94eacbbd14840252d14202 100644 (file)
@@ -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();
index 896fe20cc6a4c02b076461cd08e7a9f9f05bf22d..ef0378a63403c53c73d05276830cfaf42b0c69de 100644 (file)
@@ -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");
index fdbc67ffb781178e59b9ab6f82f03c0dbf62d45f..b81fc99c949e0170fc3aa8c331629cf5b4765ac3 100644 (file)
@@ -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);
index 3370aff3d3366972bb71c2d5fbe4474e75c4fee7..049e70de3774c2268499e3995d7a1c546292d693 100644 (file)
@@ -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);
index 69a4ea14ff8dc88d12021ccb04be504898a324eb..0854abc53947dde9d26f5ee95f151b2375bc70ae 100644 (file)
@@ -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);
index 509679194343f8f330d7e83831825a36a49e6df9..bdcc09180bd775283f5737e004cdbdb3882fa667 100644 (file)
@@ -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);
index a60052d12c46e4d4b800a57f6cabf852c6e5d554..9e69a4fddf4d5e6ab51662e76c46fc9ab01dfedc 100644 (file)
@@ -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 ||