From patchwork Mon Oct 13 23:03:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramsay Jones X-Patchwork-Id: 5077521 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A4AC9F295 for ; Mon, 13 Oct 2014 23:03:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D4FF20176 for ; Mon, 13 Oct 2014 23:03:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD0D120127 for ; Mon, 13 Oct 2014 23:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbaJMXDe (ORCPT ); Mon, 13 Oct 2014 19:03:34 -0400 Received: from mdfmta005.mxout.tch.inty.net ([91.221.169.46]:50175 "EHLO smtp.demon.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751343AbaJMXDd (ORCPT ); Mon, 13 Oct 2014 19:03:33 -0400 Received: from mdfmta005.tch.inty.net (unknown [127.0.0.1]) by mdfmta005.tch.inty.net (Postfix) with ESMTP id EF3BB18CED6; Tue, 14 Oct 2014 00:03:31 +0100 (BST) Received: from mdfmta005.tch.inty.net (unknown [127.0.0.1]) by mdfmta005.tch.inty.net (Postfix) with ESMTP id AC95018CEAA; Tue, 14 Oct 2014 00:03:31 +0100 (BST) Received: from [10.0.2.15] (unknown [80.176.147.220]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mdfmta005.tch.inty.net (Postfix) with ESMTP; Tue, 14 Oct 2014 00:03:31 +0100 (BST) Message-ID: <543C5A43.9@ramsay1.demon.co.uk> Date: Tue, 14 Oct 2014 00:03:31 +0100 From: Ramsay Jones User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: Christopher Li CC: Sparse Mailing-list Subject: [PATCH] compile-i386.c: don't ignore return value of write(2) X-MDF-HostID: 18 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some versions of gcc (e.g. v4.8.2) complain about ignoring the return value of a call to the write(2) system call, since the system header files have marked its declaration with the warn_unused_result attribute. In order to suppress the compiler warning, check the return value from 'write' and, if it indicates an error (a negative return value), exit the process using 'die' to display an error message. Replace a second call to 'write', which does not provoke a compiler warning, with similar code for consistency. Signed-off-by: Ramsay Jones --- Hi Chris, This is an (almost) minimal patch to suppress the compiler warning. You could drop the second hunk (and edit the commit message) if you prefer an absolutely minimal patch. :-D ATB, Ramsay Jones compile-i386.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compile-i386.c b/compile-i386.c index 88169ec..44b72ec 100644 --- a/compile-i386.c +++ b/compile-i386.c @@ -732,7 +732,8 @@ static void emit_insn_atom(struct function *f, struct atom *atom) atom->insn, comment[0] ? "\t\t" : "", comment); - write(STDOUT_FILENO, s, strlen(s)); + if (write(STDOUT_FILENO, s, strlen(s)) < 0) + die("can't write to stdout"); } static void emit_atom_list(struct function *f) @@ -742,9 +743,8 @@ static void emit_atom_list(struct function *f) FOR_EACH_PTR(f->atom_list, atom) { switch (atom->type) { case ATOM_TEXT: { - ssize_t rc = write(STDOUT_FILENO, atom->text, - atom->text_len); - (void) rc; /* FIXME */ + if (write(STDOUT_FILENO, atom->text, atom->text_len) < 0) + die("can't write to stdout"); break; } case ATOM_INSN: