History

selftests: mptcp: Initialize variables to quiet gcc 12 warnings

In a few MPTCP selftest tools, gcc 12 complains that the 'sock' variable might be used uninitialized. This is a false positive because the only code path that could lead to uninitialized access is where getaddrinfo() fails, but the local xgetaddrinfo() wrapper exits if such a failure occurs. Initialize the 'sock' variable anyway to allow the tools to build with gcc 12.

Mat Martineau committed 4 years ago

Commit fd37c2e1 parent 06e445f3 files · +3 −3Browse files

Unified · Split

3 files
  1. tools/testing/selftests/net/mptcp/mptcp_connect.c +1 −1
  2. tools/testing/selftests/net/mptcp/mptcp_inq.c +1 −1
  3. tools/testing/selftests/net/mptcp/mptcp_sockopt.c +1 −1
tools/testing/selftests/net/mptcp/mptcp_connect.c+1−1
@@ -265,7 +265,7 @@ static void sock_test_tcpulp(int sock, int proto, unsigned int line) · 264 unmodified lines
265265 static int sock_listen_mptcp(const char * const listenaddr,
266266 const char * const port)
267267 {
268− int sock;
268+ int sock = -1;
269269 struct addrinfo hints = {
270270 .ai_protocol = IPPROTO_TCP,
271271 .ai_socktype = SOCK_STREAM,
tools/testing/selftests/net/mptcp/mptcp_inq.c+1−1
@@ -88,7 +88,7 @@ static void xgetaddrinfo(const char *node, const char *service, · 87 unmodified lines
8888 static int sock_listen_mptcp(const char * const listenaddr,
8989 const char * const port)
9090 {
91− int sock;
91+ int sock = -1;
9292 struct addrinfo hints = {
9393 .ai_protocol = IPPROTO_TCP,
9494 .ai_socktype = SOCK_STREAM,
tools/testing/selftests/net/mptcp/mptcp_sockopt.c+1−1
@@ -136,7 +136,7 @@ static void xgetaddrinfo(const char *node, const char *service, · 135 unmodified lines
136136 static int sock_listen_mptcp(const char * const listenaddr,
137137 const char * const port)
138138 {
139− int sock;
139+ int sock = -1;
140140 struct addrinfo hints = {
141141 .ai_protocol = IPPROTO_TCP,
142142 .ai_socktype = SOCK_STREAM,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t