From patchwork Tue Mar 10 05:54:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 448347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1FF0A140083 for ; Tue, 10 Mar 2015 16:54:49 +1100 (AEDT) Received: from localhost ([::1]:46615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVD7u-0008KV-Op for incoming@patchwork.ozlabs.org; Tue, 10 Mar 2015 01:54:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVD7d-000801-Mx for qemu-devel@nongnu.org; Tue, 10 Mar 2015 01:54:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVD7Y-0002C4-QA for qemu-devel@nongnu.org; Tue, 10 Mar 2015 01:54:29 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:35594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVD7Y-0002Bu-JU; Tue, 10 Mar 2015 01:54:24 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 7C88841302; Tue, 10 Mar 2015 08:54:23 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 69A44722; Tue, 10 Mar 2015 08:54:23 +0300 (MSK) Received: (nullmailer pid 13645 invoked by uid 1000); Tue, 10 Mar 2015 05:54:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Tue, 10 Mar 2015 08:54:20 +0300 Message-Id: <1425966860-13605-1-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Michael Tokarev , "Aneesh Kumar K.V" Subject: [Qemu-devel] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Michael Tokarev --- hw/9pfs/virtio-9p-proxy.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c index 59c7445..a01804a 100644 --- a/hw/9pfs/virtio-9p-proxy.c +++ b/hw/9pfs/virtio-9p-proxy.c @@ -696,9 +696,9 @@ static ssize_t proxy_preadv(FsContext *ctx, V9fsFidOpenState *fs, #ifdef CONFIG_PREADV return preadv(fs->fd, iov, iovcnt, offset); #else - int err = lseek(fs->fd, offset, SEEK_SET); - if (err == -1) { - return err; + int ret = lseek(fs->fd, offset, SEEK_SET); + if (err < 0) + return ret; } else { return readv(fs->fd, iov, iovcnt); } @@ -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