linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable
@ 2022-09-12 13:38 cgel.zte
  2022-09-12 14:05 ` Greg KH
  2022-09-12 14:06 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: cgel.zte @ 2022-09-12 13:38 UTC (permalink / raw)
  To: johan; +Cc: gregkh, linux-usb, linux-kernel, Xu Panda, Zeal Robot

From: Xu Panda <xu.panda@zte.com.cn>

Return the value usb_control_msg() directly instead of storing
it in another redundant variable.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
---
 drivers/usb/serial/ftdi_sio.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0a1da579ead5..f02dcef69cb9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1394,7 +1394,6 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
        u16 value;
        u16 index;
        u32 index_value;
-       int rv;

        index_value = get_ftdi_divisor(tty, port);
        value = (u16)index_value;
@@ -1407,13 +1406,12 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
                index = (u16)((index << 8) | priv->interface);
        }

-       rv = usb_control_msg(port->serial->dev,
-                           usb_sndctrlpipe(port->serial->dev, 0),
-                           FTDI_SIO_SET_BAUDRATE_REQUEST,
-                           FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
-                           value, index,
-                           NULL, 0, WDR_SHORT_TIMEOUT);
-       return rv;
+       return usb_control_msg(port->serial->dev,
+                              usb_sndctrlpipe(port->serial->dev, 0),
+                              FTDI_SIO_SET_BAUDRATE_REQUEST,
+                              FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
+                              value, index,
+                              NULL, 0, WDR_SHORT_TIMEOUT);
 }

 static int write_latency_timer(struct usb_serial_port *port)
-- 
2.15.2


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

* Re: [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable
  2022-09-12 13:38 [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable cgel.zte
@ 2022-09-12 14:05 ` Greg KH
  2022-09-12 14:17   ` Johan Hovold
  2022-09-12 14:06 ` Greg KH
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2022-09-12 14:05 UTC (permalink / raw)
  To: cgel.zte; +Cc: johan, linux-usb, linux-kernel, Xu Panda, Zeal Robot

On Mon, Sep 12, 2022 at 01:38:27PM +0000, cgel.zte@gmail.com wrote:
> From: Xu Panda <xu.panda@zte.com.cn>
> 
> Return the value usb_control_msg() directly instead of storing
> it in another redundant variable.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> ---
>  drivers/usb/serial/ftdi_sio.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index 0a1da579ead5..f02dcef69cb9 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1394,7 +1394,6 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
>         u16 value;
>         u16 index;
>         u32 index_value;
> -       int rv;
> 
>         index_value = get_ftdi_divisor(tty, port);
>         value = (u16)index_value;
> @@ -1407,13 +1406,12 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
>                 index = (u16)((index << 8) | priv->interface);
>         }
> 
> -       rv = usb_control_msg(port->serial->dev,
> -                           usb_sndctrlpipe(port->serial->dev, 0),
> -                           FTDI_SIO_SET_BAUDRATE_REQUEST,
> -                           FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
> -                           value, index,
> -                           NULL, 0, WDR_SHORT_TIMEOUT);
> -       return rv;
> +       return usb_control_msg(port->serial->dev,
> +                              usb_sndctrlpipe(port->serial->dev, 0),
> +                              FTDI_SIO_SET_BAUDRATE_REQUEST,
> +                              FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
> +                              value, index,
> +                              NULL, 0, WDR_SHORT_TIMEOUT);
>  }

That's really not the correct use of the return value of
usb_control_msg().  Can you fix this up to properly handle the return
value, or better yet, use the usb_control_msg_send() call?

thanks,

greg k-h

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

* Re: [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable
  2022-09-12 13:38 [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable cgel.zte
  2022-09-12 14:05 ` Greg KH
@ 2022-09-12 14:06 ` Greg KH
  1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2022-09-12 14:06 UTC (permalink / raw)
  To: cgel.zte; +Cc: johan, linux-usb, linux-kernel, Xu Panda, Zeal Robot

On Mon, Sep 12, 2022 at 01:38:27PM +0000, cgel.zte@gmail.com wrote:
> From: Xu Panda <xu.panda@zte.com.cn>
> 
> Return the value usb_control_msg() directly instead of storing
> it in another redundant variable.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> ---

Also, as stated numerous times to your team, I can not accept patches
like this because of the previous issues have not been resolved at all
(email, ignoring the researcher rules, etc.)

Please fix that up first if you wish to have patches accepted.

thanks,

greg k-h

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

* Re: [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable
  2022-09-12 14:05 ` Greg KH
@ 2022-09-12 14:17   ` Johan Hovold
  2022-09-12 14:33     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2022-09-12 14:17 UTC (permalink / raw)
  To: Greg KH; +Cc: cgel.zte, linux-usb, linux-kernel, Xu Panda, Zeal Robot

On Mon, Sep 12, 2022 at 04:05:39PM +0200, Greg Kroah-Hartman wrote:
> On Mon, Sep 12, 2022 at 01:38:27PM +0000, cgel.zte@gmail.com wrote:
> > From: Xu Panda <xu.panda@zte.com.cn>
> > 
> > Return the value usb_control_msg() directly instead of storing
> > it in another redundant variable.
> > 
> > Reported-by: Zeal Robot <zealci@zte.com.cn>
> > Signed-off-by: Xu Panda <xu.panda@zte.com.cn>

> > -       rv = usb_control_msg(port->serial->dev,
> > -                           usb_sndctrlpipe(port->serial->dev, 0),
> > -                           FTDI_SIO_SET_BAUDRATE_REQUEST,
> > -                           FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
> > -                           value, index,
> > -                           NULL, 0, WDR_SHORT_TIMEOUT);
> > -       return rv;
> > +       return usb_control_msg(port->serial->dev,
> > +                              usb_sndctrlpipe(port->serial->dev, 0),
> > +                              FTDI_SIO_SET_BAUDRATE_REQUEST,
> > +                              FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
> > +                              value, index,
> > +                              NULL, 0, WDR_SHORT_TIMEOUT);
> >  }
> 
> That's really not the correct use of the return value of
> usb_control_msg().  Can you fix this up to properly handle the return
> value, or better yet, use the usb_control_msg_send() call?

It is actually correct since the buffer length is zero here (i.e. it
returns a negative errno or 0).

But I'm also ignoring patches from this email address as it is used by
multiple users, and of which none so far has replied to feedback (as if
it's all automated).

Johan

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

* Re: [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable
  2022-09-12 14:17   ` Johan Hovold
@ 2022-09-12 14:33     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2022-09-12 14:33 UTC (permalink / raw)
  To: Johan Hovold; +Cc: cgel.zte, linux-usb, linux-kernel, Xu Panda, Zeal Robot

On Mon, Sep 12, 2022 at 04:17:26PM +0200, Johan Hovold wrote:
> On Mon, Sep 12, 2022 at 04:05:39PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, Sep 12, 2022 at 01:38:27PM +0000, cgel.zte@gmail.com wrote:
> > > From: Xu Panda <xu.panda@zte.com.cn>
> > > 
> > > Return the value usb_control_msg() directly instead of storing
> > > it in another redundant variable.
> > > 
> > > Reported-by: Zeal Robot <zealci@zte.com.cn>
> > > Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> 
> > > -       rv = usb_control_msg(port->serial->dev,
> > > -                           usb_sndctrlpipe(port->serial->dev, 0),
> > > -                           FTDI_SIO_SET_BAUDRATE_REQUEST,
> > > -                           FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
> > > -                           value, index,
> > > -                           NULL, 0, WDR_SHORT_TIMEOUT);
> > > -       return rv;
> > > +       return usb_control_msg(port->serial->dev,
> > > +                              usb_sndctrlpipe(port->serial->dev, 0),
> > > +                              FTDI_SIO_SET_BAUDRATE_REQUEST,
> > > +                              FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
> > > +                              value, index,
> > > +                              NULL, 0, WDR_SHORT_TIMEOUT);
> > >  }
> > 
> > That's really not the correct use of the return value of
> > usb_control_msg().  Can you fix this up to properly handle the return
> > value, or better yet, use the usb_control_msg_send() call?
> 
> It is actually correct since the buffer length is zero here (i.e. it
> returns a negative errno or 0).

Yeah, that's a hack :)

> But I'm also ignoring patches from this email address as it is used by
> multiple users, and of which none so far has replied to feedback (as if
> it's all automated).

Great, that's the correct thing to do here, thanks.

greg k-h

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

end of thread, other threads:[~2022-09-12 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-12 13:38 [PATCH linux-next] USB: serial: ftdi_sio: remove the unneeded result variable cgel.zte
2022-09-12 14:05 ` Greg KH
2022-09-12 14:17   ` Johan Hovold
2022-09-12 14:33     ` Greg KH
2022-09-12 14:06 ` 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).