All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: return directly from dsa_to_port
@ 2019-10-25 18:48 Vivien Didelot
  2019-10-25 19:21 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vivien Didelot @ 2019-10-25 18:48 UTC (permalink / raw)
  To: David S. Miller; +Cc: Andrew Lunn, Florian Fainelli, netdev, Vivien Didelot

Return directly from within the loop as soon as the port is found,
otherwise we won't return NULL if the end of the list is reached.

Fixes: b96ddf254b09 ("net: dsa: use ports list in dsa_to_port")
Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
---
 include/net/dsa.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 73900b89c1b9..14357b576b13 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -286,13 +286,13 @@ struct dsa_switch {
 static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
 {
 	struct dsa_switch_tree *dst = ds->dst;
-	struct dsa_port *dp = NULL;
+	struct dsa_port *dp;
 
 	list_for_each_entry(dp, &dst->ports, list)
 		if (dp->ds == ds && dp->index == p)
-			break;
+			return dp;
 
-	return dp;
+	return NULL;
 }
 
 static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)
-- 
2.23.0


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

* Re: [PATCH net-next] net: dsa: return directly from dsa_to_port
  2019-10-25 18:48 [PATCH net-next] net: dsa: return directly from dsa_to_port Vivien Didelot
@ 2019-10-25 19:21 ` Andrew Lunn
  2019-10-25 20:02 ` Florian Fainelli
  2019-10-29 19:08 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2019-10-25 19:21 UTC (permalink / raw)
  To: Vivien Didelot; +Cc: David S. Miller, Florian Fainelli, netdev

On Fri, Oct 25, 2019 at 02:48:53PM -0400, Vivien Didelot wrote:
> Return directly from within the loop as soon as the port is found,
> otherwise we won't return NULL if the end of the list is reached.
> 
> Fixes: b96ddf254b09 ("net: dsa: use ports list in dsa_to_port")
> Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next] net: dsa: return directly from dsa_to_port
  2019-10-25 18:48 [PATCH net-next] net: dsa: return directly from dsa_to_port Vivien Didelot
  2019-10-25 19:21 ` Andrew Lunn
@ 2019-10-25 20:02 ` Florian Fainelli
  2019-10-29 19:08 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2019-10-25 20:02 UTC (permalink / raw)
  To: Vivien Didelot, David S. Miller; +Cc: Andrew Lunn, netdev

On 10/25/19 11:48 AM, Vivien Didelot wrote:
> Return directly from within the loop as soon as the port is found,
> otherwise we won't return NULL if the end of the list is reached.
> 
> Fixes: b96ddf254b09 ("net: dsa: use ports list in dsa_to_port")
> Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

My bad for suggesting a broken way of doing this, so thanks for fixing it ;)
-- 
Florian

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

* Re: [PATCH net-next] net: dsa: return directly from dsa_to_port
  2019-10-25 18:48 [PATCH net-next] net: dsa: return directly from dsa_to_port Vivien Didelot
  2019-10-25 19:21 ` Andrew Lunn
  2019-10-25 20:02 ` Florian Fainelli
@ 2019-10-29 19:08 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-10-29 19:08 UTC (permalink / raw)
  To: vivien.didelot; +Cc: andrew, f.fainelli, netdev

From: Vivien Didelot <vivien.didelot@gmail.com>
Date: Fri, 25 Oct 2019 14:48:53 -0400

> Return directly from within the loop as soon as the port is found,
> otherwise we won't return NULL if the end of the list is reached.
> 
> Fixes: b96ddf254b09 ("net: dsa: use ports list in dsa_to_port")
> Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2019-10-29 19:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 18:48 [PATCH net-next] net: dsa: return directly from dsa_to_port Vivien Didelot
2019-10-25 19:21 ` Andrew Lunn
2019-10-25 20:02 ` Florian Fainelli
2019-10-29 19:08 ` David Miller

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.