[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 30/30] hw/timer/sh_timer: Remove use of hw_error
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v6 30/30] hw/timer/sh_timer: Remove use of hw_error |
Date: |
Sat, 30 Oct 2021 00:06:08 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 |
On 10/29/21 23:02, BALATON Zoltan wrote:
> The hw_error function calls abort and is not meant to be used by
> devices. Use qemu_log_mask instead to log and ignore invalid accesses.
> Also fix format strings to allow dropping type casts of hwaddr and use
> __func__ instead of hard coding function name in the message which
> were wrong in two cases.
>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> hw/timer/sh_timer.c | 40 +++++++++++++++++++++++++---------------
> 1 file changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/hw/timer/sh_timer.c b/hw/timer/sh_timer.c
> index a6445092e4..8a586f2c4a 100644
> --- a/hw/timer/sh_timer.c
> +++ b/hw/timer/sh_timer.c
> @@ -10,7 +10,7 @@
>
> #include "qemu/osdep.h"
> #include "exec/memory.h"
> -#include "hw/hw.h"
> +#include "qemu/log.h"
> #include "hw/irq.h"
> #include "hw/sh4/sh.h"
> #include "hw/timer/tmu012.h"
> @@ -75,11 +75,10 @@ static uint32_t sh_timer_read(void *opaque, hwaddr offset)
> if (s->feat & TIMER_FEAT_CAPT) {
> return s->tcpr;
> }
> - /* fall through */
> - default:
> - hw_error("sh_timer_read: Bad offset %x\n", (int)offset);
> - return 0;
> }
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
> + __func__, offset);
> + return 0;
Note, keeping the default case allow to refactor for single return,
so it is easier to add trace event.
Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
- [PATCH v6 14/30] hw/char/sh_serial: Add device id to trace output, (continued)
- [PATCH v6 14/30] hw/char/sh_serial: Add device id to trace output, BALATON Zoltan, 2021/10/29
- [PATCH v6 23/30] hw/intc/sh_intc: Replace abort() with g_assert_not_reached(), BALATON Zoltan, 2021/10/29
- [PATCH v6 24/30] hw/intc/sh_intc: Avoid using continue in loops, BALATON Zoltan, 2021/10/29
- [PATCH v6 28/30] hw/timer/sh_timer: Do not wrap lines that are not too long, BALATON Zoltan, 2021/10/29
- [PATCH v6 25/30] hw/intc/sh_intc: Simplify allocating sources array, BALATON Zoltan, 2021/10/29
- [PATCH v6 26/30] hw/intc/sh_intc: Remove unneeded local variable initialisers, BALATON Zoltan, 2021/10/29
- [PATCH v6 27/30] hw/timer/sh_timer: Rename sh_timer_state to SHTimerState, BALATON Zoltan, 2021/10/29
- [PATCH v6 30/30] hw/timer/sh_timer: Remove use of hw_error, BALATON Zoltan, 2021/10/29
- Re: [PATCH v6 30/30] hw/timer/sh_timer: Remove use of hw_error,
Philippe Mathieu-Daudé <=
- [PATCH v6 29/30] hw/timer/sh_timer: Fix timer memory region size, BALATON Zoltan, 2021/10/29
- [PATCH v7 29/30] hw/timer/sh_timer: Fix timer memory region size, BALATON Zoltan, 2021/10/29
- [PATCH v6 21/30] hw/intc/sh_intc: Use array index instead of pointer arithmetics, BALATON Zoltan, 2021/10/29
- [PATCH v6 22/30] hw/intc/sh_intc: Inline and drop sh_intc_source() function, BALATON Zoltan, 2021/10/29