diff mbox

[02/10] btrfs-progs: save error number correctly in check_chunks_and_extents

Message ID 1445254680-11102-3-git-send-email-guaneryu@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eryu Guan Oct. 19, 2015, 11:37 a.m. UTC
Coverity reports assigning value from "err" to "ret", but that stored
value is overwritten by check_extent_refs() before it can be used.

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
---
 cmds-check.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

David Sterba Oct. 19, 2015, 1:41 p.m. UTC | #1
On Mon, Oct 19, 2015 at 07:37:52PM +0800, Eryu Guan wrote:
> Coverity reports assigning value from "err" to "ret", but that stored
> value is overwritten by check_extent_refs() before it can be used.

If you fix a coverity issue, please add a tag and the id, like

Resolves-coverity-id: 1234
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eryu Guan Oct. 20, 2015, 10:28 a.m. UTC | #2
On Mon, Oct 19, 2015 at 03:41:04PM +0200, David Sterba wrote:
> On Mon, Oct 19, 2015 at 07:37:52PM +0800, Eryu Guan wrote:
> > Coverity reports assigning value from "err" to "ret", but that stored
> > value is overwritten by check_extent_refs() before it can be used.
> 
> If you fix a coverity issue, please add a tag and the id, like
> 
> Resolves-coverity-id: 1234

I was looking hard for CID but without luck.. I will ask around and see
where I can find the CIDs.

Thanks,
Eryu
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Oct. 21, 2015, 9:26 a.m. UTC | #3
On Tue, Oct 20, 2015 at 06:28:00PM +0800, Eryu Guan wrote:
> On Mon, Oct 19, 2015 at 03:41:04PM +0200, David Sterba wrote:
> > On Mon, Oct 19, 2015 at 07:37:52PM +0800, Eryu Guan wrote:
> > > Coverity reports assigning value from "err" to "ret", but that stored
> > > value is overwritten by check_extent_refs() before it can be used.
> > 
> > If you fix a coverity issue, please add a tag and the id, like
> > 
> > Resolves-coverity-id: 1234
> 
> I was looking hard for CID but without luck.. I will ask around and see
> where I can find the CIDs.

Ok never mind then, I'll pick the patch as-is.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-check.c b/cmds-check.c
index 4225b21..80a7c29 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -8066,13 +8066,12 @@  again:
 		goto out;
 	}
 
-	err = check_chunks(&chunk_cache, &block_group_cache,
+	ret = check_chunks(&chunk_cache, &block_group_cache,
 			   &dev_extent_cache, NULL, NULL, NULL, 0);
-	if (err) {
-		if (err == -EAGAIN)
+	if (ret) {
+		if (ret == -EAGAIN)
 			goto loop;
-		if (!ret)
-			ret = err;
+		err = ret;
 	}
 
 	ret = check_extent_refs(root, &extent_cache);
@@ -8082,8 +8081,8 @@  again:
 		goto out;
 	}
 
-	err = check_devices(&dev_cache, &dev_extent_cache);
-	if (err && !ret)
+	ret = check_devices(&dev_cache, &dev_extent_cache);
+	if (ret && err)
 		ret = err;
 
 out: