All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1.1 2/4] sheepdog: fix return value of do_load_save_vm_state
Date: Mon, 21 May 2012 17:51:00 +0200	[thread overview]
Message-ID: <4FBA6464.8040206@redhat.com> (raw)
In-Reply-To: <1337192134-31502-3-git-send-email-morita.kazutaka@lab.ntt.co.jp>

Am 16.05.2012 20:15, schrieb MORITA Kazutaka:
> bdrv_save_vmstate and bdrv_load_vmstate should return the number of
> processed bytes on success.
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
> ---
>  block/sheepdog.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index 776a1cc..146a221 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -1932,7 +1932,7 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data,
>                                  int64_t pos, int size, int load)
>  {
>      int fd, create;
> -    int ret = 0;
> +    int ret = 0, done = 0;
>      unsigned int data_len;
>      uint64_t vmstate_oid;
>      uint32_t vdi_index;
> @@ -1971,10 +1971,14 @@ static int do_load_save_vmstate(BDRVSheepdogState *s, uint8_t *data,
>  
>          pos += data_len;
>          size -= data_len;
> -        ret += data_len;
> +        done += data_len;
>      }
>  cleanup:
>      closesocket(fd);
> +
> +    if (done)
> +        return done;

Missing braces...

> +
>      return ret;
>  }

...but I think if an error occurred, we should not return short
reads/writes anyway, but instead return the error.

Kevin

  reply	other threads:[~2012-05-21 15:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 18:15 [Qemu-devel] [PATCH 1.1 0/4] sheepdog: various sheepdog fixes MORITA Kazutaka
2012-05-16 18:15 ` [Qemu-devel] [PATCH 1.1 1/4] sheepdog: mark image as snapshot when tag is specified MORITA Kazutaka
2012-05-16 18:15 ` [Qemu-devel] [PATCH 1.1 2/4] sheepdog: fix return value of do_load_save_vm_state MORITA Kazutaka
2012-05-21 15:51   ` Kevin Wolf [this message]
2012-05-16 18:15 ` [Qemu-devel] [PATCH 1.1 3/4] sheepdog: return -errno on error MORITA Kazutaka
2012-05-16 18:15 ` [Qemu-devel] [PATCH 1.1 4/4] sheepdog: use heap instead of stack for BDRVSheepdogState MORITA Kazutaka
2012-05-21 15:53 ` [Qemu-devel] [PATCH 1.1 0/4] sheepdog: various sheepdog fixes Kevin Wolf

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=4FBA6464.8040206@redhat.com \
    --to=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=qemu-devel@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.