This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] ld: optimize vfinfo output slightly
- From: Ian Lance Taylor <iant at google dot com>
- To: nick clifton <nickc at redhat dot com>
- Cc: Mike Frysinger <vapier at gentoo dot org>, Andreas Schwab <schwab at linux-m68k dot org>, binutils at sourceware dot org
- Date: Mon, 02 Apr 2012 22:12:21 -0700
- Subject: Re: [patch] ld: optimize vfinfo output slightly
- References: <201203240122.13385.vapier@gentoo.org> <201203241318.27353.vapier@gentoo.org> <4F75DC74.9030203@redhat.com> <201203301320.26204.vapier@gentoo.org> <4F79770A.2070102@redhat.com>
nick clifton <nickc@redhat.com> writes:
> Hi Mike,
>
>>>> if (fwrite (str, 1, len, fp) != len)
>>>> {
>>>> /* Ignore. */
>>>> }
>>>
>>> Yes. Although it would be simpler to just remove the whole if (...)
>>> statment block and just call fwrite without testing its return value.
>
>> the reason i didn't do that is it causes warnings since fwrite() is marked as
>> "warn on unused result"
>
> OK, how about:
>
> (void) fwrite (str, 1, len, fp);
Doesn't work. There is no clean way to avoid a warning/error on a
warn_unused_result function. That is intentional. The
warn_unused_result attribute was designed for functions like realloc,
for which the result must be used in a correct program. It was not
designed for functions like fwrite, where a correct program can ignore
the result.
Ian