From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXRzo-0003Gs-27 for qemu-devel@nongnu.org; Mon, 16 Mar 2015 06:11:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXRzh-0005gI-R4 for qemu-devel@nongnu.org; Mon, 16 Mar 2015 06:11:40 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:37034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXRzh-0005g3-5i for qemu-devel@nongnu.org; Mon, 16 Mar 2015 06:11:33 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Mar 2015 15:41:31 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 7812F3940053 for ; Mon, 16 Mar 2015 15:41:27 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay02.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2GAB3Yt26149074 for ; Mon, 16 Mar 2015 15:41:04 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2GAB2J7024593 for ; Mon, 16 Mar 2015 15:41:03 +0530 From: "Aneesh Kumar K.V" Date: Mon, 16 Mar 2015 15:39:39 +0530 Message-Id: <1426500583-15712-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> In-Reply-To: <1426500583-15712-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1426500583-15712-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/6] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws, peter.maydell@linaro.org Cc: Michael Tokarev , qemu-devel@nongnu.org, "Aneesh Kumar K.V" From: Michael Tokarev 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 Signed-off-by: Aneesh Kumar K.V --- 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