Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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". Willem de Bruijn pointed out that this is an actual bug, and
suggested the fix that I'm using here (thanks!).

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@nvidia.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Acked-by: Mat Martineau <martineau@kernel.org>
Link: https://lore.kernel.org/r/20240506190204.28497-1-jhubbard@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

John Hubbard and committed by
Jakub Kicinski
eb709b5f 0d5044b4

+5 -2
+3
tools/testing/selftests/net/gro.c
··· 119 119 next_off = offsetof(struct ipv6hdr, nexthdr); 120 120 ipproto_off = ETH_HLEN + next_off; 121 121 122 + /* Overridden later if exthdrs are used: */ 123 + opt_ipproto_off = ipproto_off; 124 + 122 125 if (strcmp(testname, "ip") == 0) { 123 126 if (proto == PF_INET) 124 127 optlen = sizeof(struct ip_timestamp);
+1 -1
tools/testing/selftests/net/ip_local_port_range.c
··· 359 359 struct sockaddr_in v4; 360 360 struct sockaddr_in6 v6; 361 361 } addr; 362 - socklen_t addr_len; 362 + socklen_t addr_len = 0; 363 363 const int one = 1; 364 364 int fd, err; 365 365 __u32 range;
+1 -1
tools/testing/selftests/net/mptcp/pm_nl_ctl.c
··· 1276 1276 struct sockaddr_storage addr; 1277 1277 struct sockaddr_in6 *a6; 1278 1278 struct sockaddr_in *a4; 1279 - u_int16_t family; 1279 + u_int16_t family = AF_UNSPEC; 1280 1280 int enable = 1; 1281 1281 int sock; 1282 1282 int err;