From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoJgA-0006Zf-V1 for qemu-devel@nongnu.org; Sun, 16 Jun 2013 16:36:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UoJg8-0007lt-6m for qemu-devel@nongnu.org; Sun, 16 Jun 2013 16:36:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoJg7-0007ln-V8 for qemu-devel@nongnu.org; Sun, 16 Jun 2013 16:36:00 -0400 Date: Sun, 16 Jun 2013 23:36:44 +0300 From: "Michael S. Tsirkin" Message-ID: <20130616203644.GC19741@redhat.com> References: <1371398269-6213-1-git-send-email-afaerber@suse.de> <1371398269-6213-25-git-send-email-afaerber@suse.de> <20130616202626.GA19741@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH qom-cpu v2 24/29] cpu: Drop qemu_for_each_cpu() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Andreas =?iso-8859-1?Q?F=E4rber?= , qemu-devel@nongnu.org On Sun, Jun 16, 2013 at 09:30:29PM +0100, Peter Maydell wrote: > On 16 June 2013 21:26, Michael S. Tsirkin wrote: > > On Sun, Jun 16, 2013 at 05:57:44PM +0200, Andreas F=E4rber wrote: > >> Revert commit d6b9e0d60cc511eca210834428bb74508cff3d33 (cpu: Add > >> qemu_for_each_cpu()) and its usage in favor of open-coding CPU loops= , > >> now that they are based on CPUState. > >> > >> Suggested-by: Markus Armbruster > >> Signed-off-by: Andreas F=E4rber > > > > Open-coding is kind of nasty though. > > > > How about > > #define qemu_for_each_cpu(cpu) \ > > for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) >=20 > Personally for an iteration that simple I would prefer > the opencoded version -- it's more immediately > obvious what it's doing and that it's not doing anything > weird. Only if you have memorized how is the list of CPUs put together. You probably did, most other readers probably didn't, and have to waste time looking it up. > Precedent isn't everything, but a quick grep for 'foreach' > and 'for_each' suggests that we generally use the callback-fn > style rather than iterator macros. >=20 > thanks > -- PMM Callback is fine too. --=20 MST