Message ID | 20210509115513.4121549-1-olteanv@gmail.com |
---|---|
State | New |
Headers | show |
Series | [net] net: dsa: fix error code getting shifted with 4 in dsa_slave_get_sset_count | expand |
On 5/9/2021 2:54 PM, Vladimir Oltean wrote: > On Sun, May 09, 2021 at 10:35:27AM -0700, Florian Fainelli wrote: >> On 5/9/2021 4:55 AM, Vladimir Oltean wrote: >> I would have a preference for keeping the count variable and treating it >> specifically in case it is negative. > > Thanks. I hope I've understood you correctly that renaming "err" back to > "count" was all that you were asking for. Anyway, patch is superseded by > https://patchwork.kernel.org/project/netdevbpf/patch/20210509193338.451174-1-olteanv@gmail.com/ You did, thanks for the quick spin.
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 3689ffa2dbb8..dda232a8d6f5 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -798,13 +798,15 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset) struct dsa_switch *ds = dp->ds; if (sset == ETH_SS_STATS) { - int count; + int err = 0; - count = 4; - if (ds->ops->get_sset_count) - count += ds->ops->get_sset_count(ds, dp->index, sset); + if (ds->ops->get_sset_count) { + err = ds->ops->get_sset_count(ds, dp->index, sset); + if (err < 0) + return err; + } - return count; + return err + 4; } else if (sset == ETH_SS_TEST) { return net_selftest_get_count(); }