Re: [PATCH] fuse: drop redundant err assignments in fuse_dev_do_write()
Miklos Szeredi <[email protected]> Fri, 17 Jul 2026 13:37:19 +0200
| Newsgroups | dev.linux.lists.fuse-devel,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAJfpegs-JKBU5OD9jj0z4fvvzdvA0j=CCCwCpYL+iFQ3SS6u7w@mail.gmail.com> |
On Wed, 8 Jul 2026 at 04:17, Li Wang <[email protected]> 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 <[email protected]> > --- > 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