From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDbvc-0007tq-VS for qemu-devel@nongnu.org; Wed, 12 Feb 2014 10:40:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDbvS-0002zJ-Nr for qemu-devel@nongnu.org; Wed, 12 Feb 2014 10:40:48 -0500 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:44845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDbvS-0002yr-1K for qemu-devel@nongnu.org; Wed, 12 Feb 2014 10:40:38 -0500 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Feb 2014 15:40:36 -0000 From: Greg Kurz Date: Wed, 12 Feb 2014 16:40:30 +0100 Message-ID: <20140212154030.393.66279.stgit@bahia.local> In-Reply-To: <20140210162515.07e11909@bahia.local> References: <20140210162515.07e11909@bahia.local> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH] target-ppc: fix warn_unused_result build break with in-kernel HTAB support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aneesh.kumar@linux.vnet.ibm.com, agraf@suse.de Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org The 7029677e4 commit introduced the following build break: target-ppc/kvm.c: In function ‘kvmppc_hash64_write_pte’: target-ppc/kvm.c:2017:10: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result] write(htab_fd, &hpte_buf, sizeof(hpte_buf)); ^ Even though nothing is done for the moment if kvm_htab_write() fails, we obviously need to be explicit. Let's add an *empty* return path to please gcc. Signed-off-by: Greg Kurz --- target-ppc/kvm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 2eaf956..343376c 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -2012,9 +2012,15 @@ void kvmppc_hash64_write_pte(CPUPPCState *env, target_ulong pte_index, hpte_buf.hpte[0] = pte0; hpte_buf.hpte[1] = pte1; /* - * Write the hpte entry + * Write the hpte entry. + * CAUTION: write() has the warn_unused_result attribute. Hence we + * need to check the return value, even though we do nothing. */ - write(htab_fd, &hpte_buf, sizeof(hpte_buf)); + if (write(htab_fd, &hpte_buf, sizeof(hpte_buf)) < 0) { + goto out_close; + } + +out_close: close(htab_fd); return;