From patchwork Sat Jan 2 03:45:28 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: 42001 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 17C34B6EEA for ; Sat, 2 Jan 2010 15:02:14 +1100 (EST) Received: from localhost ([127.0.0.1]:43182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQvBq-00044H-VA for incoming@patchwork.ozlabs.org; Fri, 01 Jan 2010 23:02:10 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQuwB-0006cH-TV for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:46:00 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQuw4-0006YH-ST for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:57 -0500 Received: from [199.232.76.173] (port=53815 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQuw4-0006Y8-Mg for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:52 -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 1NQuw4-00082k-Dk for qemu-devel@nongnu.org; Fri, 01 Jan 2010 22:45:52 -0500 Received: by mail-fx0-f222.google.com with SMTP id 22so16659819fxm.2 for ; Fri, 01 Jan 2010 19:45:52 -0800 (PST) Received: by 10.223.73.20 with SMTP id o20mr20159356faj.71.1262403951754; Fri, 01 Jan 2010 19:45:51 -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.50 (version=SSLv3 cipher=RC4-MD5); Fri, 01 Jan 2010 19:45:50 -0800 (PST) From: "Kirill A. Shutemov" To: qemu-devel@nongnu.org Date: Sat, 2 Jan 2010 05:45:28 +0200 Message-Id: <1262403933-26881-10-git-send-email-kirill@shutemov.name> X-Mailer: git-send-email 1.6.5.7 In-Reply-To: <1262403933-26881-9-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> <1262403933-26881-4-git-send-email-kirill@shutemov.name> <1262403933-26881-5-git-send-email-kirill@shutemov.name> <1262403933-26881-6-git-send-email-kirill@shutemov.name> <1262403933-26881-7-git-send-email-kirill@shutemov.name> <1262403933-26881-8-git-send-email-kirill@shutemov.name> <1262403933-26881-9-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 10/15] vl.c: fix warning 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 i386-softmmu/vl.o cc1: warnings being treated as errors /usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'qemu_event_increment': /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:3404: error: ignoring return value of 'write', declared with attribute warn_unused_result /usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'main': /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:5774: error: ignoring return value of 'write', declared with attribute warn_unused_result /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6064: error: ignoring return value of 'chdir', declared with attribute warn_unused_result /usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6083: error: ignoring return value of 'chdir', declared with attribute warn_unused_result make[1]: *** [vl.o] Error 1 Signed-off-by: Kirill A. Shutemov --- vl.c | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-) diff --git a/vl.c b/vl.c index e881e45..7fcde35 100644 --- a/vl.c +++ b/vl.c @@ -3390,11 +3390,17 @@ static int io_thread_fd = -1; static void qemu_event_increment(void) { static const char byte = 0; + int ret; if (io_thread_fd == -1) return; - write(io_thread_fd, &byte, sizeof(byte)); + ret = write(io_thread_fd, &byte, sizeof(byte)); + if (ret < 0 && (errno != EINTR && errno != EAGAIN)) { + fprintf(stderr, "qemu_event_increment: write() filed: %s\n", + strerror(errno)); + exit (1); + } } static void qemu_event_read(void *opaque) @@ -5778,7 +5784,10 @@ int main(int argc, char **argv, char **envp) #ifndef _WIN32 if (daemonize) { uint8_t status = 1; - write(fds[1], &status, 1); + if (qemu_write_full(fds[1], &status, 1) != 1) { + perror("write()"); + exit(1); + } } else #endif fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno)); @@ -6065,18 +6074,15 @@ int main(int argc, char **argv, char **envp) #ifndef _WIN32 if (daemonize) { uint8_t status = 0; - ssize_t len; - again1: - len = write(fds[1], &status, 1); - if (len == -1 && (errno == EINTR)) - goto again1; - - if (len != 1) + if (qemu_write_full(fds[1], &status, 1) != 1) exit(1); - chdir("/"); - TFR(fd = qemu_open("/dev/null", O_RDWR)); + if (chdir("/")) { + perror("chdir()"); + exit(1); + } + TFR(fd = qemu_open("/dev/null", O_RDWR)); if (fd == -1) exit(1); } @@ -6094,7 +6100,10 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "chroot failed\n"); exit(1); } - chdir("/"); + if (chdir("/")) { + perror("chdir()"); + exit(1); + } } if (run_as) {