Skip to contentSkip to conversation

nandtest: support hex/dec/oct for --offset and --length

PATCH Applied Brian Norris 1 participant 2 messages Oct 30, 2015 – Nov 11, 2015 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nandtest: support hex/dec/oct for --offset and --length

These two options are handled inconsistently, which caused an unnecessary amount of head scratching. Let's just use the simple helpers too, so we get the error handling right.

---
 nandtest.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
nandtest.c +6 -2
index 08053876506a..2ef7cc824d59 100644
@@ -15,6 +15,7 @@
 
 #include <asm/types.h>
 #include "mtd/mtd-user.h"
+#include "common.h"
 
 void usage(int status)
 {
@@ -154,6 +155,7 @@ int main(int argc, char **argv)
 	int keep_contents = 0;
 	uint32_t offset = 0;
 	uint32_t length = -1;
+	int error = 0;
 
 	seed = time(NULL);
 
@@ -205,17 +207,19 @@ int main(int argc, char **argv)
 			break;
 
 		case 'o':
-			offset = atol(optarg);
+			offset = simple_strtoul(optarg, &error);
 			break;
 
 		case 'l':
-			length = strtol(optarg, NULL, 0);
+			length = simple_strtoul(optarg, &error);
 			break;
 
 		}
 	}
 	if (argc - optind != 1)
 		usage(1);
+	if (error)
+		errmsg_die("Try --help for more information");
 
 	fd = open(argv[optind], O_RDWR);
 	if (fd < 0) {
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
author Applied
#1 lore raw
Quoted 5 lines · Brian Norris

These two options are handled inconsistently, which caused an unnecessary amount of head scratching. Let's just use the simple helpers too, so we get the error handling right.

Pushed to mtd-utils.git