From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54623 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsJ9V-00035s-C1 for qemu-devel@nongnu.org; Wed, 23 Feb 2011 13:09:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PsJ9T-0007tT-UC for qemu-devel@nongnu.org; Wed, 23 Feb 2011 13:09:29 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:58767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PsJ9T-0007s6-Iy for qemu-devel@nongnu.org; Wed, 23 Feb 2011 13:09:27 -0500 From: Stefan Weil Date: Wed, 23 Feb 2011 19:09:16 +0100 Message-Id: <1298484556-5517-1-git-send-email-weil@mail.berlios.de> Subject: [Qemu-devel] [PATCH] Fix conversions from pointer to int and vice versa List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org 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 --- cpus.c | 8 ++++---- migration-tcp.c | 4 ++-- migration-unix.c | 4 ++-- qemu-char.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index 0f33945..3c4e1b8 100644 --- a/cpus.c +++ b/cpus.c @@ -267,7 +267,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]; @@ -295,7 +295,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; @@ -316,7 +316,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; @@ -358,7 +358,7 @@ static int qemu_signalfd_init(sigset_t mask) fcntl_setfl(sigfd, O_NONBLOCK); qemu_set_fd_handler2(sigfd, NULL, sigfd_handler, NULL, - (void *)(unsigned long) sigfd); + (void *)(intptr_t)sigfd); return 0; } diff --git a/migration-tcp.c b/migration-tcp.c index b55f419..e8dff9d 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -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; diff --git a/migration-unix.c b/migration-unix.c index 57232c0..8b967f2 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -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; diff --git a/qemu-char.c b/qemu-char.c index bd4e944..cad35d7 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -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; -- 1.7.2.3