Message ID | 20211206101352.2713117-1-liu.yun@linux.dev (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: dsa: mv88e6xxx: fix uninit-value err in mv88e6393x_serdes_power | expand |
On Mon, Dec 06, 2021 at 06:13:52PM +0800, Jackie Liu wrote: > From: Jackie Liu <liuyun01@kylinos.cn> > > 'err' is not initialized. If the value of cmode is not in the switch case, > it will cause a logic error and return early. Same fix as: <20211206113219.17640-1-amhamza.mgc@gmail.com> At least here some analysis has been done why there is a warning. Should we add a default? Andrew
On Mon, 6 Dec 2021 14:45:11 +0100 Andrew Lunn <andrew@lunn.ch> wrote: > On Mon, Dec 06, 2021 at 06:13:52PM +0800, Jackie Liu wrote: > > From: Jackie Liu <liuyun01@kylinos.cn> > > > > 'err' is not initialized. If the value of cmode is not in the switch case, > > it will cause a logic error and return early. > > Same fix as: <20211206113219.17640-1-amhamza.mgc@gmail.com> > > At least here some analysis has been done why there is a warning. > > Should we add a default? > > Andrew indeed it should be err=0
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c index 55273013bfb5..33727439724a 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c @@ -1507,7 +1507,7 @@ int mv88e6393x_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane, bool on) { u8 cmode = chip->ports[port].cmode; - int err; + int err = 0; if (port != 0 && port != 9 && port != 10) return -EOPNOTSUPP;