Re: [PATCH] intel-iommu: fix build with CONFIG_BRANCH_TRACER=y

Ingo Molnar
2009-04-07T12:16:35Z

* David Woodhouse <dwmw2@infradead.org> wrote:

> On Tue, 2009-04-07 at 11:02 +0200, Ingo Molnar wrote:
> > for_each_active_iommu() and for_each_iommu() uses some tricky
> > C that is weird and borderline valid but does not allow the
> > macro evaluation trick used by the branch tracer/profiler:
> >
> > drivers/pci/intr_remapping.c:680:28: error: macro "if" passed 2
> > arguments, but takes just 1
> >
> > Switch it to a braced group statement.
>
> It doesn't even need the braces -- just putting simple parens
> around the comma-expression would have sufficed (that was Andrew's
> attempt).
>
> But it's a workaround, not a fix -- if we're going to #define if()
> then we should damn well make it transparent, and not have to work
> around breakage in arbitrary places.

Well, i consider it a feature that it flags weird if (x, y)
constructs: and yes, these iterators you introduced, while they are
legit C, definitely count as 'weird'. If regular code was doing it,
not a loop abstraction, i'd call it non-obvious and borderline
broken straight away.

We should _never ever_ put comma statements into if () constructs
without a _really_ good reason - and if yes, we can flag that we
know what we are doing, via extra parentheses.

> Hence the patch I sent to Linus last night, which fixes it in the
> _right_ place:
> http://marc.info/?l=linux-kernel&m=123907505308502&w=2

I dont think that's the right fix for the reason above - all the
places where the branch-profiler 'broke' the build before were
genuinely weird pieces of code that needed fixing.

Ingo