Drop qemu_foo() socket API wrapper

The socket API wrappers were initially introduced in commit
00aa0040 ("Wrap recv to avoid warnings"), but made redundant with
commit a2d96af4 ("osdep: add wrappers for socket functions") which fixes
the win32 declarations and thus removed the earlier warnings.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
Marc-André Lureau 2022-02-19 01:34:50 +04:00
parent 8ef2513d87
commit e7b7942822
15 changed files with 45 additions and 64 deletions

View File

@ -84,8 +84,8 @@ qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgorithm alg,
g_free(name);
/* setkey */
if (qemu_setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY, key,
nkey) != 0) {
if (setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY, key,
nkey) != 0) {
error_setg_errno(errp, errno, "Set key failed");
qcrypto_afalg_comm_free(afalg);
return NULL;

View File

@ -88,8 +88,8 @@ qcrypto_afalg_hash_hmac_ctx_new(QCryptoHashAlgorithm alg,
/* HMAC needs setkey */
if (is_hmac) {
if (qemu_setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY,
key, nkey) != 0) {
if (setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY,
key, nkey) != 0) {
error_setg_errno(errp, errno, "Set hmac key failed");
qcrypto_afalg_comm_free(afalg);
return NULL;

View File

@ -426,7 +426,7 @@ static int get_char(void)
int ret;
for(;;) {
ret = qemu_recv(gdbserver_state.fd, &ch, 1, 0);
ret = recv(gdbserver_state.fd, &ch, 1, 0);
if (ret < 0) {
if (errno == ECONNRESET)
gdbserver_state.fd = -1;

View File

@ -35,25 +35,6 @@ int qemu_pipe(int pipefd[2]);
int qemu_openpty_raw(int *aslave, char *pty_name);
#endif
#ifdef _WIN32
/* MinGW needs type casts for the 'buf' and 'optval' arguments. */
#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
getsockopt(sockfd, level, optname, (void *)optval, optlen)
#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
setsockopt(sockfd, level, optname, (const void *)optval, optlen)
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
#else
#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
getsockopt(sockfd, level, optname, optval, optlen)
#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
setsockopt(sockfd, level, optname, optval, optlen)
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
sendto(sockfd, buf, len, flags, destaddr, addrlen)
#endif
void cpu_exec_init_all(void);
void cpu_exec_step_atomic(CPUState *cpu);

View File

@ -681,9 +681,9 @@ qio_channel_socket_set_delay(QIOChannel *ioc,
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
int v = enabled ? 0 : 1;
qemu_setsockopt(sioc->fd,
IPPROTO_TCP, TCP_NODELAY,
&v, sizeof(v));
setsockopt(sioc->fd,
IPPROTO_TCP, TCP_NODELAY,
&v, sizeof(v));
}

View File

@ -120,9 +120,9 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf,
do {
if (s->dgram_dst.sin_family != AF_UNIX) {
ret = qemu_sendto(s->fd, buf, size, 0,
(struct sockaddr *)&s->dgram_dst,
sizeof(s->dgram_dst));
ret = sendto(s->fd, buf, size, 0,
(struct sockaddr *)&s->dgram_dst,
sizeof(s->dgram_dst));
} else {
ret = send(s->fd, buf, size, 0);
}
@ -163,7 +163,7 @@ static void net_socket_send(void *opaque)
uint8_t buf1[NET_BUFSIZE];
const uint8_t *buf;
size = qemu_recv(s->fd, buf1, sizeof(buf1), 0);
size = recv(s->fd, buf1, sizeof(buf1), 0);
if (size < 0) {
if (errno != EWOULDBLOCK)
goto eoc;
@ -198,7 +198,7 @@ static void net_socket_send_dgram(void *opaque)
NetSocketState *s = opaque;
int size;
size = qemu_recv(s->fd, s->rs.buf, sizeof(s->rs.buf), 0);
size = recv(s->fd, s->rs.buf, sizeof(s->rs.buf), 0);
if (size < 0)
return;
if (size == 0) {
@ -246,7 +246,7 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
* only on posix systems.
*/
val = 1;
ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't set socket option SO_REUSEADDR");
@ -268,8 +268,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
imr.imr_interface.s_addr = htonl(INADDR_ANY);
}
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't add socket to multicast group %s",
@ -279,8 +279,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
/* Force mcast msgs to loopback (eg. several QEMUs in same host */
loop = 1;
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
&loop, sizeof(loop));
ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
&loop, sizeof(loop));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't force multicast message to loopback");
@ -289,8 +289,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
/* If a bind address is given, only send packets from that address */
if (localaddr != NULL) {
ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
localaddr, sizeof(*localaddr));
ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
localaddr, sizeof(*localaddr));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't set the default network send interface");

View File

@ -91,9 +91,9 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a
g_assert_cmphex(le32_to_cpu(descr.upper.data) & dsta_dd, ==, dsta_dd);
/* Check data sent to the backend */
ret = qemu_recv(test_sockets[0], &recv_len, sizeof(recv_len), 0);
ret = recv(test_sockets[0], &recv_len, sizeof(recv_len), 0);
g_assert_cmpint(ret, == , sizeof(recv_len));
ret = qemu_recv(test_sockets[0], buffer, 64, 0);
ret = recv(test_sockets[0], buffer, 64, 0);
g_assert_cmpint(ret, >=, 5);
g_assert_cmpstr(buffer, == , "TEST");

View File

@ -94,8 +94,8 @@ static int socket_accept(int sock)
struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT,
.tv_usec = 0 };
if (qemu_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
(void *)&timeout, sizeof(timeout))) {
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
(void *)&timeout, sizeof(timeout))) {
fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
__func__, strerror(errno));
close(sock);

View File

@ -521,12 +521,12 @@ static void emc_send_verify1(QTestState *qts, const EMCModule *mod, int fd,
/* Check data sent to the backend. */
recv_len = ~0;
ret = qemu_recv(fd, &recv_len, sizeof(recv_len), MSG_DONTWAIT);
ret = recv(fd, &recv_len, sizeof(recv_len), MSG_DONTWAIT);
g_assert_cmpint(ret, == , sizeof(recv_len));
g_assert(wait_socket_readable(fd));
memset(buffer, 0xff, sizeof(buffer));
ret = qemu_recv(fd, buffer, test_size, MSG_DONTWAIT);
ret = recv(fd, buffer, test_size, MSG_DONTWAIT);
g_assert_cmpmem(buffer, ret, test_data, test_size);
}

View File

@ -58,13 +58,13 @@ static void test_mirror(void)
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock[0]);
ret = qemu_recv(recv_sock[0], &len, sizeof(len), 0);
ret = recv(recv_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock[0], recv_buf, len, 0);
ret = recv(recv_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);

View File

@ -115,13 +115,13 @@ static void test_redirector_tx(void)
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(backend_sock[0]);
ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
ret = recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock, recv_buf, len, 0);
ret = recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
@ -182,13 +182,13 @@ static void test_redirector_rx(void)
ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
ret = qemu_recv(backend_sock[0], &len, sizeof(len), 0);
ret = recv(backend_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(backend_sock[0], recv_buf, len, 0);
ret = recv(backend_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
close(send_sock);

View File

@ -87,11 +87,11 @@ static void tx_test(QVirtioDevice *dev,
QVIRTIO_NET_TIMEOUT_US);
guest_free(alloc, req_addr);
ret = qemu_recv(socket, &len, sizeof(len), 0);
ret = recv(socket, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
ret = qemu_recv(socket, buffer, len, 0);
ret = recv(socket, buffer, len, 0);
g_assert_cmpstr(buffer, ==, "TEST");
}
@ -202,11 +202,11 @@ static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc)
qobject_unref(rsp);
/* Catch the first packet and make sure it's a RARP */
ret = qemu_recv(sv[0], &len, sizeof(len), 0);
ret = recv(sv[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
ret = qemu_recv(sv[0], buffer, len, 0);
ret = recv(sv[0], buffer, len, 0);
g_assert_cmpint(*proto, ==, htons(ETH_P_RARP));
/*
@ -230,7 +230,7 @@ static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc)
while (true) {
int saved_err;
ret = qemu_recv(sv[0], buffer, 60, MSG_DONTWAIT);
ret = recv(sv[0], buffer, 60, MSG_DONTWAIT);
saved_err = errno;
now = g_get_monotonic_time();
g_assert_cmpint(now, <, deadline);

View File

@ -105,7 +105,7 @@ static int socket_can_bind_connect(const char *hostname, int family)
}
if (check_soerr) {
if (qemu_getsockopt(cfd, SOL_SOCKET, SO_ERROR, &soerr, &soerrlen) < 0) {
if (getsockopt(cfd, SOL_SOCKET, SO_ERROR, &soerr, &soerrlen) < 0) {
goto cleanup;
}
if (soerr) {

View File

@ -39,7 +39,7 @@ static const char *hw_version = QEMU_HW_VERSION;
int socket_set_cork(int fd, int v)
{
#if defined(SOL_TCP) && defined(TCP_CORK)
return qemu_setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v));
return setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v));
#else
return 0;
#endif
@ -48,7 +48,7 @@ int socket_set_cork(int fd, int v)
int socket_set_nodelay(int fd)
{
int v = 1;
return qemu_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
}
int qemu_madvise(void *addr, size_t len, int advice)

View File

@ -97,7 +97,7 @@ bool fd_is_socket(int fd)
{
int optval;
socklen_t optlen = sizeof(optval);
return !qemu_getsockopt(fd, SOL_SOCKET, SO_TYPE, &optval, &optlen);
return !getsockopt(fd, SOL_SOCKET, SO_TYPE, &optval, &optlen);
}
@ -185,8 +185,8 @@ static int try_bind(int socket, InetSocketAddress *saddr, struct addrinfo *e)
rebind:
if (e->ai_family == PF_INET6) {
qemu_setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY, &v6only,
sizeof(v6only));
setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY, &v6only,
sizeof(v6only));
}
stat = bind(socket, e->ai_addr, e->ai_addrlen);
@ -483,8 +483,8 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
if (saddr->keep_alive) {
int val = 1;
int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
&val, sizeof(val));
int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
&val, sizeof(val));
if (ret < 0) {
error_setg_errno(errp, errno, "Unable to set KEEPALIVE");