OSDN Git Service

net: dsa: return success if there was nothing to do
authorTom Rix <trix@redhat.com>
Sat, 5 Mar 2022 17:14:48 +0000 (09:14 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Mar 2022 12:25:59 +0000 (12:25 +0000)
commitcd5169841c49dab75ecc3b20b3bd1100395b6909
treeec55933b9b58a0004ffc993a9325e8686f3be4c0
parent0273d10182ec4507a43b868dd80fd62860b7e948
net: dsa: return success if there was nothing to do

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>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa.c