[libvirt] [PATCH libvirt 5/6] Cast pointer to int using intptr_t

Marc-André Lureau marcandre.lureau at gmail.com
Wed Jan 25 20:13:25 UTC 2012


Fix a few warnings with mingw64 x86_64.
---
 src/util/logging.c       |    8 ++++----
 src/util/threads-win32.c |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/logging.c b/src/util/logging.c
index 8d60280..fad322f 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -329,7 +329,7 @@ static void virLogDumpAllFD(const char *msg, int len) {
 
     for (i = 0; i < virLogNbOutputs;i++) {
         if (virLogOutputs[i].f == virLogOutputToFd) {
-            int fd = (long) virLogOutputs[i].data;
+            int fd = (intptr_t) virLogOutputs[i].data;
 
             if (fd >= 0) {
                 ignore_value (safewrite(fd, msg, len));
@@ -791,7 +791,7 @@ static int virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
                             const char *str,
                             void *data)
 {
-    int fd = (long) data;
+    int fd = (intptr_t) data;
     int ret;
     char *msg;
 
@@ -808,7 +808,7 @@ static int virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
 }
 
 static void virLogCloseFd(void *data) {
-    int fd = (long) data;
+    int fd = (intptr_t) data;
 
     VIR_FORCE_CLOSE(fd);
 }
@@ -826,7 +826,7 @@ static int virLogAddOutputToFile(int priority, const char *file) {
     fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR);
     if (fd < 0)
         return -1;
-    if (virLogDefineOutput(virLogOutputToFd, virLogCloseFd, (void *)(long)fd,
+    if (virLogDefineOutput(virLogOutputToFd, virLogCloseFd, (void *)(intptr_t)fd,
                            priority, VIR_LOG_TO_FILE, file, 0) < 0) {
         VIR_FORCE_CLOSE(fd);
         return -1;
diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index 1c33826..157439c 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -336,7 +336,7 @@ int virThreadSelfID(void)
 /* For debugging use only; see comments in threads-pthread.c.  */
 int virThreadID(virThreadPtr thread)
 {
-    return (int)thread->thread;
+    return (intptr_t)thread->thread;
 }
 
 
-- 
1.7.7.5




More information about the libvir-list mailing list