From patchwork Sun Dec 20 01:39:13 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: 41491 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 DF839B6EF5 for ; Sun, 20 Dec 2009 12:46:06 +1100 (EST) Received: from localhost ([127.0.0.1]:38194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMArz-00022a-0a for incoming@patchwork.ozlabs.org; Sat, 19 Dec 2009 20:46:03 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NMAlt-0007qI-SX for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NMAlo-0007iL-6i for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:44 -0500 Received: from [199.232.76.173] (port=54470 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMAlo-0007i3-2k for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:40 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:56134) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NMAln-0004ms-LS for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:39 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so4042062fxm.2 for ; Sat, 19 Dec 2009 17:39:39 -0800 (PST) Received: by 10.223.75.136 with SMTP id y8mr2335656faj.69.1261273179277; Sat, 19 Dec 2009 17:39:39 -0800 (PST) Received: from localhost.localdomain (a88-114-220-92.elisa-laajakaista.fi [88.114.220.92]) by mx.google.com with ESMTPS id 13sm6982256fks.45.2009.12.19.17.39.37 (version=SSLv3 cipher=RC4-MD5); Sat, 19 Dec 2009 17:39:38 -0800 (PST) From: "Kirill A. Shutemov" To: qemu-devel@nongnu.org Date: Sun, 20 Dec 2009 03:39:13 +0200 Message-Id: <1261273167-3240-4-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.6.5.6 In-Reply-To: <1261273167-3240-3-git-send-email-kirill@shutemov.name> References: <1261273167-3240-1-git-send-email-kirill@shutemov.name> <1261273167-3240-2-git-send-email-kirill@shutemov.name> <1261273167-3240-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/18] 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 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 --- block/cow.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/block/cow.c b/block/cow.c index a70854e..1132614 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 = write(cow_fd, &cow_header, sizeof(cow_header)); + if (ret != sizeof(cow_header)) { + ret = -errno; + 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)