From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBo3L-0004He-0L for qemu-devel@nongnu.org; Fri, 07 Feb 2014 11:13:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBo3E-0003XY-Ac for qemu-devel@nongnu.org; Fri, 07 Feb 2014 11:13:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBo3E-0003XN-2p for qemu-devel@nongnu.org; Fri, 07 Feb 2014 11:13:12 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s17GDAda003355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Feb 2014 11:13:10 -0500 From: Kevin Wolf Date: Fri, 7 Feb 2014 17:12:58 +0100 Message-Id: <1391789578-19601-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1391789578-19601-1-git-send-email-kwolf@redhat.com> References: <1391789578-19601-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] block: Don't call ROUND_UP with negative values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, lersek@redhat.com, stefanha@redhat.com 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 --- 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