@@ -299,7 +299,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
dev_t rdev;
va_list ap;
int size = 0;
- int retval = 0;
+ int retval = 0, err;
uint64_t offset;
ProxyHeader header = { 0, 0};
struct timespec spec[2];
@@ -310,10 +310,11 @@ static int v9fs_request(V9fsProxy *proxy, int type,
qemu_mutex_lock(&proxy->mutex);
- if (proxy->sockfd == -1) {
+ if (proxy->sockfd < 0) {
retval = -EIO;
- goto err_out;
+ goto out;
}
+
iovec = &proxy->out_iovec;
reply = &proxy->in_iovec;
va_start(ap, fmt);
@@ -529,15 +530,15 @@ static int v9fs_request(V9fsProxy *proxy, int type,
va_end(ap);
if (retval < 0) {
- goto err_out;
+ goto out;
}
/* marshal the header details */
proxy_marshal(iovec, 0, "dd", header.type, header.size);
header.size += PROXY_HDR_SZ;
- retval = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
- if (retval != header.size) {
+ err = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
+ if (err != header.size) {
goto close_error;
}
@@ -548,9 +549,7 @@ static int v9fs_request(V9fsProxy *proxy, int type,
* A file descriptor is returned as response for
* T_OPEN,T_CREATE on success
*/
- if (v9fs_receivefd(proxy->sockfd, &retval) < 0) {
- goto close_error;
- }
+ err = v9fs_receivefd(proxy->sockfd, &retval);
break;
case T_MKNOD:
case T_MKDIR:
@@ -564,41 +563,34 @@ static int v9fs_request(V9fsProxy *proxy, int type,
case T_REMOVE:
case T_LSETXATTR:
case T_LREMOVEXATTR:
- if (v9fs_receive_status(proxy, reply, &retval) < 0) {
- goto close_error;
- }
+ err = v9fs_receive_status(proxy, reply, &retval);
break;
case T_LSTAT:
case T_READLINK:
case T_STATFS:
case T_GETVERSION:
- if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
- goto close_error;
- }
+ err = v9fs_receive_response(proxy, type, &retval, response);
break;
case T_LGETXATTR:
case T_LLISTXATTR:
if (!size) {
- if (v9fs_receive_status(proxy, reply, &retval) < 0) {
- goto close_error;
- }
+ err = v9fs_receive_status(proxy, reply, &retval);
} else {
- if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
- goto close_error;
- }
+ err = v9fs_receive_response(proxy, type, &retval, response);
}
break;
}
-err_out:
- qemu_mutex_unlock(&proxy->mutex);
- return retval;
-
+ if (err < 0) {
close_error:
- close(proxy->sockfd);
- proxy->sockfd = -1;
+ close(proxy->sockfd);
+ proxy->sockfd = -1;
+ retval = -EIO;
+ }
+
+out:
qemu_mutex_unlock(&proxy->mutex);
- return -EIO;
+ return retval;
}
static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)