* [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown
@ 2017-06-12 10:50 Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 01/20] jffs2dump: " Daniel Wagner
` (20 more replies)
0 siblings, 21 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
Hi,
I run into a small problem when I was setting up my build with Yocto
using mkfs.uibfs. I used an invalid option but Yocto didn't report
this as an option and continued with the build. That resulted in a
empy image and it took a while to figure out what is happening. By
returning an error code at the right spot this would really help. So
here are some patches adding a return code when an command line option
is unknown.
Thanks,
Daniel
Daniel Wagner (20):
jffs2dump: Return error code if command line option is unknown
jffs2dump: Use defines for exit code values
mkfs.jffs2: Return error code if command line option is unknown
mkfs.jffs2: Use defines for exit code values
jffsX-utils: Return error code if command line option is unknown
mtd-utils: lash_unlock: Use defines for exit code values
mtd-utils: flashcp: Drop exit code defines
mtd-utils: ftl_format: Use return directly to leave main function
mtd-utils: nandtest: Use defines for exit code values
mtd-utils: nftl_format: Use defines for exit code values
nor-utils: rfddump: Return error code if command line option is
unknown
nor-utils: rfdformat: Return error code if command line option is
unknown
integrity: Return error code if command line option is unknown
ubi-utils: ubiblock: Return error code if command line option is
unknown
ubi-utils: ubiformat: Return error code if command line option is
unknown
ubi-utils: ubimkvol: Return error code if command line option is
unknown
ubi-utils: ubirmvol: Return error code if command line option is
unknown
ubi-utils: ubirsvol: Return error code if command line option is
unknown
ubi-utils: ubiupdatevol: Return error code if command line option is
unknown
ubi-utils: mkfs.ubifs: Return error code if command line option is
unknown
jffsX-utils/jffs2dump.c | 14 +++++++-------
jffsX-utils/mkfs.jffs2.c | 6 ++++--
jffsX-utils/sumtool.c | 4 +++-
misc-utils/flash_unlock.c | 10 +++++-----
misc-utils/flashcp.c | 3 ---
misc-utils/ftl_format.c | 3 +--
nand-utils/nandtest.c | 6 +++---
nand-utils/nftl_format.c | 6 +++---
nor-utils/rfddump.c | 8 ++++----
nor-utils/rfdformat.c | 8 ++++----
tests/fs-tests/integrity/integck.c | 5 ++++-
ubi-utils/ubiblock.c | 6 +++++-
ubi-utils/ubiformat.c | 6 +++++-
ubi-utils/ubimkvol.c | 7 ++++++-
ubi-utils/ubirmvol.c | 7 ++++++-
ubi-utils/ubirsvol.c | 7 ++++++-
ubi-utils/ubiupdatevol.c | 7 ++++++-
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 ++++--
18 files changed, 76 insertions(+), 43 deletions(-)
--
2.9.4
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v0 01/20] jffs2dump: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 02/20] jffs2dump: Use defines for exit code values Daniel Wagner
` (19 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
jffsX-utils/jffs2dump.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/jffsX-utils/jffs2dump.c b/jffsX-utils/jffs2dump.c
index a8d082bf1e39..df5b1e120b69 100644
--- a/jffsX-utils/jffs2dump.c
+++ b/jffsX-utils/jffs2dump.c
@@ -50,7 +50,7 @@
long imglen; // length of image
char *data; // image data
-void display_help (void)
+void display_help (int error)
{
printf("Usage: %s [OPTION]... INPUTFILE\n"
"Dump the contents of a binary JFFS2 image.\n\n"
@@ -65,7 +65,7 @@ void display_help (void)
" -o, --oobsize=LEN size of oob data chunk in binary image (NAND only)\n"
" -v, --verbose verbose output\n",
PROGRAM_NAME);
- exit(0);
+ exit(error ? EXIT_FAILURE : EXIT_SUCCESS);
}
void display_version (void)
@@ -124,7 +124,7 @@ void process_options (int argc, char *argv[])
switch (c) {
case 'h':
- display_help();
+ display_help(EXIT_SUCCESS);
break;
case 'V':
display_version();
@@ -161,7 +161,7 @@ void process_options (int argc, char *argv[])
}
if ((argc - optind) != 1 || error)
- display_help ();
+ display_help (error);
img = argv[optind];
}
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 02/20] jffs2dump: Use defines for exit code values
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 01/20] jffs2dump: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 03/20] mkfs.jffs2: Return error code if command line option is unknown Daniel Wagner
` (18 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
Make the usage of exit consist. That is use the pre defined exit
values.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
---
jffsX-utils/jffs2dump.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/jffsX-utils/jffs2dump.c b/jffsX-utils/jffs2dump.c
index df5b1e120b69..2200f06919a5 100644
--- a/jffsX-utils/jffs2dump.c
+++ b/jffsX-utils/jffs2dump.c
@@ -751,7 +751,7 @@ int main(int argc, char **argv)
/* Open the input file */
if ((fd = open(img, O_RDONLY)) == -1) {
perror("open input file");
- exit(1);
+ exit(EXIT_FAILURE);
}
// get image length
@@ -762,7 +762,7 @@ int main(int argc, char **argv)
if (!data) {
perror("out of memory");
close (fd);
- exit(1);
+ exit(EXIT_FAILURE);
}
if (datsize && oobsize) {
@@ -796,5 +796,5 @@ int main(int argc, char **argv)
free (data);
// Return happy
- exit (0);
+ exit (EXIT_SUCCESS);
}
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 03/20] mkfs.jffs2: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 01/20] jffs2dump: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 02/20] jffs2dump: Use defines for exit code values Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 04/20] mkfs.jffs2: Use defines for exit code values Daniel Wagner
` (17 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
jffsX-utils/mkfs.jffs2.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
index ca5e0d560f98..c77f19005b3e 100644
--- a/jffsX-utils/mkfs.jffs2.c
+++ b/jffsX-utils/mkfs.jffs2.c
@@ -1629,9 +1629,11 @@ int main(int argc, char **argv)
break;
case 'h':
- case '?':
puts(helptext);
exit(EXIT_SUCCESS);
+ case '?':
+ puts(helptext);
+ exit(EXIT_FAILURE);
case 'v':
verbose = 1;
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 04/20] mkfs.jffs2: Use defines for exit code values
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (2 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 03/20] mkfs.jffs2: Return error code if command line option is unknown Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 05/20] jffsX-utils: Return error code if command line option is unknown Daniel Wagner
` (16 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
Make the usage of exit consist. That is use the pre defined exit
values.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
---
jffsX-utils/mkfs.jffs2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
index c77f19005b3e..2fb77301431f 100644
--- a/jffsX-utils/mkfs.jffs2.c
+++ b/jffsX-utils/mkfs.jffs2.c
@@ -1052,7 +1052,7 @@ static void formalize_posix_acl(void *xvalue, int *value_len)
if (offset > *value_len) {
printf("Length of JFFS2 ACL expression(%u) is longer than general one(%u).\n",
offset, *value_len);
- exit(1);
+ exit(EXIT_FAILURE);
}
memcpy(xvalue, buffer, offset);
*value_len = offset;
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 05/20] jffsX-utils: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (3 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 04/20] mkfs.jffs2: Use defines for exit code values Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 06/20] mtd-utils: lash_unlock: Use defines for exit code values Daniel Wagner
` (15 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
jffsX-utils/sumtool.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/jffsX-utils/sumtool.c b/jffsX-utils/sumtool.c
index 09586155f74c..a995bdf21d8e 100644
--- a/jffsX-utils/sumtool.c
+++ b/jffsX-utils/sumtool.c
@@ -156,9 +156,11 @@ void process_options (int argc, char **argv)
target_endian = __LITTLE_ENDIAN;
break;
case 'h':
- case '?':
puts(helptext);
exit(EXIT_SUCCESS);
+ case '?':
+ puts(helptext);
+ exit(EXIT_FAILURE);
case 'v':
verbose = 1;
break;
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 06/20] mtd-utils: lash_unlock: Use defines for exit code values
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (4 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 05/20] jffsX-utils: Return error code if command line option is unknown Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 07/20] mtd-utils: flashcp: Drop exit code defines Daniel Wagner
` (14 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
misc-utils/flash_unlock.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/misc-utils/flash_unlock.c b/misc-utils/flash_unlock.c
index 94f476114355..5a3aac532053 100644
--- a/misc-utils/flash_unlock.c
+++ b/misc-utils/flash_unlock.c
@@ -87,7 +87,7 @@ static void process_args(int argc, char *argv[])
switch (c) {
case 'h':
- usage(0);
+ usage(EXIT_SUCCESS);
break;
case 'i':
req = REQUEST_ISLOCKED;
@@ -105,14 +105,14 @@ static void process_args(int argc, char *argv[])
common_print_version();
exit(0);
default:
- usage(1);
+ usage(EXIT_FAILURE);
break;
}
}
if (req_set > 1) {
errmsg("cannot specify more than one lock/unlock/islocked option");
- usage(1);
+ usage(EXIT_FAILURE);
}
arg_idx = optind;
@@ -120,10 +120,10 @@ static void process_args(int argc, char *argv[])
/* Sanity checks */
if (argc - arg_idx < 1) {
errmsg("too few arguments");
- usage(1);
+ usage(EXIT_FAILURE);
} else if (argc - arg_idx > 3) {
errmsg("too many arguments");
- usage(1);
+ usage(EXIT_FAILURE);
}
/* First non-option argument */
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 07/20] mtd-utils: flashcp: Drop exit code defines
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (5 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 06/20] mtd-utils: lash_unlock: Use defines for exit code values Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 08/20] mtd-utils: ftl_format: Use return directly to leave main function Daniel Wagner
` (13 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
The EXIT_{FAILURE|SUCCESS} are already defined in stdlib.h.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
---
misc-utils/flashcp.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/misc-utils/flashcp.c b/misc-utils/flashcp.c
index af3c88de9ced..a35e6fca9d8d 100644
--- a/misc-utils/flashcp.c
+++ b/misc-utils/flashcp.c
@@ -45,9 +45,6 @@
#include "common.h"
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
/* for debugging purposes only */
#ifdef DEBUG
#undef DEBUG
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 08/20] mtd-utils: ftl_format: Use return directly to leave main function
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (6 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 07/20] mtd-utils: flashcp: Drop exit code defines Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 09/20] mtd-utils: nandtest: Use defines for exit code values Daniel Wagner
` (12 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
We can use return with the exit code instead of the sliglty odd exit,
return pattern.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
---
misc-utils/ftl_format.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/misc-utils/ftl_format.c b/misc-utils/ftl_format.c
index 74322c7f03eb..649984b2a8cc 100644
--- a/misc-utils/ftl_format.c
+++ b/misc-utils/ftl_format.c
@@ -333,6 +333,5 @@ int main(int argc, char *argv[])
}
close(fd);
- exit((ret) ? EXIT_FAILURE : EXIT_SUCCESS);
- return 0;
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;
}
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 09/20] mtd-utils: nandtest: Use defines for exit code values
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (7 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 08/20] mtd-utils: ftl_format: Use return directly to leave main function Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 10/20] mtd-utils: nftl_format: " Daniel Wagner
` (11 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
nand-utils/nandtest.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nand-utils/nandtest.c b/nand-utils/nandtest.c
index 56767337846b..9e39446de257 100644
--- a/nand-utils/nandtest.c
+++ b/nand-utils/nandtest.c
@@ -181,14 +181,14 @@ int main(int argc, char **argv)
switch (c) {
case 'h':
- usage(0);
+ usage(EXIT_SUCCESS);
break;
case 'V':
common_print_version();
exit(EXIT_SUCCESS);
break;
case '?':
- usage(1);
+ usage(EXIT_FAILURE);
break;
case 'm':
@@ -222,7 +222,7 @@ int main(int argc, char **argv)
}
}
if (argc - optind != 1)
- usage(1);
+ usage(EXIT_FAILURE);
if (error)
errmsg_die("Try --help for more information");
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 10/20] mtd-utils: nftl_format: Use defines for exit code values
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (8 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 09/20] mtd-utils: nandtest: Use defines for exit code values Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 11/20] nor-utils: rfddump: Return error code if command line option is unknown Daniel Wagner
` (10 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
nand-utils/nftl_format.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nand-utils/nftl_format.c b/nand-utils/nftl_format.c
index a329c59fc504..ea8199d5509d 100644
--- a/nand-utils/nftl_format.c
+++ b/nand-utils/nftl_format.c
@@ -234,7 +234,7 @@ int main(int argc, char **argv)
int idx = 0;
if (argc < 2)
- usage(1);
+ usage(EXIT_FAILURE);
nftl = "NFTL";
@@ -249,13 +249,13 @@ int main(int argc, char **argv)
break;
case 'h':
case '?':
- usage(0);
+ usage(EXIT_SUCCESS);
break;
case 'V':
display_version();
break;
default:
- usage(1);
+ usage(EXIT_FAILURE);
break;
}
}
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 11/20] nor-utils: rfddump: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (9 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 10/20] mtd-utils: nftl_format: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 12/20] nor-utils: rfdformat: " Daniel Wagner
` (9 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@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
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 12/20] nor-utils: rfdformat: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (10 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 11/20] nor-utils: rfddump: Return error code if command line option is unknown Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 13/20] integrity: " Daniel Wagner
` (8 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
nor-utils/rfdformat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/nor-utils/rfdformat.c b/nor-utils/rfdformat.c
index d393975e2354..1f01a8531012 100644
--- a/nor-utils/rfdformat.c
+++ b/nor-utils/rfdformat.c
@@ -30,7 +30,7 @@
#include "common.h"
-void display_help(void)
+void display_help(int status)
{
printf("Usage: %s [OPTIONS] MTD-device\n"
"Formats NOR flash for resident flash disk\n"
@@ -38,7 +38,7 @@ void display_help(void)
"-h --help display this help and exit\n"
"-V --version output version information and exit\n",
PROGRAM_NAME);
- exit(0);
+ exit(status);
}
void display_version(void)
@@ -69,7 +69,7 @@ void process_options(int argc, char *argv[], const char **mtd_filename)
switch (c) {
case 'h':
- display_help();
+ display_help(EXIT_SUCCESS);
break;
case 'V':
display_version();
@@ -81,7 +81,7 @@ void process_options(int argc, char *argv[], const char **mtd_filename)
}
if ((argc - optind) != 1 || error)
- display_help();
+ display_help(EXIT_FAILURE);
*mtd_filename = argv[optind];
}
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 13/20] integrity: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (11 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 12/20] nor-utils: rfdformat: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 14/20] ubi-utils: ubiblock: " Daniel Wagner
` (7 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
tests/fs-tests/integrity/integck.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 7cb530515d42..827adc5205bf 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");
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 14/20] ubi-utils: ubiblock: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (12 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 13/20] integrity: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 15/20] ubi-utils: ubiformat: " Daniel Wagner
` (6 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
ubi-utils/ubiblock.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubiblock.c b/ubi-utils/ubiblock.c
index 1e12be8fb978..8e366789a88c 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();
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 15/20] ubi-utils: ubiformat: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (13 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 14/20] ubi-utils: ubiblock: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 16/20] ubi-utils: ubimkvol: " Daniel Wagner
` (5 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
ubi-utils/ubiformat.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index 896fe20cc6a4..ef0378a63403 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");
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 16/20] ubi-utils: ubimkvol: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (14 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 15/20] ubi-utils: ubiformat: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 17/20] ubi-utils: ubirmvol: " Daniel Wagner
` (4 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
ubi-utils/ubimkvol.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubimkvol.c b/ubi-utils/ubimkvol.c
index fdbc67ffb781..b81fc99c949e 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);
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 17/20] ubi-utils: ubirmvol: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (15 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 16/20] ubi-utils: ubimkvol: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 18/20] ubi-utils: ubirsvol: " Daniel Wagner
` (3 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
ubi-utils/ubirmvol.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubirmvol.c b/ubi-utils/ubirmvol.c
index 3370aff3d336..049e70de3774 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);
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 18/20] ubi-utils: ubirsvol: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (16 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 17/20] ubi-utils: ubirmvol: " Daniel Wagner
@ 2017-06-12 10:50 ` Daniel Wagner
2017-06-12 10:51 ` [PATCH v0 19/20] ubi-utils: ubiupdatevol: " Daniel Wagner
` (2 subsequent siblings)
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:50 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
ubi-utils/ubirsvol.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubirsvol.c b/ubi-utils/ubirsvol.c
index 69a4ea14ff8d..0854abc53947 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);
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 19/20] ubi-utils: ubiupdatevol: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (17 preceding siblings ...)
2017-06-12 10:50 ` [PATCH v0 18/20] ubi-utils: ubirsvol: " Daniel Wagner
@ 2017-06-12 10:51 ` Daniel Wagner
2017-06-12 10:51 ` [PATCH v0 20/20] ubi-utils: mkfs.ubifs: " Daniel Wagner
2017-06-14 9:12 ` [PATCH v0 00/20] mtd-utils: " David Oberhollenzer
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:51 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@siemens.com>
---
ubi-utils/ubiupdatevol.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubiupdatevol.c b/ubi-utils/ubiupdatevol.c
index 509679194343..bdcc09180bd7 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);
--
2.9.4
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v0 20/20] ubi-utils: mkfs.ubifs: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (18 preceding siblings ...)
2017-06-12 10:51 ` [PATCH v0 19/20] ubi-utils: ubiupdatevol: " Daniel Wagner
@ 2017-06-12 10:51 ` Daniel Wagner
2017-06-14 9:12 ` [PATCH v0 00/20] mtd-utils: " David Oberhollenzer
20 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-12 10:51 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Wagner
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@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
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
` (19 preceding siblings ...)
2017-06-12 10:51 ` [PATCH v0 20/20] ubi-utils: mkfs.ubifs: " Daniel Wagner
@ 2017-06-14 9:12 ` David Oberhollenzer
2017-06-14 10:37 ` Daniel Wagner
20 siblings, 1 reply; 23+ messages in thread
From: David Oberhollenzer @ 2017-06-14 9:12 UTC (permalink / raw)
To: Daniel Wagner, linux-mtd
Hi Daniel,
I applied your patches to mtd-utils.git. However, I took the liberty
of reordering and squashing some of the patches with identical commit
messages and identical, tiny changes to different programs.
Thanks,
David
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown
2017-06-14 9:12 ` [PATCH v0 00/20] mtd-utils: " David Oberhollenzer
@ 2017-06-14 10:37 ` Daniel Wagner
0 siblings, 0 replies; 23+ messages in thread
From: Daniel Wagner @ 2017-06-14 10:37 UTC (permalink / raw)
To: David Oberhollenzer; +Cc: linux-mtd
Hi David,
On 06/14/2017 11:12 AM, David Oberhollenzer wrote:
> I applied your patches to mtd-utils.git. However, I took the liberty
> of reordering and squashing some of the patches with identical commit
> messages and identical, tiny changes to different programs.
Works for me. Thanks!
cheers,
Daniel
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2017-06-14 10:37 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 10:50 [PATCH v0 00/20] mtd-utils: Return error code if command line option is unknown Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 01/20] jffs2dump: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 02/20] jffs2dump: Use defines for exit code values Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 03/20] mkfs.jffs2: Return error code if command line option is unknown Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 04/20] mkfs.jffs2: Use defines for exit code values Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 05/20] jffsX-utils: Return error code if command line option is unknown Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 06/20] mtd-utils: lash_unlock: Use defines for exit code values Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 07/20] mtd-utils: flashcp: Drop exit code defines Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 08/20] mtd-utils: ftl_format: Use return directly to leave main function Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 09/20] mtd-utils: nandtest: Use defines for exit code values Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 10/20] mtd-utils: nftl_format: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 11/20] nor-utils: rfddump: Return error code if command line option is unknown Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 12/20] nor-utils: rfdformat: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 13/20] integrity: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 14/20] ubi-utils: ubiblock: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 15/20] ubi-utils: ubiformat: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 16/20] ubi-utils: ubimkvol: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 17/20] ubi-utils: ubirmvol: " Daniel Wagner
2017-06-12 10:50 ` [PATCH v0 18/20] ubi-utils: ubirsvol: " Daniel Wagner
2017-06-12 10:51 ` [PATCH v0 19/20] ubi-utils: ubiupdatevol: " Daniel Wagner
2017-06-12 10:51 ` [PATCH v0 20/20] ubi-utils: mkfs.ubifs: " Daniel Wagner
2017-06-14 9:12 ` [PATCH v0 00/20] mtd-utils: " David Oberhollenzer
2017-06-14 10:37 ` Daniel Wagner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.