All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gonglei <arei.gonglei@huawei.com>
To: Michael Tokarev <mjt@tls.msk.ru>, <qemu-devel@nongnu.org>
Cc: qemu-trivial@nongnu.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv
Date: Tue, 10 Mar 2015 15:15:34 +0800	[thread overview]
Message-ID: <54FE9A16.7000108@huawei.com> (raw)
In-Reply-To: <1425966860-13605-1-git-send-email-mjt@msgid.tls.msk.ru>

On 2015/3/10 13:54, Michael Tokarev wrote:
> 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 <mjt@tls.msk.ru>
> ---
>  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;

The above code fragment is confused.

Regards,
-Gonglei
>      } 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
> 




WARNING: multiple messages have this Message-ID (diff)
From: Gonglei <arei.gonglei@huawei.com>
To: Michael Tokarev <mjt@tls.msk.ru>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv
Date: Tue, 10 Mar 2015 15:15:34 +0800	[thread overview]
Message-ID: <54FE9A16.7000108@huawei.com> (raw)
In-Reply-To: <1425966860-13605-1-git-send-email-mjt@msgid.tls.msk.ru>

On 2015/3/10 13:54, Michael Tokarev wrote:
> 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 <mjt@tls.msk.ru>
> ---
>  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;

The above code fragment is confused.

Regards,
-Gonglei
>      } 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
> 

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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10  5:54 [Qemu-trivial] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv Michael Tokarev
2015-03-10  5:54 ` [Qemu-devel] " Michael Tokarev
2015-03-10  7:15 ` Gonglei [this message]
2015-03-10  7:15   ` Gonglei
2015-03-10  7:20   ` [Qemu-trivial] " Michael Tokarev
2015-03-10  7:20     ` Michael Tokarev
2015-03-10  7:27     ` [Qemu-trivial] " Gonglei
2015-03-10  7:27       ` Gonglei
2015-03-10 17:23 ` [Qemu-trivial] " Aneesh Kumar K.V
2015-03-10 17:23   ` [Qemu-devel] " Aneesh Kumar K.V
2015-03-12  6:30   ` [Qemu-trivial] " Michael Tokarev
2015-03-12  6:30     ` [Qemu-devel] " 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=54FE9A16.7000108@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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.