[PATCH v0 20/20] ubi-utils: mkfs.ubifs: Return error code if command line option is unknown

Daniel Wagner daniel.wagner at siemens.com
Mon Jun 12 03:51:01 PDT 2017


The tool 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 at siemens.com>
---
 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index a60052d12c46..9e69a4fddf4d 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 ||
-- 
2.9.4




More information about the linux-mtd mailing list