diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-06-04 14:49:02 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:33 -0400 |
commit | 4a7a7ea1f59032e182b9faba06df61d6375a1f97 (patch) | |
tree | df771bfe2d78db30e4f4e0cf8b44a7a7e4b17688 /fs/bcachefs/opts.c | |
parent | 636d4eef1eefe447deef134bdf8e34c979ff009e (diff) | |
download | linux-4a7a7ea1f59032e182b9faba06df61d6375a1f97.tar.gz linux-4a7a7ea1f59032e182b9faba06df61d6375a1f97.tar.bz2 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.c | 24 |
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); |