Skip to contentSkip to conversation

staging: comedi: Remove if condition.

PATCH In review Navya Sri Nizamkari 2 participants 2 messages Mar 3, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: comedi: Remove if condition.

This patch removes a if condition which has a semicolon after it. As the conditional check is redundant, the comment before it is also changed. The following coccinelle script was used to detect the pattern of a semicolon after if.

@r1@
position p;
@@
if (...);@p
@script:python@
p0 << r1.p;
@@
// Emacs org-mode output
cocci.print_main("", p0)
cocci.print_secs("", p0)

---
Changes in v2:
-Updated the commit subject and message.
-Removed the if-condition completely as
it was redundant.
-Changed the comment about the statements
which follow the if-condition.

 drivers/staging/comedi/drivers/das1800.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/das1800.c +1 -3
index 0790a28..8ffc9d0b 100644
@@ -491,9 +491,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
 
 	while (inb(dev->iobase + DAS1800_STATUS) & FNE) {
 		dpnt = inw(dev->iobase + DAS1800_FIFO);
-		/* convert to unsigned type if we are in a bipolar mode */
-		if (!unipolar)
-			;
+		/* convert to unsigned type */
 		dpnt = munge_bipolar_sample(dev, dpnt);
 		comedi_buf_write_samples(s, &dpnt, 1);
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Navya Sri Nizamkari

This patch removes a if condition which has a semicolon after it. As the conditional check is redundant, the comment before it is also changed. The following coccinelle script was used to detect the pattern of a semicolon after if.

Quoted 10 lines

@r1@
position p;
@@
if (...);@p
@script:python@
p0 << r1.p;
@@
// Emacs org-mode output
cocci.print_main("", p0)
cocci.print_secs("", p0)

A simpler way to do this is just

@@
@@

*if (...) ;

You will get a diff in which there is a - in front of each match. Of course you don't want to remove the matches, but it highlights the matched code and shows some context.

julia

Quoted 37 lines

---
Changes in v2:
-Updated the commit subject and message.
-Removed the if-condition completely as
it was redundant.
-Changed the comment about the statements
which follow the if-condition.

 drivers/staging/comedi/drivers/das1800.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/das1800.c +1 -4
index 0790a28..8ffc9d0b 100644
@@ -491,9 +491,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
 
 	while (inb(dev->iobase + DAS1800_STATUS) & FNE) {
 		dpnt = inw(dev->iobase + DAS1800_FIFO);
-		/* convert to unsigned type if we are in a bipolar mode */
-		if (!unipolar)
-			;
+		/* convert to unsigned type */
 		dpnt = munge_bipolar_sample(dev, dpnt);
 		comedi_buf_write_samples(s, &dpnt, 1);
 
--

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/20150303113806.GA8173%40localhost.
For more options, visit https://groups.google.com/d/optout.