On Sun, Jun 16, 2013 at 09:30:29PM +0100, Peter Maydell wrote: > On 16 June 2013 21:26, Michael S. Tsirkin <m...@redhat.com> wrote: > > On Sun, Jun 16, 2013 at 05:57:44PM +0200, Andreas Färber 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 <arm...@redhat.com> > >> Signed-off-by: Andreas Färber <afaer...@suse.de> > > > > Open-coding is kind of nasty though. > > > > How about > > #define qemu_for_each_cpu(cpu) \ > > for (cpu = first_cpu; cpu != NULL; cpu = 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.
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. > > thanks > -- PMM Callback is fine too. -- MST