Skip to contentSkip to conversation

net: dsa: return success if there was nothing to do

PATCH Applied [email protected] 4 participants 4 messages Mar 5, 2022 – Mar 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: return success if there was nothing to do

From: Tom Rix <[email protected]>

Clang static analysis reports this representative issue dsa.c:486:2: warning: Undefined or garbage value
returned to caller
return err;
^~~~~~~~~~

err is only set in the loop. If the loop is empty, garbage will be returned. So initialize err to 0 to handle this noop case.

---
 net/dsa/dsa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/dsa.c +2 -2
index 06d5de28a43ea..fe971a2c15cd1 100644
@@ -471,7 +471,7 @@ int dsa_port_walk_fdbs(struct dsa_switch *ds, int port, dsa_fdb_walk_cb_t cb)
 {
 	struct dsa_port *dp = dsa_to_port(ds, port);
 	struct dsa_mac_addr *a;
-	int err;
+	int err = 0;
 
 	mutex_lock(&dp->addr_lists_lock);
 
@@ -491,7 +491,7 @@ int dsa_port_walk_mdbs(struct dsa_switch *ds, int port, dsa_fdb_walk_cb_t cb)
 {
 	struct dsa_port *dp = dsa_to_port(ds, port);
 	struct dsa_mac_addr *a;
-	int err;
+	int err = 0;
 
 	mutex_lock(&dp->addr_lists_lock);
 
Signature · 1 line
2.26.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Sat, Mar 05, 2022 at 09:14:48AM -0800, [email protected] wrote:

From: Tom Rix <[email protected]>

Clang static analysis reports this representative issue dsa.c:486:2: warning: Undefined or garbage value
returned to caller
return err;
^~~~~~~~~~

Quoted 5 lines

err is only set in the loop. If the loop is empty, garbage will be returned. So initialize err to 0 to handle this noop case.

Andrew

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Sat, Mar 05, 2022 at 09:14:48AM -0800, [email protected] wrote:

From: Tom Rix <[email protected]>

Clang static analysis reports this representative issue dsa.c:486:2: warning: Undefined or garbage value
returned to caller
return err;
^~~~~~~~~~

Quoted 6 lines

err is only set in the loop. If the loop is empty, garbage will be returned. So initialize err to 0 to handle this noop case.

---

#3 lore raw
In reply to [email protected]
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 9 lines · On Sat, 5 Mar 2022 09:14:48 -0800 you wrote:

From: Tom Rix <[email protected]>

Clang static analysis reports this representative issue dsa.c:486:2: warning: Undefined or garbage value
returned to caller
return err;
^~~~~~~~~~

[...]

Here is the summary with links:
- net: dsa: return success if there was nothing to do

    https://git.kernel.org/netdev/net-next/c/cd5169841c49

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html