From patchwork Sat Jan 2 03:45:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 41997 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 D4C55B6EEA for ; Sat, 2 Jan 2010 14:55:36 +1100 (EST) Received: from localhost ([127.0.0.1]:45596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQv5S-0001J3-4O for incoming@patchwork.ozlabs.org; Fri, 01 Jan 2010 22:55:34 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQuw6-0006ZD-3o for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQuw0-0006Vo-DQ for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:52 -0500 Received: from [199.232.76.173] (port=53812 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQuw0-0006Vd-0C for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:48 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:55673) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NQuvz-00082i-Le for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:47 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so16659813fxm.2 for ; Fri, 01 Jan 2010 19:45:47 -0800 (PST) Received: by 10.223.161.215 with SMTP id s23mr6922545fax.44.1262403947163; Fri, 01 Jan 2010 19:45:47 -0800 (PST) Received: from localhost.localdomain (a88-114-220-92.elisa-laajakaista.fi [88.114.220.92]) by mx.google.com with ESMTPS id 35sm22820386fkt.40.2010.01.01.19.45.45 (version=SSLv3 cipher=RC4-MD5); Fri, 01 Jan 2010 19:45:46 -0800 (PST) From: "Kirill A. Shutemov" To: qemu-devel@nongnu.org Date: Sat, 2 Jan 2010 05:45:25 +0200 Message-Id: <1262403933-26881-7-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.6.5.7 In-Reply-To: <1262403933-26881-6-git-send-email-kirill@shutemov.name> References: <1262403933-26881-1-git-send-email-kirill@shutemov.name> <1262403933-26881-2-git-send-email-kirill@shutemov.name> <1262403933-26881-3-git-send-email-kirill@shutemov.name> <1262403933-26881-4-git-send-email-kirill@shutemov.name> <1262403933-26881-5-git-send-email-kirill@shutemov.name> <1262403933-26881-6-git-send-email-kirill@shutemov.name> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: "Kirill A. Shutemov" Subject: [Qemu-devel] [PATCH 07/15] block/qcow2.c: fix warnings with _FORTIFY_SOURCE 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 CC block/qcow2.o cc1: warnings being treated as errors block/qcow2.c: In function 'qcow_create2': block/qcow2.c:829: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:838: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:839: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:841: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:844: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:849: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:852: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow2.c:855: error: ignoring return value of 'write', declared with attribute warn_unused_result make: *** [block/qcow2.o] Error 1 Signed-off-by: Kirill A. Shutemov --- block/qcow2.c | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 10 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 984264b..1874124 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -743,7 +743,7 @@ static int qcow_create2(const char *filename, int64_t total_size, uint64_t tmp, offset; QCowCreateState s1, *s = &s1; QCowExtension ext_bf = {0, 0}; - + int ret; memset(s, 0, sizeof(*s)); @@ -826,7 +826,11 @@ static int qcow_create2(const char *filename, int64_t total_size, ref_clusters * s->cluster_size); /* write all the data */ - write(fd, &header, sizeof(header)); + ret = qemu_write_full(fd, &header, sizeof(header)); + if (ret != sizeof(header)) { + ret = -errno; + goto exit; + } if (backing_file) { if (backing_format_len) { char zero[16]; @@ -835,25 +839,56 @@ static int qcow_create2(const char *filename, int64_t total_size, memset(zero, 0, sizeof(zero)); cpu_to_be32s(&ext_bf.magic); cpu_to_be32s(&ext_bf.len); - write(fd, &ext_bf, sizeof(ext_bf)); - write(fd, backing_format, backing_format_len); + ret = qemu_write_full(fd, &ext_bf, sizeof(ext_bf)); + if (ret != sizeof(ext_bf)) { + ret = -errno; + goto exit; + } + ret = qemu_write_full(fd, backing_format, backing_format_len); + if (ret != backing_format_len) { + ret = -errno; + goto exit; + } if (padding > 0) { - write(fd, zero, padding); + ret = qemu_write_full(fd, zero, padding); + if (ret != padding) { + ret = -errno; + goto exit; + } } } - write(fd, backing_file, backing_filename_len); + ret = qemu_write_full(fd, backing_file, backing_filename_len); + if (ret != backing_filename_len) { + ret = -errno; + goto exit; + } } lseek(fd, s->l1_table_offset, SEEK_SET); tmp = 0; for(i = 0;i < l1_size; i++) { - write(fd, &tmp, sizeof(tmp)); + ret = qemu_write_full(fd, &tmp, sizeof(tmp)); + if (ret != sizeof(tmp)) { + ret = -errno; + goto exit; + } } lseek(fd, s->refcount_table_offset, SEEK_SET); - write(fd, s->refcount_table, s->cluster_size); + ret = qemu_write_full(fd, s->refcount_table, s->cluster_size); + if (ret != s->cluster_size) { + ret = -errno; + goto exit; + } lseek(fd, s->refcount_block_offset, SEEK_SET); - write(fd, s->refcount_block, ref_clusters * s->cluster_size); + ret = qemu_write_full(fd, s->refcount_block, + ref_clusters * s->cluster_size); + if (ret != s->cluster_size) { + ret = -errno; + goto exit; + } + ret = 0; +exit: qemu_free(s->refcount_table); qemu_free(s->refcount_block); close(fd); @@ -867,7 +902,7 @@ static int qcow_create2(const char *filename, int64_t total_size, bdrv_close(bs); } - return 0; + return ret; } static int qcow_create(const char *filename, QEMUOptionParameter *options)