[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220305171448.692839-1-trix@redhat.com>
Date: Sat, 5 Mar 2022 09:14:48 -0800
From: trix@...hat.com
To: andrew@...n.ch, vivien.didelot@...il.com, f.fainelli@...il.com,
olteanv@...il.com, davem@...emloft.net, kuba@...nel.org,
nathan@...nel.org, ndesaulniers@...gle.com
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, Tom Rix <trix@...hat.com>
Subject: [PATCH] net: dsa: return success if there was nothing to do
From: Tom Rix <trix@...hat.com>
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.
Signed-off-by: Tom Rix <trix@...hat.com>
---
net/dsa/dsa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 06d5de28a43ea..fe971a2c15cd1 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -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);
--
2.26.3
Powered by blists - more mailing lists