From: Johannes Sixt <j6t@kdbg.org>
To: Stepan Kasal <kasal@ucw.cz>
Cc: GIT Mailing-list <git@vger.kernel.org>,
msysGit <msysgit@googlegroups.com>
Subject: Re: [msysGit] [PATCH] mingw: redefine the wrapper macro after the corresponding function
Date: Thu, 05 Jun 2014 18:56:25 +0200 [thread overview]
Message-ID: <5390A139.2090406@kdbg.org> (raw)
In-Reply-To: <20140605080519.GB28029@camelia.ucw.cz>
Am 05.06.2014 10:05, schrieb Stepan Kasal:
> mingw.c defines several wrapper functionsi, like mingw_unlink().
> These wrappers are deployed by macros like this:
> #define unlink mingw_unlink
> The function itself is preceded by #undef, leaving the wrapper out
> of the game for the rest of mingw.c.
>
> This was not probably intentional; for example, there are three
> calls to open() below the definition mingw_open() that probably
> have no reason to circumvent the wrapper.
> OTOH, there is one call to gethostbyname() before it was undefined;
> probably happy that it actually calls mingw_gethostbyname().
>
> This patch adds back the #define after each wrapper definition.
>
> Signed-off-by: Stepan Kasal <kasal@ucw.cz>
> ---
> compat/mingw.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/compat/mingw.c b/compat/mingw.c
> index a0e13bc..e7193c0 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -224,6 +224,7 @@ int mingw_unlink(const char *pathname)
> ret = unlink(pathname);
> return ret;
> }
> +#define unlink mingw_unlink
(etc...)
I don't particularly like this approach: It robs the precise control of
which function we can invoke from other places in mingw.c.
Within mingw.c, if some other function inside mingw.c wants to use
mingw_unlink, then it should be written as 'mingw_unlink(foo)', not
'unlink(foo)'.
So, IMO the macros should be #undef'ed at the top of the file, and all
users (like the open() and gethostbyname() invocations that you
identified) should be audited and changed to call the function they
actually need (i.e., the system open vs. mingw_open).
-- Hannes
next prev parent reply other threads:[~2014-06-05 16:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 8:05 [PATCH] mingw: redefine the wrapper macro after the corresponding function Stepan Kasal
2014-06-05 14:51 ` Karsten Blees
2014-06-05 15:13 ` [msysGit] " Stepan Kasal
2014-06-05 22:12 ` Karsten Blees
2014-06-05 16:56 ` Johannes Sixt [this message]
2014-06-05 22:00 ` Karsten Blees
2014-06-06 8:32 ` Stepan Kasal
2014-06-06 8:41 ` [PATCH v2] " Stepan Kasal
2014-06-06 9:43 ` [PATCH] " Karsten Blees
2014-06-06 11:10 ` Stepan Kasal
2014-06-06 18:20 ` Karsten Blees
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5390A139.2090406@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=kasal@ucw.cz \
--cc=msysgit@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).