lkml.org 
[lkml]   [2009]   [Jan]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH for -tip 4/4] irq: for_each_irq_desc() makes simplify
Date
Hi,

KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> writes:

> Subject: [PATCH] irq: for_each_irq_desc() makes simplify
> Impact: cleanup
>
> all for_each_irq_desc() usage point have !desc check.
> then its check can move into for_each_irq_desc() macro.
[snip]
> Index: b/include/linux/irqnr.h
> ===================================================================
> --- a/include/linux/irqnr.h
> +++ b/include/linux/irqnr.h
> @@ -25,10 +25,14 @@ extern struct irq_desc *irq_to_desc(unsi
>
> # define for_each_irq_desc(irq, desc) \
> for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
> - irq++, desc = irq_to_desc(irq))
> + irq++, desc = irq_to_desc(irq)) \
> + if (desc)
> +
> +
> # define for_each_irq_desc_reverse(irq, desc) \
> for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
> - irq--, desc = irq_to_desc(irq))
> + irq--, desc = irq_to_desc(irq)) \
> + if (desc)

I know this has gone in, but isn't this naked 'if' unsafe. Consider the
following hypothetical code:

if (safe)
for_each_irq_desc(irq, desc) {
...
}
else
panic();

With the macro definition above, the loop would panic() each time !desc,
and _not_ panic() when !safe. I'd consider this behaviour to be
unexpected, to say the least :-)

The fix is to change the

if (desc)

in the macro to

if (!desc) ; else

- Hari



\
 
 \ /
  Last update: 2009-01-02 04:27    [W:0.056 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site