All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 2/2] check for close() errors on qcow2_create()
Date: Fri, 08 Oct 2010 12:14:07 +0200	[thread overview]
Message-ID: <4CAEEEEF.1090603@redhat.com> (raw)
In-Reply-To: <1286483105-9768-3-git-send-email-ehabkost@redhat.com>

Am 07.10.2010 22:25, schrieb Eduardo Habkost:
> Errors when closing the file we just created should not be ignored. I/O errors
> may happen and "qemu-img create" should fail in those cases.
> 
> If we are already exiting due to an error, we will still return the original
> error number, though.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  block/qcow2.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index c5fb28e..d3a056b 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -882,7 +882,7 @@ static int qcow_create2(const char *filename, int64_t total_size,
>      uint64_t old_ref_clusters;
>      QCowCreateState s1, *s = &s1;
>      QCowExtension ext_bf = {0, 0};
> -    int ret;
> +    int ret, cret;
>  
>      memset(s, 0, sizeof(*s));
>  
> @@ -1055,7 +1055,9 @@ exit:
>      qemu_free(s->refcount_block);
>  
>  exit_close:
> -    close(fd);
> +    cret = close(fd);
> +    if (ret == 0 && cret < 0)
> +        ret = -errno;

Braces are missing here.

Kevin

  parent reply	other threads:[~2010-10-08 10:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-07 20:25 [Qemu-devel] [PATCH 0/2] qcow2_create() error handling fixes Eduardo Habkost
2010-10-07 20:25 ` [Qemu-devel] [PATCH 1/2] fix fd leak on one qcow2_create2() error path Eduardo Habkost
2010-10-08  9:36   ` Stefan Hajnoczi
2010-10-07 20:25 ` [Qemu-devel] [PATCH 2/2] check for close() errors on qcow2_create() Eduardo Habkost
2010-10-08  9:28   ` Stefan Hajnoczi
2010-10-08 15:29     ` Eduardo Habkost
2010-10-08 10:14   ` Kevin Wolf [this message]
2010-10-08 17:39     ` [Qemu-devel] " Eduardo Habkost
2010-10-08 10:11 ` [Qemu-devel] Re: [PATCH 0/2] qcow2_create() error handling 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=4CAEEEEF.1090603@redhat.com \
    --to=kwolf@redhat.com \
    --cc=ehabkost@redhat.com \
    --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.