fuse: drop redundant err assignments in fuse_dev_do_write()
Subsystems (2)
PATCH 1/1 fuse: drop redundant err assignments in fuse_dev_do_write()
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.
--- fs/fuse/dev.c | 2 -- 1 file changed, 2 deletions(-)
fs/fuse/dev.c +0 -2
@@ -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;
@@ -1898,7 +1897,6 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, goto copy_finish; } - err = -EINVAL ;if (oh.error <=-512 || oh.error >0 ) goto copy_finish;
Signature · 1 line
2.34.1
Quoted 23 lines · Li Wang
After
fuse_copy_one()succeeds, err is set to-EINVALbefore 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(-)fs/fuse/dev.c +0
-1@@ -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;
fs/fuse/dev.c static ssize_t fuse_dev_do_write(struct fuse_dev *fud, · line 1902
Quoted 7 lines
fs/fuse/dev.c +0
-1@@ -1898,7 +1897,6 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, goto copy_finish; } - err = -EINVAL ;if (oh.error <=-512 || oh.error >0 ) goto copy_finish;
Miklos Szeredi
maintainerQuoted 15 lines · Li Wang
After
fuse_copy_one()succeeds, err is set to-EINVALbefore 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(-)fs/fuse/dev.c +0
-0
fs/fuse/dev.c static ssize_t fuse_dev_do_write(struct fuse_dev *fud, · line 1891
Quoted 6 lines
fs/fuse/dev.c +0
-1@@ -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