Skip to contentSkip to conversation

Staging: comedi: remove redundant bitwise OR assignment

PATCH In review Haneen Mohammed 2 participants 2 messages Mar 4, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: comedi: remove redundant bitwise OR assignment

No need to combine variable with value of 0 with other expressions using "|", for "0 | x = x". eg. if (x == 0) x |= e;
same as: if (x == 0) x = e;
Issue found using coccinelle.

---
 drivers/staging/comedi/drivers/amplc_pci230.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers/amplc_pci230.c +3 -3
index a977156..7930438 100644
@@ -1108,7 +1108,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
@@ -1118,7 +1118,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
 		if (num_scans == 0 &&
 		    (dacstat & PCI230P2_DAC_FIFO_HALF) == 0) {
 			dev_err(dev->class_dev, "AO buffer underrun\n");
-			events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+			events = COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
 		}
 	}
 	if (events == 0) {
@@ -1163,7 +1163,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
 		dacstat = inw(devpriv->daqio + PCI230_DACCON);
 		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;
 		}
 	}
 	async->events |= events;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 24 lines · Haneen Mohammed

No need to combine variable with value of 0 with other expressions using "|", for "0 | x = x". eg. if (x == 0) x |= e;
same as: if (x == 0) x = e;
Issue found using coccinelle.

---
 drivers/staging/comedi/drivers/amplc_pci230.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers/amplc_pci230.c +1 -1
index a977156..7930438 100644
@@ -1108,7 +1108,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

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

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

I think that this is not correct. If the then branch of the above if is taken, then events will not be 0 any more.

julia

Quoted 22 lines
drivers/staging/comedi/drivers/amplc_pci230.c +1 -2
 		}
 	}
 	if (events == 0) {
@@ -1163,7 +1163,7 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
 		dacstat = inw(devpriv->daqio + PCI230_DACCON);
 		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;
 		}
 	}
 	async->events |= events;
--

1.9.1

--
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/1425497904-13815-1-git-send-email-hamohammed.sa%40gmail.com.
For more options, visit https://groups.google.com/d/optout.