]> git.proxmox.com Git - qemu.git/commitdiff
Fix conversions from pointer to int and vice versa
authorStefan Weil <weil@mail.berlios.de>
Wed, 23 Feb 2011 18:09:16 +0000 (19:09 +0100)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 20 Mar 2011 21:39:23 +0000 (21:39 +0000)
Here the int values fds[0], sigfd, s, sock and fd are converted
to void pointers which are later converted back to an int value.

These conversions should always use intptr_t instead of unsigned long.

They are needed for environments where sizeof(long) != sizeof(void *).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
cpus.c
migration-tcp.c
migration-unix.c
qemu-char.c

diff --git a/cpus.c b/cpus.c
index 077729c507d0acb02ebbcdaf4874b60ecbfed781..b6e658da6252a91638aa132aa8e0e93c87d68571 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -278,7 +278,7 @@ static void qemu_event_increment(void)
 
 static void qemu_event_read(void *opaque)
 {
-    int fd = (unsigned long)opaque;
+    int fd = (intptr_t)opaque;
     ssize_t len;
     char buffer[512];
 
@@ -306,7 +306,7 @@ static int qemu_event_init(void)
         goto fail;
     }
     qemu_set_fd_handler2(fds[0], NULL, qemu_event_read, NULL,
-                         (void *)(unsigned long)fds[0]);
+                         (void *)(intptr_t)fds[0]);
 
     io_thread_fd = fds[1];
     return 0;
@@ -327,7 +327,7 @@ static void dummy_signal(int sig)
  */
 static void sigfd_handler(void *opaque)
 {
-    int fd = (unsigned long) opaque;
+    int fd = (intptr_t)opaque;
     struct qemu_signalfd_siginfo info;
     struct sigaction action;
     ssize_t len;
@@ -395,7 +395,7 @@ static int qemu_signal_init(void)
     fcntl_setfl(sigfd, O_NONBLOCK);
 
     qemu_set_fd_handler2(sigfd, NULL, sigfd_handler, NULL,
-                         (void *)(unsigned long) sigfd);
+                         (void *)(intptr_t)sigfd);
 
     return 0;
 }
index b55f419b654f51de8309db59c43020194f632460..e8dff9d71a42be6c4dc75d13e043a2119cae0c02 100644 (file)
@@ -139,7 +139,7 @@ static void tcp_accept_incoming_migration(void *opaque)
 {
     struct sockaddr_in addr;
     socklen_t addrlen = sizeof(addr);
-    int s = (unsigned long)opaque;
+    int s = (intptr_t)opaque;
     QEMUFile *f;
     int c;
 
@@ -194,7 +194,7 @@ int tcp_start_incoming_migration(const char *host_port)
         goto err;
 
     qemu_set_fd_handler2(s, NULL, tcp_accept_incoming_migration, NULL,
-                         (void *)(unsigned long)s);
+                         (void *)(intptr_t)s);
 
     return 0;
 
index 57232c07a934156ff8948418970ce925d0da5191..8b967f2938fabd27222cd36e86582bace06d9b96 100644 (file)
@@ -147,7 +147,7 @@ static void unix_accept_incoming_migration(void *opaque)
 {
     struct sockaddr_un addr;
     socklen_t addrlen = sizeof(addr);
-    int s = (unsigned long)opaque;
+    int s = (intptr_t)opaque;
     QEMUFile *f;
     int c;
 
@@ -204,7 +204,7 @@ int unix_start_incoming_migration(const char *path)
     }
 
     qemu_set_fd_handler2(sock, NULL, unix_accept_incoming_migration, NULL,
-                        (void *)(unsigned long)sock);
+                        (void *)(intptr_t)sock);
 
     return 0;
 
index bd4e944e1d0b42a99822c4d4dcbcee3ec21d1676..cad35d7717dfb75680ccee1d80ca61e21807a614 100644 (file)
@@ -1376,7 +1376,7 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
 {
-    int fd = (int)(long)chr->opaque;
+    int fd = (int)(intptr_t)chr->opaque;
     uint8_t b;
 
     switch(cmd) {
@@ -1422,7 +1422,7 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
         return NULL;
 
     chr = qemu_mallocz(sizeof(CharDriverState));
-    chr->opaque = (void *)(long)fd;
+    chr->opaque = (void *)(intptr_t)fd;
     chr->chr_write = null_chr_write;
     chr->chr_ioctl = pp_ioctl;
     return chr;