* [PATCH] net: dsa: return success if there was nothing to do
@ 2022-03-05 17:14 trix
2022-03-05 19:11 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: trix @ 2022-03-05 17:14 UTC (permalink / raw)
To: andrew, vivien.didelot, f.fainelli, olteanv, davem, kuba, nathan,
ndesaulniers
Cc: netdev, linux-kernel, llvm, Tom Rix
From: Tom Rix <trix@redhat.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@redhat.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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: return success if there was nothing to do
2022-03-05 17:14 [PATCH] net: dsa: return success if there was nothing to do trix
@ 2022-03-05 19:11 ` Andrew Lunn
2022-03-05 20:32 ` Vladimir Oltean
2022-03-07 12:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2022-03-05 19:11 UTC (permalink / raw)
To: trix
Cc: vivien.didelot, f.fainelli, olteanv, davem, kuba, nathan,
ndesaulniers, netdev, linux-kernel, llvm
On Sat, Mar 05, 2022 at 09:14:48AM -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.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@redhat.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: return success if there was nothing to do
2022-03-05 17:14 [PATCH] net: dsa: return success if there was nothing to do trix
2022-03-05 19:11 ` Andrew Lunn
@ 2022-03-05 20:32 ` Vladimir Oltean
2022-03-07 12:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2022-03-05 20:32 UTC (permalink / raw)
To: trix
Cc: andrew, vivien.didelot, f.fainelli, davem, kuba, nathan,
ndesaulniers, netdev, linux-kernel, llvm
On Sat, Mar 05, 2022 at 09:14:48AM -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.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@redhat.com>
> ---
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: return success if there was nothing to do
2022-03-05 17:14 [PATCH] net: dsa: return success if there was nothing to do trix
2022-03-05 19:11 ` Andrew Lunn
2022-03-05 20:32 ` Vladimir Oltean
@ 2022-03-07 12:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-07 12:30 UTC (permalink / raw)
To: Tom Rix
Cc: andrew, vivien.didelot, f.fainelli, olteanv, davem, kuba, nathan,
ndesaulniers, netdev, linux-kernel, llvm
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 5 Mar 2022 09:14:48 -0800 you wrote:
> From: Tom Rix <trix@redhat.com>
>
> 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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-07 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-05 17:14 [PATCH] net: dsa: return success if there was nothing to do trix
2022-03-05 19:11 ` Andrew Lunn
2022-03-05 20:32 ` Vladimir Oltean
2022-03-07 12:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).