diff mbox series

[net-next,v3] geneve: Initialize addr6 with memset

Message ID 20181117013626.4808-1-natechancellor@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series [net-next,v3] geneve: Initialize addr6 with memset | expand

Commit Message

Nathan Chancellor Nov. 17, 2018, 1:36 a.m. UTC
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 <davem@davemloft.net>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

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(-)

Comments

David Miller Nov. 18, 2018, 6:03 a.m. UTC | #1
From: Nathan Chancellor <natechancellor@gmail.com>
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 <davem@davemloft.net>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Applied.
diff mbox series

Patch

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;