Staging:dgap :Compression of lines for immediate return
diff mbox series

Message ID 20150726173413.GA30485@shraddha-370R4E-370R4V-370R5E-3570RE-370R5V
State New, archived
Headers show
Series
  • Staging:dgap :Compression of lines for immediate return
Related show

Commit Message

Shraddha Barke July 26, 2015, 5:34 p.m. UTC
This patch compresses two lines into a single line if immediate return statement
is found. Also,remove variable rc as it is no longer needed.
It is done using tool Coccinelle. And semantic patch used for this is as follows:

@@
expression ret;
identifier f;
@@

-ret =
+return
     f(...);
-return ret;
---
 drivers/staging/dgap/dgap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Joe Perches July 26, 2015, 7:39 p.m. UTC | #1
On Sun, 2015-07-26 at 23:04 +0530, Shraddha Barke wrote:
> This patch compresses two lines into a single line if immediate return statement
> is found. Also,remove variable rc as it is no longer needed.
> It is done using tool Coccinelle. And semantic patch used for this is as follows:
> 
> @@
> expression ret;
> identifier f;
> @@
> -ret =
> +return
>      f(...);
> -return ret;

This isn't an always safe or side-effect free
semantic patch as there may be a cast lost by
such a conversion.

int foo(void)
{
	char i = 0xffffffff;
	return i;
}

where i is now int not char

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Sudip Mukherjee July 27, 2015, 4:30 a.m. UTC | #2
On Sun, Jul 26, 2015 at 11:04:13PM +0530, Shraddha Barke wrote:
> This patch compresses two lines into a single line if immediate return statement
> is found. Also,remove variable rc as it is no longer needed.
> It is done using tool Coccinelle. And semantic patch used for this is as follows:
> 
> @@
> expression ret;
> identifier f;
> @@
> 
> -ret =
> +return
>      f(...);
> -return ret;
> ---
Missed the Signed-off-by: here also, and always add the maintainers in
your To: list.

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Patch
diff mbox series

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 26b0446..2bb6c68 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -4953,9 +4953,8 @@  static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 		spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
 		spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
 
-		rc = put_user(C_CLOCAL(tty) ? 1 : 0,
+		return put_user(C_CLOCAL(tty) ? 1 : 0,
 				(unsigned long __user *) arg);
-		return rc;
 
 	case TIOCSSOFTCAR:
 		spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);