# HG changeset patch # User Eric Blake # Date 1357231904 25200 # Node ID 283c189edcabe96f98be609fde99b025b5fdf254 # Parent aa1920a5636c2882db6fb20fbb32708c3968b2ee 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 diff -r aa1920a5636c -r 283c189edcab ChangeLog --- a/ChangeLog Thu Jan 03 10:23:30 2013 +0100 +++ b/ChangeLog Thu Jan 03 09:51:44 2013 -0700 @@ -1,3 +1,10 @@ +2013-01-03 Eric Blake + + 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 update-copyright: avoid copyright notice date corruption diff -r aa1920a5636c -r 283c189edcab lib/stdio.in.h --- a/lib/stdio.in.h Thu Jan 03 10:23:30 2013 +0100 +++ b/lib/stdio.in.h Thu Jan 03 09:51:44 2013 -0700 @@ -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 @@ -583,18 +578,12 @@ /* Work around glibc bug 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 diff -r aa1920a5636c -r 283c189edcab modules/stdio --- a/modules/stdio Thu Jan 03 10:23:30 2013 +0100 +++ b/modules/stdio Thu Jan 03 09:51:44 2013 -0700 @@ -7,7 +7,6 @@ m4/stdio_h.m4 Depends-on: -extern-inline include_next snippet/arg-nonnull snippet/c++defs