From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCQ2f-0003kn-2u for qemu-devel@nongnu.org; Sun, 09 Feb 2014 03:47:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCQ2Z-0001Ar-4G for qemu-devel@nongnu.org; Sun, 09 Feb 2014 03:47:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCQ2Y-0001Al-TH for qemu-devel@nongnu.org; Sun, 09 Feb 2014 03:47:03 -0500 From: Kevin Wolf Date: Sun, 9 Feb 2014 09:46:28 +0100 Message-Id: <1391935590-12264-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1391935590-12264-1-git-send-email-kwolf@redhat.com> References: <1391935590-12264-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 16/18] block: Don't call ROUND_UP with negative values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org The behaviour of the ROUND_UP macro with negative numbers isn't obvious. It happens to do the right thing in this please, but better avoid it. Suggested-by: Laszlo Ersek Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Laszlo Ersek --- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index a027823..b0c5025 100644 --- a/block.c +++ b/block.c @@ -2915,8 +2915,8 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs, } total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE); - max_nb_sectors = MAX(0, ROUND_UP(total_sectors - sector_num, - align >> BDRV_SECTOR_BITS)); + max_nb_sectors = ROUND_UP(MAX(0, total_sectors - sector_num), + align >> BDRV_SECTOR_BITS); if (max_nb_sectors > 0) { ret = drv->bdrv_co_readv(bs, sector_num, MIN(nb_sectors, max_nb_sectors), qiov); -- 1.8.1.4