From patchwork Fri Oct 30 00:12:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 538085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BC57E1400A0 for ; Fri, 30 Oct 2015 11:14:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Um+q8geF; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrxJ8-0003k6-OC; Fri, 30 Oct 2015 00:12:38 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrxJ5-0003O6-Uu for linux-mtd@lists.infradead.org; Fri, 30 Oct 2015 00:12:36 +0000 Received: by pacfv9 with SMTP id fv9so57379847pac.3 for ; Thu, 29 Oct 2015 17:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=27zjk5v4VuX4ZLETZCkO/+BBYK0KiGDsmtqjt/tUw1A=; b=Um+q8geF2Ji+ggv+5A6hXxhg1BGeXVHAqAoPiAp0GHAikV7W3UnKTgZG+MLLpprZRo iMa9d33RONbdEQDe/dCKfbzcrtJBSnXdL67O83cxgmSpgYBfJGjcY3N7yrbx2Icognxx NsXCchf7SnKhnF/P3LY9QLKbYd6be6f8gt2Vusm5VJKaMEqPOsOwEuaCpeO97NsvMr+3 8tYpRonuYHRg7c4GmO9DNMT11Ey+bq0/4apecLb3iUdpTgmaaaYeeYtd5zG92KRczsLU gIQ0XN2M7W7wqAFOnq5zlAnYQwqNMc8CdkBIA6UowxNhC0P4BBFKUIX+2FRQeISlHh3/ GcMA== X-Received: by 10.66.129.137 with SMTP id nw9mr5021174pab.107.1446163932848; Thu, 29 Oct 2015 17:12:12 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id bs3sm4387356pbd.89.2015.10.29.17.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 17:12:12 -0700 (PDT) From: Brian Norris To: Subject: [mtd-utils PATCH] nandtest: support hex/dec/oct for --offset and --length Date: Thu, 29 Oct 2015 17:12:01 -0700 Message-Id: <1446163921-115867-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151029_171236_075560_F2295957 X-CRM114-Status: GOOD ( 10.75 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:22f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Brian Norris MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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 #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) {