git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [msysGit] [PATCH] mingw: redefine the wrapper macro after the corresponding function

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 5, 2014, 16:56 UTC
Message-ID
<5390A139.2090406@kdbg.org>
In-Reply-To
<20140605080519.GB28029@camelia.ucw.cz>
Am 05.06.2014 10:05, schrieb Stepan Kasal:
Show 28 quoted lines
> 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
Previous: Karsten BleesNext: Karsten Blees
Message 5 of 11 in “mingw: redefine the wrapper macro after the corresponding function”
  1. mingw: redefine the wrapper macro after the corresponding functionStepan Kasal, Jun 5, 2014
  2. Karsten BleesJun 5, 2014
  3. Stepan KasalJun 5, 2014
  4. Karsten BleesJun 5, 2014
  5. Johannes SixtJun 5, 2014
  6. Karsten BleesJun 5, 2014
  7. Stepan KasalJun 6, 2014
  8. mingw: redefine the wrapper macro after the corresponding functionStepan Kasal, Jun 6, 2014
  9. Karsten BleesJun 6, 2014
  10. Stepan KasalJun 6, 2014
  11. Karsten BleesJun 6, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.