On Wed, Feb 21, 2024 at 05:37:04PM +0800, Hongbo Li wrote:
> For mount option with bool type, the value must be 0 or 1 (See
> bch2_opt_parse). But this seems does not well intercepted cause
> for other value(like 2...), it returns the unexpect return code
> with error message printed.
> 
> Signed-off-by: Hongbo Li <[email protected]>
> ---
>  fs/bcachefs/opts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
> index b1ed0b9a20d3..fe1f17830694 100644
> --- a/fs/bcachefs/opts.c
> +++ b/fs/bcachefs/opts.c
> @@ -314,7 +314,7 @@ int bch2_opt_parse(struct bch_fs *c,
>               if (ret < 0 || (*res != 0 && *res != 1)) {
>                       if (err)
>                               prt_printf(err, "%s: must be bool", 
> opt->attr.name);
> -                     return ret;
> +                     return ret < 0 ?: -EINVAL;

It might be nice for that error message to be more specific in that the
bool value must be 0 or 1, but LGTM regardless:

Reviewed-by: Brian Foster <[email protected]>

>               }
>               break;
>       case BCH_OPT_UINT:
> -- 
> 2.34.1
> 


Reply via email to