This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] fix warnings with -D_FORTIFY_SOURCE and -Wformat-security
- From: Matthias Klose <doko at ubuntu dot com>
- To: Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: Matthias Klose <doko at ubuntu dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, fortran at gcc dot gnu dot org
- Date: Sun, 15 Mar 2009 23:49:40 +0100
- Subject: Re: [patch] fix warnings with -D_FORTIFY_SOURCE and -Wformat-security
- References: <49BD8445.6070705@ubuntu.com> <alpine.LSU.1.99.0903152345450.20299@acrux.dbai.tuwien.ac.at>
Gerald Pfeifer schrieb:
> Matthias,
>
> On Sun, 15 Mar 2009, Matthias Klose wrote:
>> when GCC is built with a compiler which has some hardening options
>> turned on by default, the build fails when configured without
>> --disable-werror. This patch fixes all these warnings
>
> I believe
>
> + size_t rv_neverused ATTRIBUTE_UNUSED;
> print.src_line += lines;
> - fwrite (buf, 1, size, print.outf);
> + rv_neverused = fwrite (buf, 1, size, print.outf);
>
> could also bee written as
>
> (void) fwrite (buf, 1, size, print.outf);
>
> which looks simpler and expresses the same in a more straightforward
> manner. (If it doesn't work, that may be something to address.)
No, unfortunately this warning cannot be avoid by the (void) cast.
Matthias