From b9c649470ba0d4056b2d486105a0f8fb982654ae Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 5 Feb 2015 13:58:25 -0500 Subject: block: Keep bdrv_check*_request()'s return value Do not throw away the value returned by bdrv_check_request() and bdrv_check_byte_request(). Fix up some coding style issues in the proximity of the affected hunks. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-id: 1423162705-32065-17-git-send-email-mreitz@redhat.com Signed-off-by: Stefan Hajnoczi --- block.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'block.c') diff --git a/block.c b/block.c index 4d5ae992d3..9b707e3d1b 100644 --- a/block.c +++ b/block.c @@ -3098,8 +3098,10 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, if (!drv) { return -ENOMEDIUM; } - if (bdrv_check_byte_request(bs, offset, bytes)) { - return -EIO; + + ret = bdrv_check_byte_request(bs, offset, bytes); + if (ret < 0) { + return ret; } if (bs->copy_on_read) { @@ -3342,8 +3344,10 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, if (bs->read_only) { return -EACCES; } - if (bdrv_check_byte_request(bs, offset, bytes)) { - return -EIO; + + ret = bdrv_check_byte_request(bs, offset, bytes); + if (ret < 0) { + return ret; } /* throttling disk I/O */ @@ -4197,12 +4201,18 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BlockDriver *drv = bs->drv; - if (!drv) + int ret; + + if (!drv) { return -ENOMEDIUM; - if (!drv->bdrv_write_compressed) + } + if (!drv->bdrv_write_compressed) { return -ENOTSUP; - if (bdrv_check_request(bs, sector_num, nb_sectors)) - return -EIO; + } + ret = bdrv_check_request(bs, sector_num, nb_sectors); + if (ret < 0) { + return ret; + } assert(QLIST_EMPTY(&bs->dirty_bitmaps)); @@ -5117,12 +5127,15 @@ static void coroutine_fn bdrv_discard_co_entry(void *opaque) int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { - int max_discard; + int max_discard, ret; if (!bs->drv) { return -ENOMEDIUM; - } else if (bdrv_check_request(bs, sector_num, nb_sectors)) { - return -EIO; + } + + ret = bdrv_check_request(bs, sector_num, nb_sectors); + if (ret < 0) { + return ret; } else if (bs->read_only) { return -EROFS; } -- cgit v1.2.3