From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQuvy-0006Uk-4h for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQuvt-0006TN-ER for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:45 -0500 Received: from [199.232.76.173] (port=53808 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQuvt-0006TK-Ab for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:41 -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 1NQuvt-00082i-2d for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:41 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so16659813fxm.2 for ; Fri, 01 Jan 2010 19:45:40 -0800 (PST) From: "Kirill A. Shutemov" Date: Sat, 2 Jan 2010 05:45:21 +0200 Message-Id: <1262403933-26881-3-git-send-email-kirill@shutemov.name> In-Reply-To: <1262403933-26881-2-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> Subject: [Qemu-devel] [PATCH 03/15] block/cow.c: fix warnings with _FORTIFY_SOURCE List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "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 --- block/cow.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/block/cow.c b/block/cow.c index a70854e..ba07b97 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 = -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) -- 1.6.5.7