Skip to content

mingw: avoid the comma operator #5660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,10 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
DWORD create = (oflags & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING;

/* 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;
}

/*
* FILE_SHARE_WRITE is required to permit child processes
Expand Down Expand Up @@ -3096,12 +3098,14 @@ static int start_timer_thread(void)
timer_event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (timer_event) {
timer_thread = (HANDLE) _beginthreadex(NULL, 0, ticktack, NULL, 0, NULL);
if (!timer_thread )
return errno = ENOMEM,
error("cannot start timer thread");
} else
return errno = ENOMEM,
error("cannot allocate resources for timer");
if (!timer_thread ) {
errno = ENOMEM;
return error("cannot start timer thread");
}
} else {
errno = ENOMEM;
return error("cannot allocate resources for timer");
}
return 0;
}

Expand Down Expand Up @@ -3134,13 +3138,15 @@ int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
static const struct timeval zero;
static int atexit_done;

if (out)
return errno = EINVAL,
error("setitimer param 3 != NULL not implemented");
if (out) {
errno = EINVAL;
return error("setitimer param 3 != NULL not implemented");
}
if (!is_timeval_eq(&in->it_interval, &zero) &&
!is_timeval_eq(&in->it_interval, &in->it_value))
return errno = EINVAL,
error("setitimer: it_interval must be zero or eq it_value");
!is_timeval_eq(&in->it_interval, &in->it_value)) {
errno = EINVAL;
return error("setitimer: it_interval must be zero or eq it_value");
}

if (timer_thread)
stop_timer_thread();
Expand All @@ -3160,12 +3166,14 @@ int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)

int sigaction(int sig, struct sigaction *in, struct sigaction *out)
{
if (sig != SIGALRM)
return errno = EINVAL,
error("sigaction only implemented for SIGALRM");
if (out)
return errno = EINVAL,
error("sigaction: param 3 != NULL not implemented");
if (sig != SIGALRM) {
errno = EINVAL;
return error("sigaction only implemented for SIGALRM");
}
if (out) {
errno = EINVAL;
return error("sigaction: param 3 != NULL not implemented");
}

timer_fn = in->sa_handler;
return 0;
Expand Down
Loading