From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoJb9-00046j-VA for qemu-devel@nongnu.org; Sun, 16 Jun 2013 16:30:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UoJb8-0006H9-Ve for qemu-devel@nongnu.org; Sun, 16 Jun 2013 16:30:51 -0400 Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:60507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoJb8-0006H5-OJ for qemu-devel@nongnu.org; Sun, 16 Jun 2013 16:30:50 -0400 Received: by mail-la0-f54.google.com with SMTP id ec20so1802438lab.41 for ; Sun, 16 Jun 2013 13:30:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20130616202626.GA19741@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> From: Peter Maydell Date: Sun, 16 Jun 2013 21:30:29 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 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: "Michael S. Tsirkin" Cc: =?UTF-8?Q?Andreas_F=C3=A4rber?= , qemu-devel@nongnu.org On 16 June 2013 21:26, Michael S. Tsirkin wrote: > On Sun, Jun 16, 2013 at 05:57:44PM +0200, Andreas F=C3=A4rber 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=C3=A4rber > > 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) 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. 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. thanks -- PMM