staging: comedi: comedi_fops: Remove useless statements
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
@@ -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
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>Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/comedi/comedi_fops.c | 6 ------ 1 file changed, 6 deletions(-)drivers/staging/comedi/comedi_fops.c +0
-7@@ -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.
Greg KH
maintainerQuoted 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>Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/staging/comedi/comedi_fops.c | 6 ------ 1 file changed, 6 deletions(-)drivers/staging/comedi/comedi_fops.c +0
-0
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