bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11829: Build failure with --enable-gcc-warnings


From: Eric Blake
Subject: bug#11829: Build failure with --enable-gcc-warnings
Date: Sat, 30 Jun 2012 17:38:12 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

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.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]