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

Re: [PATCH] mingw: avoid the comma operator

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 17, 2025, 22:16 UTC
Message-ID
<xmqqy0o4gv99.fsf@gitster.g>
In-Reply-To
<pull.2007.git.1763412374866.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 21 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The pattern `return errno = ..., -1;` is observed several times in
> `compat/mingw.c`. It has served us well over the years, but now clang
> starts complaining:
>
>   compat/mingw.c:723:24: error: possible misuse of comma operator here [-Werror,-Wcomma]
>     723 |                 return errno = ENOSYS, -1;
>         |                                      ^
>
> See for example this failing workflow run:
> https://github.com/git-for-windows/git-sdk-arm64/actions/runs/15457893907/job/43513458823#step:8:201
>
> Let's appease clang (and also reduce the use of the no longer common
> comma operator).
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>     mingw: avoid the comma operator
>     
>     I wonder how many more times I will deal with the comma operator...
;-)
Show 7 quoted lines
>  	/* only these flags are supported */
> -	if ((oflags & ~O_CREAT) != (O_WRONLY | O_APPEND))
> -		return errno = ENOSYS, -1;
> +	if ((oflags & ~O_CREAT) != (O_WRONLY | O_APPEND)) {
> +		errno = ENOSYS;
> +		return -1;
> +	}

Good riddance. It indeed is somewhat hard to read, especially because it may not be apparent to readers how "A = B, C" binds (answer: B gets assigned to A and then the whole thing yields C).

I wonder if
	return (errno = ENOSYS), -1;

is accepted by the compiler, but in these error handling we do not have to be cute, and updated code that is both simple and stupid reads very well.

Will queue.  Thanks.
Previous: Johannes Schindelin via GitGitGadgetNext: Jeff King
Message 2 of 3 in “mingw: avoid the comma operator”
  1. mingw: avoid the comma operatorJohannes Schindelin via GitGitGadget, Nov 17, 2025
  2. Junio C HamanoNov 17, 2025
  3. Jeff KingNov 18, 2025

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.