DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] staging: rtl8723bs: rtw_cmd: Compress lines for immediate return
@ 2020-03-25 21:22 Simran Singhal
  2020-03-30  6:47 ` [Outreachy kernel] " Stefano Brivio
  0 siblings, 1 reply; 2+ messages in thread
From: Simran Singhal @ 2020-03-25 21:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel, linux-kernel, outreachy-kernel

Compress two lines into a single line if immediate return statement is found.
It also removes variable cmd_obj as it is no longer needed.

It is done using script Coccinelle.
And coccinelle uses following semantic patch for this compression function:

@@
expression ret;
identifier f;
@@

-ret =
+return
     f(...);
-return ret;

Signed-off-by: Simran Singhal <singhalsimran0@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 744b40dd4cf0..42b0ea8abd9c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -362,11 +362,7 @@ int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
 
 struct	cmd_obj	*rtw_dequeue_cmd(struct cmd_priv *pcmdpriv)
 {
-	struct cmd_obj *cmd_obj;
-
-	cmd_obj = _rtw_dequeue_cmd(&pcmdpriv->cmd_queue);
-
-	return cmd_obj;
+	return _rtw_dequeue_cmd(&pcmdpriv->cmd_queue);
 }
 
 void rtw_free_cmd_obj(struct cmd_obj *pcmd)
-- 
2.17.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: rtl8723bs: rtw_cmd: Compress lines for immediate return
  2020-03-25 21:22 [PATCH] staging: rtl8723bs: rtw_cmd: Compress lines for immediate return Simran Singhal
@ 2020-03-30  6:47 ` " Stefano Brivio
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2020-03-30  6:47 UTC (permalink / raw)
  To: Simran Singhal; +Cc: devel, Greg Kroah-Hartman, linux-kernel, outreachy-kernel

On Thu, 26 Mar 2020 02:52:53 +0530
Simran Singhal <singhalsimran0@gmail.com> wrote:

> Compress two lines into a single line if immediate return statement is found.
> It also removes variable cmd_obj as it is no longer needed.
> 
> It is done using script Coccinelle.

This should be consistent. What does "it" refer to, now? If you start
with an imperative mode, switching to indicative makes it hard to
follow.

By the way, Coccinelle is not exactly a script. Saying something is
detected by Coccinelle is enough, you don't need to qualify that
further.

-- 
Stefano

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 21:22 [PATCH] staging: rtl8723bs: rtw_cmd: Compress lines for immediate return Simran Singhal
2020-03-30  6:47 ` [Outreachy kernel] " Stefano Brivio

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git