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
265static int sock_listen_mptcp(const char * const listenaddr,265static int sock_listen_mptcp(const char * const listenaddr,
266 const char * const port)266 const char * const port)
267{267{
268 int sock;268 int sock = -1;
269 struct addrinfo hints = {269 struct addrinfo hints = {
270 .ai_protocol = IPPROTO_TCP,270 .ai_protocol = IPPROTO_TCP,
271 .ai_socktype = SOCK_STREAM,271 .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
88static int sock_listen_mptcp(const char * const listenaddr,88static int sock_listen_mptcp(const char * const listenaddr,
89 const char * const port)89 const char * const port)
90{90{
91 int sock;91 int sock = -1;
92 struct addrinfo hints = {92 struct addrinfo hints = {
93 .ai_protocol = IPPROTO_TCP,93 .ai_protocol = IPPROTO_TCP,
94 .ai_socktype = SOCK_STREAM,94 .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
136static int sock_listen_mptcp(const char * const listenaddr,136static int sock_listen_mptcp(const char * const listenaddr,
137 const char * const port)137 const char * const port)
138{138{
139 int sock;139 int sock = -1;
140 struct addrinfo hints = {140 struct addrinfo hints = {
141 .ai_protocol = IPPROTO_TCP,141 .ai_protocol = IPPROTO_TCP,
142 .ai_socktype = SOCK_STREAM,142 .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