Skip to contentSkip to conversation

staging: comedi: comedi_fops: 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 3/6 staging: comedi: comedi_fops: 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/comedi_fops.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/staging/comedi/comedi_fops.c +0 -6
index d6bcf73..35e79d7 100644
@@ -2811,12 +2811,6 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
 {
 	unsigned int i;
 
-	if (!s)
-		return;
-	if (s->minor < COMEDI_NUM_BOARD_MINORS ||
-	    s->minor >= COMEDI_NUM_MINORS)
-		return;
-
 	i = s->minor - COMEDI_NUM_BOARD_MINORS;
 	mutex_lock(&comedi_subdevice_minor_table_lock);
 	if (s == comedi_subdevice_minor_table[i])
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.

The return is needed if it doesn´t come at the end of the function. You want to skip over the rest of the code.

julia

Quoted 57 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/comedi_fops.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/staging/comedi/comedi_fops.c +0 -7
index d6bcf73..35e79d7 100644
@@ -2811,12 +2811,6 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
 {
 	unsigned int i;
 
-	if (!s)
-		return;
-	if (s->minor < COMEDI_NUM_BOARD_MINORS ||
-	    s->minor >= COMEDI_NUM_MINORS)
-		return;
-
 	i = s->minor - COMEDI_NUM_BOARD_MINORS;
 	mutex_lock(&comedi_subdevice_minor_table_lock);
 	if (s == comedi_subdevice_minor_table[i])
--

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/20160210085922.GA14616%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/comedi_fops.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/staging/comedi/comedi_fops.c +0 -0
index d6bcf73..35e79d7 100644

drivers/staging/comedi/comedi_fops.c void comedi_free_subdevice_minor(struct comedi_subdevice *s) · line 2819

Quoted 9 lines
drivers/staging/comedi/comedi_fops.c +0 -6
@@ -2811,12 +2811,6 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
 {
 	unsigned int i;
 
-	if (!s)
-		return;
-	if (s->minor < COMEDI_NUM_BOARD_MINORS ||
-	    s->minor >= COMEDI_NUM_MINORS)
-		return;
-

And you just crashed the kernel :(

not good...

Please be more careful.

greg k-h