mingw: avoid the comma operator

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Nov 17, 2025 at 20:46 UTC af3919816f20c7c54e6d377945b2f6344b3588fe
1 file changed +28 -20
compat/mingw.c
+28 -20
@@ -491,8 +491,10 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
491 DWORD create = (oflags & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING;
492
493 /* only these flags are supported */
494 - if ((oflags & ~O_CREAT) != (O_WRONLY | O_APPEND))
495 - return errno = ENOSYS, -1;
494 + if ((oflags & ~O_CREAT) != (O_WRONLY | O_APPEND)) {
495 + errno = ENOSYS;
496 + return -1;
497 + }
498
499 /*
500 * FILE_SHARE_WRITE is required to permit child processes
@@ -2450,12 +2452,14 @@ static int start_timer_thread(void)
2452 timer_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2453 if (timer_event) {
2454 timer_thread = (HANDLE) _beginthreadex(NULL, 0, ticktack, NULL, 0, NULL);
2453 - if (!timer_thread )
2454 - return errno = ENOMEM,
2455 - error("cannot start timer thread");
2456 - } else
2457 - return errno = ENOMEM,
2458 - error("cannot allocate resources for timer");
2455 + if (!timer_thread ) {
2456 + errno = ENOMEM;
2457 + return error("cannot start timer thread");
2458 + }
2459 + } else {
2460 + errno = ENOMEM;
2461 + return error("cannot allocate resources for timer");
2462 + }
2463 return 0;
2464 }
2465
@@ -2488,13 +2492,15 @@ int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
2492 static const struct timeval zero;
2493 static int atexit_done;
2494
2491 - if (out)
2492 - return errno = EINVAL,
2493 - error("setitimer param 3 != NULL not implemented");
2495 + if (out) {
2496 + errno = EINVAL;
2497 + return error("setitimer param 3 != NULL not implemented");
2498 + }
2499 if (!is_timeval_eq(&in->it_interval, &zero) &&
2495 - !is_timeval_eq(&in->it_interval, &in->it_value))
2496 - return errno = EINVAL,
2497 - error("setitimer: it_interval must be zero or eq it_value");
2500 + !is_timeval_eq(&in->it_interval, &in->it_value)) {
2501 + errno = EINVAL;
2502 + return error("setitimer: it_interval must be zero or eq it_value");
2503 + }
2504
2505 if (timer_thread)
2506 stop_timer_thread();
@@ -2516,12 +2522,14 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
2522 {
2523 if (sig == SIGCHLD)
2524 return -1;
2519 - else if (sig != SIGALRM)
2520 - return errno = EINVAL,
2521 - error("sigaction only implemented for SIGALRM");
2522 - if (out)
2523 - return errno = EINVAL,
2524 - error("sigaction: param 3 != NULL not implemented");
2525 + else if (sig != SIGALRM) {
2526 + errno = EINVAL;
2527 + return error("sigaction only implemented for SIGALRM");
2528 + }
2529 + if (out) {
2530 + errno = EINVAL;
2531 + return error("sigaction: param 3 != NULL not implemented");
2532 + }
2533
2534 timer_fn = in->sa_handler;
2535 return 0;