[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] target-ppc: fix warn_unused_result build break with
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PATCH] target-ppc: fix warn_unused_result build break with in-kernel HTAB support |
Date: |
Wed, 12 Feb 2014 16:40:30 +0100 |
User-agent: |
StGit/0.16 |
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 <address@hidden>
---
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;