From: Eric Blake Date: Wed, 11 May 2011 17:35:06 +0000 (-0600) Subject: fclose: preserve fflush errors X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64a5e38bced6c8f5117efbed95cdfd8ca133ed54;p=pspp 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 --- diff --git a/ChangeLog b/ChangeLog index f4d78dd888..e8e37db0e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-05-11 Eric Blake + 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 diff --git a/lib/fclose.c b/lib/fclose.c index a8d68b4d81..c0dfa27e9f 100644 --- a/lib/fclose.c +++ b/lib/fclose.c @@ -57,12 +57,6 @@ rpl_fclose (FILE *fp) 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 @@ rpl_fclose (FILE *fp) #endif /* !WINDOWS_SOCKETS */ + if (saved_errno != 0) + { + errno = saved_errno; + result = EOF; + } + return result; }