From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] 9pfs-proxy: simplify v9fs_request(), P1
Date: Sun, 08 Mar 2015 22:09:24 +0530 [thread overview]
Message-ID: <87385f4f5v.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1425633831-3101-2-git-send-email-mjt@msgid.tls.msk.ru>
Michael Tokarev <mjt@tls.msk.ru> 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 <mjt@tls.msk.ru>
> ---
> 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
next prev parent reply other threads:[~2015-03-08 16:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1425633831-3101-1-git-send-email-mjt@tls.msk.ru>
2015-03-06 9:23 ` [Qemu-devel] [PATCH 1/5] 9pfs-proxy: simplify v9fs_request(), P1 Michael Tokarev
2015-03-08 16:39 ` Aneesh Kumar K.V [this message]
2015-03-10 4:19 ` Michael Tokarev
2015-03-10 4:51 ` Michael Tokarev
2015-03-10 17:31 ` Aneesh Kumar K.V
2015-03-06 9:23 ` [Qemu-devel] [PATCH 2/5] 9pfs-proxy: simplify v9fs_request(), P2 Michael Tokarev
2015-03-06 9:23 ` [Qemu-devel] [PATCH 3/5] 9pfs-proxy: simplify error handling Michael Tokarev
2015-03-06 9:23 ` [Qemu-devel] [PATCH 4/5] 9pfs-proxy: rename a few local variables for consistency Michael Tokarev
2015-03-06 9:23 ` [Qemu-devel] [PATCH 5/5] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87385f4f5v.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.