Re: [PATCH] http: cast result to FILE *
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 4, 2019, 18:10 UTC
- Message-ID
- <xmqq1s4nwhjl.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CACsJy8BtaxMRTG4-r3iJfUuR9k-=r=4QTRxCkFt3k3p7826Z9A@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 9 quoted lines
>> 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.