Skip to contentSkip to conversation

block: Return the real error code in bdrv_getlength

PATCH In review Tuguoyi 2 participants 2 messages Nov 5, 2020

lore
Share & tools
lore

Tuguoyi

author
#0 lore raw

PATCH 1/1 block: Return the real error code in bdrv_getlength

The return code from bdrv_nb_sectors() should be checked before doing the following sanity check.

---
 block.c | 4 ++++
 1 file changed, 4 insertions(+)
block.c +4 -0
index 430edf7..19ebbc0 100644
@@ -5082,6 +5082,10 @@ int64_t bdrv_getlength(BlockDriverState *bs)
 {
     int64_t ret = bdrv_nb_sectors(bs);
 
+    if (ret < 0) {
+        return ret;
+    }
+
     ret = ret > INT64_MAX / BDRV_SECTOR_SIZE ? -EFBIG : ret;
     return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
 }
Signature · 6 lines
2.7.4


--
Best regards,
Guoyi
#1 lore raw
Quoted 4 lines · Tuguoyi

The return code from bdrv_nb_sectors() should be checked before doing the following sanity check.

It looks like you sent several variations on this patch. A
meta-observation: your mailer is attributing the patch to the spelling "Tuguoyi", while your S-o-b line is spelling "Guoyi Tu". It's worth being consistent between the two.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org