changeset 14730:f0a9a2cd267c

fclose: preserve fflush errors Caught by gcc -Werror=unused-but-set-variable. * lib/fclose.c (rpl_fclose): Don't lose fflush errors. Reported by Jim Meyering. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Wed, 11 May 2011 11:35:06 -0600
parents 28442a65c23e
children 687d9ec4a38c
files ChangeLog lib/fclose.c
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-05-11  Eric Blake  <eblake@redhat.com>
 
+	fclose: preserve fflush errors
+	* lib/fclose.c (rpl_fclose): Don't lose fflush errors.
+	Reported by Jim Meyering.
+
 	bootstrap: support a prereq of 'rpcgen -' on RHEL5
 	* build-aux/bootstrap (check_versions): When no specific version
 	is required, merely check that the app produces an exit status
--- a/lib/fclose.c
+++ b/lib/fclose.c
@@ -57,12 +57,6 @@
 
   fclose (fp); /* will fail with errno = EBADF, if we did not lose a race */
 
-  if (saved_errno != 0)
-    {
-      errno = saved_errno;
-      result = EOF;
-    }
-
 #else /* !WINDOWS_SOCKETS */
   /* Call fclose() and invoke all hooks of the overridden close().  */
 
@@ -80,5 +74,11 @@
 
 #endif /* !WINDOWS_SOCKETS */
 
+  if (saved_errno != 0)
+    {
+      errno = saved_errno;
+      result = EOF;
+    }
+
   return result;
 }