From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55164 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P49xP-00026j-9Y for qemu-devel@nongnu.org; Fri, 08 Oct 2010 06:14:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P49xI-0004th-0m for qemu-devel@nongnu.org; Fri, 08 Oct 2010 06:13:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P49xH-0004tc-Qn for qemu-devel@nongnu.org; Fri, 08 Oct 2010 06:13:35 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o98ADZRt016855 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Oct 2010 06:13:35 -0400 Message-ID: <4CAEEEEF.1090603@redhat.com> Date: Fri, 08 Oct 2010 12:14:07 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1286483105-9768-1-git-send-email-ehabkost@redhat.com> <1286483105-9768-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1286483105-9768-3-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/2] check for close() errors on qcow2_create() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: qemu-devel@nongnu.org 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 > --- > 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