From patchwork Wed Mar 3 12:06:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 46792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3BCE3B7CEC for ; Wed, 3 Mar 2010 23:17:30 +1100 (EST) Received: from localhost ([127.0.0.1]:41927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmnW3-00065d-AA for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2010 07:17:27 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NmnM6-0000m0-U1 for qemu-devel@nongnu.org; Wed, 03 Mar 2010 07:07:10 -0500 Received: from [199.232.76.173] (port=53673 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmnM6-0000lo-J8 for qemu-devel@nongnu.org; Wed, 03 Mar 2010 07:07:10 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NmnM5-0005IO-3w for qemu-devel@nongnu.org; Wed, 03 Mar 2010 07:07:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33829) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NmnM4-0005IG-MJ for qemu-devel@nongnu.org; Wed, 03 Mar 2010 07:07:08 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o23C77vb010590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Mar 2010 07:07:08 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o23C71A7004209; Wed, 3 Mar 2010 07:07:06 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 3 Mar 2010 13:06:53 +0100 Message-Id: <5933e47934d62e622de91b1c8ad0e92d0e5a7b6c.1267617582.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, amit.shah@redhat.com Subject: [Qemu-devel] [PATCH 03/10] qcow2: return errno instead of -1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- block/qcow2.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index bf8170e..5b6dad9 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -851,7 +851,7 @@ static int qcow_create2(const char *filename, int64_t total_size, fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) - return -1; + return -errno; memset(&header, 0, sizeof(header)); header.magic = cpu_to_be32(QCOW_MAGIC); header.version = cpu_to_be32(QCOW_VERSION); @@ -930,7 +930,7 @@ static int qcow_create2(const char *filename, int64_t total_size, /* write all the data */ ret = qemu_write_full(fd, &header, sizeof(header)); if (ret != sizeof(header)) { - ret = -1; + ret = -errno; goto exit; } if (backing_file) { @@ -943,25 +943,25 @@ static int qcow_create2(const char *filename, int64_t total_size, cpu_to_be32s(&ext_bf.len); ret = qemu_write_full(fd, &ext_bf, sizeof(ext_bf)); if (ret != sizeof(ext_bf)) { - ret = -1; + ret = -errno; goto exit; } ret = qemu_write_full(fd, backing_format, backing_format_len); if (ret != backing_format_len) { - ret = -1; + ret = -errno; goto exit; } if (padding > 0) { ret = qemu_write_full(fd, zero, padding); if (ret != padding) { - ret = -1; + ret = -errno; goto exit; } } } ret = qemu_write_full(fd, backing_file, backing_filename_len); if (ret != backing_filename_len) { - ret = -1; + ret = -errno; goto exit; } } @@ -970,14 +970,14 @@ static int qcow_create2(const char *filename, int64_t total_size, for(i = 0;i < l1_size; i++) { ret = qemu_write_full(fd, &tmp, sizeof(tmp)); if (ret != sizeof(tmp)) { - ret = -1; + ret = -errno; goto exit; } } lseek(fd, s->refcount_table_offset, SEEK_SET); ret = qemu_write_full(fd, s->refcount_table, s->cluster_size); if (ret != s->cluster_size) { - ret = -1; + ret = -errno; goto exit; } @@ -985,7 +985,7 @@ static int qcow_create2(const char *filename, int64_t total_size, ret = qemu_write_full(fd, s->refcount_block, ref_clusters * s->cluster_size); if (ret != ref_clusters * s->cluster_size) { - ret = -1; + ret = -errno; goto exit; }