Re: [PATCH] tempfile: avoid "ferror | fclose" trick
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Feb 17, 2017, 10:42 UTC
- Message-ID
- <64eedabd-c0de-a7e0-8d98-ad23a9625b45@alum.mit.edu>
- In-Reply-To
- <20170217080759.2357wzdiuymcyosw@sigill.intra.peff.net>
On 02/17/2017 09:07 AM, Jeff King wrote:
Show 9 quoted lines
> [...] > That's similar to what I wrote earlier, but if we don't mind overwriting > errno unconditionally, I think just: > > errno = EIO; /* covers ferror(), overwritten by failing fclose() */ > err |= ferror(fp); > err |= fclose(fp); > > does the same thing.
True; I'd forgotten the convention that non-failing functions are allowed to change errno. Your solution is obviously simpler and faster.
Michael