[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240505222639.70317-2-jhubbard@nvidia.com>
Date: Sun, 5 May 2024 15:26:39 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Shuah Khan <shuah@...nel.org>
Cc: "David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Steffen Klassert <steffen.klassert@...unet.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Andreas Färber <afaerber@...e.de>,
Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
Matthieu Baerts <matttbe@...nel.org>,
Mat Martineau <martineau@...nel.org>,
Geliang Tang <geliang@...nel.org>,
Pravin B Shelar <pshelar@....org>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Alexander Mikhalitsyn <alexander@...alicyn.com>,
zhujun2 <zhujun2@...s.chinamobile.com>,
Petr Machata <petrm@...dia.com>,
Ido Schimmel <idosch@...dia.com>,
Hangbin Liu <liuhangbin@...il.com>,
Nikolay Aleksandrov <razor@...ckwall.org>,
Benjamin Poirier <bpoirier@...dia.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Dmitry Safonov <0x7f454c46@...il.com>,
netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-actions@...ts.infradead.org,
mptcp@...ts.linux.dev,
dev@...nvswitch.org,
Valentin Obst <kernel@...entinobst.de>,
linux-kselftest@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>,
llvm@...ts.linux.dev,
John Hubbard <jhubbard@...dia.com>
Subject: [PATCH 2/2] selftests/net: fix uninitialized variables
When building with clang, via:
make LLVM=1 -C tools/testing/selftest
..clang warns about three variables that are not initialized in all
cases:
1) The opt_ipproto_off variable is used uninitialized if "testname" is
not "ip". This seems like an actual bug.
2) The addr_len is used uninitialized, but only in the assert case,
which bails out, so this is harmless.
3) The family variable in add_listener() is only used uninitialized in
the error case (neither IPv4 nor IPv6 is specified), so it's also
harmless.
Fix by initializing each variable.
Signed-off-by: John Hubbard <jhubbard@...dia.com>
---
tools/testing/selftests/net/gro.c | 3 ++-
tools/testing/selftests/net/ip_local_port_range.c | 2 +-
tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/net/gro.c
index 353e1e867fbb..0eb61edaad83 100644
--- a/tools/testing/selftests/net/gro.c
+++ b/tools/testing/selftests/net/gro.c
@@ -110,7 +110,8 @@ static void setup_sock_filter(int fd)
const int dport_off = tcp_offset + offsetof(struct tcphdr, dest);
const int ethproto_off = offsetof(struct ethhdr, h_proto);
int optlen = 0;
- int ipproto_off, opt_ipproto_off;
+ int ipproto_off;
+ int opt_ipproto_off = 0;
int next_off;
if (proto == PF_INET)
diff --git a/tools/testing/selftests/net/ip_local_port_range.c b/tools/testing/selftests/net/ip_local_port_range.c
index 193b82745fd8..29451d2244b7 100644
--- a/tools/testing/selftests/net/ip_local_port_range.c
+++ b/tools/testing/selftests/net/ip_local_port_range.c
@@ -359,7 +359,7 @@ TEST_F(ip_local_port_range, late_bind)
struct sockaddr_in v4;
struct sockaddr_in6 v6;
} addr;
- socklen_t addr_len;
+ socklen_t addr_len = 0;
const int one = 1;
int fd, err;
__u32 range;
diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
index 7426a2cbd4a0..7ad5a59adff2 100644
--- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
+++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
@@ -1276,7 +1276,7 @@ int add_listener(int argc, char *argv[])
struct sockaddr_storage addr;
struct sockaddr_in6 *a6;
struct sockaddr_in *a4;
- u_int16_t family;
+ u_int16_t family = AF_UNSPEC;
int enable = 1;
int sock;
int err;
--
2.45.0
Powered by blists - more mailing lists