aboutsummaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2016-03-07 20:36:03 +0000
committerDaniel P. Berrange <berrange@redhat.com>2016-03-10 17:19:34 +0000
commitb16a44e13e89ee397a3d9a9e3cfa1605c3c1dc68 (patch)
tree894551b8e7841e2fddfd790c204b7ef453d6f2eb /io
parenta2d96af4bb267bd1844f71f593d07273c7fc134c (diff)
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>
Diffstat (limited to 'io')
-rw-r--r--io/channel-socket.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/io/channel-socket.c b/io/channel-socket.c
index ae67ab18f5..d005070584 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -82,11 +82,11 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc,
if (getpeername(fd, (struct sockaddr *)&sioc->remoteAddr,
&sioc->remoteAddrLen) < 0) {
- if (socket_error() == ENOTCONN) {
+ if (errno == ENOTCONN) {
memset(&sioc->remoteAddr, 0, sizeof(sioc->remoteAddr));
sioc->remoteAddrLen = sizeof(sioc->remoteAddr);
} else {
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to query remote socket address");
goto error;
}
@@ -94,7 +94,7 @@ qio_channel_socket_set_fd(QIOChannelSocket *sioc,
if (getsockname(fd, (struct sockaddr *)&sioc->localAddr,
&sioc->localAddrLen) < 0) {
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to query local socket address");
goto error;
}
@@ -356,7 +356,7 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
&cioc->remoteAddrLen);
if (cioc->fd < 0) {
trace_qio_channel_socket_accept_fail(ioc);
- if (socket_error() == EINTR) {
+ if (errno == EINTR) {
goto retry;
}
goto error;
@@ -364,7 +364,7 @@ qio_channel_socket_accept(QIOChannelSocket *ioc,
if (getsockname(cioc->fd, (struct sockaddr *)&cioc->localAddr,
&cioc->localAddrLen) < 0) {
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to query local socket address");
goto error;
}
@@ -478,14 +478,14 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
retry:
ret = recvmsg(sioc->fd, &msg, sflags);
if (ret < 0) {
- if (socket_error() == EAGAIN) {
+ if (errno == EAGAIN) {
return QIO_CHANNEL_ERR_BLOCK;
}
- if (socket_error() == EINTR) {
+ if (errno == EINTR) {
goto retry;
}
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to read from socket");
return -1;
}
@@ -537,13 +537,13 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
retry:
ret = sendmsg(sioc->fd, &msg, 0);
if (ret <= 0) {
- if (socket_error() == EAGAIN) {
+ if (errno == EAGAIN) {
return QIO_CHANNEL_ERR_BLOCK;
}
- if (socket_error() == EINTR) {
+ if (errno == EINTR) {
goto retry;
}
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to write to socket");
return -1;
}
@@ -569,16 +569,16 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc,
iov[i].iov_len,
0);
if (ret < 0) {
- if (socket_error() == EAGAIN) {
+ if (errno == EAGAIN) {
if (done) {
return done;
} else {
return QIO_CHANNEL_ERR_BLOCK;
}
- } else if (socket_error() == EINTR) {
+ } else if (errno == EINTR) {
goto retry;
} else {
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to read from socket");
return -1;
}
@@ -611,16 +611,16 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
iov[i].iov_len,
0);
if (ret < 0) {
- if (socket_error() == EAGAIN) {
+ if (errno == EAGAIN) {
if (done) {
return done;
} else {
return QIO_CHANNEL_ERR_BLOCK;
}
- } else if (socket_error() == EINTR) {
+ } else if (errno == EINTR) {
goto retry;
} else {
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to write to socket");
return -1;
}
@@ -692,7 +692,7 @@ qio_channel_socket_close(QIOChannel *ioc,
#endif
if (closesocket(sioc->fd) < 0) {
sioc->fd = -1;
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to close socket");
return -1;
}
@@ -723,7 +723,7 @@ qio_channel_socket_shutdown(QIOChannel *ioc,
}
if (shutdown(sioc->fd, sockhow) < 0) {
- error_setg_errno(errp, socket_error(),
+ error_setg_errno(errp, errno,
"Unable to shutdown socket");
return -1;
}