From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753279AbdBUXjP (ORCPT ); Tue, 21 Feb 2017 18:39:15 -0500 Received: from gateway36.websitewelcome.com ([192.185.188.18]:15416 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000AbdBUXjG (ORCPT ); Tue, 21 Feb 2017 18:39:06 -0500 X-Greylist: delayed 1306 seconds by postgrey-1.27 at vger.kernel.org; Tue, 21 Feb 2017 18:39:06 EST Date: Tue, 21 Feb 2017 17:17:08 -0600 From: "Gustavo A. R. Silva" To: Alan Stern , Greg Kroah-Hartman , Felipe Balbi , Peter Chen , Chunfeng Yun , Mathias Nyman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , Peter Senna Tschudin Subject: [PATCH] usb: misc: add a missing continue and refactor code Message-ID: <20170221231708.GA8073@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170221153958.Horde.6KlAXD4A9Gyww1VviVYeCDh@gator4166.hostgator.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.253.171 X-Exim-ID: 1cgJgI-000FoJ-R9 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-253-171.static.axtel.net (embeddedgus) [187.162.253.171]:41362 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 8 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Gustavo A. R. Silva --- 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; + } +} + static int get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) { @@ -158,11 +184,12 @@ get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) break; case USB_ENDPOINT_XFER_INT: if (dev->info->intr) - goto try_intr; + try_intr(e, int_in, int_out); + continue; case USB_ENDPOINT_XFER_ISOC: if (dev->info->iso) - goto try_iso; - /* FALLTHROUGH */ + try_iso(e, iso_in, iso_out); + /* fall through */ default: continue; } @@ -174,23 +201,6 @@ get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) out = e; } continue; -try_intr: - if (usb_endpoint_dir_in(&e->desc)) { - if (!int_in) - int_in = e; - } else { - if (!int_out) - int_out = e; - } - continue; -try_iso: - if (usb_endpoint_dir_in(&e->desc)) { - if (!iso_in) - iso_in = e; - } else { - if (!iso_out) - iso_out = e; - } } if ((in && out) || iso_in || iso_out || int_in || int_out) goto found; -- 2.5.0