From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcWK-0003eO-4B for qemu-devel@nongnu.org; Thu, 30 Jun 2016 10:00:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIcWE-0007w5-E7 for qemu-devel@nongnu.org; Thu, 30 Jun 2016 10:00:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcWE-0007vv-8A for qemu-devel@nongnu.org; Thu, 30 Jun 2016 10:00:38 -0400 Date: Thu, 30 Jun 2016 10:00:27 -0400 From: Jeff Cody Message-ID: <20160630140027.GB17242@localhost.localdomain> References: <1467273706-5732-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <20160630082515.GG23296@ad.usersys.redhat.com> <5774DC40.8090806@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5774DC40.8090806@cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH] dirty-bitmap: remove unnecessary return List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Changlong Xie Cc: Fam Zheng , qemu devel , Kevin Wolf , Max Reitz , Stefan Hajnoczi 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 > >>--- > >> 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