Mercurial > hg > octave-lojdl > gnulib-hg
changeset 17263:283c189edcab
fwrite: silence __wur without using inline
The libvirt folks reported[1] a link error of multiple rpl_fwrite
definitions that hits only when optimization and FORTIFY_SOURCE
are both enabled, due to improper use of inline. But since that
particular use of rpl_fwrite exists only to work around a spurious
gcc warning on some versions of glibc, we can use gcc extensions
to acheive the same effect without using inline. This approach
copies from ignore-value.h.
[1] https://lists.gnu.org/archive/html/bug-gnulib/2013-01/msg00014.html
* lib/stdio.in.h (fwrite): Limit warn_unused_result workaround to
just gcc, and in a way that avoids inline issues.
* modules/stdio (Depends-on): Drop extern-inline.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Thu, 03 Jan 2013 09:51:44 -0700 |
parents | aa1920a5636c |
children | 66e6219b0ff0 |
files | ChangeLog lib/stdio.in.h modules/stdio |
diffstat | 3 files changed, 12 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-01-03 Eric Blake <eblake@redhat.com> + + fwrite: silence __wur without using inline + * lib/stdio.in.h (fwrite): Limit warn_unused_result workaround to + just gcc, and in a way that avoids inline issues. + * modules/stdio (Depends-on): Drop extern-inline. + 2013-01-03 Jim Meyering <jim@meyering.net> update-copyright: avoid copyright notice date corruption
--- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -46,11 +46,6 @@ #ifndef _@GUARD_PREFIX@_STDIO_H #define _@GUARD_PREFIX@_STDIO_H -_GL_INLINE_HEADER_BEGIN -#ifndef _GL_STDIO_INLINE -# define _GL_STDIO_INLINE _GL_INLINE -#endif - /* Get va_list. Needed on many systems, including glibc 2.8. */ #include <stdarg.h> @@ -583,18 +578,12 @@ /* Work around glibc bug 11959 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>, which sometimes causes an unwanted diagnostic for fwrite calls. - This affects only function declaration attributes, so it's not - needed for C++. */ -# if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL -_GL_STDIO_INLINE size_t _GL_ARG_NONNULL ((1, 4)) -rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream) -{ - size_t r = fwrite (ptr, s, n, stream); - (void) r; - return r; -} + This affects only function declaration attributes under certain + versions of gcc, and is not needed for C++. */ +# if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL \ + && 3 < (__GNUC__ + (4 <= __GNUC_MINOR__)) # undef fwrite -# define fwrite rpl_fwrite +# define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; }) # endif # endif _GL_CXXALIASWARN (fwrite); @@ -1338,8 +1327,6 @@ "POSIX compliance"); #endif -_GL_INLINE_HEADER_END - #endif /* _@GUARD_PREFIX@_STDIO_H */ #endif /* _@GUARD_PREFIX@_STDIO_H */ #endif