staging: comedi: comedi_fops: Merge if conditions
PATCH v2 2/5 staging: comedi: comedi_fops: 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>
---
Changes in v2:
-Merged Patch 2/6 and 3/6 of first version by not dropping if
conditions and only merging them for the same file.
drivers/staging/comedi/comedi_fops.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/staging/comedi/comedi_fops.c +3 -11
@@ -795,9 +795,7 @@ static int is_device_busy(struct comedi_device *dev)for (i =0 ; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; -if (s->busy) -return 1 ; -if (s->async &&comedi_buf_is_mmapped (s)) +if (s->busy || (s->async &&comedi_buf_is_mmapped (s)))return 1 ; }
@@ -2216,11 +2214,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) } size = vma->vm_end - vma->vm_start; -if (size > async->prealloc_bufsz) { - retval = -EFAULT ; - goto done; - } -if (size & (~PAGE_MASK )) { +if ((size > async->prealloc_bufsz) || (size & (~PAGE_MASK ))) { retval = -EFAULT ; goto done; }
@@ -2817,9 +2811,7 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s) {unsigned int i; -if (!s) -return ; -if (s->minor <COMEDI_NUM_BOARD_MINORS || +if (!s || s->minor <COMEDI_NUM_BOARD_MINORS || s->minor >=COMEDI_NUM_MINORS )return ;
Signature · 1 line
1.9.1
Quoted 40 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>Signed-off-by Amitoj Kaur Chawla <[email protected]>---
Changes in v2:
-Merged Patch 2/6 and 3/6 of first version by not dropping if
conditions and only merging them for the same file.drivers/staging/comedi/comedi_fops.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)drivers/staging/comedi/comedi_fops.c +0
-0
drivers/staging/comedi/comedi_fops.c static int is_device_busy(struct comedi_device *dev) · line 798
Quoted 7 lines
drivers/staging/comedi/comedi_fops.c +1
-3@@ -795,9 +795,7 @@ static int is_device_busy(struct comedi_device *dev)for (i =0 ; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; -if (s->busy) -return 1 ; -if (s->async &&comedi_buf_is_mmapped (s)) +if (s->busy || (s->async &&comedi_buf_is_mmapped (s)))
These parentheses are ok to keep.
drivers/staging/comedi/comedi_fops.c static int comedi_mmap(struct file *file, struct vm_area_struct *vma) · line 2217
Quoted 13 lines
drivers/staging/comedi/comedi_fops.c +1
-5return 1 ; }@@ -2216,11 +2214,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) } size = vma->vm_end - vma->vm_start; -if (size > async->prealloc_bufsz) { - retval = -EFAULT ; - goto done; - } -if (size & (~PAGE_MASK )) { +if ((size > async->prealloc_bufsz) || (size & (~PAGE_MASK ))) {
These aren't needed.
julia
Quoted 24 lines
drivers/staging/comedi/comedi_fops.c +1
-4retval = -EFAULT ; goto done; }@@ -2817,9 +2811,7 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s) {unsigned int i; -if (!s) -return ; -if (s->minor <COMEDI_NUM_BOARD_MINORS || +if (!s || s->minor <COMEDI_NUM_BOARD_MINORS || s->minor >=COMEDI_NUM_MINORS )return ; --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/20160210101249.GA29055%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.