linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: <linux-mtd@lists.infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Subject: [mtd-utils PATCH] nandtest: support hex/dec/oct for --offset and --length
Date: Thu, 29 Oct 2015 17:12:01 -0700	[thread overview]
Message-ID: <1446163921-115867-1-git-send-email-computersforpeace@gmail.com> (raw)

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>
---
 nandtest.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/nandtest.c b/nandtest.c
index 08053876506a..2ef7cc824d59 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) {
-- 
2.6.0.rc2.230.g3dd15c0

             reply	other threads:[~2015-10-30  0:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30  0:12 Brian Norris [this message]
2015-11-11 22:06 ` [mtd-utils PATCH] nandtest: support hex/dec/oct for --offset and --length Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446163921-115867-1-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).