Commit fd37c2ec authored by Mat Martineau's avatar Mat Martineau Committed by Jakub Kicinski
Browse files

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.

Fixes: 048d19d4 ("mptcp: add basic kselftest for mptcp")
Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 06e445f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -265,7 +265,7 @@ static void sock_test_tcpulp(int sock, int proto, unsigned int line)
static int sock_listen_mptcp(const char * const listenaddr,
static int sock_listen_mptcp(const char * const listenaddr,
			     const char * const port)
			     const char * const port)
{
{
	int sock;
	int sock = -1;
	struct addrinfo hints = {
	struct addrinfo hints = {
		.ai_protocol = IPPROTO_TCP,
		.ai_protocol = IPPROTO_TCP,
		.ai_socktype = SOCK_STREAM,
		.ai_socktype = SOCK_STREAM,
+1 −1
Original line number Original line Diff line number Diff line
@@ -88,7 +88,7 @@ static void xgetaddrinfo(const char *node, const char *service,
static int sock_listen_mptcp(const char * const listenaddr,
static int sock_listen_mptcp(const char * const listenaddr,
			     const char * const port)
			     const char * const port)
{
{
	int sock;
	int sock = -1;
	struct addrinfo hints = {
	struct addrinfo hints = {
		.ai_protocol = IPPROTO_TCP,
		.ai_protocol = IPPROTO_TCP,
		.ai_socktype = SOCK_STREAM,
		.ai_socktype = SOCK_STREAM,
+1 −1
Original line number Original line Diff line number Diff line
@@ -136,7 +136,7 @@ static void xgetaddrinfo(const char *node, const char *service,
static int sock_listen_mptcp(const char * const listenaddr,
static int sock_listen_mptcp(const char * const listenaddr,
			     const char * const port)
			     const char * const port)
{
{
	int sock;
	int sock = -1;
	struct addrinfo hints = {
	struct addrinfo hints = {
		.ai_protocol = IPPROTO_TCP,
		.ai_protocol = IPPROTO_TCP,
		.ai_socktype = SOCK_STREAM,
		.ai_socktype = SOCK_STREAM,