Skip to contentSkip to conversation

staging: comedi: drivers: Do not use | with a variable with value 0

PATCH In review Janani Ravichandran 2 participants 2 messages Feb 23, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: comedi: drivers: Do not use | with a variable with value 0

The variable events has a value equal to 0. There is no point combining it with other things with |. Semantic patch used:
@@
expression x, e, e1;
statement S;
@@

  if(x == 0) {
    ... when != x = e1
        when != while(...) S
	when != for(...;...;...) S

(
* x |= e
|
* x | e
)
... when any
}

---
 drivers/staging/comedi/drivers/amplc_pci230.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/amplc_pci230.c +1 -1
index 4b39f69..0c4d9fe 100644
@@ -1107,7 +1107,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
 		/* Check for FIFO underrun. */
 		if (dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) {
 			dev_err(dev->class_dev, "AO FIFO underrun\n");
-			events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+			events = COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
 		}
 		/*
 		 * Check for buffer underrun if FIFO less than half full
Signature · 1 line
2.5.0
#1 lore raw
Quoted 29 lines · Janani Ravichandran

The variable events has a value equal to 0. There is no point combining it with other things with |. Semantic patch used:
@@
expression x, e, e1;
statement S;
@@

  if(x == 0) {
    ... when != x = e1
        when != while(...) S
	when != for(...;...;...) S

(
* x |= e
|
* x | e
)
... when any
}

---
 drivers/staging/comedi/drivers/amplc_pci230.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/amplc_pci230.c +0 -0
index 4b39f69..0c4d9fe 100644

drivers/staging/comedi/drivers/amplc_pci230.c static bool pci230_handle_ao_fifo(struct comedi_device *dev, · line 1110

Quoted 5 lines
drivers/staging/comedi/drivers/amplc_pci230.c +1 -1
@@ -1107,7 +1107,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
 		/* Check for FIFO underrun. */
 		if (dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) {
 			dev_err(dev->class_dev, "AO FIFO underrun\n");
-			events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+			events = COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;

Maybe it's better as is, to keep the code simple and uniform.

julia

Quoted 13 lines
drivers/staging/comedi/drivers/amplc_pci230.c +0 -0
 		}
 		/*
 		 * Check for buffer underrun if FIFO less than half full
Signature · 8 lines
2.5.0

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160224005517.GA3677%40janani-Inspiron-3521.
For more options, visit https://groups.google.com/d/optout.