Skip to contentSkip to conversation

staging: comedi: drivers: comedi_8254: Remove useless statements

PATCH In review Amitoj Kaur Chawla 3 participants 3 messages Feb 10, 2016 – Feb 12, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 staging: comedi: drivers: comedi_8254: Remove useless statements

Drop if conditions that have an unrequired return in a void function.

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>

---
 drivers/staging/comedi/drivers/comedi_8254.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/staging/comedi/drivers/comedi_8254.c +0 -5
index 0d5d56b..1feb2af 100644
@@ -241,11 +241,6 @@ void comedi_8254_write(struct comedi_8254 *i8254,
 {
 	unsigned int byte;
 
-	if (counter > 2)
-		return;
-	if (val > 0xffff)
-		return;
-
 	/* load LSB then MSB */
 	byte = val & 0xff;
 	__i8254_write(i8254, byte, counter);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 1 line · Amitoj Kaur Chawla

Drop if conditions that have an unrequired return in a void function.

Again, the return is needed, because it is not at the end of the function.

julia

Quoted 56 lines

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>

---
 drivers/staging/comedi/drivers/comedi_8254.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/staging/comedi/drivers/comedi_8254.c +0 -6
index 0d5d56b..1feb2af 100644
@@ -241,11 +241,6 @@ void comedi_8254_write(struct comedi_8254 *i8254,
 {
 	unsigned int byte;
 
-	if (counter > 2)
-		return;
-	if (val > 0xffff)
-		return;
-
 	/* load LSB then MSB */
 	byte = val & 0xff;
 	__i8254_write(i8254, byte, counter);
--

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

maintainer
#2 lore raw
In reply to Amitoj Kaur Chawla
Quoted 36 lines · Amitoj Kaur Chawla

Drop if conditions that have an unrequired return in a void function.

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>

---
 drivers/staging/comedi/drivers/comedi_8254.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/staging/comedi/drivers/comedi_8254.c +0 -0
index 0d5d56b..1feb2af 100644

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

Quoted 5 lines
drivers/staging/comedi/drivers/comedi_8254.c +0 -2
@@ -241,11 +241,6 @@ void comedi_8254_write(struct comedi_8254 *i8254,
 {
 	unsigned int byte;
 
-	if (counter > 2)
-		return;

I don't understand, why did you change the logic of the code here?

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

Quoted 2 lines
drivers/staging/comedi/drivers/comedi_8254.c +0 -2
-	if (val > 0xffff)
-		return;

And here? This code was doing something useful, why must it be removed?

confused,

greg k-h