[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH] ppce500_spin: Replace assert by hw_error (fixes c
From: |
Andreas Färber |
Subject: |
Re: [Qemu-ppc] [PATCH] ppce500_spin: Replace assert by hw_error (fixes compiler warning) |
Date: |
Sat, 28 Apr 2012 18:09:32 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120328 Thunderbird/11.0.1 |
Am 28.04.2012 17:52, schrieb Stefan Weil:
> The default case in function spin_read should never be reached,
> therefore the old code used assert(0) to abort QEMU.
>
> This does not work when QEMU is compiled with macro NDEBUG defined.
> In this case (and also when the compiler does not know that assert
> never returns), there is a compiler warning because of the missing
> return value.
>
> Using hw_error allows an improved error message and aborts always.
>
> Signed-off-by: Stefan Weil <address@hidden>
> ---
> hw/ppce500_spin.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c
> index 960b7b0..57dc995 100644
> --- a/hw/ppce500_spin.c
> +++ b/hw/ppce500_spin.c
> @@ -178,7 +178,7 @@ static uint64_t spin_read(void *opaque,
> target_phys_addr_t addr, unsigned len)
> case 4:
> return ldl_p(spin_p);
> default:
> - assert(0);
> + hw_error("ppce500: unexpected spin_read with len = %u", len);
Thanks. Bonus points for using __func__. :)
Andreas
> }
> }
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg