From patchwork Mon Jul 14 11:42:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 369596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B462F14008B for ; Mon, 14 Jul 2014 21:46:30 +1000 (EST) Received: from localhost ([::1]:56666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6eiC-0000Yy-K9 for incoming@patchwork.ozlabs.org; Mon, 14 Jul 2014 07:46:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6efK-00048M-OK for qemu-devel@nongnu.org; Mon, 14 Jul 2014 07:43:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6efD-0005BA-AV for qemu-devel@nongnu.org; Mon, 14 Jul 2014 07:43:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6efD-0005An-0z for qemu-devel@nongnu.org; Mon, 14 Jul 2014 07:43:23 -0400 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 s6EBhLW9001164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 14 Jul 2014 07:43:22 -0400 Received: from noname.redhat.com (ovpn-116-24.ams2.redhat.com [10.36.116.24]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6EBhGgL008192; Mon, 14 Jul 2014 07:43:20 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 14 Jul 2014 13:42:52 +0200 Message-Id: <1405338192-18850-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1405338192-18850-1-git-send-email-kwolf@redhat.com> References: <1405338192-18850-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PULL v2 for-2.1 02/22] block: Fix bdrv_is_allocated() return value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Eric Blake --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 8800a6b..c9629a4 100644 --- a/block.c +++ b/block.c @@ -4040,7 +4040,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); } /*