aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2015-10-29 17:12:01 -0700
committerBrian Norris <computersforpeace@gmail.com>2015-11-11 14:05:07 -0800
commit892f17ce795b64ba024989785ca62ef72299df52 (patch)
treea262cee4ccdbd13e26c4b3cce8180e43822a6bd9
parenta494d30ab1ae40cb7665680cadf5af3ca3830a73 (diff)
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. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--nandtest.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/nandtest.c b/nandtest.c
index 0805387..2ef7cc8 100644
--- a/nandtest.c
+++ b/nandtest.c
@@ -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) {