Received: from eggs.gnu.org ([2001:4830:134:3::10]:53788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn8x5-0003jQ-4z for qemu-devel@nongnu.org; Thu, 22 Sep 2016 14:42:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn8wz-0006BY-RO for qemu-devel@nongnu.org; Thu, 22 Sep 2016 14:42:30 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:47771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn8wz-0006BG-Ey for qemu-devel@nongnu.org; Thu, 22 Sep 2016 14:42:25 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <1474533652-31170-1-git-send-email-berrange@redhat.com> <1474533652-31170-9-git-send-email-berrange@redhat.com> <87ponwnmcl.fsf@fimbulvetr.bsc.es> <20160922124423.GL352@redhat.com> <87h997lxq3.fsf@fimbulvetr.bsc.es> Date: Thu, 22 Sep 2016 20:42:23 +0200 In-Reply-To: <87h997lxq3.fsf@fimbulvetr.bsc.es> (=?utf-8?Q?=22Llu=C3=ADs?= Vilanova"'s message of "Thu, 22 Sep 2016 18:12:52 +0200") Message-ID: <8760pnlqsw.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 08/17] trace: remove the TraceEventID and TraceEventVCPUID enums List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Llu=C3=ADs Vilanova writes: > Daniel P Berrange writes: >> On Thu, Sep 22, 2016 at 02:35:38PM +0200, Llu=C3=ADs Vilanova wrote: >>> Daniel P Berrange writes: > [...] >>> > diff --git a/scripts/tracetool/format/events_h.py b/scripts/tracetool= /format/events_h.py >>> > index 80a66c5..5da1d4c 100644 >>> > --- a/scripts/tracetool/format/events_h.py >>> > +++ b/scripts/tracetool/format/events_h.py >>> > @@ -29,27 +29,15 @@ def generate(events, backend): >>> > out('extern TraceEvent %(event)s;', >>> > event =3D e.api(e.QEMU_EVENT)) >>>=20 >>> > - # event identifiers >>> > - out('typedef enum {') >>> > - >>> > - for e in events: >>> > - out(' TRACE_%s,' % e.name.upper()) >>> > - >>> > - out(' TRACE_EVENT_COUNT', >>> > - '} TraceEventID;') >>> > - >>> > for e in events: >>> > out('extern uint16_t %s;' % e.api(e.QEMU_DSTATE)) >>>=20 >>> > - # per-vCPU event identifiers >>> > - out('typedef enum {') >>> > - >>> > + numvcpu =3D 0 >>> > for e in events: >>> > if "vcpu" in e.properties: >>> > - out(' TRACE_VCPU_%s,' % e.name.upper()) >>> > + numvcpu +=3D 1 >>>=20 >>> > - out(' TRACE_VCPU_EVENT_COUNT', >>> > - '} TraceEventVCPUID;') >>>=20 >>> Here's a more pythonic way to write it: >>>=20 >>> numvcpu =3D len([e for e in events if "vcpu" in e.properties]) >> FWIW I was tending to avoid this kind of idiom, since most of QEMU >> maintainers are C developers, for whom this looks rather alien. > I dont wanna enter into a coding style discussion, since I don't know how= alien > QEMU developers feel about this (to me, it certainly looks ugly to keep t= he > explicit for loop). Feel free to ignore it. BTW, the pythonic one is the style used in many other places on the traceto= ol code. Cheers, Lluis