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

Re: [PATCH 1/2] mingw.h: permit arguments with side effects for is_dir_sep

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 22, 2017, 11:52 UTC
Message-ID
<alpine.DEB.2.21.1.1705221349200.3610@virtualbox>
In-Reply-To
<69bafb7c9e08ba837a9b92573bef165a62c5bf92.1495261020.git.j6t@kdbg.org>
Hi Hannes,
On Sat, 20 May 2017, Johannes Sixt wrote:
Show 5 quoted lines
> The implementation of is_dir_sep in git-compat-util.h uses an inline
> function. Use one also for the implementation in compat/mingw.h to support
> non-trivial argument expressions.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
I was a bit confused by the oneline. Maybe something like
	mingw.h: avoid side effects with is_dir_sep()'s argument
	Taking git-compat-util.h's cue (which uses an inline function
	to back is_dir_sep()), let's use an inline function to back
	also the Windows version of is_dir_sep(); This avoids problems
	when calling the function with arguments that do more than just
	provide a single character, e.g. incrementing a pointer. Example:
		is_dir_sep(*(p++))
Show 17 quoted lines
> diff --git a/compat/mingw.h b/compat/mingw.h
> index cdc112526a..5e8447019b 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -398,7 +398,11 @@ HANDLE winansi_get_osfhandle(int fd);
>  	(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
>  int mingw_skip_dos_drive_prefix(char **path);
>  #define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
> -#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
> +static inline int mingw_is_dir_sep(int c)
> +{
> +	return c == '/' || c == '\\';
> +}
> +#define is_dir_sep mingw_is_dir_sep
>  static inline char *mingw_find_last_dir_sep(const char *path)
>  {
>  	char *ret = NULL;
The patch is very good, of course.

ACK, Dscho

Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 19 in “Fix warnings on access of a remote with Windows paths”
  1. 0/2 Fix warnings on access of a remote with Windows pathsJohannes Sixt, May 20, 2017
  2. 1/2 mingw.h: permit arguments with side effects for is_dir_sepJohannes Sixt, May 20, 2017
  3. Johannes SchindelinMay 22, 2017
  4. 2/2 Windows: do not treat a path with backslashes as a remote's nick nameJohannes Sixt, May 20, 2017
  5. Johannes SchindelinMay 22, 2017
  6. Johannes SchindelinMay 22, 2017
  7. Johannes SixtMay 22, 2017
  8. Johannes SchindelinMay 23, 2017
  9. Johannes SixtMay 23, 2017
  10. stefan.naewe@atlas-elektronik.comMay 22, 2017
  11. Johannes SchindelinMay 22, 2017
  12. Johannes SixtMay 22, 2017
  13. Johannes SchindelinMay 23, 2017
  14. Junio C HamanoMay 23, 2017
  15. Johannes SixtMay 24, 2017
  16. 2/2 Windows: do not treat a path with backslashes as a remote's nick nameJohannes Sixt, May 25, 2017
  17. Junio C HamanoMay 25, 2017
  18. 1/2 mingw.h: permit arguments with side effects for is_dir_sepJohannes Sixt, May 22, 2017
  19. 2/2 Windows: do not treat a path with backslashes as a remote's nick nameJohannes Sixt, May 22, 2017

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.