MinGW: Replace setsockopt by qemu_setsocketopt
Instead of adding missing type casts which are needed by MinGW for the
4th argument, the patch uses qemu_setsockopt which was invented for this
purpose.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
diff --git a/misc.c b/misc.c
index a2abe2d..10c233f 100644
--- a/misc.c
+++ b/misc.c
@@ -207,9 +207,9 @@
} while (so->s < 0 && errno == EINTR);
closesocket(s);
opt = 1;
- setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
+ qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
opt = 1;
- setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
+ qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
socket_set_nonblock(so->s);
/* Append the telnet options now */
diff --git a/socket.c b/socket.c
index 8786c6f..b7e9e49 100644
--- a/socket.c
+++ b/socket.c
@@ -633,8 +633,7 @@
addr.sin_port = hport;
if (((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0) ||
- (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int)) <
- 0) ||
+ (qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)) < 0) ||
(bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) ||
(listen(s, 1) < 0)) {
int tmperrno = errno; /* Don't clobber the real reason we failed */
@@ -649,7 +648,7 @@
#endif
return NULL;
}
- setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
+ qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
getsockname(s, (struct sockaddr *)&addr, &addrlen);
so->so_fport = addr.sin_port;
diff --git a/tcp_subr.c b/tcp_subr.c
index 9c93612..6881f1f 100644
--- a/tcp_subr.c
+++ b/tcp_subr.c
@@ -336,9 +336,9 @@
socket_set_nonblock(s);
opt = 1;
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));
+ qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
opt = 1;
- setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(opt));
+ qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
addr.sin_family = AF_INET;
if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==
@@ -426,9 +426,9 @@
}
socket_set_nonblock(s);
opt = 1;
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
+ qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
opt = 1;
- setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
+ qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
socket_set_nodelay(s);
so->so_fport = addr.sin_port;
diff --git a/udp.c b/udp.c
index 8206e02..dfc314a 100644
--- a/udp.c
+++ b/udp.c
@@ -362,7 +362,7 @@
udp_detach(so);
return NULL;
}
- setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
+ qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
getsockname(so->s, (struct sockaddr *)&addr, &addrlen);
so->so_fport = addr.sin_port;