[PATCH] fwrite: silence __wur without using inline

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

 



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 the method used in 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@xxxxxxxxxx>
---
 ChangeLog      |  7 +++++++
 lib/stdio.in.h | 23 +++++------------------
 modules/stdio  |  1 -
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 73c186d..0bae990 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-01-03  Eric Blake  <eblake@xxxxxxxxxx>
+
+	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@xxxxxxxxxxxx>

 	update-copyright: avoid copyright notice date corruption
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index ec39c7d..0f20171 100644
--- 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 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
 /* 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 @@ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
                       "POSIX compliance");
 #endif

-_GL_INLINE_HEADER_END
-
 #endif /* _@GUARD_PREFIX@_STDIO_H */
 #endif /* _@GUARD_PREFIX@_STDIO_H */
 #endif
diff --git a/modules/stdio b/modules/stdio
index c33ad31..54189dc 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -7,7 +7,6 @@ lib/stdio.in.h
 m4/stdio_h.m4

 Depends-on:
-extern-inline
 include_next
 snippet/arg-nonnull
 snippet/c++defs
-- 
1.8.0.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]