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

[PATCH 3/4] mingw: squash another warning about a cast

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 15, 2016, 13:24 UTC
Message-ID
<8075ca3dff83486406b05b1701d025727ab86da9.1452864241.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1452864241.git.johannes.schindelin@gmx.de>

MSys2's compiler is correct that casting a "void *" to a "DWORD" loses precision, but in the case of pthread_exit() we know that the value fits into a DWORD.

Just like casting handles to DWORDs, let's work around this issue by casting to "intrptr_t" first, and immediately cast to the final type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/win32/pthread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index 8ad1873..d3dd872 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -77,7 +77,7 @@ extern pthread_t pthread_self(void);
 
 static inline int pthread_exit(void *ret)
 {
-	ExitThread((DWORD)ret);
+	ExitThread((DWORD)(intptr_t)ret);
 }
 
 typedef DWORD pthread_key_t;
-- 
2.7.0.windows.1.7.g55a05c8
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 4 of 7 in “Fix compile warnings with MSys2's compiler”
  1. 0/4 Fix compile warnings with MSys2's compilerJohannes Schindelin, Jan 15, 2016
  2. 1/4 mingw: avoid redefining S_* constantsJohannes Schindelin, Jan 15, 2016
  3. 2/4 mingw: avoid warnings when casting HANDLEs to intJohannes Schindelin, Jan 15, 2016
  4. 3/4 mingw: squash another warning about a castJohannes Schindelin, Jan 15, 2016
  5. 4/4 mingw: uglify (a, 0) definitions to shut up warningsJohannes Schindelin, Jan 15, 2016
  6. Junio C HamanoJan 15, 2016
  7. Johannes SchindelinJan 16, 2016

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.