qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Cc: Fam Zheng <famz@redhat.com>, qemu devel <qemu-devel@nongnu.org>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] dirty-bitmap: remove unnecessary return
Date: Thu, 30 Jun 2016 10:00:27 -0400	[thread overview]
Message-ID: <20160630140027.GB17242@localhost.localdomain> (raw)
In-Reply-To: <5774DC40.8090806@cn.fujitsu.com>

On Thu, Jun 30, 2016 at 04:45:52PM +0800, Changlong Xie wrote:
> On 06/30/2016 04:25 PM, Fam Zheng wrote:
> >On Thu, 06/30 16:01, Changlong Xie wrote:
> >>Otherwise, we could never trigger assert(!bitmap->successor)
> >>
> >>Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
> >>---
> >>  block/dirty-bitmap.c | 1 -
> >>  1 file changed, 1 deletion(-)
> >>
> >>diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> >>index 4902ca5..e9df5ac 100644
> >>--- a/block/dirty-bitmap.c
> >>+++ b/block/dirty-bitmap.c
> >>@@ -131,7 +131,6 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
> >>      if (bdrv_dirty_bitmap_frozen(bitmap)) {
> >>          error_setg(errp, "Cannot create a successor for a bitmap that is "
> >>                     "currently frozen");
> >>-        return -1;
> >>      }
> >>      assert(!bitmap->successor);
> >
> >This is wrong. Then we will always trigger assert for a frozen bitmap.
> >
> 
> IMO, when it's a frozen bitmap, we will always return -1. So
> "assert(!bitmap->successor)" is useless here, am i right?
>

I don't see a path where the assert could trigger, so I would agree that the
assert itself, while harmless, is not necessary (although it could be argued
it is in place in case the code above it changes in a way that does not
check bitmap->successor).

That doesn't mean we want to try and trigger an assert, however! :) The
error return is the proper error handling -- we don't expect that asserts
should ever be encountered QEMU, if one happens that is a sign of a bug.

Jeff

  reply	other threads:[~2016-06-30 14:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30  8:01 [Qemu-devel] [PATCH] dirty-bitmap: remove unnecessary return Changlong Xie
2016-06-30  8:25 ` Fam Zheng
2016-06-30  8:45   ` Changlong Xie
2016-06-30 14:00     ` Jeff Cody [this message]
2016-06-30 18:18       ` John Snow
2016-07-01  1:20         ` Changlong Xie

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=20160630140027.GB17242@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xiecl.fnst@cn.fujitsu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).