<div dir="ltr"><div>Hi Gao,</div><div><br></div><div>Yes, I will include those changes and resend the patch.</div><div><br></div><div>--Pratik.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 4, 2019 at 9:40 AM Gao Xiang <<a href="mailto:hsiangkao@aol.com">hsiangkao@aol.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Pratik,<br>
<br>
On Sat, Aug 03, 2019 at 01:33:10PM +0530, Pratik Shinde wrote:<br>
> handling the case of incorrect debug level.<br>
> Added an enumerated type for supported debug levels.<br>
> Using 'atoi' in place of 'parse_num_from_str'.<br>
> <br>
> I have dropped the check for invalid compression algo name(which was there<br>
> in last patch)<br>
> Note:I think this patch covers different set of code changes than previous<br>
> patch,Hence I am sending a new patch instead of 'v2' of previous patch.<br>
> <br>
> Signed-off-by: Pratik Shinde <<a href="mailto:pratikshinde320@gmail.com" target="_blank">pratikshinde320@gmail.com</a>><br>
<br>
It looks good to me, and I'd like to introduce "EROFS_MSG_MIN / EROFS_MSG_MAX" as well.<br>
Do you agree with these modifications attached below? :)<br>
<br>
Thanks,<br>
Gao Xiang<br>
<br>
diff --git a/include/erofs/print.h b/include/erofs/print.h<br>
index bc0b8d4..e29fc1d 100644<br>
--- a/include/erofs/print.h<br>
+++ b/include/erofs/print.h<br>
@@ -12,6 +12,15 @@<br>
#include "config.h"<br>
#include <stdio.h><br>
<br>
+enum {<br>
+ EROFS_MSG_MIN = 0,<br>
+ EROFS_ERR = 0,<br>
+ EROFS_WARN = 2,<br>
+ EROFS_INFO = 3,<br>
+ EROFS_DBG = 7,<br>
+ EROFS_MSG_MAX = 9<br>
+};<br>
+<br>
#define FUNC_LINE_FMT "%s() Line[%d] "<br>
<br>
#ifndef pr_fmt<br>
@@ -19,7 +28,7 @@<br>
#endif<br>
<br>
#define erofs_dbg(fmt, ...) do { \<br>
- if (cfg.c_dbg_lvl >= 7) { \<br>
+ if (cfg.c_dbg_lvl >= EROFS_DBG) { \<br>
fprintf(stdout, \<br>
pr_fmt(fmt), \<br>
__func__, \<br>
@@ -29,7 +38,7 @@<br>
} while (0)<br>
<br>
#define erofs_info(fmt, ...) do { \<br>
- if (cfg.c_dbg_lvl >= 3) { \<br>
+ if (cfg.c_dbg_lvl >= EROFS_INFO) { \<br>
fprintf(stdout, \<br>
pr_fmt(fmt), \<br>
__func__, \<br>
@@ -40,7 +49,7 @@<br>
} while (0)<br>
<br>
#define erofs_warn(fmt, ...) do { \<br>
- if (cfg.c_dbg_lvl >= 2) { \<br>
+ if (cfg.c_dbg_lvl >= EROFS_WARN) { \<br>
fprintf(stdout, \<br>
pr_fmt(fmt), \<br>
__func__, \<br>
@@ -51,7 +60,7 @@<br>
} while (0)<br>
<br>
#define erofs_err(fmt, ...) do { \<br>
- if (cfg.c_dbg_lvl >= 0) { \<br>
+ if (cfg.c_dbg_lvl >= EROFS_ERR) { \<br>
fprintf(stderr, \<br>
"Err: " pr_fmt(fmt), \<br>
__func__, \<br>
diff --git a/mkfs/main.c b/mkfs/main.c<br>
index fdb65fd..33b0db5 100644<br>
--- a/mkfs/main.c<br>
+++ b/mkfs/main.c<br>
@@ -30,16 +30,6 @@ static void usage(void)<br>
fprintf(stderr, " -EX[,...] X=extended options\n");<br>
}<br>
<br>
-u64 parse_num_from_str(const char *str)<br>
-{<br>
- u64 num = 0;<br>
- char *endptr = NULL;<br>
-<br>
- num = strtoull(str, &endptr, 10);<br>
- BUG_ON(num == ULLONG_MAX);<br>
- return num;<br>
-}<br>
-<br>
static int parse_extended_opts(const char *opts)<br>
{<br>
#define MATCH_EXTENTED_OPT(opt, token, keylen) \<br>
@@ -108,7 +98,13 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])<br>
break;<br>
<br>
case 'd':<br>
- cfg.c_dbg_lvl = parse_num_from_str(optarg);<br>
+ cfg.c_dbg_lvl = atoi(optarg);<br>
+ if (cfg.c_dbg_lvl < EROFS_MSG_MIN<br>
+ || cfg.c_dbg_lvl > EROFS_MSG_MAX) {<br>
+ erofs_err("invalid debug level %d",<br>
+ cfg.c_dbg_lvl);<br>
+ return -EINVAL;<br>
+ }<br>
break;<br>
<br>
case 'E':<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>