From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NMAlv-0007sQ-O5 for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NMAlp-0007lj-UV for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:46 -0500 Received: from [199.232.76.173] (port=54471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMAlp-0007lX-Pl for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:41 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:53674) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NMAlp-0004mU-Dj for qemu-devel@nongnu.org; Sat, 19 Dec 2009 20:39:41 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so4042055fxm.2 for ; Sat, 19 Dec 2009 17:39:41 -0800 (PST) From: "Kirill A. Shutemov" Date: Sun, 20 Dec 2009 03:39:14 +0200 Message-Id: <1261273167-3240-5-git-send-email-kirill@shutemov.name> In-Reply-To: <1261273167-3240-4-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> <1261273167-3240-4-git-send-email-kirill@shutemov.name> Subject: [Qemu-devel] [PATCH 05/18] block/qcow.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/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 | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/block/qcow.c b/block/qcow.c index 7fc85ae..db5a0e2 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,34 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options) } /* write all the data */ - write(fd, &header, sizeof(header)); + ret = write(fd, &header, sizeof(header)); + if (ret != sizeof(header)) { + ret = -errno; + goto exit; + } + if (backing_file) { - write(fd, backing_file, backing_filename_len); + ret = write(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 = write(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) -- 1.6.5.6