[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] target-ppc: fix warn_unused_result build break
From: |
Aneesh Kumar K.V |
Subject: |
Re: [Qemu-devel] [PATCH] target-ppc: fix warn_unused_result build break with in-kernel HTAB support |
Date: |
Thu, 13 Feb 2014 08:30:23 +0530 |
User-agent: |
Notmuch/0.17+7~gc734dd75344e (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) |
Greg Kurz <address@hidden> writes:
> 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.
>
Reviewed-by: Aneesh Kumar K.V <address@hidden>
> 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;
>