[PATCH v0 11/20] nor-utils: rfddump: Return error code if command line option is unknown

Daniel Wagner daniel.wagner at siemens.com
Mon Jun 12 03:50:52 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.

Signed-off-by: Daniel Wagner <daniel.wagner at siemens.com>
---
 nor-utils/rfddump.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/nor-utils/rfddump.c b/nor-utils/rfddump.c
index 048f58ca4ec9..5141ea37b926 100644
--- a/nor-utils/rfddump.c
+++ b/nor-utils/rfddump.c
@@ -55,7 +55,7 @@ struct rfd {
 	int verbose;
 };
 
-void display_help(void)
+void display_help(int status)
 {
 	printf("Usage: %s [OPTIONS] MTD-device filename\n"
 			"Dumps the contents of a resident flash disk\n"
@@ -65,7 +65,7 @@ void display_help(void)
 			"-v         --verbose		Be verbose\n"
 			"-b size    --blocksize          Block size (defaults to erase unit)\n",
 			PROGRAM_NAME);
-	exit(0);
+	exit(status);
 }
 
 void display_version(void)
@@ -101,7 +101,7 @@ void process_options(int argc, char *argv[], struct rfd *rfd)
 
 		switch (c) {
 			case 'h':
-				display_help();
+				display_help(EXIT_SUCCESS);
 				break;
 			case 'V':
 				display_version();
@@ -119,7 +119,7 @@ void process_options(int argc, char *argv[], struct rfd *rfd)
 	}
 
 	if ((argc - optind) != 2 || error)
-		display_help();
+		display_help(EXIT_FAILURE);
 
 	rfd->mtd_filename = argv[optind];
 	rfd->out_filename = argv[optind + 1];
-- 
2.9.4




More information about the linux-mtd mailing list