diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2017-09-06 11:40:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-09-18 06:25:31 -0400 |
commit | b72703e26b9478da531144ce5c4552dd22f1103d (patch) | |
tree | fa72c43bc8b5390668c8f04c5044fed16cabcfae | |
parent | e1bf28868ab0bfd1fc73dd8d5e642d88456c30e9 (diff) |
staging: pi433: Move limit check to switch default to kill warning
With gcc-4.1.2:
drivers/staging/pi433/rf69.c: In function ‘rf69_set_dio_mapping’:
drivers/staging/pi433/rf69.c:566: warning: ‘regaddr’ may be used uninitialized in this function
drivers/staging/pi433/rf69.c:565: warning: ‘shift’ may be used uninitialized in this function
drivers/staging/pi433/rf69.c:564: warning: ‘mask’ may be used uninitialized in this function
While this is a false positive, it can easily be fixed by moving the
limit check into the "default" case of the switch statement.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/pi433/rf69.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index c4b1b218ea38..290b419aa9dd 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c | |||
@@ -570,12 +570,6 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) | |||
570 | dev_dbg(&spi->dev, "set: DIO mapping"); | 570 | dev_dbg(&spi->dev, "set: DIO mapping"); |
571 | #endif | 571 | #endif |
572 | 572 | ||
573 | // check DIO number | ||
574 | if (DIONumber > 5) { | ||
575 | dev_dbg(&spi->dev, "set: illegal input param"); | ||
576 | return -EINVAL; | ||
577 | } | ||
578 | |||
579 | switch (DIONumber) { | 573 | switch (DIONumber) { |
580 | case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; | 574 | case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; |
581 | case 1: mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; | 575 | case 1: mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; |
@@ -583,6 +577,9 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) | |||
583 | case 3: mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; | 577 | case 3: mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; |
584 | case 4: mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; | 578 | case 4: mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; |
585 | case 5: mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; | 579 | case 5: mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; |
580 | default: | ||
581 | dev_dbg(&spi->dev, "set: illegal input param"); | ||
582 | return -EINVAL; | ||
586 | } | 583 | } |
587 | 584 | ||
588 | // read reg | 585 | // read reg |