Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1683901 > unrolled thread

[PATCH] usb: isp1760: compress return logic into one line

Started by"Gustavo A. R. Silva" <garsilva@embeddedor.com>
First post2017-07-10 04:10 +0200
Last post2017-07-11 10:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: isp1760: compress return logic into one line "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-10 04:10 +0200
    Re: [PATCH] usb: isp1760: compress return logic into one line Oliver Neukum <oneukum@suse.com> - 2017-07-10 09:40 +0200
      Re: [PATCH] usb: isp1760: compress return logic into one line "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-10 22:30 +0200
        Re: [PATCH] usb: isp1760: compress return logic into one line Oliver Neukum <oneukum@suse.com> - 2017-07-11 10:20 +0200

#1683901 — [PATCH] usb: isp1760: compress return logic into one line

From"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Date2017-07-10 04:10 +0200
Subject[PATCH] usb: isp1760: compress return logic into one line
Message-ID<u1wj7-7ix-11@gated-at.bofh.it>
Simplify return logic to avoid unnecessary variable assignment.

This issue was detected using Coccinelle and the following
semantic patch:

@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/usb/isp1760/isp1760-hcd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index ac31d19..8e59e0c 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -396,7 +396,6 @@ static int handshake(struct usb_hcd *hcd, u32 reg,
 /* reset a non-running (STS_HALT == 1) controller */
 static int ehci_reset(struct usb_hcd *hcd)
 {
-	int retval;
 	struct isp1760_hcd *priv = hcd_to_priv(hcd);
 
 	u32 command = reg_read32(hcd->regs, HC_USBCMD);
@@ -405,9 +404,8 @@ static int ehci_reset(struct usb_hcd *hcd)
 	reg_write32(hcd->regs, HC_USBCMD, command);
 	hcd->state = HC_STATE_HALT;
 	priv->next_statechange = jiffies;
-	retval = handshake(hcd, HC_USBCMD,
-			    CMD_RESET, 0, 250 * 1000);
-	return retval;
+
+	return handshake(hcd, HC_USBCMD, CMD_RESET, 0, 250 * 1000);
 }
 
 static struct isp1760_qh *qh_alloc(gfp_t flags)
-- 
2.5.0

[toc] | [next] | [standalone]


#1684012

FromOliver Neukum <oneukum@suse.com>
Date2017-07-10 09:40 +0200
Message-ID<u1Bst-236-3@gated-at.bofh.it>
In reply to#1683901
Am Sonntag, den 09.07.2017, 21:00 -0500 schrieb  Gustavo A. R. Silva :
> Simplify return logic to avoid unnecessary variable assignment.
> 
> This issue was detected using Coccinelle and the following
> semantic patch:
> 

Hi,

I need to ask: Where is the improvement? The compiler does not bother
and for the human reader you do not do anything obvious and you
decreased grepability.

	Regards
		Oliver

[toc] | [prev] | [next] | [standalone]


#1684620

From"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Date2017-07-10 22:30 +0200
Message-ID<u1NtE-1hE-15@gated-at.bofh.it>
In reply to#1684012
Hi Oliver,

Quoting Oliver Neukum <oneukum@suse.com>:

> Am Sonntag, den 09.07.2017, 21:00 -0500 schrieb  Gustavo A. R. Silva :
>> Simplify return logic to avoid unnecessary variable assignment.
>>
>> This issue was detected using Coccinelle and the following
>> semantic patch:
>>
>
> Hi,
>
> I need to ask: Where is the improvement? The compiler does not bother
> and for the human reader you do not do anything obvious and you
> decreased grepability.
>

The declaration of local variable _retval_ was removed also.
So both, variable declaration and assignment removal are the improvements.

Regarding the greability, I think that depends on the context.

Thanks!
--
Gustavo A. R. Silva

[toc] | [prev] | [next] | [standalone]


#1684871

FromOliver Neukum <oneukum@suse.com>
Date2017-07-11 10:20 +0200
Message-ID<u1YyJ-8ip-3@gated-at.bofh.it>
In reply to#1684620
Am Montag, den 10.07.2017, 14:58 -0500 schrieb  Gustavo A. R. Silva :
> Hi Oliver,
> 
> Quoting Oliver Neukum <oneukum@suse.com>:
> 
> > 
> > Am Sonntag, den 09.07.2017, 21:00 -0500 schrieb  Gustavo A. R. Silva :
> > > 
> > > Simplify return logic to avoid unnecessary variable assignment.
> > > 
> > > This issue was detected using Coccinelle and the following
> > > semantic patch:
> > > 
> > 
> > Hi,
> > 
> > I need to ask: Where is the improvement? The compiler does not bother
> > and for the human reader you do not do anything obvious and you
> > decreased grepability.
> > 
> 
> The declaration of local variable _retval_ was removed also.
> So both, variable declaration and assignment removal are the improvements.

Yeah, but a variable called "retval" has an extremely clear function.
Simplifying code is an improvement. Making it clearer is an
improvement.
I am sorry but the proposed change is almost like removing blank lines
to make it more compact

> Regarding the greability, I think that depends on the context.

"retval" has a clear function and is unique.

	Regards
		Oliver

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web