]> git.proxmox.com Git - mirror_qemu.git/commit - block/dmg.c
dmg: drop broken bdrv_pread() loop
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 26 Mar 2014 12:05:56 +0000 (13:05 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 1 Apr 2014 13:22:35 +0000 (15:22 +0200)
commitb404bf854217dbe8a5649449eb3ad33777f7d900
tree3fc3cd3965a783341aa1653d147ad5e9aee8ef7e
parent73ed27ec28a1dbebdd2ae792284151f029950fbe
dmg: drop broken bdrv_pread() loop

It is not necessary to check errno for EINTR and the block layer does
not produce short reads.  Therefore we can drop the loop that attempts
to read a compressed chunk.

The loop is buggy because it incorrectly adds the transferred bytes
twice:

  do {
      ret = bdrv_pread(...);
      i += ret;
  } while (ret >= 0 && ret + i < s->lengths[chunk]);

Luckily we can drop the loop completely and perform a single
bdrv_pread().

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/dmg.c