Re: [RFC PATCH] cpumask_t initializers

From: Janis Johnson
Date: Sat Nov 20 2004 - 13:57:58 EST


On Fri, Nov 19, 2004 at 05:45:57PM -0800, Matthew Dobson wrote:
>
> Janis Johnson, a GCC hacker, told me the following:
>> Extra parens can be thrown away in expressions, but the syntax for
>> initializers has curly braces on the outside of the list. GCC doesn't
>> seem to mind if there are parens outside the braces for a struct
>> initializer, but that's probably a bug and could change in a future
>> version of GCC's C parser.
>
> So, in order to both make my code compile and future-proof (heh) the
> CPU_MASK_* initializers I wrote up this little patch. This DEFINITELY
> needs to be tested further (I've compile-tested it on x86, x86 NUMA,
> x86_64 & ppc64), but the good news is that any breakage from the patch
> will be compile-time breakage and should be obvious.
>
> The fact that GCC's parser may change in the future to disallow struct
> initializers wrapped in parens kind of scares me, because just about
> every struct initializer I've ever seen in the kernel is wrapped in
> parens!! This needs to be delved into further, but I'm leaving for home
> for a week for Thanksgiving and will have limited access to email.

I'm not an expert on the C language (I just pass for one in this
building) so this ought to be looked at by someone who is. As for
changes to the C parser, Joseph Myers is writing a recursive-descent
C parser for GCC tentatively slated to replace the existing C parser
for GCC 4.1.

Janis
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/