qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH qom-cpu v2 24/29] cpu: Drop qemu_for_each_cpu()


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH qom-cpu v2 24/29] cpu: Drop qemu_for_each_cpu()
Date: Sun, 16 Jun 2013 23:36:44 +0300

On Sun, Jun 16, 2013 at 09:30:29PM +0100, Peter Maydell wrote:
> On 16 June 2013 21:26, Michael S. Tsirkin <address@hidden> 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 <address@hidden>
> >> Signed-off-by: Andreas Färber <address@hidden>
> >
> > 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]