Merge branch 'js/mingw-assign-comma-fix'

The "return errno = EFOO, -1" construct, which is heavily used in
compat/mingw.c and triggers warnings under "-Wcomma", has been
rewritten to avoid the warnings.

* js/mingw-assign-comma-fix:
  mingw: avoid the comma operator
This commit is contained in:
Junio C Hamano
2025-11-26 10:32:41 -08:00

View File

@@ -491,8 +491,10 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
DWORD create = (oflags & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING; DWORD create = (oflags & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING;
/* only these flags are supported */ /* only these flags are supported */
if ((oflags & ~O_CREAT) != (O_WRONLY | O_APPEND)) if ((oflags & ~O_CREAT) != (O_WRONLY | O_APPEND)) {
return errno = ENOSYS, -1; errno = ENOSYS;
return -1;
}
/* /*
* FILE_SHARE_WRITE is required to permit child processes * FILE_SHARE_WRITE is required to permit child processes
@@ -2450,12 +2452,14 @@ static int start_timer_thread(void)
timer_event = CreateEvent(NULL, FALSE, FALSE, NULL); timer_event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (timer_event) { if (timer_event) {
timer_thread = (HANDLE) _beginthreadex(NULL, 0, ticktack, NULL, 0, NULL); timer_thread = (HANDLE) _beginthreadex(NULL, 0, ticktack, NULL, 0, NULL);
if (!timer_thread ) if (!timer_thread ) {
return errno = ENOMEM, errno = ENOMEM;
error("cannot start timer thread"); return error("cannot start timer thread");
} else }
return errno = ENOMEM, } else {
error("cannot allocate resources for timer"); errno = ENOMEM;
return error("cannot allocate resources for timer");
}
return 0; return 0;
} }
@@ -2488,13 +2492,15 @@ int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
static const struct timeval zero; static const struct timeval zero;
static int atexit_done; static int atexit_done;
if (out) if (out) {
return errno = EINVAL, errno = EINVAL;
error("setitimer param 3 != NULL not implemented"); return error("setitimer param 3 != NULL not implemented");
}
if (!is_timeval_eq(&in->it_interval, &zero) && if (!is_timeval_eq(&in->it_interval, &zero) &&
!is_timeval_eq(&in->it_interval, &in->it_value)) !is_timeval_eq(&in->it_interval, &in->it_value)) {
return errno = EINVAL, errno = EINVAL;
error("setitimer: it_interval must be zero or eq it_value"); return error("setitimer: it_interval must be zero or eq it_value");
}
if (timer_thread) if (timer_thread)
stop_timer_thread(); stop_timer_thread();
@@ -2516,12 +2522,14 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
{ {
if (sig == SIGCHLD) if (sig == SIGCHLD)
return -1; return -1;
else if (sig != SIGALRM) else if (sig != SIGALRM) {
return errno = EINVAL, errno = EINVAL;
error("sigaction only implemented for SIGALRM"); return error("sigaction only implemented for SIGALRM");
if (out) }
return errno = EINVAL, if (out) {
error("sigaction: param 3 != NULL not implemented"); errno = EINVAL;
return error("sigaction: param 3 != NULL not implemented");
}
timer_fn = in->sa_handler; timer_fn = in->sa_handler;
return 0; return 0;