diff options
author | Michael Tokarev <mjt@tls.msk.ru> | 2015-03-12 09:36:12 +0300 |
---|---|---|
committer | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2015-03-12 15:27:35 +0530 |
commit | 7752efcacf41daf34f9fefc5e78131f2afa3d4d7 (patch) | |
tree | 84dac466d97c826c1257d035303edb086636d7c1 /hw/9pfs/virtio-9p-proxy.c | |
parent | 1b6f85e2cb9302a8587772d04983a3ecc0ecfe68 (diff) | |
download | qemu-7752efcacf41daf34f9fefc5e78131f2afa3d4d7.tar.gz qemu-7752efcacf41daf34f9fefc5e78131f2afa3d4d7.tar.bz2 qemu-7752efcacf41daf34f9fefc5e78131f2afa3d4d7.zip |
9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv
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>
Diffstat (limited to 'hw/9pfs/virtio-9p-proxy.c')
-rw-r--r-- | hw/9pfs/virtio-9p-proxy.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c index 59c7445dea..6bb191ee6a 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 |