aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/oslib-win32.c2
-rw-r--r--util/qemu-coroutine-io.c6
-rw-r--r--util/qemu-sockets.c10
3 files changed, 8 insertions, 10 deletions
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index a6256de0fc..a3f0664763 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -145,7 +145,7 @@ int socket_set_fast_reuse(int fd)
}
-int socket_error(void)
+static int socket_error(void)
{
switch (WSAGetLastError()) {
case 0:
diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
index 0d5041c1c3..91b9357d4a 100644
--- a/util/qemu-coroutine-io.c
+++ b/util/qemu-coroutine-io.c
@@ -35,18 +35,16 @@ qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
{
size_t done = 0;
ssize_t ret;
- int err;
while (done < bytes) {
ret = iov_send_recv(sockfd, iov, iov_cnt,
offset + done, bytes - done, do_send);
if (ret > 0) {
done += ret;
} else if (ret < 0) {
- err = socket_error();
- if (err == EAGAIN || err == EWOULDBLOCK) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
qemu_coroutine_yield();
} else if (done == 0) {
- return -err;
+ return -errno;
} else {
break;
}
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index ad7c00c9ad..fd37ac209b 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -268,7 +268,7 @@ static void wait_for_connect(void *opaque)
do {
rc = qemu_getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &val, &valsize);
- } while (rc == -1 && socket_error() == EINTR);
+ } while (rc == -1 && errno == EINTR);
/* update rc to contain error */
if (!rc && val) {
@@ -330,7 +330,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress,
do {
rc = 0;
if (connect(sock, addr->ai_addr, addr->ai_addrlen) < 0) {
- rc = -socket_error();
+ rc = -errno;
}
} while (rc == -EINTR);
@@ -787,7 +787,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp,
do {
rc = 0;
if (connect(sock, (struct sockaddr *) &un, sizeof(un)) < 0) {
- rc = -socket_error();
+ rc = -errno;
}
} while (rc == -EINTR);
@@ -1082,7 +1082,7 @@ SocketAddress *socket_local_address(int fd, Error **errp)
socklen_t sslen = sizeof(ss);
if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0) {
- error_setg_errno(errp, socket_error(), "%s",
+ error_setg_errno(errp, errno, "%s",
"Unable to query local socket address");
return NULL;
}
@@ -1097,7 +1097,7 @@ SocketAddress *socket_remote_address(int fd, Error **errp)
socklen_t sslen = sizeof(ss);
if (getpeername(fd, (struct sockaddr *)&ss, &sslen) < 0) {
- error_setg_errno(errp, socket_error(), "%s",
+ error_setg_errno(errp, errno, "%s",
"Unable to query remote socket address");
return NULL;
}