From patchwork Sat Jan 2 03:45:22 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: 41994 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 B7CB7B6EEE for ; Sat, 2 Jan 2010 14:50:48 +1100 (EST) Received: from localhost ([127.0.0.1]:33967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQv0o-0007yx-3K for incoming@patchwork.ozlabs.org; Fri, 01 Jan 2010 22:50:46 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQuvz-0006Vf-VU for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQuvv-0006Th-8g for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:47 -0500 Received: from [199.232.76.173] (port=53809 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQuvv-0006Te-79 for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:43 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:63383) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NQuvu-00082k-UJ for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:43 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so16659819fxm.2 for ; Fri, 01 Jan 2010 19:45:42 -0800 (PST) Received: by 10.223.17.87 with SMTP id r23mr8155568faa.8.1262403942354; Fri, 01 Jan 2010 19:45:42 -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.40 (version=SSLv3 cipher=RC4-MD5); Fri, 01 Jan 2010 19:45:41 -0800 (PST) From: "Kirill A. Shutemov" To: qemu-devel@nongnu.org Date: Sat, 2 Jan 2010 05:45:22 +0200 Message-Id: <1262403933-26881-4-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.6.5.7 In-Reply-To: <1262403933-26881-3-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> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: "Kirill A. Shutemov" Subject: [Qemu-devel] [PATCH 04/15] block/qcow.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/qcow.o cc1: warnings being treated as errors block/qcow.c: In function 'qcow_create': block/qcow.c:804: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow.c:806: error: ignoring return value of 'write', declared with attribute warn_unused_result block/qcow.c:811: error: ignoring return value of 'write', declared with attribute warn_unused_result make: *** [block/qcow.o] Error 1 Signed-off-by: Kirill A. Shutemov --- block/qcow.c | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/block/qcow.c b/block/qcow.c index 7fc85ae..28cc092 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -750,6 +750,7 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options) int64_t total_size = 0; const char *backing_file = NULL; int flags = 0; + int ret; /* Read out options */ while (options && options->name) { @@ -801,17 +802,33 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options) } /* 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) { - 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, header_size, 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; + } } + + ret = 0; +exit: close(fd); - return 0; + return ret; } static int qcow_make_empty(BlockDriverState *bs)