[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 59/62] qcow2: Return useful error code in refcount_in
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 59/62] qcow2: Return useful error code in refcount_init() |
Date: |
Fri, 8 Aug 2014 19:40:00 +0200 |
From: Max Reitz <address@hidden>
If bdrv_pread() returns an error, it is very unlikely that it was
ENOMEM. In this case, the return value should be passed along; as
bdrv_pread() will always either return the number of bytes read or a
negative value (the error code), the condition for checking whether
bdrv_pread() failed can be simplified (and clarified) as well.
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Benoit Canet <address@hidden>
---
block/qcow2-refcount.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 87a56d8..d60e2fe 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -50,19 +50,21 @@ int qcow2_refcount_init(BlockDriverState *bs)
if (s->refcount_table_size > 0) {
if (s->refcount_table == NULL) {
+ ret = -ENOMEM;
goto fail;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
ret = bdrv_pread(bs->file, s->refcount_table_offset,
s->refcount_table, refcount_table_size2);
- if (ret != refcount_table_size2)
+ if (ret < 0) {
goto fail;
+ }
for(i = 0; i < s->refcount_table_size; i++)
be64_to_cpus(&s->refcount_table[i]);
}
return 0;
fail:
- return -ENOMEM;
+ return ret;
}
void qcow2_refcount_close(BlockDriverState *bs)
--
1.8.3.1
- [Qemu-devel] [PULL 50/62] qed: Handle failure for potentially large allocations, (continued)
- [Qemu-devel] [PULL 50/62] qed: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 48/62] qcow1: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 51/62] raw-posix: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 52/62] raw-win32: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 49/62] qcow2: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 54/62] vdi: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 53/62] rbd: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 55/62] vhdx: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 57/62] vpc: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 58/62] mirror: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 59/62] qcow2: Return useful error code in refcount_init(),
Kevin Wolf <=
- [Qemu-devel] [PULL 56/62] vmdk: Handle failure for potentially large allocations, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 60/62] qcow2: Catch !*host_offset for data allocation, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 61/62] iotests: Add test for image header overlap, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 62/62] block: Catch !bs->drv in bdrv_check(), Kevin Wolf, 2014/08/08
- Re: [Qemu-devel] [PULL 00/62] Block patches, Peter Maydell, 2014/08/15