From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: get_block_status: use "else" when testing the opposite condition
Date: Thu, 14 May 2015 22:09:25 +0800 [thread overview]
Message-ID: <20150514140925.GE22867@ad.nay.redhat.com> (raw)
In-Reply-To: <1431599702-10431-1-git-send-email-pbonzini@redhat.com>
On Thu, 05/14 12:35, Paolo Bonzini wrote:
> 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 <pbonzini@redhat.com>
> ---
> block/io.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index 1ce62c4..494e3b3 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -1456,9 +1456,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) {
> --
> 2.4.0
>
Reviewed-by: Fam Zheng <famz@redhat.com>
next prev parent reply other threads:[~2015-05-14 14:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-14 10:35 [Qemu-devel] [PATCH] block: get_block_status: use "else" when testing the opposite condition Paolo Bonzini
2015-05-14 14:07 ` Eric Blake
2015-05-14 14:09 ` Fam Zheng [this message]
2015-05-19 10:49 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150514140925.GE22867@ad.nay.redhat.com \
--to=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.