]> git.proxmox.com Git - mirror_qemu.git/commit
block: Fix integer promotion error in bdrv_getlength()
authorEric Blake <eblake@redhat.com>
Thu, 5 Nov 2020 15:51:22 +0000 (09:51 -0600)
committerMax Reitz <mreitz@redhat.com>
Mon, 9 Nov 2020 14:44:21 +0000 (15:44 +0100)
commit122860bae7c3a3cf45f9f2dedddb0e2492f09888
treeac8bdc3f5c27a7c5eb78fe97ad88f867ac8ee612
parent7c5c53830636a9da263a9be5b510ac528bbd75d5
block: Fix integer promotion error in bdrv_getlength()

Back in 2015, we attempted to fix error reporting for images that
claimed to have more than INT64_MAX/512 sectors, but due to the type
promotions caused by BDRV_SECTOR_SIZE being unsigned, this
inadvertently forces all negative ret values to be slammed into -EFBIG
rather than the original error.  While we're at it, we can avoid the
confusing ?: by spelling the logic more directly.

Fixes: 4a9c9ea0d3
Reported-by: Guoyi Tu <tu.guoyi@h3c.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20201105155122.60943-1-eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block.c