[PATCH 2/3] Avoid compiler warnings about int -> void * casts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



GCC is a little confused about the cast of beginthread/beginthreadex
from unsigned long -> void *. Go via an intermediate variable avoids
the bogus warning, and makes the code a little cleaner

* src/util/threads-win32.c: Avoid compiler warning in cast
---
 src/util/threads-win32.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index ddb4737..5661437 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -262,6 +262,7 @@ int virThreadCreate(virThreadPtr thread,
                     void *opaque)
 {
     struct virThreadArgs *args;
+    uintptr_t ret;
 
     if (VIR_ALLOC(args) < 0)
         return -1;
@@ -271,17 +272,20 @@ int virThreadCreate(virThreadPtr thread,
 
     thread->joinable = joinable;
     if (joinable) {
-        thread->thread = (HANDLE)_beginthreadex(NULL, 0,
-                                                virThreadHelperJoinable,
-                                                args, 0, NULL);
-        if (thread->thread == 0)
+        ret = _beginthreadex(NULL, 0,
+                             virThreadHelperJoinable,
+                             args, 0, NULL);
+        if (ret == 0)
             return -1;
     } else {
-        thread->thread = (HANDLE)_beginthread(virThreadHelperDaemon,
-                                              0, args);
-        if (thread->thread == (HANDLE)-1L)
+        ret = _beginthread(virThreadHelperDaemon,
+                           0, args);
+        if (ret == -1L)
             return -1;
     }
+
+    thread->thread = (HANDLE)ret;
+
     return 0;
 }
 
-- 
1.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]