From patchwork Fri May 22 09:02:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 475513 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 6CC741402AD for ; Fri, 22 May 2015 19:24:25 +1000 (AEST) Received: from localhost ([::1]:32953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvjBm-0006xZ-QO for incoming@patchwork.ozlabs.org; Fri, 22 May 2015 05:24:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvirk-0005aK-6J for qemu-devel@nongnu.org; Fri, 22 May 2015 05:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yviri-0005FK-Gc for qemu-devel@nongnu.org; Fri, 22 May 2015 05:03:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yviri-0005F4-CA for qemu-devel@nongnu.org; Fri, 22 May 2015 05:03:38 -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 (Postfix) with ESMTPS id 083113674BC; Fri, 22 May 2015 09:03:38 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4M93a9d003801; Fri, 22 May 2015 05:03:37 -0400 From: Stefan Hajnoczi To: Date: Fri, 22 May 2015 10:02:10 +0100 Message-Id: <1432285330-13994-39-git-send-email-stefanha@redhat.com> In-Reply-To: <1432285330-13994-1-git-send-email-stefanha@redhat.com> References: <1432285330-13994-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Paolo Bonzini Subject: [Qemu-devel] [PULL 38/38] block: get_block_status: use "else" when testing the opposite condition 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 From: Paolo Bonzini A bit of Boolean algebra (and common sense) tells us that the second "if" here is looking for blocks that are not allocated. This is the opposite of the "if" that sets BDRV_BLOCK_ALLOCATED, and thus it can use an "else". Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Message-id: 1431599702-10431-1-git-send-email-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi --- block/io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index 284784e..e394d92 100644 --- a/block/io.c +++ b/block/io.c @@ -1521,9 +1521,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |= BDRV_BLOCK_ALLOCATED; - } - - if (!(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO)) { + } else { if (bdrv_unallocated_blocks_are_zero(bs)) { ret |= BDRV_BLOCK_ZERO; } else if (bs->backing_hd) {