2018-11-12 22:15:40

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH] geneve: Add missing braces in addr6 initializer

Clang warns:

drivers/net/geneve.c:428:29: error: suggest braces around initialization
of subobject [-Werror,-Wmissing-braces]
struct in6_addr addr6 = { 0 };
^
{}

Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
Signed-off-by: Nathan Chancellor <[email protected]>
---
drivers/net/geneve.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 7c53e06b31c3..224d8b0bb5de 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -425,7 +425,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
#if IS_ENABLED(CONFIG_IPV6)
if (geneve_get_sk_family(gs) == AF_INET6) {
struct ipv6hdr *ip6h = ipv6_hdr(skb);
- struct in6_addr addr6 = { 0 };
+ struct in6_addr addr6 = { { 0 } };

if (!gs->collect_md) {
vni = geneve_hdr(skb)->vni;
--
2.19.1



2018-11-12 22:20:21

by Stefano Brivio

[permalink] [raw]
Subject: Re: [PATCH] geneve: Add missing braces in addr6 initializer

On Mon, 12 Nov 2018 15:12:48 -0700
Nathan Chancellor <[email protected]> wrote:

> Clang warns:
>
> drivers/net/geneve.c:428:29: error: suggest braces around initialization
> of subobject [-Werror,-Wmissing-braces]
> struct in6_addr addr6 = { 0 };
> ^
> {}
>
> Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
> Signed-off-by: Nathan Chancellor <[email protected]>

Thanks for spotting this. By the way, I guess you should indicate in
the subject when patches are meant for net-next.

Reviewed-by: Stefano Brivio <[email protected]>

--
Stefano

2018-11-12 22:23:04

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] geneve: Add missing braces in addr6 initializer

On Mon, Nov 12, 2018 at 11:19:17PM +0100, Stefano Brivio wrote:
> On Mon, 12 Nov 2018 15:12:48 -0700
> Nathan Chancellor <[email protected]> wrote:
>
> > Clang warns:
> >
> > drivers/net/geneve.c:428:29: error: suggest braces around initialization
> > of subobject [-Werror,-Wmissing-braces]
> > struct in6_addr addr6 = { 0 };
> > ^
> > {}
> >
> > Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
> > Signed-off-by: Nathan Chancellor <[email protected]>
>
> Thanks for spotting this. By the way, I guess you should indicate in
> the subject when patches are meant for net-next.
>

Sure, I'll be better about that in the future.

> Reviewed-by: Stefano Brivio <[email protected]>
>

Thank you for the review!
Nathan

> --
> Stefano

2018-11-12 22:36:57

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] geneve: Add missing braces in addr6 initializer

On Mon, 2018-11-12 at 15:12 -0700, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/net/geneve.c:428:29: error: suggest braces around initialization
> of subobject [-Werror,-Wmissing-braces]
> struct in6_addr addr6 = { 0 };
> ^
> {}

Perhaps just remove the 0.

> diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
[]
> @@ -425,7 +425,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
> #if IS_ENABLED(CONFIG_IPV6)
> if (geneve_get_sk_family(gs) == AF_INET6) {
> struct ipv6hdr *ip6h = ipv6_hdr(skb);
> - struct in6_addr addr6 = { 0 };
> + struct in6_addr addr6 = { { 0 } };
>
> if (!gs->collect_md) {
> vni = geneve_hdr(skb)->vni;


2018-11-13 06:13:28

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

Clang warns:

drivers/net/geneve.c:428:29: error: suggest braces around initialization
of subobject [-Werror,-Wmissing-braces]
struct in6_addr addr6 = { 0 };
^
{}

Most initializations of structs in the kernel seem to use this format.

Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
Suggested-by: Joe Perches <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
---

v1 -> v2:

* Just remove the zero instead of adding more braces as it seems to
match the rest of the kernel (as suggested by Joe Perches).

drivers/net/geneve.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 7c53e06b31c3..f09e58b7b01e 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -425,7 +425,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
#if IS_ENABLED(CONFIG_IPV6)
if (geneve_get_sk_family(gs) == AF_INET6) {
struct ipv6hdr *ip6h = ipv6_hdr(skb);
- struct in6_addr addr6 = { 0 };
+ struct in6_addr addr6 = { };

if (!gs->collect_md) {
vni = geneve_hdr(skb)->vni;
--
2.19.1


2018-11-13 09:03:39

by Stefano Brivio

[permalink] [raw]
Subject: Re: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

On Mon, 12 Nov 2018 23:11:47 -0700
Nathan Chancellor <[email protected]> wrote:

> Clang warns:
>
> drivers/net/geneve.c:428:29: error: suggest braces around initialization
> of subobject [-Werror,-Wmissing-braces]
> struct in6_addr addr6 = { 0 };
> ^
> {}
>
> Most initializations of structs in the kernel seem to use this format.
>
> Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
> Suggested-by: Joe Perches <[email protected]>
> Signed-off-by: Nathan Chancellor <[email protected]>

Also,

Reviewed-by: Stefano Brivio <[email protected]>

--
Stefano

2018-11-15 19:37:17

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] geneve: Add missing braces in addr6 initializer

From: Nathan Chancellor <[email protected]>
Date: Mon, 12 Nov 2018 15:12:48 -0700

> Clang warns:
>
> drivers/net/geneve.c:428:29: error: suggest braces around initialization
> of subobject [-Werror,-Wmissing-braces]
> struct in6_addr addr6 = { 0 };
> ^
> {}
>
> Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
> Signed-off-by: Nathan Chancellor <[email protected]>

And this makes GCC warn.

drivers/net/geneve.c: In function ‘geneve_udp_encap_err_lookup’:
drivers/net/geneve.c:428:27: warning: missing braces around initializer [-Wmissing-braces]
struct in6_addr addr6 = { { 0 } };
^
{ }

(╯°□°)╯︵ ┻━┻

2018-11-15 19:39:44

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] geneve: Add missing braces in addr6 initializer

On Thu, Nov 15, 2018 at 11:35:01AM -0800, David Miller wrote:
> From: Nathan Chancellor <[email protected]>
> Date: Mon, 12 Nov 2018 15:12:48 -0700
>
> > Clang warns:
> >
> > drivers/net/geneve.c:428:29: error: suggest braces around initialization
> > of subobject [-Werror,-Wmissing-braces]
> > struct in6_addr addr6 = { 0 };
> > ^
> > {}
> >
> > Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
> > Signed-off-by: Nathan Chancellor <[email protected]>
>
> And this makes GCC warn.
>
> drivers/net/geneve.c: In function ‘geneve_udp_encap_err_lookup’:
> drivers/net/geneve.c:428:27: warning: missing braces around initializer [-Wmissing-braces]
> struct in6_addr addr6 = { { 0 } };
> ^
> { }
>
> (╯°□°)╯︵ ┻━┻

Yes, sorry, I thought I test built before sending it but apparently not
:( v2 should be sitting in your inbox as a reply to this one unless I
screwed that up too...

Nathan

2018-11-16 14:05:49

by Stefano Brivio

[permalink] [raw]
Subject: Re: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

On Mon, 12 Nov 2018 23:11:47 -0700
Nathan Chancellor <[email protected]> wrote:

> Clang warns:
>
> drivers/net/geneve.c:428:29: error: suggest braces around initialization
> of subobject [-Werror,-Wmissing-braces]
> struct in6_addr addr6 = { 0 };
> ^
> {}
>
> Most initializations of structs in the kernel seem to use this format.

Actually, even with this, we get a warning with gcc 4.4 and 4.8. I tried a
few compilers:

$ gcc-4.4 --version | head -n1
rhel-6.9-gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
$ gcc-4.8 --version | head -n1
rhel-7.5-gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
$ gcc-7.3 --version | head -n1
gcc-7.3-gcc (GCC) 7.3.0
$ gcc-8.2 --version | head -n1
gcc (Debian 8.2.0-9) 8.2.0
$ clang --version | head -n1
clang version 6.0.1-9.2 (tags/RELEASE_601/final)

$ cat init.c
#include <linux/in6.h>

int main()
{
struct in6_addr addr6 = INIT;

return addr6.in6_u.u6_addr8[0];
}

$ gcc-4.4 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
init.c:5: warning: missing initializer
$ gcc-4.4 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
init.c:5: warning: missing braces around initializer
$ gcc-4.4 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1

$ gcc-4.8 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
init.c:5:16: warning: missing initializer for field 'in6_u' of 'struct in6_addr' [-Wmissing-field-initializers]
$ gcc-4.8 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
init.c:5:16: warning: missing braces around initializer [-Wmissing-braces]
$ gcc-4.8 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1

$ gcc-7.3 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
$ gcc-7.3 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
$ gcc-7.3 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1

$ gcc-8.2 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
$ gcc-8.2 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
$ gcc-8.2 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1

$ clang -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
$ clang -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
init.c:5:33: warning: suggest braces around initialization of subobject [-Wmissing-braces]
$ clang -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1

So { { { 0 } } } seems to be the safest option. We could go with static
but it looks even uglier to me.

Joe, suggestions?

--
Stefano

2018-11-16 15:37:59

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

On Fri, Nov 16, 2018 at 03:04:32PM +0100, Stefano Brivio wrote:
> On Mon, 12 Nov 2018 23:11:47 -0700
> Nathan Chancellor <[email protected]> wrote:
>
> > Clang warns:
> >
> > drivers/net/geneve.c:428:29: error: suggest braces around initialization
> > of subobject [-Werror,-Wmissing-braces]
> > struct in6_addr addr6 = { 0 };
> > ^
> > {}
> >
> > Most initializations of structs in the kernel seem to use this format.
>
> Actually, even with this, we get a warning with gcc 4.4 and 4.8. I tried a
> few compilers:
>
> $ gcc-4.4 --version | head -n1
> rhel-6.9-gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
> $ gcc-4.8 --version | head -n1
> rhel-7.5-gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
> $ gcc-7.3 --version | head -n1
> gcc-7.3-gcc (GCC) 7.3.0
> $ gcc-8.2 --version | head -n1
> gcc (Debian 8.2.0-9) 8.2.0
> $ clang --version | head -n1
> clang version 6.0.1-9.2 (tags/RELEASE_601/final)
>
> $ cat init.c
> #include <linux/in6.h>
>
> int main()
> {
> struct in6_addr addr6 = INIT;
>
> return addr6.in6_u.u6_addr8[0];
> }
>
> $ gcc-4.4 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> init.c:5: warning: missing initializer
> $ gcc-4.4 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> init.c:5: warning: missing braces around initializer
> $ gcc-4.4 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
>
> $ gcc-4.8 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> init.c:5:16: warning: missing initializer for field 'in6_u' of 'struct in6_addr' [-Wmissing-field-initializers]
> $ gcc-4.8 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> init.c:5:16: warning: missing braces around initializer [-Wmissing-braces]
> $ gcc-4.8 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
>
> $ gcc-7.3 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> $ gcc-7.3 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> $ gcc-7.3 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
>
> $ gcc-8.2 -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> $ gcc-8.2 -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> $ gcc-8.2 -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
>
> $ clang -DINIT="{ }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> $ clang -DINIT="{ 0 }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
> init.c:5:33: warning: suggest braces around initialization of subobject [-Wmissing-braces]
> $ clang -DINIT="{ { { 0 } } }" -S -Wall -Wextra -o init init.c 2>&1 | grep warning | head -n1
>
> So { { { 0 } } } seems to be the safest option. We could go with static
> but it looks even uglier to me.
>
> Joe, suggestions?
>
> --
> Stefano

Yes, I used the wrong number of braces in the initial patch hence this
one. I'm fine with pushing that change as v3 if everyone agrees that is
fine.

Thanks for looking into this!
Nathan

2018-11-16 20:37:01

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

From: Stefano Brivio <[email protected]>
Date: Fri, 16 Nov 2018 15:04:32 +0100

> Joe, suggestions?

Let's just memset() this thing already instead of fighting the
compiler(s).

2018-11-17 01:42:51

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH net-next v3] geneve: Initialize addr6 with memset

Clang warns:

drivers/net/geneve.c:428:29: error: suggest braces around initialization
of subobject [-Werror,-Wmissing-braces]
struct in6_addr addr6 = { 0 };
^
{}

Rather than trying to appease the various compilers that support the
kernel, use memset, which is unambiguous.

Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
Suggested-by: David S. Miller <[email protected]>
Signed-off-by: Nathan Chancellor <[email protected]>
---

v1 -> v2:

* Just remove the zero instead of adding more braces as it seems to
match the rest of the kernel (as suggested by Joe Perches).

v2 -> v3:

* Use memset as suggested by David Miller.

drivers/net/geneve.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 7c53e06b31c3..58bbba8582b0 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -425,7 +425,9 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
#if IS_ENABLED(CONFIG_IPV6)
if (geneve_get_sk_family(gs) == AF_INET6) {
struct ipv6hdr *ip6h = ipv6_hdr(skb);
- struct in6_addr addr6 = { 0 };
+ struct in6_addr addr6;
+
+ memset(&addr6, 0, sizeof(struct in6_addr));

if (!gs->collect_md) {
vni = geneve_hdr(skb)->vni;
--
2.19.1


2018-11-17 02:34:38

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

On Fri, 2018-11-16 at 08:37 -0700, Nathan Chancellor wrote:
> On Fri, Nov 16, 2018 at 03:04:32PM +0100, Stefano Brivio wrote:
> > On Mon, 12 Nov 2018 23:11:47 -0700
> > Nathan Chancellor <[email protected]> wrote:
> >
> > > Clang warns:
> > >
> > > drivers/net/geneve.c:428:29: error: suggest braces around initialization
> > > of subobject [-Werror,-Wmissing-braces]
> > > struct in6_addr addr6 = { 0 };
> > > ^
> > > {}
> > >
> > > Most initializations of structs in the kernel seem to use this format.
[]
> > So { { { 0 } } } seems to be the safest option. We could go with static
> > but it looks even uglier to me.
> >
> > Joe, suggestions?

If this is really an issue, I don't know why the other uses
haven't been reported. Perhaps change the rest of them too?

$ git grep -P "struct\s+in6_addr\s+\w+\s*=\s*{\s*}"
include/net/ip6_fib.h: struct in6_addr in6_zero = {};
include/trace/events/fib6.h: struct in6_addr in6_zero = {};
net/6lowpan/iphc.c: struct in6_addr network_pfx = {};
net/6lowpan/iphc.c: struct in6_addr tmp = {};
net/6lowpan/iphc.c: struct in6_addr tmp = {};
net/6lowpan/iphc.c: struct in6_addr tmp = {};
net/6lowpan/iphc.c: struct in6_addr tmp = {};




2018-11-17 11:32:45

by Stefano Brivio

[permalink] [raw]
Subject: Re: [PATCH net-next v2] geneve: Use empty braces for addr6 initializer

On Fri, 16 Nov 2018 18:33:40 -0800
Joe Perches <[email protected]> wrote:

> If this is really an issue, I don't know why the other uses
> haven't been reported.

It causes warnings with some older gcc versions and clang, I don't see
it as an issue, but others might.

> Perhaps change the rest of them too?

But then look, we already have a delicious strict C89 initialiser in
include/linux/in6.h, and we can do this:

drivers/net/geneve.c | 4 ++--
include/net/ip6_fib.h | 9 +++------
include/trace/events/fib6.h | 4 +---
net/6lowpan/iphc.c | 12 ++++++------
4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 7c53e06b31c3..96588adc294c 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -191,7 +191,7 @@ static struct geneve_dev *geneve_lookup_skb(struct geneve_sock *gs,
return geneve_lookup(gs, addr, vni);
#if IS_ENABLED(CONFIG_IPV6)
} else if (geneve_get_sk_family(gs) == AF_INET6) {
- static struct in6_addr zero_addr6;
+ struct in6_addr zero_addr6 = IN6ADDR_ANY_INIT;
struct ipv6hdr *ip6h;
struct in6_addr addr6;

@@ -424,8 +424,8 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)

#if IS_ENABLED(CONFIG_IPV6)
if (geneve_get_sk_family(gs) == AF_INET6) {
+ struct in6_addr addr6 = IN6ADDR_ANY_INIT;
struct ipv6hdr *ip6h = ipv6_hdr(skb);
- struct in6_addr addr6 = { 0 };

if (!gs->collect_md) {
vni = geneve_hdr(skb)->vni;
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 84097010237c..24543caf5a9f 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -427,13 +427,10 @@ void rt6_get_prefsrc(const struct rt6_info *rt, struct in6_addr *addr)
rcu_read_lock();

from = rcu_dereference(rt->from);
- if (from) {
+ if (from)
*addr = from->fib6_prefsrc.addr;
- } else {
- struct in6_addr in6_zero = {};
-
- *addr = in6_zero;
- }
+ else
+ *addr = in6addr_any;

rcu_read_unlock();
}
diff --git a/include/trace/events/fib6.h b/include/trace/events/fib6.h
index b088b54d699c..6496ca1594ac 100644
--- a/include/trace/events/fib6.h
+++ b/include/trace/events/fib6.h
@@ -68,10 +68,8 @@ TRACE_EVENT(fib6_table_lookup,
__assign_str(name, "-");
}
if (f6i == net->ipv6.fib6_null_entry) {
- struct in6_addr in6_zero = {};
-
in6 = (struct in6_addr *)__entry->gw;
- *in6 = in6_zero;
+ *in6 = in6addr_any;

} else if (f6i) {
in6 = (struct in6_addr *)__entry->gw;
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 52fad5dad9f7..f0e0bac91e71 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -246,8 +246,8 @@ lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
const struct in6_addr *addr)
{
struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table;
+ struct in6_addr addr_mcast, network_pfx = IN6ADDR_ANY_INIT;
struct lowpan_iphc_ctx *ret = NULL;
- struct in6_addr addr_mcast, network_pfx = {};
int i;

/* init mcast address with */
@@ -481,7 +481,7 @@ static int lowpan_uncompress_multicast_ctx_daddr(struct sk_buff *skb,
struct in6_addr *ipaddr,
u8 address_mode)
{
- struct in6_addr network_pfx = {};
+ struct in6_addr network_pfx = IN6ADDR_ANY_INIT;
bool fail;

ipaddr->s6_addr[0] = 0xFF;
@@ -794,8 +794,8 @@ lowpan_iphc_compress_ctx_802154_lladdr(const struct in6_addr *ipaddr,
{
const struct ieee802154_addr *addr = lladdr;
unsigned char extended_addr[EUI64_ADDR_LEN];
+ struct in6_addr tmp = IN6ADDR_ANY_INIT;
bool lladdr_compress = false;
- struct in6_addr tmp = {};

switch (addr->mode) {
case IEEE802154_ADDR_LONG:
@@ -833,7 +833,7 @@ static bool lowpan_iphc_addr_equal(const struct net_device *dev,
const struct in6_addr *ipaddr,
const void *lladdr)
{
- struct in6_addr tmp = {};
+ struct in6_addr tmp = IN6ADDR_ANY_INIT;

lowpan_iphc_uncompress_lladdr(dev, &tmp, lladdr);

@@ -848,7 +848,7 @@ static u8 lowpan_compress_ctx_addr(u8 **hc_ptr, const struct net_device *dev,
const struct lowpan_iphc_ctx *ctx,
const unsigned char *lladdr, bool sam)
{
- struct in6_addr tmp = {};
+ struct in6_addr tmp = IN6ADDR_ANY_INIT;
u8 dam;

switch (lowpan_dev(dev)->lltype) {
@@ -907,8 +907,8 @@ lowpan_iphc_compress_802154_lladdr(const struct in6_addr *ipaddr,
{
const struct ieee802154_addr *addr = lladdr;
unsigned char extended_addr[EUI64_ADDR_LEN];
+ struct in6_addr tmp = IN6ADDR_ANY_INIT;
bool lladdr_compress = false;
- struct in6_addr tmp = {};

switch (addr->mode) {
case IEEE802154_ADDR_LONG:

--
Stefano

2018-11-18 06:04:21

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next v3] geneve: Initialize addr6 with memset

From: Nathan Chancellor <[email protected]>
Date: Fri, 16 Nov 2018 18:36:27 -0700

> Clang warns:
>
> drivers/net/geneve.c:428:29: error: suggest braces around initialization
> of subobject [-Werror,-Wmissing-braces]
> struct in6_addr addr6 = { 0 };
> ^
> {}
>
> Rather than trying to appease the various compilers that support the
> kernel, use memset, which is unambiguous.
>
> Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
> Suggested-by: David S. Miller <[email protected]>
> Signed-off-by: Nathan Chancellor <[email protected]>

Applied.