Skip to contentSkip to conversation

hv_sock: Suppress bogus "may be used uninitialized" warnings

PATCH Applied Dexuan Cui 3 participants 3 messages Jun 15, 2019 – Jun 16, 2019

Subsystems (5)
lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH 1/1 hv_sock: Suppress bogus "may be used uninitialized" warnings

gcc 8.2.0 may report these bogus warnings under some condition:

warning: ‘vnew’ may be used uninitialized in this function
warning: ‘hvs_new’ may be used uninitialized in this function

Actually, the 2 pointers are only initialized and used if the variable "conn_from_host" is true. The code is not buggy here.

---
 net/vmw_vsock/hyperv_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/vmw_vsock/hyperv_transport.c +2 -2
index 8d1ea9eda8a2..cd3f47f54fa7 100644
@@ -329,8 +329,8 @@ static void hvs_open_connection(struct vmbus_channel *chan)
 
 	struct sockaddr_vm addr;
 	struct sock *sk, *new = NULL;
-	struct vsock_sock *vnew;
-	struct hvsock *hvs, *hvs_new;
+	struct vsock_sock *vnew = NULL;
+	struct hvsock *hvs, *hvs_new = NULL;
 	int ret;
 
 	if_type = &chan->offermsg.offer.if_type;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 30 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Dexuan Cui
Sent: Friday, June 14, 2019 10:01 PM
To: [email protected]; [email protected]; Michael Kelley <[email protected]>
Cc: [email protected]; [email protected]; KY Srinivasan <[email protected]>; Stephen Hemminger <[email protected]>; Haiyang Zhang <[email protected]>; Sasha Levin <[email protected]>; [email protected]; [email protected]; [email protected]; vkuznets <[email protected]>; [email protected]; Dexuan Cui <[email protected]>
Subject: [PATCH net] hv_sock: Suppress bogus "may be used uninitialized" warnings

gcc 8.2.0 may report these bogus warnings under some condition:

warning: ‘vnew’ may be used uninitialized in this function
warning: ‘hvs_new’ may be used uninitialized in this function

Actually, the 2 pointers are only initialized and used if the variable "conn_from_host" is true. The code is not buggy here.

---
 net/vmw_vsock/hyperv_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/vmw_vsock/hyperv_transport.c +0 -0
index 8d1ea9eda8a2..cd3f47f54fa7 100644

net/vmw_vsock/hyperv_transport.c static void hvs_open_connection(struct vmbus_channel *chan) · line 335

Quoted 9 lines
net/vmw_vsock/hyperv_transport.c +2 -2
@@ -329,8 +329,8 @@ static void hvs_open_connection(struct vmbus_channel *chan)
 
 	struct sockaddr_vm addr;
 	struct sock *sk, *new = NULL;
-	struct vsock_sock *vnew;
-	struct hvsock *hvs, *hvs_new;
+	struct vsock_sock *vnew = NULL;
+	struct hvsock *hvs, *hvs_new = NULL;
 	int ret;
 

These are all already fixed under
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=ac383f58f3c98de37fa67452acc5bd677396e9f3
Its just that that commit hasn't merged with the 'net' branch yet.

Quoted 3 lines
net/vmw_vsock/hyperv_transport.c +0 -1
 	if_type = &chan->offermsg.offer.if_type;
--

2.19.1

maintainer Applied
#2 lore raw
In reply to Dexuan Cui

From: Dexuan Cui <[email protected]>
Date: Sat, 15 Jun 2019 05:00:57 +0000

Quoted 9 lines

gcc 8.2.0 may report these bogus warnings under some condition:

warning: ‘vnew’ may be used uninitialized in this function
warning: ‘hvs_new’ may be used uninitialized in this function

Actually, the 2 pointers are only initialized and used if the variable "conn_from_host" is true. The code is not buggy here.

Applied.