qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: anthony@codemonkey.ws, peter.maydell@linaro.org
Cc: Michael Tokarev <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 2/6] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv
Date: Mon, 16 Mar 2015 15:39:39 +0530	[thread overview]
Message-ID: <1426500583-15712-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1426500583-15712-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

From: Michael Tokarev <mjt@tls.msk.ru>

Don't compare syscall return with -1, use "<0" condition.
Don't introduce useless local variables when we already
have similar variable
Rename local variable to be consistent with other usages
Finally make the two methods, read and write, to be similar to each other

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 hw/9pfs/virtio-9p-proxy.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 59c7445deab9..6bb191ee6ab8 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -693,16 +693,16 @@ static ssize_t proxy_preadv(FsContext *ctx, V9fsFidOpenState *fs,
                             const struct iovec *iov,
                             int iovcnt, off_t offset)
 {
+    ssize_t ret;
 #ifdef CONFIG_PREADV
-    return preadv(fs->fd, iov, iovcnt, offset);
+    ret = preadv(fs->fd, iov, iovcnt, offset);
 #else
-    int err = lseek(fs->fd, offset, SEEK_SET);
-    if (err == -1) {
-        return err;
-    } else {
-        return readv(fs->fd, iov, iovcnt);
+    ret = lseek(fs->fd, offset, SEEK_SET);
+    if (ret >= 0) {
+        ret = readv(fs->fd, iov, iovcnt);
     }
 #endif
+    return ret;
 }
 
 static ssize_t proxy_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
@@ -714,10 +714,8 @@ static ssize_t proxy_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
 #ifdef CONFIG_PREADV
     ret = pwritev(fs->fd, iov, iovcnt, offset);
 #else
-    int err = lseek(fs->fd, offset, SEEK_SET);
-    if (err == -1) {
-        return err;
-    } else {
+    ret = lseek(fs->fd, offset, SEEK_SET);
+    if (ret >= 0) {
         ret = writev(fs->fd, iov, iovcnt);
     }
 #endif
-- 
2.1.0

  parent reply	other threads:[~2015-03-16 10:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 10:09 [Qemu-devel] [PULL] VirtFS update Aneesh Kumar K.V
2015-03-16 10:09 ` [Qemu-devel] [PATCH 1/6] 9pfs-local: simplify/optimize local_mapped_attr_path() Aneesh Kumar K.V
2015-03-16 10:09 ` Aneesh Kumar K.V [this message]
2015-03-16 10:09 ` [Qemu-devel] [PATCH 3/6] hw/9pfs/virtio-9p-posix-acl: Fix out-of-bounds access Aneesh Kumar K.V
2015-03-16 10:09 ` [Qemu-devel] [PATCH 4/6] fsdev/virtfs-proxy-helper: Fix improper use of negative value Aneesh Kumar K.V
2015-03-16 10:09 ` [Qemu-devel] [PATCH 5/6] virtfs-proxy: Fix possible overflow Aneesh Kumar K.V
2015-03-16 10:09 ` [Qemu-devel] [PATCH 6/6] virtio: Fix memory leaks reported by Coverity Aneesh Kumar K.V
2015-03-16 13:55 ` [Qemu-devel] [PULL] VirtFS update Peter Maydell

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=1426500583-15712-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=mjt@tls.msk.ru \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).