Re: [PATCH 00/15] Handle fopen() errors
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 21, 2017, 11:52 UTC
- Message-ID
- <CAPc5daXPgEFibr28-EZjk9_vYrrO2qt9VLXW6PepmFXUChpk7Q@mail.gmail.com>
- In-Reply-To
- <CACsJy8D1LuH6qVp15MSkCM_oQphVUUK0r9SeKC5AzX+9Xi2dcw@mail.gmail.com>
On Fri, Apr 21, 2017 at 8:04 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 20 quoted lines
> On Fri, Apr 21, 2017 at 1:29 PM, Jeff King <peff@peff.net> wrote:
>>
>> I had a similar thought while reading through it. I think it would be
>> shorter still with:
>>
>> FILE *fopen_or_warn(const char *path, const char *mode)
>> {
>> FILE *fh = fopen(path, mode);
>> if (!fh)
>> warn_failure_to_read_open_optional_path(path);
>> return fh;
>> }
>>
>> And then quite a few of the patches could just be
>> s/fopen/fopen_or_warn/.
>
> Jeff.. oh Jeff.. you have made it _way_ too convenient that after a
> quick grep at fopen( again, I found a couple more places that I would
> have just ignored last time (too much work), but now all I need to do
> is Alt-f to the end of fopen and Alt-/ a few times. Too tempting.. :)Yes, but (1) we'd need to be careful about --quiet, and (2) we would also need a wrapper for open(2).