* [PATCH 1/11] USB: kl5kusb105: Remove useless return variables
@ 2014-05-31 13:14 Peter Senna Tschudin
2014-05-31 14:58 ` Johan Hovold
2014-05-31 21:17 ` Sergei Shtylyov
0 siblings, 2 replies; 6+ messages in thread
From: Peter Senna Tschudin @ 2014-05-31 13:14 UTC (permalink / raw)
To: Oliver Neukum
Cc: kernel-janitors, Johan Hovold, Greg Kroah-Hartman, linux-usb,
linux-kernel
This patch remove variables that are initialized with a constant,
are never updated, and are only used as parameter of return.
Return the constant instead of using a variable.
Verified by compilation only.
The coccinelle script that find and fixes this issue is:
// <smpl>
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
when strict
return
- ret
+ C
;
// </smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
drivers/usb/serial/kl5kusb105.c | 23 +----------------------
1 file changed, 1 insertion(+), 22 deletions(-)
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index d7440b7..2657c00 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -605,28 +605,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)
static int klsi_105_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
{
- int retval = -EINVAL;
-
-/* if this ever gets implemented, it should be done something like this:
- struct usb_serial *serial = port->serial;
- struct klsi_105_private *priv = usb_get_serial_port_data(port);
- unsigned long flags;
- int control;
-
- spin_lock_irqsave (&priv->lock, flags);
- if (set & TIOCM_RTS)
- priv->control_state |= TIOCM_RTS;
- if (set & TIOCM_DTR)
- priv->control_state |= TIOCM_DTR;
- if (clear & TIOCM_RTS)
- priv->control_state &= ~TIOCM_RTS;
- if (clear & TIOCM_DTR)
- priv->control_state &= ~TIOCM_DTR;
- control = priv->control_state;
- spin_unlock_irqrestore (&priv->lock, flags);
- retval = mct_u232_set_modem_ctrl(serial, control);
-*/
- return retval;
+ return -EINVAL;
}
module_usb_serial_driver(serial_drivers, id_table);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/11] USB: kl5kusb105: Remove useless return variables
2014-05-31 13:14 [PATCH 1/11] USB: kl5kusb105: Remove useless return variables Peter Senna Tschudin
@ 2014-05-31 14:58 ` Johan Hovold
2014-05-31 16:05 ` Peter Senna Tschudin
2014-05-31 21:17 ` Sergei Shtylyov
1 sibling, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2014-05-31 14:58 UTC (permalink / raw)
To: Peter Senna Tschudin
Cc: Oliver Neukum, kernel-janitors, Johan Hovold, Greg Kroah-Hartman,
linux-usb, linux-kernel
On Sat, May 31, 2014 at 10:14:01AM -0300, Peter Senna Tschudin wrote:
> This patch remove variables that are initialized with a constant,
> are never updated, and are only used as parameter of return.
> Return the constant instead of using a variable.
>
> Verified by compilation only.
>
> The coccinelle script that find and fixes this issue is:
> // <smpl>
> @@
> type T;
> constant C;
> identifier ret;
> @@
> - T ret = C;
> ... when != ret
> when strict
> return
> - ret
> + C
> ;
> // </smpl>
>
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
>
> ---
> drivers/usb/serial/kl5kusb105.c | 23 +----------------------
> 1 file changed, 1 insertion(+), 22 deletions(-)
>
> diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
> index d7440b7..2657c00 100644
> --- a/drivers/usb/serial/kl5kusb105.c
> +++ b/drivers/usb/serial/kl5kusb105.c
> @@ -605,28 +605,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)
> static int klsi_105_tiocmset(struct tty_struct *tty,
> unsigned int set, unsigned int clear)
> {
> - int retval = -EINVAL;
> -
> -/* if this ever gets implemented, it should be done something like this:
> - struct usb_serial *serial = port->serial;
> - struct klsi_105_private *priv = usb_get_serial_port_data(port);
> - unsigned long flags;
> - int control;
> -
> - spin_lock_irqsave (&priv->lock, flags);
> - if (set & TIOCM_RTS)
> - priv->control_state |= TIOCM_RTS;
> - if (set & TIOCM_DTR)
> - priv->control_state |= TIOCM_DTR;
> - if (clear & TIOCM_RTS)
> - priv->control_state &= ~TIOCM_RTS;
> - if (clear & TIOCM_DTR)
> - priv->control_state &= ~TIOCM_DTR;
> - control = priv->control_state;
> - spin_unlock_irqrestore (&priv->lock, flags);
> - retval = mct_u232_set_modem_ctrl(serial, control);
> -*/
> - return retval;
> + return -EINVAL;
Your patch does a bit more than what the description says, although
removing this out-commented code would be perfectly fine.
But please just remove the entire function (and the corresponding entry
in the struct usb_serial_driver) and update the commit message.
Thanks,
Johan
> }
>
> module_usb_serial_driver(serial_drivers, id_table);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/11] USB: kl5kusb105: Remove useless return variables
2014-05-31 14:58 ` Johan Hovold
@ 2014-05-31 16:05 ` Peter Senna Tschudin
0 siblings, 0 replies; 6+ messages in thread
From: Peter Senna Tschudin @ 2014-05-31 16:05 UTC (permalink / raw)
To: Johan Hovold
Cc: Oliver Neukum, kernel-janitors, Greg Kroah-Hartman, linux-usb,
linux-kernel
On Sat, May 31, 2014 at 11:58 AM, Johan Hovold <jhovold@gmail.com> wrote:
> On Sat, May 31, 2014 at 10:14:01AM -0300, Peter Senna Tschudin wrote:
>> This patch remove variables that are initialized with a constant,
>> are never updated, and are only used as parameter of return.
>> Return the constant instead of using a variable.
>>
>> Verified by compilation only.
>>
>> The coccinelle script that find and fixes this issue is:
>> // <smpl>
>> @@
>> type T;
>> constant C;
>> identifier ret;
>> @@
>> - T ret = C;
>> ... when != ret
>> when strict
>> return
>> - ret
>> + C
>> ;
>> // </smpl>
>>
>> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
>>
>> ---
>> drivers/usb/serial/kl5kusb105.c | 23 +----------------------
>> 1 file changed, 1 insertion(+), 22 deletions(-)
>>
>> diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
>> index d7440b7..2657c00 100644
>> --- a/drivers/usb/serial/kl5kusb105.c
>> +++ b/drivers/usb/serial/kl5kusb105.c
>> @@ -605,28 +605,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)
>> static int klsi_105_tiocmset(struct tty_struct *tty,
>> unsigned int set, unsigned int clear)
>> {
>> - int retval = -EINVAL;
>> -
>> -/* if this ever gets implemented, it should be done something like this:
>> - struct usb_serial *serial = port->serial;
>> - struct klsi_105_private *priv = usb_get_serial_port_data(port);
>> - unsigned long flags;
>> - int control;
>> -
>> - spin_lock_irqsave (&priv->lock, flags);
>> - if (set & TIOCM_RTS)
>> - priv->control_state |= TIOCM_RTS;
>> - if (set & TIOCM_DTR)
>> - priv->control_state |= TIOCM_DTR;
>> - if (clear & TIOCM_RTS)
>> - priv->control_state &= ~TIOCM_RTS;
>> - if (clear & TIOCM_DTR)
>> - priv->control_state &= ~TIOCM_DTR;
>> - control = priv->control_state;
>> - spin_unlock_irqrestore (&priv->lock, flags);
>> - retval = mct_u232_set_modem_ctrl(serial, control);
>> -*/
>> - return retval;
>> + return -EINVAL;
>
> Your patch does a bit more than what the description says, although
> removing this out-commented code would be perfectly fine.
Sorry for that, my fault.
>
> But please just remove the entire function (and the corresponding entry
> in the struct usb_serial_driver) and update the commit message.
Sent V2.
>
> Thanks,
> Johan
>
>> }
>>
>> module_usb_serial_driver(serial_drivers, id_table);
>>
--
Peter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/11] USB: kl5kusb105: Remove useless return variables
2014-05-31 13:14 [PATCH 1/11] USB: kl5kusb105: Remove useless return variables Peter Senna Tschudin
2014-05-31 14:58 ` Johan Hovold
@ 2014-05-31 21:17 ` Sergei Shtylyov
2014-05-31 21:21 ` Peter Senna Tschudin
1 sibling, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2014-05-31 21:17 UTC (permalink / raw)
To: Peter Senna Tschudin, Oliver Neukum
Cc: kernel-janitors, Johan Hovold, Greg Kroah-Hartman, linux-usb,
linux-kernel
Hello.
On 05/31/2014 05:14 PM, Peter Senna Tschudin wrote:
> This patch remove variables that are initialized with a constant,
> are never updated, and are only used as parameter of return.
> Return the constant instead of using a variable.
The patch does more than just that, it also removes commented out code.
> Verified by compilation only.
[...]
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/11] USB: kl5kusb105: Remove useless return variables
2014-05-31 21:17 ` Sergei Shtylyov
@ 2014-05-31 21:21 ` Peter Senna Tschudin
2014-05-31 21:24 ` Sergei Shtylyov
0 siblings, 1 reply; 6+ messages in thread
From: Peter Senna Tschudin @ 2014-05-31 21:21 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Oliver Neukum, kernel-janitors, Johan Hovold, Greg Kroah-Hartman,
linux-usb, linux-kernel
On Sat, May 31, 2014 at 6:17 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> Hello.
>
>
> On 05/31/2014 05:14 PM, Peter Senna Tschudin wrote:
>
>> This patch remove variables that are initialized with a constant,
>> are never updated, and are only used as parameter of return.
>> Return the constant instead of using a variable.
>
>
> The patch does more than just that, it also removes commented out code.
That was my fault. It was fixed on V2:
http://marc.info/?l=kernel-janitors&m=140155221232137&w=2
>
>> Verified by compilation only.
>
>
> [...]
>
>
>> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
>
>
> WBR, Sergei
>
>
--
Peter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/11] USB: kl5kusb105: Remove useless return variables
2014-05-31 21:21 ` Peter Senna Tschudin
@ 2014-05-31 21:24 ` Sergei Shtylyov
0 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2014-05-31 21:24 UTC (permalink / raw)
To: Peter Senna Tschudin
Cc: Oliver Neukum, kernel-janitors, Johan Hovold, Greg Kroah-Hartman,
linux-usb, linux-kernel
Hello.
On 06/01/2014 01:21 AM, Peter Senna Tschudin wrote:
>>> This patch remove variables that are initialized with a constant,
>>> are never updated, and are only used as parameter of return.
>>> Return the constant instead of using a variable.
>> The patch does more than just that, it also removes commented out code.
> That was my fault. It was fixed on V2:
> http://marc.info/?l=kernel-janitors&m=140155221232137&w=2
Yes, I forgot to look at the follow-ups before replying.
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-31 21:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-31 13:14 [PATCH 1/11] USB: kl5kusb105: Remove useless return variables Peter Senna Tschudin
2014-05-31 14:58 ` Johan Hovold
2014-05-31 16:05 ` Peter Senna Tschudin
2014-05-31 21:17 ` Sergei Shtylyov
2014-05-31 21:21 ` Peter Senna Tschudin
2014-05-31 21:24 ` Sergei Shtylyov
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).