[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11829: Build failure with --enable-gcc-warnings
From: |
Pádraig Brady |
Subject: |
bug#11829: Build failure with --enable-gcc-warnings |
Date: |
Sun, 01 Jul 2012 00:47:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 07/01/2012 12:38 AM, Eric Blake wrote:
> On 06/30/2012 05:10 PM, Pádraig Brady wrote:
>
>> This should address it:
>>
>> commit 8f4dcad477da1a952a04478ae125d5453f29dcc9
>> Author: Pádraig Brady <address@hidden>
>> Date: Sun Jul 1 00:04:37 2012 +0100
>>
>> maint: avoid a -Wunsed-but-set warning on some systems
>>
>> * src/stty.c (main): Mark speed_was_set as unused when
>> CIBAUD undefined (like on ppc64 GNU/Linux for example).
>> Reported-by: Stefano Lattarini
>>
>> diff --git a/src/stty.c b/src/stty.c
>> index 83b502c..b2dd849 100644
>> --- a/src/stty.c
>> +++ b/src/stty.c
>> @@ -737,7 +737,11 @@ main (int argc, char **argv)
>> int argi = 0;
>> int opti = 1;
>> bool require_set_attr;
>> +#ifdef CIBAUD
>> bool speed_was_set;
>> +#else
>> + bool speed_was_set ATTRIBUTE_UNUSED;
>> +#endif
>
> Three lines too many. ATTRIBUTE_UNUSED is defined by gcc to mean 'might
> be unused, therefore don't warn if it was not used', and not 'must not
> be used, and therefore warn if it is used'. Therefore, it is always
> safe to use the one-liner:
>
> bool speed_was_set ATTRIBUTE_UNUSED;
>
> even if, when CIBAUD is defined, it was actually used. No need for
> extra #ifdef.
>
But then you would never get such warnings for this variable.
I was trying to disable the warning only where it's incorrect,
and thought the single ifdef worth it?