lkml.org 
[lkml]   [2011]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [tip:core/urgent] WARN_ON_SMP(): Add comment to explain ({0;})
From
On Mon, Mar 28, 2011 at 4:51 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 03/28/2011 07:45 AM, tip-bot for Steven Rostedt wrote:
>>
>> WARN_ON_SMP(): Add comment to explain ({0;})
>>
>> The define to use ({0;}) for the !CONFIG_SMP case of WARN_ON_SMP()
>> can be confusing. As the WARN_ON_SMP() needs to be a nop when
>> CONFIG_SMP is not set, including all its parameters must not be
>> evaluated, and that it must work as both a stand alone statement
>> and inside an if condition, we define it to a funky ({0;}).
>>
>> A simple "0" will not work as it causes gcc to give the warning that
>> the statement has no effect.
>>
>> As this strange definition has raised a few eyebrows from some
>> major kernel developers, it is wise to document why we create such
>> a work of art.
>>
>
> What the heck is wrong with the idiomatic and non-gcc-extension-using:
>
>        ((void)0)
>
> ?

AFAIK you cannot use it within an if-statement.

>        -hpa
>
> --
> H. Peter Anvin, Intel Open Source Technology Center
> I work for Intel.  I don't speak on their behalf.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

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

\
 
 \ /
  Last update: 2011-03-28 16:59    [W:0.108 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site