From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJRdY-000768-7C for qemu-devel@nongnu.org; Thu, 05 Feb 2015 13:58:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJRdW-0002Kb-C8 for qemu-devel@nongnu.org; Thu, 05 Feb 2015 13:58:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJRdW-0002Jz-4B for qemu-devel@nongnu.org; Thu, 05 Feb 2015 13:58:46 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t15Iwja4013166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 5 Feb 2015 13:58:45 -0500 From: Max Reitz Date: Thu, 5 Feb 2015 13:58:25 -0500 Message-Id: <1423162705-32065-17-git-send-email-mreitz@redhat.com> In-Reply-To: <1423162705-32065-1-git-send-email-mreitz@redhat.com> References: <1423162705-32065-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v4 16/16] block: Keep bdrv_check*_request()'s return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz 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 --- block.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 47468a5..f35a437 100644 --- a/block.c +++ b/block.c @@ -3101,8 +3101,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) { @@ -3345,8 +3347,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 */ @@ -4200,12 +4204,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)); @@ -5120,12 +5130,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; } -- 2.1.0