From: Willy Tarreau <willy@w.ods.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>,
kernel-stuff@comcast.net, linux-kernel@vger.kernel.org,
alex-kernel@digriz.org.uk, jun.nakajima@intel.com,
davej@redhat.com, viro@ftp.linux.org.uk
Subject: Re: OOPS: 2.6.16-rc6 cpufreq_conservative
Date: Mon, 20 Mar 2006 08:18:46 +0100 [thread overview]
Message-ID: <20060320071846.GA19642@w.ods.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0603192223530.3622@g5.osdl.org>
On Sun, Mar 19, 2006 at 10:26:30PM -0800, Linus Torvalds wrote:
>
>
> On Mon, 20 Mar 2006, Willy Tarreau wrote:
> >
> > Now, does removing the macro completely change the output code ?
> > I think that if something written like this produces the same
> > code, it would be easier to read :
> >
> > #define for_each_cpu_mask(cpu, mask) \
> > for ((cpu) = 0; (cpu) < NR_CPUS; (cpu)++) { \
> > unsigned long __bits = (mask).bits[0] >> (cpu); \
> > if (!__bits) \
> > break; \
> > if (!__bits & 1) \
> > continue; \
> > else
>
> Absolutely, but now it has a dangling "{" that didn't get closed. So the
> above would definitely be more readable, it just doesn't actually work.
>
> Unless you'd do the "end_for_each_cpu" define (to close the statement),
> and update the 300+ places that use this. Which might well be worth it.
>
> So the subtle "break from the middle of a statement expression" was just a
> rather hacky way to avoid having to change all the users of this macro.
>
> Linus
Oh, you're right, now I understand your motivation in doing this.
Then perhaps using your trick but applying it to the whole for loop
would make it easier to read ?
#define for_each_cpu_mask(cpu, mask) \
for ((cpu) = 0; (cpu) < NR_CPUS; (cpu)++) \
({ unsigned long __bits = (mask).bits[0] >> (cpu); \
if (!__bits) \
break; \
if (!__bits & 1) \
continue; \
else \
... \
})
Please note that I've not read the rest of the code, so there
may be some problems left. However, if the above works, I find
it easier to read. And in this case, yes, it's interesting to
be able to break from within an expression.
Cheers,
Willy
next prev parent reply other threads:[~2006-03-20 7:20 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-18 20:25 OOPS: 2.6.16-rc6 cpufreq_conservative Parag Warudkar
2006-03-18 21:40 ` Linus Torvalds
2006-03-18 22:09 ` Parag Warudkar
2006-03-18 23:12 ` Linus Torvalds
2006-03-18 22:26 ` Parag Warudkar
2006-03-19 0:53 ` Andrew Morton
2006-03-19 2:38 ` Linus Torvalds
2006-03-19 5:08 ` Paul Jackson
2006-03-19 17:43 ` Linus Torvalds
2006-03-19 18:46 ` Linus Torvalds
2006-03-19 19:02 ` Linus Torvalds
2006-03-19 19:33 ` Linus Torvalds
2006-03-19 19:40 ` Al Viro
2006-03-19 20:01 ` Linus Torvalds
2006-03-19 20:31 ` Linus Torvalds
2006-03-19 20:47 ` Andrew Morton
2006-03-19 22:18 ` Linus Torvalds
2006-03-19 22:35 ` Andrew Morton
2006-03-19 22:55 ` Linus Torvalds
2006-03-19 22:46 ` Linus Torvalds
2006-03-19 23:04 ` Andrew Morton
2006-03-19 20:57 ` Parag Warudkar
2006-03-20 6:12 ` Willy Tarreau
2006-03-20 6:26 ` Linus Torvalds
2006-03-20 7:18 ` Willy Tarreau [this message]
2006-03-21 6:32 ` Willy Tarreau
2006-03-20 8:22 ` Peter T. Breuer
2006-03-19 6:34 ` Parag Warudkar
2006-03-19 12:00 ` Alexander Clouter
2006-03-19 14:06 ` Parag Warudkar
2006-03-19 17:34 ` Alexander Clouter
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=20060320071846.GA19642@w.ods.org \
--to=willy@w.ods.org \
--cc=akpm@osdl.org \
--cc=alex-kernel@digriz.org.uk \
--cc=davej@redhat.com \
--cc=jun.nakajima@intel.com \
--cc=kernel-stuff@comcast.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=viro@ftp.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.