aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/block.c b/block.c
index 56bacc9..2fd9321 100644
--- a/block.c
+++ b/block.c
@@ -5091,8 +5091,13 @@ int64_t bdrv_getlength(BlockDriverState *bs)
{
int64_t ret = bdrv_nb_sectors(bs);
- ret = ret > INT64_MAX / BDRV_SECTOR_SIZE ? -EFBIG : ret;
- return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
+ if (ret < 0) {
+ return ret;
+ }
+ if (ret > INT64_MAX / BDRV_SECTOR_SIZE) {
+ return -EFBIG;
+ }
+ return ret * BDRV_SECTOR_SIZE;
}
/* return 0 as number of sectors if no device present or error */