Skip to contentSkip to conversation

staging: comedi: drivers: comedi_8254: Merge if conditions

PATCH Superseded Amitoj Kaur Chawla 2 participants 2 messages Feb 10, 2016 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 staging: comedi: drivers: comedi_8254: Merge if conditions

Merge if conditions with the same statements.

Found using Coccinelle. The semantic patch used to find this is as follows:

//<smpl>
@@
statement S;
expression e,x;
@@

* if(e)
(
{ ... return ...; }
&
S
)

* if(x)
(
{ ... return ...; }
&
S
)
//</smpl>

---
Changes in v2:
-Merged if conditions instead of dropping them.

 drivers/staging/comedi/drivers/comedi_8254.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/comedi_8254.c +1 -3
index 0d5d56b..e00d467 100644
@@ -241,9 +241,7 @@ void comedi_8254_write(struct comedi_8254 *i8254,
 {
 	unsigned int byte;
 
-	if (counter > 2)
-		return;
-	if (val > 0xffff)
+	if ((counter > 2) || (val > 0xffff))
 		return;
 
 	/* load LSB then MSB */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 39 lines · Amitoj Kaur Chawla

Merge if conditions with the same statements.

Found using Coccinelle. The semantic patch used to find this is as follows:

//<smpl>
@@
statement S;
expression e,x;
@@

* if(e)
(
{ ... return ...; }
&
S
)

* if(x)
(
{ ... return ...; }
&
S
)
//</smpl>

---
Changes in v2:
-Merged if conditions instead of dropping them.

 drivers/staging/comedi/drivers/comedi_8254.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/comedi_8254.c +0 -0
index 0d5d56b..e00d467 100644

drivers/staging/comedi/drivers/comedi_8254.c void comedi_8254_write(struct comedi_8254 *i8254, · line 244

Quoted 7 lines
drivers/staging/comedi/drivers/comedi_8254.c +1 -3
@@ -241,9 +241,7 @@ void comedi_8254_write(struct comedi_8254 *i8254,
 {
 	unsigned int byte;
 
-	if (counter > 2)
-		return;
-	if (val > 0xffff)
+	if ((counter > 2) || (val > 0xffff))

The parentheses are not needed. || and && have lower precedence than the other operators.

julia

Quoted 13 lines
drivers/staging/comedi/drivers/comedi_8254.c +0 -1
 		return;
 
 	/* load LSB then MSB */
--

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/20160210101237.GA29034%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.