dcavalca / rpms / qemu

Forked from rpms/qemu 11 months ago
Clone

Blame 0226-net-socket-Fix-compiler-warning-regression-for-MinGW.patch

5544c1
From 96f47b0d2c307173e0a545ea230e21f1ce8d3fa2 Mon Sep 17 00:00:00 2001
5544c1
From: Stefan Weil <sw@weilnetz.de>
5544c1
Date: Sat, 22 Sep 2012 21:13:28 +0200
5544c1
Subject: [PATCH] net/socket: Fix compiler warning (regression for MinGW)
5544c1
MIME-Version: 1.0
5544c1
Content-Type: text/plain; charset=UTF-8
5544c1
Content-Transfer-Encoding: 8bit
5544c1
5544c1
Commit 213fd5087e2e4e2da10ad266df0ba950cf7618bf removed a type cast
5544c1
which is needed for MinGW:
5544c1
5544c1
net/socket.c:136: warning:
5544c1
 pointer targets in passing argument 2 of ‘sendto’ differ in signedness
5544c1
/usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note:
5544c1
 expected ‘const char *’ but argument is of type ‘const uint8_t *’
5544c1
5544c1
Add a 'qemu_sendto' macro which provides that type cast where needed
5544c1
and use the new macro instead of 'sendto'.
5544c1
5544c1
Signed-off-by: Stefan Weil <sw@weilnetz.de>
5544c1
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
5544c1
(cherry picked from commit 73062dfe6be0050dbd43ce3516e935ebb2545add)
5544c1
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 net/socket.c  | 6 +++---
5544c1
 qemu-common.h | 5 +++++
5544c1
 2 files changed, 8 insertions(+), 3 deletions(-)
5544c1
5544c1
diff --git a/net/socket.c b/net/socket.c
5544c1
index c3e55b8..83f21b5 100644
5544c1
--- a/net/socket.c
5544c1
+++ b/net/socket.c
5544c1
@@ -131,9 +131,9 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf,
5544c1
     ssize_t ret;
5544c1
 
5544c1
     do {
5544c1
-        ret = sendto(s->fd, buf, size, 0,
5544c1
-                     (struct sockaddr *)&s->dgram_dst,
5544c1
-                     sizeof(s->dgram_dst));
5544c1
+        ret = qemu_sendto(s->fd, buf, size, 0,
5544c1
+                          (struct sockaddr *)&s->dgram_dst,
5544c1
+                          sizeof(s->dgram_dst));
5544c1
     } while (ret == -1 && errno == EINTR);
5544c1
 
5544c1
     if (ret == -1 && errno == EAGAIN) {
5544c1
diff --git a/qemu-common.h b/qemu-common.h
5544c1
index e5c2bcd..15d9e4e 100644
5544c1
--- a/qemu-common.h
5544c1
+++ b/qemu-common.h
5544c1
@@ -223,9 +223,14 @@ int qemu_pipe(int pipefd[2]);
5544c1
 #endif
5544c1
 
5544c1
 #ifdef _WIN32
5544c1
+/* MinGW needs a type cast for the 'buf' argument. */
5544c1
 #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
5544c1
+#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
5544c1
+    sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
5544c1
 #else
5544c1
 #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
5544c1
+#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
5544c1
+    sendto(sockfd, buf, len, flags, destaddr, addrlen)
5544c1
 #endif
5544c1
 
5544c1
 /* Error handling.  */
5544c1
-- 
5544c1
1.7.12.1
5544c1