From d8d12558dc24e32f489dc471ba19f25273edce7c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 18 Feb 2008 09:55:04 -0500 Subject: [PATCH] debugfs: Fix error handling in strtoblk() and common_block_args_process() Fix strtoblk() to allow a block number 0, and common_block_args_process() so it prints an error message if a block number that can't be parsed by strtoul(). Signed-off-by: "Theodore Ts'o" --- debugfs/util.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/debugfs/util.c b/debugfs/util.c index 7031850..cb84bd2 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -274,10 +274,8 @@ int strtoblk(const char *cmd, const char *str, blk_t *ret) blk = parse_ulong(str, cmd, "block number", &err); *ret = blk; - if (err == 0 && blk == 0) { - com_err(cmd, 0, "Invalid block number 0"); - err = 1; - } + if (err) + com_err(cmd, 0, "Invalid block number: %s", str); return err; } @@ -337,6 +335,11 @@ int common_block_args_process(int argc, char *argv[], if (strtoblk(argv[0], argv[1], block)) return 1; + if (*block == 0) { + com_err(argv[0], 0, "Invalid block number 0"); + err = 1; + } + if (argc > 2) { *count = parse_ulong(argv[2], argv[0], "count", &err); if (err) -- 1.8.3.1