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

[PATCH 3/4] Fix comma warnings with clang on Windows

From
Mike Hommey <mh@glandium.org>
Date
Jun 3, 2025, 23:06 UTC
Message-ID
<20250603230646.2322671-3-mh@glandium.org>
In-Reply-To
<20250603230646.2322671-1-mh@glandium.org>
e.g.
```
  compat/mingw.c:723:24: error: possible misuse of comma operator here [-Werror,-Wcomma]
    723 |                 return errno = ENOSYS, -1;
        |                                      ^
  compat/mingw.c:723:10: note: cast expression to void to silence warning
    723 |                 return errno = ENOSYS, -1;
        |                        ^~~~~~~~~~~~~~
        |                        (void)(       )
  /usr/x86_64-w64-mingw32/include/stdlib.h:155:15: note: expanded from macro 'errno'
    155 | #define errno (*_errno())
        |               ^
```
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 compat/mingw.c | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 8a9972a1ca..cd54937ebd 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -501,8 +501,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
@@ -2497,12 +2499,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;
 }
 
@@ -2535,13 +2539,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();
@@ -2561,12 +2567,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;
-- 
2.50.0.rc1.593.g042f21cb9b
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 11 in “Fix maybe-uninitialized warning with GCC at -O3”
  1. 1/4 Fix maybe-uninitialized warning with GCC at -O3Mike Hommey, Jun 3, 2025
  2. 4/4 Fix unreachable-code warning with clang on WindowsMike Hommey, Jun 3, 2025
  3. Patrick SteinhardtJun 4, 2025
  4. Junio C HamanoJun 4, 2025
  5. 3/4 Fix comma warnings with clang on WindowsMike Hommey, Jun 3, 2025
  6. Junio C HamanoJun 3, 2025
  7. 2/4 Fix use-after-free warning with GCC at -O3Mike Hommey, Jun 3, 2025
  8. Junio C HamanoJun 3, 2025
  9. Patrick SteinhardtJun 4, 2025
  10. Patrick SteinhardtJun 4, 2025
  11. Jeff KingJun 6, 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.