[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/2] hw/gpio/max7310: Remove impossible check
From: |
Laurent Vivier |
Subject: |
Re: [PATCH v2 1/2] hw/gpio/max7310: Remove impossible check |
Date: |
Wed, 16 Sep 2020 10:45:27 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
Le 10/09/2020 à 09:23, Philippe Mathieu-Daudé a écrit :
> The max7310_gpio_set() handler is static and only used by
> qdev_init_gpio_in, initialized with 8 IRQs. The 'line'
> argument can not be out of the [0-8[ range.
> Replace the dead code by an assertion.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/gpio/max7310.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
> index 4f78774dc8f..158b0a074e5 100644
> --- a/hw/gpio/max7310.c
> +++ b/hw/gpio/max7310.c
> @@ -8,9 +8,7 @@
> */
>
> #include "qemu/osdep.h"
> -#include "hw/hw.h"
> #include "hw/i2c/i2c.h"
> -#include "hw/hw.h"
> #include "hw/irq.h"
> #include "migration/vmstate.h"
> #include "qemu/module.h"
> @@ -173,8 +171,7 @@ static const VMStateDescription vmstate_max7310 = {
> static void max7310_gpio_set(void *opaque, int line, int level)
> {
> MAX7310State *s = (MAX7310State *) opaque;
> - if (line >= ARRAY_SIZE(s->handler) || line < 0)
> - hw_error("bad GPIO line");
> + assert(line >= 0 && line < ARRAY_SIZE(s->handler));
>
> if (level)
> s->level |= s->direction & (1 << line);
>
Applied to my trivial-patches branch.
Thanks,
Laurent