Re: [PATCH] http: cast result to FILE *
- From
- Dan McGregor <dkm560@usask.ca>
- Date
- Feb 5, 2019, 01:36 UTC
- Message-ID
- <49B9198C-53E5-42BD-8834-B1EDEB3332CB@usask.ca>
- In-Reply-To
- <xmqq1s4nwhjl.fsf@gitster-ct.c.googlers.com>
On February 4, 2019 12:10:54 p.m. CST, Junio C Hamano <gitster@pobox.com> wrote:
Show 33 quoted lines
>Duy Nguyen <pclouds@gmail.com> writes:
>
>>> The disadvantage, of course, would be that other call sites would
>not
>>> benefit from a manual auditing whether the argument has side effects
>(and
>>> thus, whether a macro using the argument multiple times would result
>in
>>> very unexpected multiple side effects).
>>
>> That's just a better reason to "fix" it in compat/. If you define a
>> git_fileno() function and map fileno to it, then you won't have to
>> deal with side effects of FreeBSD's fileno() macro. All evaluation
>> happens before git_fileno() is called.
>
>Hmph, so the idea is to have
>
> /* do not include git-compat-util.h here */
> int wrapped_fileno(FILE *f)
> {
> return fileno(f);
> }
>
>in compat/fileno.c and then do something like this
>
> #ifdef fileno
> #undef fileno
> #define fileno(x) wrapped_fileno(x)
> #endif
>
>for FreeBSD in git-compat-util.h or something like that?
>
>I think I can buy that.Works for me too. FreeBSD's not alone in this, either. It looks like NetBSD does the same thing. I'll send a v2 tomorrow.