From: Junio C Hamano Date: Mon, 17 Nov 2025 22:16:34 GMT Subject: Re: [PATCH] mingw: avoid the comma operator Message-ID: In-Reply-To: "Johannes Schindelin via GitGitGadget" writes: > From: Johannes Schindelin > > 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 > --- > mingw: avoid the comma operator > > I wonder how many more times I will deal with the comma operator... ;-) > /* 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.