summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/opts.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-06-04 20:49:02 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:09:33 +0200
commit4a7a7ea1f59032e182b9faba06df61d6375a1f97 (patch)
treedf771bfe2d78db30e4f4e0cf8b44a7a7e4b17688 /fs/bcachefs/opts.c
parentbcachefs: Fix memory corruption in encryption path (diff)
downloadlinux-4a7a7ea1f59032e182b9faba06df61d6375a1f97.tar.xz
linux-4a7a7ea1f59032e182b9faba06df61d6375a1f97.zip
bcachefs: Add some missing error messages
bch2_opt_parse() was failing to generate error messages in error path. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/opts.c')
-rw-r--r--fs/bcachefs/opts.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index 385451ef865e..c4ccb42d7851 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -267,20 +267,32 @@ int bch2_opt_parse(struct bch_fs *c,
switch (opt->type) {
case BCH_OPT_BOOL:
ret = kstrtou64(val, 10, res);
- if (ret < 0)
+ if (ret < 0 || (*res != 0 && *res != 1)) {
+ if (err)
+ pr_buf(err, "%s: must be bool",
+ opt->attr.name);
return ret;
+ }
break;
case BCH_OPT_UINT:
ret = opt->flags & OPT_HUMAN_READABLE
? bch2_strtou64_h(val, res)
: kstrtou64(val, 10, res);
- if (ret < 0)
+ if (ret < 0) {
+ if (err)
+ pr_buf(err, "%s: must be a number",
+ opt->attr.name);
return ret;
+ }
break;
case BCH_OPT_STR:
ret = match_string(opt->choices, -1, val);
- if (ret < 0)
+ if (ret < 0) {
+ if (err)
+ pr_buf(err, "%s: invalid selection",
+ opt->attr.name);
return ret;
+ }
*res = ret;
break;
@@ -289,8 +301,12 @@ int bch2_opt_parse(struct bch_fs *c,
return 0;
ret = opt->parse(c, val, res);
- if (ret < 0)
+ if (ret < 0) {
+ if (err)
+ pr_buf(err, "%s: parse error",
+ opt->attr.name);
return ret;
+ }
}
return bch2_opt_validate(opt, *res, err);