[v2,1/4] eal/windows: fix pedantic build

Message ID 20230112203719.1528619-2-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/4] eal/windows: fix pedantic build |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Jan. 12, 2023, 8:37 p.m. UTC
  MinGW GCC 12 shows an illegal pointer conversion
when included in a pedantic module:

lib/eal/windows/include/pthread.h:137:41: error:
	ISO C forbids conversion of object pointer to function pointer type
	[-Werror=pedantic]
 137 | hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
     |                                 ^

Fixes: e8428a9d89f1 ("eal/windows: add some basic functions and macros")
Cc: stable@dpdk.org

By using uintptr_t, the compiler is forced to accept the conversion.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/windows/include/pthread.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon March 1, 2023, 4:33 p.m. UTC | #1
12/01/2023 21:37, Thomas Monjalon:
> MinGW GCC 12 shows an illegal pointer conversion
> when included in a pedantic module:
> 
> lib/eal/windows/include/pthread.h:137:41: error:
> 	ISO C forbids conversion of object pointer to function pointer type
> 	[-Werror=pedantic]
>  137 | hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
>      |                                 ^
> 
> Fixes: e8428a9d89f1 ("eal/windows: add some basic functions and macros")
> Cc: stable@dpdk.org
> 
> By using uintptr_t, the compiler is forced to accept the conversion.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Applied this single patch, so the rest of the series can be managed in mlx tree.
  

Patch

diff --git a/lib/eal/windows/include/pthread.h b/lib/eal/windows/include/pthread.h
index 27fd2cca52..f7cf0e9ddf 100644
--- a/lib/eal/windows/include/pthread.h
+++ b/lib/eal/windows/include/pthread.h
@@ -134,7 +134,8 @@  pthread_create(void *threadid, const void *threadattr, void *threadfunc,
 {
 	RTE_SET_USED(threadattr);
 	HANDLE hThread;
-	hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc,
+	hThread = CreateThread(NULL, 0,
+		(LPTHREAD_START_ROUTINE)(uintptr_t)threadfunc,
 		args, 0, (LPDWORD)threadid);
 	if (hThread) {
 		SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);