diff mbox series

nfc: mrvl: remove useless "continue" at end of loop

Message ID 20210601160713.312622-1-krzysztof.kozlowski@canonical.com
State New
Headers show
Series nfc: mrvl: remove useless "continue" at end of loop | expand

Commit Message

Krzysztof Kozlowski June 1, 2021, 4:07 p.m. UTC
The "continue" statement at the end of a for loop does not have an
effect.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/nfc/nfcmrvl/usb.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Joe Perches June 1, 2021, 4:30 p.m. UTC | #1
On Tue, 2021-06-01 at 18:07 +0200, Krzysztof Kozlowski wrote:
> The "continue" statement at the end of a for loop does not have an
> effect.
[]
> diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c
[]
> @@ -325,7 +325,6 @@ static int nfcmrvl_probe(struct usb_interface *intf,
>  		if (!drv_data->bulk_rx_ep &&
>  		    usb_endpoint_is_bulk_in(ep_desc)) {
>  			drv_data->bulk_rx_ep = ep_desc;
> -			continue;
>  		}
>  	}

I think this code would be clearer with an if/else instead of
multiple continues.

---
 drivers/nfc/nfcmrvl/usb.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c
index bcd563cb556ce..1616b873b15e6 100644
--- a/drivers/nfc/nfcmrvl/usb.c
+++ b/drivers/nfc/nfcmrvl/usb.c
@@ -296,7 +296,6 @@ static void nfcmrvl_waker(struct work_struct *work)
 static int nfcmrvl_probe(struct usb_interface *intf,
 			 const struct usb_device_id *id)
 {
-	struct usb_endpoint_descriptor *ep_desc;
 	struct nfcmrvl_usb_drv_data *drv_data;
 	struct nfcmrvl_private *priv;
 	int i;
@@ -314,19 +313,16 @@ static int nfcmrvl_probe(struct usb_interface *intf,
 		return -ENOMEM;
 
 	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
+		struct usb_endpoint_descriptor *ep_desc;
+
 		ep_desc = &intf->cur_altsetting->endpoint[i].desc;
 
 		if (!drv_data->bulk_tx_ep &&
-		    usb_endpoint_is_bulk_out(ep_desc)) {
+		    usb_endpoint_is_bulk_out(ep_desc))
 			drv_data->bulk_tx_ep = ep_desc;
-			continue;
-		}
-
-		if (!drv_data->bulk_rx_ep &&
-		    usb_endpoint_is_bulk_in(ep_desc)) {
+		else if (!drv_data->bulk_rx_ep &&
+			 usb_endpoint_is_bulk_in(ep_desc))
 			drv_data->bulk_rx_ep = ep_desc;
-			continue;
-		}
 	}
 
 	if (!drv_data->bulk_tx_ep || !drv_data->bulk_rx_ep)
Krzysztof Kozlowski June 2, 2021, 11:10 a.m. UTC | #2
On 01/06/2021 18:30, Joe Perches wrote:
> On Tue, 2021-06-01 at 18:07 +0200, Krzysztof Kozlowski wrote:

>> The "continue" statement at the end of a for loop does not have an

>> effect.

> []

>> diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c

> []

>> @@ -325,7 +325,6 @@ static int nfcmrvl_probe(struct usb_interface *intf,

>>  		if (!drv_data->bulk_rx_ep &&

>>  		    usb_endpoint_is_bulk_in(ep_desc)) {

>>  			drv_data->bulk_rx_ep = ep_desc;

>> -			continue;

>>  		}

>>  	}

> 

> I think this code would be clearer with an if/else instead of

> multiple continues.


Makes sense. I'll send a v2.


Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c
index bcd563cb556c..433bdc37ba91 100644
--- a/drivers/nfc/nfcmrvl/usb.c
+++ b/drivers/nfc/nfcmrvl/usb.c
@@ -325,7 +325,6 @@  static int nfcmrvl_probe(struct usb_interface *intf,
 		if (!drv_data->bulk_rx_ep &&
 		    usb_endpoint_is_bulk_in(ep_desc)) {
 			drv_data->bulk_rx_ep = ep_desc;
-			continue;
 		}
 	}