From patchwork Thu Dec 31 01:33:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 41952 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 1A0891007D1 for ; Thu, 31 Dec 2009 12:43:42 +1100 (EST) Received: from localhost ([127.0.0.1]:50642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQA4h-0000hR-7o for incoming@patchwork.ozlabs.org; Wed, 30 Dec 2009 20:43:39 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQ9v6-0005s7-Hu for qemu-devel@nongnu.org; Wed, 30 Dec 2009 20:33:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQ9v1-0005pf-Ib for qemu-devel@nongnu.org; Wed, 30 Dec 2009 20:33:44 -0500 Received: from [199.232.76.173] (port=40614 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQ9v1-0005pQ-A8 for qemu-devel@nongnu.org; Wed, 30 Dec 2009 20:33:39 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:55327) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NQ9v0-00031j-Nd for qemu-devel@nongnu.org; Wed, 30 Dec 2009 20:33:39 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so15607316fxm.2 for ; Wed, 30 Dec 2009 17:33:37 -0800 (PST) Received: by 10.223.14.20 with SMTP id e20mr122835faa.16.1262223217757; Wed, 30 Dec 2009 17:33:37 -0800 (PST) Received: from localhost.localdomain (a88-114-220-92.elisa-laajakaista.fi [88.114.220.92]) by mx.google.com with ESMTPS id 18sm20568832fks.34.2009.12.30.17.33.36 (version=SSLv3 cipher=RC4-MD5); Wed, 30 Dec 2009 17:33:37 -0800 (PST) From: "Kirill A. Shutemov" To: qemu-devel@nongnu.org Date: Thu, 31 Dec 2009 03:33:17 +0200 Message-Id: <1262223199-19062-7-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.6.5.7 In-Reply-To: <1262223199-19062-6-git-send-email-kirill@shutemov.name> References: <1262223199-19062-1-git-send-email-kirill@shutemov.name> <1262223199-19062-2-git-send-email-kirill@shutemov.name> <1262223199-19062-3-git-send-email-kirill@shutemov.name> <1262223199-19062-4-git-send-email-kirill@shutemov.name> <1262223199-19062-5-git-send-email-kirill@shutemov.name> <1262223199-19062-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/14] 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..44dc195 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)