qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 2/2] check for close() errors on qcow2_create()


From: Kevin Wolf
Subject: [Qemu-devel] Re: [PATCH 2/2] check for close() errors on qcow2_create()
Date: Fri, 08 Oct 2010 12:14:07 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 Fedora/3.0.7-1.fc12 Thunderbird/3.0.7

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



reply via email to

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