qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] qcow2: Return useful error code in refcount


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH 2/2] qcow2: Return useful error code in refcount_init()
Date: Thu, 29 May 2014 00:35:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 29.05.2014 00:33, Eric Blake wrote:
On 05/28/2014 04:19 PM, Max Reitz wrote:
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>
---
  block/qcow2-refcount.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

          ret = bdrv_pread(bs->file, s->refcount_table_offset,
                           s->refcount_table, refcount_table_size2);
-        if (ret != refcount_table_size2)
Can bdrv_pread() ever do a short read?  If it can, then in the old code,
that was an error,

As far as I'm informed, it cannot (see for instance the commit message of b404bf854217dbe8a5649449eb3ad33777f7d900).

+        if (ret < 0) {
              goto fail;
but in the new code it falls through to the remaining code; and I'm not
sure whether that changes semantics.

(My quick read of bdrv_pread() didn't find an obvious answer, but it DID
raise another question: why do we have '.iov_base = (void *)buf' when
buf is already void*?)

Perhaps because that way it resembles bdrv_pwrite() more closely. :-P

Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]