Re: [PATCH] fuse: drop redundant err assignments in fuse_dev_do_write()
From: Miklos Szeredi
Date: Fri Jul 17 2026 - 08:01:59 EST
On Wed, 8 Jul 2026 at 04:17, Li Wang <liwang@xxxxxxxxxx> wrote:
>
> After fuse_copy_one() succeeds, err is set to -EINVAL before validating
> oh.len. When oh.len equals nbytes, err is already -EINVAL, so the extra
> assignments before the notification and oh.error checks are redundant.
>
> Signed-off-by: Li Wang <liwang@xxxxxxxxxx>
> ---
> fs/fuse/dev.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 5763a7cd3b37..7813f6214d0e 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -1887,7 +1887,6 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
> * Only allow notifications during while the connection is in an
> * initialized and connected state
> */
> - err = -EINVAL;
> if (!fch->initialized || !fch->connected)
> goto copy_finish;
Sorry, I won't apply this. It's neither an optimization (the
compiler will remove the assignment) nor makes the code more readable
(moves the error value further from where the error happens).
If we have a series of error conditions with the same error values,
then omitting the "err = ..." each time is valid, but this time
there's definite documentation value in redoing the assignment.
Thanks,
Miklos