Wrap recv to avoid warnings

Avoid warnings like these by wrapping recv():
  CC    slirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *'

Remove also casts used to avoid warnings.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Blue Swirl 2011-07-23 20:04:29 +00:00
parent aad04cd024
commit 00aa0040e8
13 changed files with 21 additions and 15 deletions

View File

@ -496,7 +496,7 @@ static ssize_t recvmsg(int s, struct msghdr *msg, int flags)
}
buf = qemu_malloc(size);
ret = recv(s, buf, size, flags);
ret = qemu_recv(s, buf, size, flags);
if (ret < 0) {
goto out;
}

View File

@ -319,7 +319,7 @@ static int get_char(GDBState *s)
int ret;
for(;;) {
ret = recv(s->fd, &ch, 1, 0);
ret = qemu_recv(s->fd, &ch, 1, 0);
if (ret < 0) {
if (errno == ECONNRESET)
s->fd = -1;

View File

@ -2004,7 +2004,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
ret = get_errno(recvfrom(fd, host_msg, len, flags, addr, &addrlen));
} else {
addr = NULL; /* To keep compiler quiet. */
ret = get_errno(recv(fd, host_msg, len, flags));
ret = get_errno(qemu_recv(fd, host_msg, len, flags));
}
if (!is_error(ret)) {
if (target_addr) {

2
nbd.c
View File

@ -78,7 +78,7 @@ size_t nbd_wr_sync(int fd, void *buffer, size_t size, bool do_read)
ssize_t len;
if (do_read) {
len = recv(fd, buffer + offset, size - offset, 0);
len = qemu_recv(fd, buffer + offset, size - offset, 0);
} else {
len = send(fd, buffer + offset, size - offset, 0);
}

View File

@ -76,7 +76,7 @@ static void net_socket_send(void *opaque)
uint8_t buf1[4096];
const uint8_t *buf;
size = recv(s->fd, (void *)buf1, sizeof(buf1), 0);
size = qemu_recv(s->fd, buf1, sizeof(buf1), 0);
if (size < 0) {
err = socket_error();
if (err != EWOULDBLOCK)
@ -138,7 +138,7 @@ static void net_socket_send_dgram(void *opaque)
NetSocketState *s = opaque;
int size;
size = recv(s->fd, (void *)s->buf, sizeof(s->buf), 0);
size = qemu_recv(s->fd, s->buf, sizeof(s->buf), 0);
if (size < 0)
return;
if (size == 0) {

View File

@ -1860,7 +1860,7 @@ static void udp_chr_read(void *opaque)
if (s->max_size == 0)
return;
s->bufcnt = recv(s->fd, (void *)s->buf, sizeof(s->buf), 0);
s->bufcnt = qemu_recv(s->fd, s->buf, sizeof(s->buf), 0);
s->bufptr = s->bufcnt;
if (s->bufcnt <= 0)
return;
@ -2078,7 +2078,7 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
{
TCPCharDriver *s = chr->opaque;
return recv(s->fd, buf, len, 0);
return qemu_recv(s->fd, buf, len, 0);
}
#endif

View File

@ -200,6 +200,12 @@ int qemu_eventfd(int pipefd[2]);
int qemu_pipe(int pipefd[2]);
#endif
#ifdef _WIN32
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
#else
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
#endif
/* Error handling. */
void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);

View File

@ -194,7 +194,7 @@ static int socket_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
ssize_t len;
do {
len = recv(s->fd, (void *)buf, size, 0);
len = qemu_recv(s->fd, buf, size, 0);
} while (len == -1 && socket_error() == EINTR);
if (len == -1)

View File

@ -415,7 +415,7 @@ void icmp_receive(struct socket *so)
icp = mtod(m, struct icmp *);
id = icp->icmp_id;
len = recv(so->s, icp, m->m_len, 0);
len = qemu_recv(so->s, icp, m->m_len, 0);
icp->icmp_id = id;
m->m_data -= hlen;

View File

@ -522,7 +522,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
*/
#ifdef PROBE_CONN
if (so->so_state & SS_ISFCONNECTING) {
ret = recv(so->s, (char *)&ret, 0,0);
ret = qemu_recv(so->s, &ret, 0,0);
if (ret < 0) {
/* XXX */

View File

@ -166,7 +166,7 @@ soread(struct socket *so)
nn = readv(so->s, (struct iovec *)iov, n);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#else
nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
nn = qemu_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
#endif
if (nn <= 0) {
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
@ -191,7 +191,7 @@ soread(struct socket *so)
*/
if (n == 2 && nn == iov[0].iov_len) {
int ret;
ret = recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
ret = qemu_recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
if (ret > 0)
nn += ret;
}

View File

@ -89,7 +89,7 @@ static ssize_t vnc_tls_pull(gnutls_transport_ptr_t transport,
int ret;
retry:
ret = recv(vs->csock, data, len, 0);
ret = qemu_recv(vs->csock, data, len, 0);
if (ret < 0) {
if (errno == EINTR)
goto retry;

View File

@ -1199,7 +1199,7 @@ long vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
}
} else
#endif /* CONFIG_VNC_TLS */
ret = recv(vs->csock, (void *)data, datalen, 0);
ret = qemu_recv(vs->csock, data, datalen, 0);
VNC_DEBUG("Read wire %p %zd -> %ld\n", data, datalen, ret);
return vnc_client_io_error(vs, ret, socket_error());
}