From patchwork Tue Jan 19 23:56:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 43241 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 38986B7CEE for ; Wed, 20 Jan 2010 11:12:37 +1100 (EST) Received: from localhost ([127.0.0.1]:47932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXO5E-0000An-HO for incoming@patchwork.ozlabs.org; Tue, 19 Jan 2010 19:06:04 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXNwB-0005o9-VG for qemu-devel@nongnu.org; Tue, 19 Jan 2010 18:56:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXNw7-0005kp-HD for qemu-devel@nongnu.org; Tue, 19 Jan 2010 18:56:43 -0500 Received: from [199.232.76.173] (port=59373 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXNw6-0005kV-Q5 for qemu-devel@nongnu.org; Tue, 19 Jan 2010 18:56:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3962) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXNw6-0005vG-1W for qemu-devel@nongnu.org; Tue, 19 Jan 2010 18:56:38 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0JNubMC018602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 19 Jan 2010 18:56:37 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0JNuT3l027975; Tue, 19 Jan 2010 18:56:35 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 20 Jan 2010 00:56:11 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kirill@shutemov.name Subject: [Qemu-devel] [PATCH 04/17] block/cow.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 From: Kirill A. Shutemov CC block/cow.o cc1: warnings being treated as errors block/cow.c: In function 'cow_create': block/cow.c:251: error: ignoring return value of 'write', declared with attribute warn_unused_result block/cow.c:253: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result make: *** [block/cow.o] Error 1 Signed-off-by: Kirill A. Shutemov Signed-off-by: Juan Quintela --- block/cow.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/block/cow.c b/block/cow.c index a70854e..3733385 100644 --- a/block/cow.c +++ b/block/cow.c @@ -209,6 +209,7 @@ static int cow_create(const char *filename, QEMUOptionParameter *options) struct stat st; int64_t image_sectors = 0; const char *image_filename = NULL; + int ret; /* Read out options */ while (options && options->name) { @@ -248,11 +249,23 @@ static int cow_create(const char *filename, QEMUOptionParameter *options) } cow_header.sectorsize = cpu_to_be32(512); cow_header.size = cpu_to_be64(image_sectors * 512); - write(cow_fd, &cow_header, sizeof(cow_header)); + ret = qemu_write_full(cow_fd, &cow_header, sizeof(cow_header)); + if (ret != sizeof(cow_header)) { + ret = -1; + goto exit; + } + /* resize to include at least all the bitmap */ - ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3)); + ret = ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3)); + if (ret) { + ret = -errno; + goto exit; + } + + ret = 0; +exit: close(cow_fd); - return 0; + return ret; } static void cow_flush(BlockDriverState *bs)