* [PATCH] net: mscc: ocelot: Fix some struct initializations
@ 2019-06-03 20:49 Nathan Chancellor
2019-06-03 21:00 ` Nick Desaulniers
2019-06-04 21:25 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-06-03 20:49 UTC (permalink / raw)
To: Alexandre Belloni, Horatiu Vultur,
Microchip Linux Driver Support, David S. Miller
Cc: netdev, linux-kernel, clang-built-linux, Nathan Chancellor
Clang warns:
drivers/net/ethernet/mscc/ocelot_ace.c:335:37: warning: suggest braces
around initialization of subobject [-Wmissing-braces]
struct ocelot_vcap_u64 payload = { 0 };
^
{}
drivers/net/ethernet/mscc/ocelot_ace.c:336:28: warning: suggest braces
around initialization of subobject [-Wmissing-braces]
struct vcap_data data = { 0 };
^
{}
drivers/net/ethernet/mscc/ocelot_ace.c:683:37: warning: suggest braces
around initialization of subobject [-Wmissing-braces]
struct ocelot_ace_rule del_ace = { 0 };
^
{}
drivers/net/ethernet/mscc/ocelot_ace.c:743:28: warning: suggest braces
around initialization of subobject [-Wmissing-braces]
struct vcap_data data = { 0 };
^
{}
4 warnings 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: b596229448dd ("net: mscc: ocelot: Add support for tcam")
Link: https://github.com/ClangBuiltLinux/linux/issues/505
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/net/ethernet/mscc/ocelot_ace.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mscc/ocelot_ace.c b/drivers/net/ethernet/mscc/ocelot_ace.c
index afbeb837a372..34d8260b8cb8 100644
--- a/drivers/net/ethernet/mscc/ocelot_ace.c
+++ b/drivers/net/ethernet/mscc/ocelot_ace.c
@@ -332,10 +332,13 @@ static void is2_entry_set(struct ocelot *ocelot, int ix,
{
u32 val, msk, type, type_mask = 0xf, i, count;
struct ocelot_ace_vlan *tag = &ace->vlan;
- struct ocelot_vcap_u64 payload = { 0 };
- struct vcap_data data = { 0 };
+ struct ocelot_vcap_u64 payload;
+ struct vcap_data data;
int row = (ix / 2);
+ memset(&payload, 0, sizeof(payload));
+ memset(&data, 0, sizeof(data));
+
/* Read row */
vcap_row_cmd(ocelot, row, VCAP_CMD_READ, VCAP_SEL_ALL);
vcap_cache2entry(ocelot, &data);
@@ -680,10 +683,12 @@ static void ocelot_ace_rule_del(struct ocelot_acl_block *block,
int ocelot_ace_rule_offload_del(struct ocelot_ace_rule *rule)
{
- struct ocelot_ace_rule del_ace = { 0 };
+ struct ocelot_ace_rule del_ace;
struct ocelot_ace_rule *ace;
int i, index;
+ memset(&del_ace, 0, sizeof(del_ace));
+
/* Gets index of the rule */
index = ocelot_ace_rule_get_index_id(acl_block, rule);
@@ -740,8 +745,9 @@ static void ocelot_acl_block_destroy(struct ocelot_acl_block *block)
int ocelot_ace_init(struct ocelot *ocelot)
{
- struct vcap_data data = { 0 };
+ struct vcap_data data;
+ memset(&data, 0, sizeof(data));
vcap_entry2cache(ocelot, &data);
ocelot_write(ocelot, vcap_is2.entry_count, S2_CORE_MV_CFG);
vcap_cmd(ocelot, 0, VCAP_CMD_INITIALIZE, VCAP_SEL_ENTRY);
--
2.22.0.rc3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: mscc: ocelot: Fix some struct initializations
2019-06-03 20:49 [PATCH] net: mscc: ocelot: Fix some struct initializations Nathan Chancellor
@ 2019-06-03 21:00 ` Nick Desaulniers
2019-06-04 21:25 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2019-06-03 21:00 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Alexandre Belloni, Horatiu Vultur,
Microchip Linux Driver Support, David S. Miller, netdev, LKML,
clang-built-linux
On Mon, Jun 3, 2019 at 1:51 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
> Fixes: b596229448dd ("net: mscc: ocelot: Add support for tcam")
> Link: https://github.com/ClangBuiltLinux/linux/issues/505
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
LGTM thanks Nathan.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: mscc: ocelot: Fix some struct initializations
2019-06-03 20:49 [PATCH] net: mscc: ocelot: Fix some struct initializations Nathan Chancellor
2019-06-03 21:00 ` Nick Desaulniers
@ 2019-06-04 21:25 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-06-04 21:25 UTC (permalink / raw)
To: natechancellor
Cc: alexandre.belloni, horatiu.vultur, UNGLinuxDriver, netdev,
linux-kernel, clang-built-linux
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Mon, 3 Jun 2019 13:49:53 -0700
> Clang warns:
>
> drivers/net/ethernet/mscc/ocelot_ace.c:335:37: warning: suggest braces
> around initialization of subobject [-Wmissing-braces]
> struct ocelot_vcap_u64 payload = { 0 };
> ^
> {}
> drivers/net/ethernet/mscc/ocelot_ace.c:336:28: warning: suggest braces
> around initialization of subobject [-Wmissing-braces]
> struct vcap_data data = { 0 };
> ^
> {}
> drivers/net/ethernet/mscc/ocelot_ace.c:683:37: warning: suggest braces
> around initialization of subobject [-Wmissing-braces]
> struct ocelot_ace_rule del_ace = { 0 };
> ^
> {}
> drivers/net/ethernet/mscc/ocelot_ace.c:743:28: warning: suggest braces
> around initialization of subobject [-Wmissing-braces]
> struct vcap_data data = { 0 };
> ^
> {}
> 4 warnings 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: b596229448dd ("net: mscc: ocelot: Add support for tcam")
> Link: https://github.com/ClangBuiltLinux/linux/issues/505
> 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-06-04 21:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03 20:49 [PATCH] net: mscc: ocelot: Fix some struct initializations Nathan Chancellor
2019-06-03 21:00 ` Nick Desaulniers
2019-06-04 21:25 ` 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).