* [PATCH] staging: pi433: Move limit check to switch default to kill warning
@ 2017-09-06 15:40 Geert Uytterhoeven
0 siblings, 0 replies; only message in thread
From: Geert Uytterhoeven @ 2017-09-06 15:40 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Arnd Bergmann, devel, linux-kernel, Geert Uytterhoeven
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>
---
drivers/staging/pi433/rf69.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index c4b1b218ea38f8d1..290b419aa9dd7135 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)
dev_dbg(&spi->dev, "set: DIO mapping");
#endif
- // check DIO number
- if (DIONumber > 5) {
- dev_dbg(&spi->dev, "set: illegal input param");
- return -EINVAL;
- }
-
switch (DIONumber) {
case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break;
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)
case 3: mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break;
case 4: mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break;
case 5: mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break;
+ default:
+ dev_dbg(&spi->dev, "set: illegal input param");
+ return -EINVAL;
}
// read reg
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-06 15:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 15:40 [PATCH] staging: pi433: Move limit check to switch default to kill warning Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®