osdep: remove use of socket_error() from all code

Now that QEMU wraps the Win32 sockets methods to automatically
set errno upon failure, there is no reason for callers to use
the socket_error() method. They can rely on accessing errno
even on Win32. Remove all use of socket_error() from general
code, leaving it as a static method in oslib-win32.c only.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2016-03-07 20:36:03 +00:00
parent a2d96af4bb
commit b16a44e13e
11 changed files with 46 additions and 63 deletions

View file

@ -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;
}