All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: error handling for incorrect dbg lvl & compression algorithm
@ 2019-08-01 19:18 Pratik Shinde
  2019-08-02  2:00 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Pratik Shinde @ 2019-08-01 19:18 UTC (permalink / raw)


handling the case of incorrect debug level.
also, an early check for valid compression algorithm.

Signed-off-by: Pratik Shinde <pratikshinde320 at gmail.com>
---
 mkfs/main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/mkfs/main.c b/mkfs/main.c
index fdb65fd..4231d13 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -105,10 +105,22 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 				}
 			}
 			cfg.c_compr_alg_master = strndup(optarg, i);
+			if (strcmp(cfg.c_compr_alg_master, "lz4")
+			    && strcmp(cfg.c_compr_alg_master, "lz4hc")) {
+				erofs_err("invalid compressor algorithm %s",
+					  cfg.c_compr_alg_master);
+				return -EINVAL;
+			}
 			break;
 
 		case 'd':
 			cfg.c_dbg_lvl = parse_num_from_str(optarg);
+			if (cfg.c_dbg_lvl < 0 || cfg.c_dbg_lvl > 9) {
+				fprintf(stderr,
+					"invalid debug level %d\n",
+					cfg.c_dbg_lvl);
+				return -EINVAL;
+			}
 			break;
 
 		case 'E':
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-02  6:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-01 19:18 [PATCH] erofs-utils: error handling for incorrect dbg lvl & compression algorithm Pratik Shinde
2019-08-02  2:00 ` Gao Xiang
     [not found]   ` <CAGu0czT-HLnhAKQV6OhtgNu83fGDdHKu7+NZK15m-K7md3zVUQ@mail.gmail.com>
2019-08-02  6:14     ` Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.