Re: Confusing git messages when disk is full.
- From
Andreas Schwab <schwab@linux-m68k.org>
- Date
- Feb 16, 2017, 10:10 UTC
- Message-ID
- <87tw7uv439.fsf@linux-m68k.org>
- In-Reply-To
- <20170215231832.bzg3ygz4ualcvqlc@sigill.intra.peff.net>
On Feb 15 2017, Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> 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@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."