net, vxlan Fix compile warning
Subsystems (2)
PATCH 1/1 net, vxlan Fix compile warning
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
vs->sock = sock;
^
drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here
struct socket *sock;
^--- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +1 -1
@@ -2276,7 +2276,7 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port, {struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_sock *vs; -struct socket *sock; +struct socket *uninitialized_var (sock );struct sock *sk;int rc =0 ;unsigned int h;
Signature · 1 line
1.7.9.3
Quoted 10 lines · Fri, Sep 13, 2013 at 02:29:12PM CEST, [email protected] wrote:
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]vs->sock = sock; ^ drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here struct socket *sock; ^
Quoted 4 lines
Signed-off-by Prarit Bhargava <[email protected]>Cc "David S. Miller" <[email protected]>
Quoted 10 lines · On Fri, 13 Sep 2013 08:29:12 -0400 Prarit Bhargava <[email protected]> wrote:
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]vs->sock = sock; ^ drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here struct socket *sock; ^
Quoted 4 lines
Signed-off-by Prarit Bhargava <[email protected]>Cc "David S. Miller" <[email protected]>
Which compiler version? Gcc 4.6 is known to be stupid, and I would rather not change the source if it is only caused by a gcc bug fixed in a later release.
Quoted 13 lines · Stephen Hemminger
Quoted 10 lines · On Fri, 13 Sep 2013 08:29:12 -0400 Prarit Bhargava <[email protected]> wrote:
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]vs->sock = sock; ^ drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here struct socket *sock; ^
Quoted 8 lines
Quoted 4 lines
Signed-off-by Prarit Bhargava <[email protected]>Cc "David S. Miller" <[email protected]>Which compiler version? Gcc 4.6 is known to be stupid, and I would rather not change the source if it is only caused by a gcc bug fixed in a later release.
Hi Stephen,
[root@intel-rosecity-06 ~]# gcc --version
gcc (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
P.
Stephen Hemminger
Acked-byQuoted 27 lines · On Fri, 13 Sep 2013 10:23:51 -0400 Prarit Bhargava <[email protected]> wrote:
Quoted 13 lines · Stephen Hemminger
Quoted 10 lines · On Fri, 13 Sep 2013 08:29:12 -0400 Prarit Bhargava <[email protected]> wrote:
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]vs->sock = sock; ^ drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here struct socket *sock; ^Quoted 8 lines
Quoted 4 lines
Signed-off-by Prarit Bhargava <[email protected]>Cc "David S. Miller" <[email protected]>Which compiler version? Gcc 4.6 is known to be stupid, and I would rather not change the source if it is only caused by a gcc bug fixed in a later release.
Hi Stephen,
Quoted 7 lines
[root@intel-rosecity-06 ~]# gcc --version
gcc (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.P.
Argh, gcc got stupid again. I guess we have to live it.
David Miller
maintainerFrom: Prarit Bhargava <[email protected]>
Date: Fri, 13 Sep 2013 08:29:12 -0400
Quoted 11 lines
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]vs->sock = sock; ^ drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here struct socket *sock; ^Signed-off-by Prarit Bhargava <[email protected]>
Make create_v{4,6}_sock() return an err pointer.
Problem solved and no incredibly ugly, unnecessary, annotations.
The error code return from these functions already gets turned into and error pointer at the call site, which makes this situation even more rediculous.
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
vs->sock = sock;
^
drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here
struct socket *sock;
^[v2]: davem suggested resolving this by making create_v{4,6}_sock() return an err pointer.
--- drivers/net/vxlan.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/vxlan.c +12 -14
@@ -2184,7 +2184,7 @@ static void vxlan_del_work(struct work_struct *work)* could be used for both IPv4 and IPv6 communications, but * users may set bindv6only=1. */ -static int create_v6_sock (struct net *net,__be16 port,struct socket **psock) +static struct socket *create_v6_sock (struct net *net,__be16 port) {struct sock *sk;struct socket *sock;
@@ -2197,7 +2197,7 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock) rc =sock_create_kern (AF_INET6 ,SOCK_DGRAM ,IPPROTO_UDP , &sock);if (rc <0 ) {pr_debug ("UDPv6 socket create failed\n" ); -return rc; +return ERR_PTR (rc); }/* Put in proper namespace */
@@ -2212,28 +2212,27 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock)pr_debug ("bind for UDPv6 socket %pI6:%u (%d)\n" , &vxlan_addr.sin6_addr,ntohs (vxlan_addr.sin6_port), rc);sk_release_kernel (sk); - return rc; + return ERR_PTR(rc); }/* At this point, IPv6 module should have been loaded in * sock_create_kern(). */ BUG_ON (!ipv6_stub); - *psock = sock;/* Disable multicast loopback */ inet_sk (sk)->mc_loop =0 ; -return 0 ; +return sock; }#else -static int create_v6_sock (struct net *net,__be16 port,struct socket **psock) +static struct socket *create_v6_sock (struct net *net,__be16 port) { -return -EPFNOSUPPORT ; +return ERR_PTR (-EPFNOSUPPORT ); }#endif -static int create_v4_sock (struct net *net,__be16 port,struct socket **psock) +static struct socket *create_v4_sock (struct net *net,__be16 port) {struct sock *sk;struct socket *sock;
@@ -2248,7 +2247,7 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock) rc =sock_create_kern (AF_INET ,SOCK_DGRAM ,IPPROTO_UDP , &sock);if (rc <0 ) {pr_debug ("UDP socket create failed\n" ); -return rc; +return ERR_PTR (rc); }/* Put in proper namespace */
@@ -2261,13 +2260,12 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock)pr_debug ("bind for UDP socket %pI4:%u (%d)\n" , &vxlan_addr.sin_addr,ntohs (vxlan_addr.sin_port), rc);sk_release_kernel (sk); -return rc; +return ERR_PTR (rc); } - *psock = sock;/* Disable multicast loopback */ inet_sk (sk)->mc_loop =0 ; -return 0 ; +return sock; }/* Create new listen socket if needed */
@@ -2291,9 +2289,9 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,INIT_WORK (&vs->del_work, vxlan_del_work);if (ipv6) - rc =create_v6_sock (net, port, &sock); + sock =create_v6_sock (net, port);else - rc =create_v4_sock (net, port, &sock); + sock =create_v4_sock (net, port);if (rc <0 ) {kfree (vs);return ERR_PTR (rc);
Signature · 1 line
1.7.9.3
You don't seem to have completed this change:
On Tue, 2013-09-17 at 15:12 -0400, Prarit Bhargava wrote:
[...]
drivers/net/vxlan.c static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port, · line 2295
Quoted 10 lines
drivers/net/vxlan.c +2
-2@@ -2291,9 +2289,9 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,INIT_WORK (&vs->del_work, vxlan_del_work);if (ipv6) - rc =create_v6_sock (net, port, &sock); + sock =create_v6_sock (net, port);else - rc =create_v4_sock (net, port, &sock); + sock =create_v4_sock (net, port);if (rc <0 ) {
if (IS_ERR(sock)) {drivers/net/vxlan.c static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port, · line 2297
Quoted 2 lines
drivers/net/vxlan.c +0
-0kfree (vs);return ERR_PTR (rc);
return ERR_CAST(sock);
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH 1/2] net, vxlan Fix compile warning [v3]
Fix a unintialized variable warning.
drivers/net/vxlan.c: In function ‘vxlan_sock_add’:drivers/net/vxlan.c:2240:11: error: ‘sock’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
vs->sock = sock;
^
drivers/net/vxlan.c:2217:17: note: ‘sock’ was declared here
struct socket *sock;
^[v2]: davem suggested resolving this by making create_v{4,6}_sock() return an err pointer.
[v3]: Ben Hutchings pointed out a missed conversion
--- drivers/net/vxlan.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/net/vxlan.c +14 -17
@@ -2184,7 +2184,7 @@ static void vxlan_del_work(struct work_struct *work)* could be used for both IPv4 and IPv6 communications, but * users may set bindv6only=1. */ -static int create_v6_sock (struct net *net,__be16 port,struct socket **psock) +static struct socket *create_v6_sock (struct net *net,__be16 port) {struct sock *sk;struct socket *sock;
@@ -2197,7 +2197,7 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock) rc =sock_create_kern (AF_INET6 ,SOCK_DGRAM ,IPPROTO_UDP , &sock);if (rc <0 ) {pr_debug ("UDPv6 socket create failed\n" ); -return rc; +return ERR_PTR (rc); }/* Put in proper namespace */
@@ -2212,28 +2212,27 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock)pr_debug ("bind for UDPv6 socket %pI6:%u (%d)\n" , &vxlan_addr.sin6_addr,ntohs (vxlan_addr.sin6_port), rc);sk_release_kernel (sk); - return rc; + return ERR_PTR(rc); }/* At this point, IPv6 module should have been loaded in * sock_create_kern(). */ BUG_ON (!ipv6_stub); - *psock = sock;/* Disable multicast loopback */ inet_sk (sk)->mc_loop =0 ; -return 0 ; +return sock; }#else -static int create_v6_sock (struct net *net,__be16 port,struct socket **psock) +static struct socket *create_v6_sock (struct net *net,__be16 port) { -return -EPFNOSUPPORT ; +return ERR_PTR (-EPFNOSUPPORT ); }#endif -static int create_v4_sock (struct net *net,__be16 port,struct socket **psock) +static struct socket *create_v4_sock (struct net *net,__be16 port) {struct sock *sk;struct socket *sock;
@@ -2248,7 +2247,7 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock) rc =sock_create_kern (AF_INET ,SOCK_DGRAM ,IPPROTO_UDP , &sock);if (rc <0 ) {pr_debug ("UDP socket create failed\n" ); -return rc; +return ERR_PTR (rc); }/* Put in proper namespace */
@@ -2261,13 +2260,12 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock)pr_debug ("bind for UDP socket %pI4:%u (%d)\n" , &vxlan_addr.sin_addr,ntohs (vxlan_addr.sin_port), rc);sk_release_kernel (sk); -return rc; +return ERR_PTR (rc); } - *psock = sock;/* Disable multicast loopback */ inet_sk (sk)->mc_loop =0 ; -return 0 ; +return sock; }/* Create new listen socket if needed */
@@ -2278,7 +2276,6 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,struct vxlan_sock *vs;struct socket *sock;struct sock *sk; -int rc =0 ;unsigned int h; vs =kmalloc (sizeof (*vs),GFP_KERNEL );
@@ -2291,12 +2288,12 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,INIT_WORK (&vs->del_work, vxlan_del_work);if (ipv6) - rc =create_v6_sock (net, port, &sock); + sock =create_v6_sock (net, port);else - rc =create_v4_sock (net, port, &sock); -if (rc <0 ) { + sock =create_v4_sock (net, port); +if (IS_ERR (sock)) {kfree (vs); -return ERR_PTR (rc); +return ERR_CAST (sock); } vs->sock = sock;
Signature · 1 line
1.7.9.3
David Miller
maintainerRe: [PATCH 1/2] net, vxlan Fix compile warning [v3]
You must resend all of the patches in the series when you make updates, not just the patches you have changed.
Re: [PATCH 1/2] net, vxlan Fix compile warning [v3]
Quoted 3 lines · David Miller
You must resend all of the patches in the series when you make updates, not just the patches you have changed.
Ah, okay :) I've been dealing with other mailing lists and they prefer single patch updates like this. My apologies ... I'll send out a new update in a week or so when Jack Morgenstein, [email protected], returns.
Again, my apologies for not adhering to this list's rules and procedures.
P.