Re: [PATCH] Staging: comedi: clean up conditional statement in addi_apci_3xxx.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2014-02-13 10:08, Ian Abbott wrote:
On 2014-02-13 03:29, Chase Southwood wrote:
In this if-else conditional statement, if (chan < 16), but
(data[0] == INSN_CONFIG_DIO_QUERY), the function does not return early,
but the else-branch does not get executed either.  As a result, mask
would be used uninitialized in the next line.  What we want here is if
(chan < 16) and (data[0] != INSN_CONFIG_DIO_QUERY), return an error, but
in every other case, initialize mask and then proceed.  Found by a static
checker.

Signed-off-by: Chase Southwood <chase.southwood@xxxxxxxxx>
---
  drivers/staging/comedi/drivers/addi_apci_3xxx.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
index ceadf8e..04c5153 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
@@ -688,13 +688,11 @@ static int apci3xxx_dio_insn_config(struct
comedi_device *dev,
       * Port 1 (channels 8-15) are always outputs
       * Port 2 (channels 16-23) are programmable i/o
       */
-    if (chan < 16) {
-        if (data[0] != INSN_CONFIG_DIO_QUERY)
-            return -EINVAL;
-    } else {
-        /* changing any channel in port 2 changes the entire port */
-        mask = 0xff0000;
-    }
+    if ((chan < 16) && (data[0] != INSN_CONFIG_DIO_QUERY))
+        return -EINVAL;
+
+    /* changing any channel in port 2 changes the entire port */
+    mask = 0xff0000;

      ret = comedi_dio_insn_config(dev, s, insn, data, mask);
      if (ret)

Seems correct.

Acked-by: Ian Abbott <abbotti@xxxxxxxxx>

Okay, as Hartley pointed out, it isn't correct, so I withdraw my "Acked-by".

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux