LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: fieldbus: anybuss: Remove variables
@ 2019-05-24  6:03 Nishka Dasgupta
  2019-05-24  6:56 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Nishka Dasgupta @ 2019-05-24  6:03 UTC (permalink / raw)
  To: gregkh, thesven73, hofrat, devel, linux-kernel; +Cc: Nishka Dasgupta

The local variable cd, used in multiple functions, is immediately passed
to another function call, whose result is returned. As that is the only
use of cd, it can be replaced with its variable.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/staging/fieldbus/anybuss/host.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index f69dc4930457..9679cd0b737b 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1046,10 +1046,8 @@ EXPORT_SYMBOL_GPL(anybuss_start_init);
 
 int anybuss_finish_init(struct anybuss_client *client)
 {
-	struct anybuss_host *cd = client->host;
-
-	return _anybus_mbox_cmd(cd, CMD_END_INIT, false, NULL, 0,
-					NULL, 0, NULL, 0);
+	return _anybus_mbox_cmd(client->host, CMD_END_INIT, false, NULL, 0,
+				NULL, 0, NULL, 0);
 }
 EXPORT_SYMBOL_GPL(anybuss_finish_init);
 
@@ -1146,20 +1144,16 @@ EXPORT_SYMBOL_GPL(anybuss_send_msg);
 int anybuss_send_ext(struct anybuss_client *client, u16 cmd_num,
 		     const void *buf, size_t count)
 {
-	struct anybuss_host *cd = client->host;
-
-	return _anybus_mbox_cmd(cd, cmd_num, true, NULL, 0, NULL, 0,
-					buf, count);
+	return _anybus_mbox_cmd(client->host, cmd_num, true, NULL, 0, NULL, 0,
+				buf, count);
 }
 EXPORT_SYMBOL_GPL(anybuss_send_ext);
 
 int anybuss_recv_msg(struct anybuss_client *client, u16 cmd_num,
 		     void *buf, size_t count)
 {
-	struct anybuss_host *cd = client->host;
-
-	return _anybus_mbox_cmd(cd, cmd_num, true, NULL, 0, buf, count,
-					NULL, 0);
+	return _anybus_mbox_cmd(client->host, cmd_num, true, NULL, 0, buf,
+				count, NULL, 0);
 }
 EXPORT_SYMBOL_GPL(anybuss_recv_msg);
 
-- 
2.19.1


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

* Re: [PATCH] staging: fieldbus: anybuss: Remove variables
  2019-05-24  6:03 [PATCH] staging: fieldbus: anybuss: Remove variables Nishka Dasgupta
@ 2019-05-24  6:56 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-05-24  6:56 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: thesven73, hofrat, devel, linux-kernel

On Fri, May 24, 2019 at 11:33:28AM +0530, Nishka Dasgupta wrote:
> The local variable cd, used in multiple functions, is immediately passed
> to another function call, whose result is returned. As that is the only
> use of cd, it can be replaced with its variable.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/staging/fieldbus/anybuss/host.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)

Your subject line might say:
	"remove unneeded temporary variables"
or something like that?

> 
> diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
> index f69dc4930457..9679cd0b737b 100644
> --- a/drivers/staging/fieldbus/anybuss/host.c
> +++ b/drivers/staging/fieldbus/anybuss/host.c
> @@ -1046,10 +1046,8 @@ EXPORT_SYMBOL_GPL(anybuss_start_init);
>  
>  int anybuss_finish_init(struct anybuss_client *client)
>  {
> -	struct anybuss_host *cd = client->host;
> -
> -	return _anybus_mbox_cmd(cd, CMD_END_INIT, false, NULL, 0,
> -					NULL, 0, NULL, 0);
> +	return _anybus_mbox_cmd(client->host, CMD_END_INIT, false, NULL, 0,
> +				NULL, 0, NULL, 0);
>  }

While a potential change, this really doesn't help anything be it object
code size, or make anything easier to understand.

Again, don't change things just because a tool said it could be changed,
think about what you are doing and why it would, or would not, be
something that is worth doing.

thanks,

greg k-h

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

end of thread, other threads:[~2019-05-24  6:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24  6:03 [PATCH] staging: fieldbus: anybuss: Remove variables Nishka Dasgupta
2019-05-24  6:56 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).