qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev an


From: Aneesh Kumar K.V
Subject: Re: [Qemu-trivial] [PATCH] 9pfs-proxy: tiny cleanups in proxy_pwritev and proxy_preadv
Date: Tue, 10 Mar 2015 22:53:46 +0530
User-agent: Notmuch/0.19+30~gd241a48 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu)

Michael Tokarev <address@hidden> writes:

> 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 <address@hidden>
> ---
>  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);
>      }

I am not sure this is needed, whether to use int err or int ret as the
variable name is simply a matter of preference for the author. Also did
you compile test the above ? (note: int ret followed by a check with
variable name 'err').


> @@ -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

-aneesh




reply via email to

[Prev in Thread] Current Thread [Next in Thread]