diff mbox

nandtest: fix --reads argument

Message ID 1408033785-20264-1-git-send-email-guido@vanguardiasur.com.ar
State Accepted
Headers show

Commit Message

Guido Martínez Aug. 14, 2014, 4:29 p.m. UTC
The --reads option specifies the argument as optional, but doesn't check
for a null optarg, which means that nandtest segfaults when run as
"nandtest --reads".

Fix this by making the argument required, and changing the help text to
not specify it as optional. Argument -r already specifies the argument
as required, so we fix this inconsistency too.

Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>
---
 nandtest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ezequiel Garcia Aug. 21, 2014, 7:14 p.m. UTC | #1
On 14 Aug 01:29 PM, Guido Martínez wrote:
> The --reads option specifies the argument as optional, but doesn't check
> for a null optarg, which means that nandtest segfaults when run as
> "nandtest --reads".
> 
> Fix this by making the argument required, and changing the help text to
> not specify it as optional. Argument -r already specifies the argument
> as required, so we fix this inconsistency too.
> 
> Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>

Nice catch!

Acked-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Artem Bityutskiy Sept. 8, 2014, 10:30 a.m. UTC | #2
On Thu, 2014-08-14 at 13:29 -0300, Guido Martínez wrote:
> The --reads option specifies the argument as optional, but doesn't check
> for a null optarg, which means that nandtest segfaults when run as
> "nandtest --reads".
> 
> Fix this by making the argument required, and changing the help text to
> not specify it as optional. Argument -r already specifies the argument
> as required, so we fix this inconsistency too.
> 
> Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>

Pushed, thanks!
diff mbox

Patch

diff --git a/nandtest.c b/nandtest.c
index 8ea39d3..0805387 100644
--- a/nandtest.c
+++ b/nandtest.c
@@ -24,7 +24,7 @@  void usage(int status)
 		"  -m, --markbad        Mark blocks bad if they appear so\n"
 		"  -s, --seed           Supply random seed\n"
 		"  -p, --passes         Number of passes\n"
-		"  -r, --reads          Read & check iterations per pass (default=4)\n"
+		"  -r <n>, --reads=<n>  Read & check <n> times per pass\n"
 		"  -o, --offset         Start offset on flash\n"
 		"  -l, --length         Length of flash to test\n"
 		"  -k, --keep           Restore existing contents after test\n",
@@ -166,7 +166,7 @@  int main(int argc, char **argv)
 			{ "passes", required_argument, 0, 'p' },
 			{ "offset", required_argument, 0, 'o' },
 			{ "length", required_argument, 0, 'l' },
-			{ "reads", optional_argument, 0, 'r' },
+			{ "reads", required_argument, 0, 'r' },
 			{ "keep", no_argument, 0, 'k' },
 			{0, 0, 0, 0},
 		};