diff mbox series

[1/5] hw/gpio/max7310: Remove impossible check

Message ID 20200901104043.91383-2-f4bug@amsat.org
State New
Headers show
Series hw: Replace some impossible checks by assertions | expand

Commit Message

Philippe Mathieu-Daudé Sept. 1, 2020, 10:40 a.m. UTC
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.
Remove the dead code.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/gpio/max7310.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Peter Maydell Sept. 1, 2020, 10:42 a.m. UTC | #1
On Tue, 1 Sep 2020 at 11:40, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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.
> Remove the dead code.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/gpio/max7310.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
> index bebb4030d27..7f5de189acf 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"
> @@ -176,8 +174,6 @@ 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");

I think it would be reasonable to retain this one as an assert.

-- PMM
diff mbox series

Patch

diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index bebb4030d27..7f5de189acf 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"
@@ -176,8 +174,6 @@  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");
 
     if (level)
         s->level |= s->direction & (1 << line);