summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorPratik Shinde <pratikshinde320@gmail.com>2019-08-04 13:49:43 +0530
committerGao Xiang <hsiangkao@aol.com>2019-08-04 18:25:05 +0800
commit26097242976cce68e21d8b569dfda63fb68f356c (patch)
tree39577fd76271950692bdd21ce0e98dc2aefc9094 /mkfs
parent1ab9a08fa23163f361922c3aa94cb4a6918ce080 (diff)
erofs-utils: code for handling incorrect debug level
handling the case of incorrect debug level. Added an enumerated type for supported debug levels. Using 'atoi' in place of 'parse_num_from_str'. Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/main.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/mkfs/main.c b/mkfs/main.c
index fdb65fd..93cacca 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -30,16 +30,6 @@ static void usage(void)
fprintf(stderr, " -EX[,...] X=extended options\n");
}
-u64 parse_num_from_str(const char *str)
-{
- u64 num = 0;
- char *endptr = NULL;
-
- num = strtoull(str, &endptr, 10);
- BUG_ON(num == ULLONG_MAX);
- return num;
-}
-
static int parse_extended_opts(const char *opts)
{
#define MATCH_EXTENTED_OPT(opt, token, keylen) \
@@ -108,7 +98,12 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
break;
case 'd':
- cfg.c_dbg_lvl = parse_num_from_str(optarg);
+ i = atoi(optarg);
+ if (i < EROFS_MSG_MIN || i > EROFS_MSG_MAX) {
+ erofs_err("invalid debug level %d", i);
+ return -EINVAL;
+ }
+ cfg.c_dbg_lvl = i;
break;
case 'E':