net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats
PATCH 1/1 net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats
Clang warns:
drivers/net/dsa/sja1105/sja1105_ethtool.c:316:39: warning: suggest braces around initialization of subobject [-Wmissing-braces]
struct sja1105_port_status status = {0};
^
{}1 warning generated.
One way to fix these warnings is to add additional braces like Clang suggests; however, there has been a bit of push back from some maintainers[1][2], who just prefer memset as it is unambiguous, doesn't depend on a particular compiler version[3], and properly initializes all subobjects. Do that here so there are no more warnings.
[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/
--- drivers/net/dsa/sja1105/sja1105_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/sja1105/sja1105_ethtool.c +3 -1
@@ -313,9 +313,11 @@ static char sja1105pqrs_extra_port_stats[][ETH_GSTRING_LEN] = {void sja1105_get_ethtool_stats (struct dsa_switch *ds,int port,u64 *data) {struct sja1105_private *priv = ds->priv; -struct sja1105_port_status status = {0 }; +struct sja1105_port_status status;int rc, i, k =0 ; +memset (&status,0 ,sizeof (status)); + rc =sja1105_port_status_get (priv, &status, port);if (rc <0 ) { dev_err(ds->dev, "Failed to read port %d counters: %d\n",
Signature · 1 line
2.21.0
Quoted 45 lines · Nathan Chancellor
Clang warns:
drivers/net/dsa/sja1105/sja1105_ethtool.c:316:39: warning: suggest braces around initialization of subobject [-Wmissing-braces]struct sja1105_port_status status = {0}; ^ {}1 warning generated.
One way to fix these warnings is to add additional braces like Clang suggests; however, there has been a bit of push back from some maintainers[1][2], who just prefer memset as it is unambiguous, doesn't depend on a particular compiler version[3], and properly initializes all subobjects. Do that here so there are no more warnings.
[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/Fixes 52c34e6e125c ("net: dsa: sja1105: Add support for ethtool port counters")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/dsa/sja1105/sja1105_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/dsa/sja1105/sja1105_ethtool.c +3
-2@@ -313,9 +313,11 @@ static char sja1105pqrs_extra_port_stats[][ETH_GSTRING_LEN] = {void sja1105_get_ethtool_stats (struct dsa_switch *ds,int port,u64 *data) {struct sja1105_private *priv = ds->priv; -struct sja1105_port_status status = {0 }; +struct sja1105_port_status status;int rc, i, k =0 ; +memset (&status,0 ,sizeof (status)); + rc =sja1105_port_status_get (priv, &status, port);if (rc <0 ) { dev_err(ds->dev, "Failed to read port %d counters: %d\n", --
Quoted 2 lines
2.21.0
Thanks Nathan, compound literals got me this time. -Vladimir
From: Nathan Chancellor <[email protected]>
Date: Mon, 6 May 2019 13:24:47 -0700
Quoted 15 lines
Clang warns:
drivers/net/dsa/sja1105/sja1105_ethtool.c:316:39: warning: suggest braces around initialization of subobject [-Wmissing-braces]struct sja1105_port_status status = {0}; ^ {}1 warning generated.
One way to fix these warnings is to add additional braces like Clang suggests; however, there has been a bit of push back from some maintainers[1][2], who just prefer memset as it is unambiguous, doesn't depend on a particular compiler version[3], and properly initializes all subobjects. Do that here so there are no more warnings.
Quoted 7 lines
[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/Fixes 52c34e6e125c ("net: dsa: sja1105: Add support for ethtool port counters")Signed-off-by Nathan Chancellor <[email protected]>
Applied to net-next.