[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
- Re: [Qemu-devel] [PATCH qom-cpu v2 20/29] kvm: Change kvm_remove_all_breakpoints() argument to CPUState, (continued)
- [Qemu-devel] [PATCH qom-cpu v2 26/29] intc/sh_intc: Build sh_intc only once, Andreas Färber, 2013/06/16
- [Qemu-devel] [PATCH qom-cpu v2 25/29] cpu: Move CPU_INTERRUPT_* to qom/cpu.h, Andreas Färber, 2013/06/16
- [Qemu-devel] [PATCH qom-cpu v2 27/29] intc/arm_gic: Build arm_gic only once, Andreas Färber, 2013/06/16
- [Qemu-devel] [PATCH qom-cpu v2 29/29] timer/arm_mptimer: Build arm_mptimer only once, Andreas Färber, 2013/06/16
- [Qemu-devel] [PATCH qom-cpu v2 28/29] intc/openpic: Build openpic only once, Andreas Färber, 2013/06/16