Re: [RFC/PATCH v11 03/13] bisect--helper: `write_terms` shell function in C
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 4, 2016, 15:39 UTC
- Message-ID
- <xmqqvazg5ysb.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAFZEwPNFz60GrX9ZqaFAvCU4HoNg8rmuqa0t5+DXFjaEHTmDeg@mail.gmail.com>
Pranit Bauva <pranit.bauva@gmail.com> writes:
Show 17 quoted lines
>>> + res = fprintf(fp, "%s\n%s\n", bad, good); >>> + res |= fclose(fp); >>> + return (res < 0) ? -1 : 0; >>> +} >> >> If fprintf(3) were a function that returns 0 on success and negative >> on error (like fclose(3) is), the pattern to cascade the error >> return with "res |= another_call()" is appropriate, but the made me >> hiccup a bit while reading it. It is not wrong per-se and it would >> certainly be making it worse if we did something silly like >> >> res = fprintf(...) < 0 ? -1 : 0; >> res |= fclose(fp); >> >> so I guess what you have is the most succinct way to do this. > > I agree with your point and your suggested code is better!
Puzzled... Read it again, I was not suggesting it---I was saying "this could be a silly rewrite, which I think is making it worse".