Web lists-archives.com

Re: [PATCH] http: cast result to FILE *





On February 4, 2019 12:10:54 p.m. CST, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>Duy Nguyen <pclouds@xxxxxxxxx> 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.