From: "KOSAKI Motohiro" <kosaki.motohiro@gmail.com>
To: "Raja R Harinath" <harinath@hurrynot.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH for -tip 4/4] irq: for_each_irq_desc() makes simplify
Date: Fri, 2 Jan 2009 14:56:23 +0900 [thread overview]
Message-ID: <2f11576a0901012156w30a6b162v96aed31d357929e6@mail.gmail.com> (raw)
In-Reply-To: <87wsdezyu6.fsf@hariville.hurrynot.org>
Hi
>> # 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 :-)
Correct.
> The fix is to change the
>
> if (desc)
>
> in the macro to
>
> if (!desc) ; else
Ok. I'll do that.
Very thanks for good reviewing.
btw, actually current kernel aready have similar macros.
e.g.
#define for_each_node_with_cpus(node) \
for_each_online_node(node) \
if (nr_cpus_node(node))
Shoud we fixed it too? ;-)
next prev parent reply other threads:[~2009-01-02 5:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-26 3:21 [PATCH for -tip 0/4] various irq cleanups KOSAKI Motohiro
2008-12-26 3:23 ` [PATCH for -tip 1/4] hrtimer: remove #include <linux/irq.h> KOSAKI Motohiro
2008-12-26 3:24 ` [PATCH for -tip 2/4] irq: for_each_irq_desc() move to irqnr.h KOSAKI Motohiro
2008-12-26 3:28 ` [PATCH for -tip 3/4] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c KOSAKI Motohiro
2008-12-26 4:18 ` Yinghai Lu
2008-12-26 4:21 ` KOSAKI Motohiro
2008-12-26 4:36 ` Yinghai Lu
2008-12-26 5:24 ` KOSAKI Motohiro
2008-12-26 5:59 ` Yinghai Lu
2008-12-26 8:49 ` Ingo Molnar
2008-12-26 3:29 ` [PATCH for -tip 4/4] irq: for_each_irq_desc() makes simplify KOSAKI Motohiro
2008-12-26 4:23 ` Yinghai Lu
2009-01-01 18:05 ` Raja R Harinath
2009-01-02 5:56 ` KOSAKI Motohiro [this message]
2009-01-03 18:11 ` KOSAKI Motohiro
2009-01-07 22:18 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2f11576a0901012156w30a6b162v96aed31d357929e6@mail.gmail.com \
--to=kosaki.motohiro@gmail.com \
--cc=harinath@hurrynot.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®