Skip to contentSkip to conversation

staging: comedi: range: Merge if conditions

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

lore
Share & tools
lore
#0 lore raw

PATCH 4/6 staging: comedi: range: 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>

---
 drivers/staging/comedi/range.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/range.c +1 -3
index ce3a58a..f5c63ab 100644
@@ -67,9 +67,7 @@ int do_rangeinfo_ioctl(struct comedi_device *dev,
 	subd = (it.range_type >> 24) & 0xf;
 	chan = (it.range_type >> 16) & 0xff;
 
-	if (!dev->attached)
-		return -EINVAL;
-	if (subd >= dev->n_subdevices)
+	if (!dev->attached || (subd >= dev->n_subdevices))
 		return -EINVAL;
 	s = &dev->subdevices[subd];
 	if (s->range_table) {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 36 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>

---
 drivers/staging/comedi/range.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/range.c +0 -0
index ce3a58a..f5c63ab 100644

drivers/staging/comedi/range.c int do_rangeinfo_ioctl(struct comedi_device *dev, · line 70

Quoted 7 lines
drivers/staging/comedi/range.c +1 -3
@@ -67,9 +67,7 @@ int do_rangeinfo_ioctl(struct comedi_device *dev,
 	subd = (it.range_type >> 24) & 0xf;
 	chan = (it.range_type >> 16) & 0xff;
 
-	if (!dev->attached)
-		return -EINVAL;
-	if (subd >= dev->n_subdevices)
+	if (!dev->attached || (subd >= dev->n_subdevices))

You don´t need the parentheses.

julia

Quoted 13 lines
drivers/staging/comedi/range.c +0 -1
 		return -EINVAL;
 	s = &dev->subdevices[subd];
 	if (s->range_table) {
--

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