* [PATCH 4/6] staging: comedi: range: Merge if conditions
@ 2016-02-10 8:59 Amitoj Kaur Chawla
2016-02-10 9:11 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-10 8:59 UTC (permalink / raw)
To: outreachy-kernel
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>
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/staging/comedi/range.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
index ce3a58a..f5c63ab 100644
--- a/drivers/staging/comedi/range.c
+++ b/drivers/staging/comedi/range.c
@@ -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) {
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Outreachy kernel] [PATCH 4/6] staging: comedi: range: Merge if conditions
2016-02-10 8:59 [PATCH 4/6] staging: comedi: range: Merge if conditions Amitoj Kaur Chawla
@ 2016-02-10 9:11 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2016-02-10 9:11 UTC (permalink / raw)
To: Amitoj Kaur Chawla; +Cc: outreachy-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1640 bytes --]
On Wed, 10 Feb 2016, Amitoj Kaur Chawla wrote:
> 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>
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> drivers/staging/comedi/range.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
> index ce3a58a..f5c63ab 100644
> --- a/drivers/staging/comedi/range.c
> +++ b/drivers/staging/comedi/range.c
> @@ -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
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-10 9:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-10 8:59 [PATCH 4/6] staging: comedi: range: Merge if conditions Amitoj Kaur Chawla
2016-02-10 9:11 ` [Outreachy kernel] " Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.