From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXtCP-0000uP-LH for qemu-devel@nongnu.org; Thu, 11 Aug 2016 12:51:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXtCL-0002eL-H5 for qemu-devel@nongnu.org; Thu, 11 Aug 2016 12:51:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXtCL-0002du-B9 for qemu-devel@nongnu.org; Thu, 11 Aug 2016 12:51:13 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 804E283F45 for ; Thu, 11 Aug 2016 16:51:12 +0000 (UTC) Date: Thu, 11 Aug 2016 17:51:08 +0100 From: "Daniel P. Berrange" Message-ID: <20160811165108.GL27458@redhat.com> Reply-To: "Daniel P. Berrange" References: <147093187892.24979.13675730389787023008.stgit@fimbulvetr.bsc.es> <147093188968.24979.8739712285459220697.stgit@fimbulvetr.bsc.es> <20160811163116.GK27458@redhat.com> <87ziojdzr3.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87ziojdzr3.fsf@fimbulvetr.bsc.es> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 2/2] trace: Avoid implicit bool->integer conversions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi On Thu, Aug 11, 2016 at 06:41:36PM +0200, Llu=C3=ADs Vilanova wrote: > Daniel P Berrange writes: >=20 > > On Thu, Aug 11, 2016 at 06:11:29PM +0200, Llu=C3=ADs Vilanova wrote: > >> An explicit if/else is clearer than arithmetic assuming #true is 1, > >> while the compiler should be able to generate just as optimal code. > >>=20 > >> Signed-off-by: Llu=C3=ADs Vilanova > >> --- > >> stubs/trace-control.c | 9 +++++++-- > >> trace/control-target.c | 18 ++++++++++++++---- > >> 2 files changed, 21 insertions(+), 6 deletions(-) > >>=20 > >> diff --git a/stubs/trace-control.c b/stubs/trace-control.c > >> index 3740c38..099c2b5 100644 > >> --- a/stubs/trace-control.c > >> +++ b/stubs/trace-control.c > >> @@ -21,8 +21,13 @@ void trace_event_set_state_dynamic(TraceEvent *ev= , bool state) > >> TraceEventID id; > >> assert(trace_event_get_state_static(ev)); > >> id =3D trace_event_get_id(ev); > >> - trace_events_enabled_count +=3D state - trace_events_dstate[id]= ; > >> - trace_events_dstate[id] =3D state; > >> + if (state) { > >> + trace_events_enabled_count++; > >> + trace_events_dstate[id] =3D 1; > >> + } else { > >> + trace_events_enabled_count--; >=20 > > SHouldn't this be trace_events_enabled_count -=3D trace_events_dstate= [id]; > > as it is possible to call this method for a trace event that is a per= -vcpu > > event >=20 > The "stub" code will never have vCPUs around, it's used by qemu-img and= the like > (any program without "target" code). I just picked the first example of that in this file - you've got the sam= e pattern in the other 2 places you change Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|