All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Peter Chen <peter.chen@nxp.com>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Peter Senna Tschudin <peter.senna@gmail.com>
Subject: Re: [PATCH] usb: misc: add a missing continue and refactor code
Date: Tue, 21 Feb 2017 20:40:53 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1702212036090.16103-100000@netrider.rowland.org> (raw)
In-Reply-To: <20170221231708.GA8073@embeddedgus>

On Tue, 21 Feb 2017, Gustavo A. R. Silva wrote:

> Code refactoring to make the flow easier to follow and add missing
> 'continue' for case USB_ENDPOINT_XFER_INT.
> 
> Addresses-Coverity-ID: 1248733
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/usb/misc/usbtest.c | 50 +++++++++++++++++++++++++++-------------------
>  1 file changed, 30 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 3525626..8723e33 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -124,6 +124,32 @@ static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test)
>  
>  /*-------------------------------------------------------------------------*/
>  
> +static inline void try_intr(struct usb_host_endpoint *e,
> +			    struct usb_host_endpoint *int_in,
> +			    struct usb_host_endpoint *int_out)
> +{
> +	if (usb_endpoint_dir_in(&e->desc)) {
> +		if (!int_in)
> +			int_in = e;
> +	} else {
> +		if (!int_out)
> +			int_out = e;
> +	}
> +}
> +
> +static inline void try_iso(struct usb_host_endpoint *e,
> +			   struct usb_host_endpoint *iso_in,
> +			   struct usb_host_endpoint *iso_out)
> +{
> +	if (usb_endpoint_dir_in(&e->desc)) {
> +		if (!iso_in)
> +			iso_in = e;
> +	} else {
> +		if (!iso_out)
> +			iso_out = e;
> +	}
> +}
> +

This is not at all what I had in mind.  First, it's incorrect (can you 
see why?).  Second, by "inline" I meant moving the code to be actually 
in-line next to the conditional, not some place else in a separate 
subroutine (even if the subroutine is declared inline).

Also, the code for the USB_ENDPOINT_XFER_BULK case should look like the 
other two.

Alan Stern

  reply	other threads:[~2017-02-22  1:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170221153958.Horde.6KlAXD4A9Gyww1VviVYeCDh@gator4166.hostgator.com>
2017-02-21 23:17 ` [PATCH] usb: misc: add a missing continue and refactor code Gustavo A. R. Silva
2017-02-22  1:40   ` Alan Stern [this message]
2017-02-22  2:48     ` Gustavo A. R. Silva
2017-02-22  5:26       ` Gustavo A. R. Silva
2017-04-03 14:39         ` [PATCH] usb: misc: add " Gustavo A. R. Silva
2017-04-03 17:57           ` Greg Kroah-Hartman
2017-04-03 18:38             ` Alan Stern
2017-04-03 19:00               ` Gustavo A. R. Silva
2017-04-03 19:47                 ` [PATCH 1/2] usb: misc: add missing continue in switch Gustavo A. R. Silva
2017-04-03 19:50                   ` [PATCH 2/2] usb: misc: refactor code Gustavo A. R. Silva
2017-04-03 21:06                     ` Alan Stern
2017-04-04  2:11                       ` Gustavo A. R. Silva
2017-04-04  3:48                         ` [PATCH v2 1/2] usb: misc: add missing continue in switch Gustavo A. R. Silva
2017-04-04  3:51                           ` [PATCH v2 2/2] usb: misc: refactor code Gustavo A. R. Silva
2017-04-04 13:44                             ` Alan Stern
2017-04-04  7:43                     ` [PATCH " Felipe Balbi
2017-04-04 11:12                       ` Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44L0.1702212036090.16103-100000@netrider.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=chunfeng.yun@mediatek.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=garsilva@embeddedor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=peter.chen@nxp.com \
    --cc=peter.senna@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.