From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YUeFl-00038r-Bq for qemu-devel@nongnu.org; Sun, 08 Mar 2015 12:40:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YUeFi-0003et-4H for qemu-devel@nongnu.org; Sun, 08 Mar 2015 12:40:33 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:52038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YUeFh-0003bv-CO for qemu-devel@nongnu.org; Sun, 08 Mar 2015 12:40:30 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Mar 2015 02:40:22 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 110222CE8050 for ; Mon, 9 Mar 2015 03:40:19 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t28Ge93T35651620 for ; Mon, 9 Mar 2015 03:40:19 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t28Gdiaa004485 for ; Mon, 9 Mar 2015 03:39:44 +1100 From: "Aneesh Kumar K.V" In-Reply-To: <1425633831-3101-2-git-send-email-mjt@msgid.tls.msk.ru> References: <1425633831-3101-1-git-send-email-mjt@tls.msk.ru> <1425633831-3101-2-git-send-email-mjt@msgid.tls.msk.ru> Date: Sun, 08 Mar 2015 22:09:24 +0530 Message-ID: <87385f4f5v.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/5] 9pfs-proxy: simplify v9fs_request(), P1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: qemu-devel@nongnu.org Michael Tokarev writes: > This simplifies code in v9fs_request() a bit by replacing several > ifs with a common variable check and rearranging error/cleanup > code a bit. Is this -V2 of http://mid.gmane.org/b98f675750ef0535cab41225240db1657fc2fe00.1425678142.git.mjt@msgid.tls.msk.ru I am slightly confused with the patch series. It does split the patch as I wanted, but i am not sure which one is the latest, so that i can start applying them. > > Signet-off-by: Michael Tokarev > --- > hw/9pfs/virtio-9p-proxy.c | 48 ++++++++++++++++++++--------------------------- > 1 file changed, 20 insertions(+), 28 deletions(-) > > diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c > index 59c7445..f252fe4 100644 > --- a/hw/9pfs/virtio-9p-proxy.c > +++ b/hw/9pfs/virtio-9p-proxy.c > @@ -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) > -- > 2.1.4