* [PATCH] net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats
@ 2019-05-06 20:24 Nathan Chancellor
2019-05-06 20:45 ` Vladimir Oltean
2019-05-07 19:21 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-05-06 20:24 UTC (permalink / raw)
To: Vladimir Oltean, Andrew Lunn, Vivien Didelot, Florian Fainelli,
David S. Miller
Cc: linux-kernel, netdev, clang-built-linux, Nick Desaulniers,
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/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
[2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/
[3]: https://lore.kernel.org/lkml/20181116150432.2408a075@redhat.com/
Fixes: 52c34e6e125c ("net: dsa: sja1105: Add support for ethtool port counters")
Link: https://github.com/ClangBuiltLinux/linux/issues/471
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/dsa/sja1105/sja1105_ethtool.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_ethtool.c b/drivers/net/dsa/sja1105/sja1105_ethtool.c
index 46d22be31309..ab581a28cd41 100644
--- a/drivers/net/dsa/sja1105/sja1105_ethtool.c
+++ b/drivers/net/dsa/sja1105/sja1105_ethtool.c
@@ -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",
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats
2019-05-06 20:24 [PATCH] net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats Nathan Chancellor
@ 2019-05-06 20:45 ` Vladimir Oltean
2019-05-07 19:21 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2019-05-06 20:45 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
linux-kernel, netdev, clang-built-linux, Nick Desaulniers
On Mon, 6 May 2019 at 23:25, Nathan Chancellor <natechancellor@gmail.com> wrote:
>
> 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/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
> [2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/
> [3]: https://lore.kernel.org/lkml/20181116150432.2408a075@redhat.com/
>
> Fixes: 52c34e6e125c ("net: dsa: sja1105: Add support for ethtool port counters")
> Link: https://github.com/ClangBuiltLinux/linux/issues/471
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/net/dsa/sja1105/sja1105_ethtool.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/sja1105/sja1105_ethtool.c b/drivers/net/dsa/sja1105/sja1105_ethtool.c
> index 46d22be31309..ab581a28cd41 100644
> --- a/drivers/net/dsa/sja1105/sja1105_ethtool.c
> +++ b/drivers/net/dsa/sja1105/sja1105_ethtool.c
> @@ -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",
> --
> 2.21.0
>
Acked-by: Vladimir Oltean <olteanv@gmail.com>
Thanks Nathan, compound literals got me this time.
-Vladimir
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats
2019-05-06 20:24 [PATCH] net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats Nathan Chancellor
2019-05-06 20:45 ` Vladimir Oltean
@ 2019-05-07 19:21 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-07 19:21 UTC (permalink / raw)
To: natechancellor
Cc: olteanv, andrew, vivien.didelot, f.fainelli, linux-kernel,
netdev, clang-built-linux, ndesaulniers
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Mon, 6 May 2019 13:24:47 -0700
> 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/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
> [2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/
> [3]: https://lore.kernel.org/lkml/20181116150432.2408a075@redhat.com/
>
> Fixes: 52c34e6e125c ("net: dsa: sja1105: Add support for ethtool port counters")
> Link: https://github.com/ClangBuiltLinux/linux/issues/471
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Applied to net-next.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-07 19:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06 20:24 [PATCH] net: dsa: sja1105: Fix status initialization in sja1105_get_ethtool_stats Nathan Chancellor
2019-05-06 20:45 ` Vladimir Oltean
2019-05-07 19:21 ` David Miller
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).