From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Az6-00029Q-UG for qemu-devel@nongnu.org; Mon, 07 Jul 2014 11:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Az0-00077W-Pd for qemu-devel@nongnu.org; Mon, 07 Jul 2014 11:37:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21463) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Az0-000760-IE for qemu-devel@nongnu.org; Mon, 07 Jul 2014 11:37:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s67FbXts012656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 7 Jul 2014 11:37:33 -0400 From: Kevin Wolf Date: Mon, 7 Jul 2014 17:37:26 +0200 Message-Id: <1404747446-10215-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com bdrv_is_allocated() should return either 0 or 1 in successful cases. We're lucky that currently, the callers that rely on this (e.g. because they check for ret == 1) don't seem to break badly. They just might skip some optimisation or in the case of qemu-io 'map' print separate lines where a single line would suffice. In theory, a wrong allocation status could lead to image corruption with certain operations, so let's fix this quickly. Signed-off-by: Kevin Wolf --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index f80e2b2..e2e9cbb 100644 --- a/block.c +++ b/block.c @@ -4039,7 +4039,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, if (ret < 0) { return ret; } - return (ret & BDRV_BLOCK_ALLOCATED); + return !!(ret & BDRV_BLOCK_ALLOCATED); } /* -- 1.8.3.1