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 <mre...@redhat.com>
---
  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