[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48BE6C58.1030606@panasas.com>
Date: Wed, 03 Sep 2008 13:52:08 +0300
From: Boaz Harrosh <bharrosh@...asas.com>
To: Jan Beulich <jbeulich@...ell.com>
CC: "David S. Miller" <davem@...emloft.net>,
Ingo Molnar <mingo@...e.hu>,
Alexey Dobriyan <adobriyan@...il.com>,
Ivo van Doorn <IvDoorn@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Theodore Tso <tytso@....edu>,
Rusty Russell <rusty@...tcorp.com.au>,
"John W. Linville" <linville@...driver.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5 ver2] debug: BUILD_BUG_ON: error on non-const expressions
Jan Beulich wrote:
>>>> Boaz Harrosh <bharrosh@...asas.com> 03.09.08 10:57 >>>
>> Jan Beulich wrote:
>>>>>> Boaz Harrosh <bharrosh@...asas.com> 02.09.08 17:57 >>>
>>>> -#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
>>>> +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
>>>> +
>>>> +/* Force a compilation error if condition is true */
>>>> +#define BUILD_BUG_ON(e) \
>>>> + do { struct {int:-!!(e); } x __maybe_unused;} while(0)
>>>
>>> As indicated before, you should at the very least use __x as the variable
>>> name.
>>>
>> The name does not matter. The scope of x is confined to the do {} while()
>> and will not interfere with any local or global name.
>
> I'm sorry to repeat this: If x is #define-d to anything but a simple identifier,
> this will break no matter that it's in a private scope. The absence of any
> identifier was a benefit of the sizeof() approach here.
>
> Jan
>
#defines are a shoot-in-the-leg, they should be CAPITAL letters and very
long and unique. If any one wants to #define x, they are welcome, it will
break the kernel even before my macro. No x in a private scope is fine
#define x is not, sorry ...
OK, I would change it, but I'm too lazy to do a new post just for that.
Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists