From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Dmitry Antipov <dmantipov@yandex.ru>,
Richard Weinberger <richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper
Date: Thu, 2 Apr 2026 19:18:05 +0800 [thread overview]
Message-ID: <67df08d1-6bbf-560c-de40-9cf1e88c406a@huawei.com> (raw)
In-Reply-To: <20260402081332.523352-1-dmantipov@yandex.ru>
在 2026/4/2 16:13, Dmitry Antipov 写道:
> Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic
> 'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,
> thus making the latter not needed anymore.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> fs/ubifs/debug.c | 44 ++++++++++----------------------------------
> 1 file changed, 10 insertions(+), 34 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 160c16aa7b6e..252cf82012cf 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
> return provide_user_output(val, u, count, ppos);
> }
>
> -/**
> - * interpret_user_input - interpret user debugfs file input.
> - * @u: user-provided buffer with the input
> - * @count: buffer size
> - *
> - * This is a helper function which interpret user input to a boolean UBIFS
> - * debugfs file. Returns %0 or %1 in case of success and a negative error code
> - * in case of failure.
> - */
> -static int interpret_user_input(const char __user *u, size_t count)
> -{
> - size_t buf_size;
> - char buf[8];
> -
> - buf_size = min_t(size_t, count, (sizeof(buf) - 1));
> - if (copy_from_user(buf, u, buf_size))
> - return -EFAULT;
> -
> - if (buf[0] == '1')
> - return 1;
> - else if (buf[0] == '0')
> - return 0;
> -
> - return -EINVAL;
> -}
> -
> static ssize_t dfs_file_write(struct file *file, const char __user *u,
> size_t count, loff_t *ppos)
> {
> struct ubifs_info *c = file->private_data;
> struct ubifs_debug_info *d = c->dbg;
> struct dentry *dent = file->f_path.dentry;
> - int val;
> + bool val;
> + int ret;
>
> if (file->f_path.dentry == d->dfs_dump_lprops) {
> ubifs_dump_lprops(c);
> @@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
> return count;
> }
>
> - val = interpret_user_input(u, count);
> - if (val < 0)
> - return val;
> + ret = kstrtobool_from_user(u, count, &val);
> + if (unlikely(ret))
> + return ret;
>
> if (dent == d->dfs_chk_gen)
> d->chk_gen = val;
> @@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
> size_t count, loff_t *ppos)
> {
> struct dentry *dent = file->f_path.dentry;
> - int val;
> + bool val;
> + int ret;
>
> - val = interpret_user_input(u, count);
> - if (val < 0)
> - return val;
> + ret = kstrtobool_from_user(u, count, &val);
> + if (unlikely(ret))
> + return ret;
>
> if (dent == dfs_chk_gen)
> ubifs_dbg.chk_gen = val;
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-04-02 11:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 8:13 [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
2026-04-02 11:18 ` Zhihao Cheng [this message]
2026-04-03 16:37 ` [PATCH v2 1/2] " Dmitry Antipov
2026-04-03 16:37 ` [PATCH v2 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
2026-04-07 2:37 ` Zhihao Cheng
2026-04-07 16:05 ` [PATCH v3 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
2026-04-07 16:05 ` [PATCH v3 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
2026-04-08 6:09 ` Zhihao Cheng
2026-04-09 4:56 ` [PATCH v4 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
2026-04-09 4:56 ` [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
2026-04-10 1:06 ` Zhihao Cheng
2026-04-10 5:57 ` Richard Weinberger
2026-04-10 11:55 ` Dmitry Antipov
2026-04-10 12:00 ` Dmitry Antipov
2026-04-16 3:30 ` Zhihao Cheng
2026-04-13 13:24 ` Dmitry Antipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67df08d1-6bbf-560c-de40-9cf1e88c406a@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=dmantipov@yandex.ru \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox