On Feb 15 2017, Jeff King <peff@xxxxxxxx> wrote: > On Wed, Feb 15, 2017 at 02:50:19PM -0800, Junio C Hamano wrote: > >> > That works, but the fact that we need a comment is a good sign that it's >> > kind of gross. It's too bad stdio does not specify the return of fclose >> > to report an error in the close _or_ any previous error. I guess we >> > could wrap it with our own function. >> >> Sure. I am happy to add something like this: >> >> /* >> * closes a FILE *, returns 0 if closing and all the >> * previous stdio operations on fp were successful, >> * otherwise non-zero. >> */ >> int xfclose(FILE *fp) >> { >> return ferror(fp) | fclose(fp); >> } > > Yes, that's exactly what I had in mind (might be worth calling out the > bitwise-OR, though, just to make it clear it's not a typo). Since the order of evaluation is unspecified, it would be better to force sequencing ferror before fclose. Andreas. -- Andreas Schwab, schwab@xxxxxxxxxxxxxx GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."