diff mbox series

[1/5] 9p: fix ignored return value in v9fs_dir_release

Message ID 20230427-scan-build-v1-1-efa05d65e2da@codewreck.org (mailing list archive)
State Superseded
Headers show
Series Fix scan-build warnings | expand

Commit Message

Dominique Martinet April 27, 2023, 11:23 a.m. UTC
retval from filemap_fdatawrite was immediately overwritten by the
following p9_fid_put: preserve any error in fdatawrite if there
was any first.

This fixes the following scan-build warning:
fs/9p/vfs_dir.c:220:4: warning: Value stored to 'retval' is never read [deadcode.DeadStores]
                        retval = filemap_fdatawrite(inode->i_mapping);
                        ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
 fs/9p/vfs_dir.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Simon Horman May 2, 2023, 2:46 p.m. UTC | #1
On Thu, Apr 27, 2023 at 08:23:34PM +0900, Dominique Martinet wrote:
> retval from filemap_fdatawrite was immediately overwritten by the
> following p9_fid_put: preserve any error in fdatawrite if there
> was any first.
> 
> This fixes the following scan-build warning:
> fs/9p/vfs_dir.c:220:4: warning: Value stored to 'retval' is never read [deadcode.DeadStores]
>                         retval = filemap_fdatawrite(inode->i_mapping);
>                         ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Perhaps:

Fixes: 89c58cb395ec ("fs/9p: fix error reporting in v9fs_dir_release")

> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Dominique Martinet May 2, 2023, 11:32 p.m. UTC | #2
Thanks for all the reviews!

Simon Horman wrote on Tue, May 02, 2023 at 04:46:17PM +0200:
> On Thu, Apr 27, 2023 at 08:23:34PM +0900, Dominique Martinet wrote:
> > retval from filemap_fdatawrite was immediately overwritten by the
> > following p9_fid_put: preserve any error in fdatawrite if there
> > was any first.
> > 
> > This fixes the following scan-build warning:
> > fs/9p/vfs_dir.c:220:4: warning: Value stored to 'retval' is never read [deadcode.DeadStores]
> >                         retval = filemap_fdatawrite(inode->i_mapping);
> >                         ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Perhaps:
> 
> Fixes: 89c58cb395ec ("fs/9p: fix error reporting in v9fs_dir_release")

Right, this one warrants a fix tag as it's the only real bug in this
series.
I'll add the Fixes and fix the typo in patch 5 and send a v2 later
today.
Simon Horman May 3, 2023, 7:17 a.m. UTC | #3
On Wed, May 03, 2023 at 08:32:49AM +0900, Dominique Martinet wrote:
> Thanks for all the reviews!
> 
> Simon Horman wrote on Tue, May 02, 2023 at 04:46:17PM +0200:
> > On Thu, Apr 27, 2023 at 08:23:34PM +0900, Dominique Martinet wrote:
> > > retval from filemap_fdatawrite was immediately overwritten by the
> > > following p9_fid_put: preserve any error in fdatawrite if there
> > > was any first.
> > > 
> > > This fixes the following scan-build warning:
> > > fs/9p/vfs_dir.c:220:4: warning: Value stored to 'retval' is never read [deadcode.DeadStores]
> > >                         retval = filemap_fdatawrite(inode->i_mapping);
> > >                         ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > Perhaps:
> > 
> > Fixes: 89c58cb395ec ("fs/9p: fix error reporting in v9fs_dir_release")
> 
> Right, this one warrants a fix tag as it's the only real bug in this
> series.

Hi Dominique,

Yes, I agree that this seems to be the only patch in this series
that warrants a fixes tag.
diff mbox series

Patch

diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index 289b58cb896e..54bb99f12390 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -209,7 +209,7 @@  int v9fs_dir_release(struct inode *inode, struct file *filp)
 	struct p9_fid *fid;
 	__le32 version;
 	loff_t i_size;
-	int retval = 0;
+	int retval = 0, put_err;
 
 	fid = filp->private_data;
 	p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n",
@@ -222,7 +222,8 @@  int v9fs_dir_release(struct inode *inode, struct file *filp)
 		spin_lock(&inode->i_lock);
 		hlist_del(&fid->ilist);
 		spin_unlock(&inode->i_lock);
-		retval = p9_fid_put(fid);
+		put_err = p9_fid_put(fid);
+		retval = retval < 0 ? retval : put_err;
 	}
 
 	if ((filp->f_mode & FMODE_WRITE)) {