Skip to contentSkip to conversation

selftests: mptcp: Mark xerror __noreturn

PATCH Superseded Ankit Khushwaha 4 participants 6 messages Nov 29, 2025 – Dec 1, 2025

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests: mptcp: Mark xerror __noreturn

Compiler reports potential uses of uninitialized variables in mptcp_connect.c when xerror() is called from failure paths.

mptcp_connect.c:1262:11: warning: variable 'raw_addr' is used
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

xerror() terminates execution by calling exit(), but it is not visible to the compiler & assumes control flow may continue past the call.

Annotate xerror() with __noreturn so the compiler can correctly reason about control flow and avoid false-positive uninitialized variable warnings.

---
changelog:
v2:
- annotate 'xerror()' with __noreturn
- remove defining 'raw_addr' to NULL

v1: https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/net/mptcp/Makefile        | 4 ++++
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ++-
 tools/testing/selftests/net/mptcp/mptcp_inq.c     | 3 ++-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 3 ++-
 4 files changed, 10 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/Makefile +4 -0
index 15d144a25d82..4c94c01b893a 100644
@@ -35,3 +35,7 @@ TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh)
 EXTRA_CLEAN := *.pcap
 
 include ../../lib.mk
+
+$(OUTPUT)/mptcp_connect: CFLAGS += -I$(top_srcdir)/tools/include
+$(OUTPUT)/mptcp_sockopt: CFLAGS += -I$(top_srcdir)/tools/include
+$(OUTPUT)/mptcp_inq: CFLAGS += -I$(top_srcdir)/tools/include
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
index 404a77bf366a..10f6f99cfd4e 100644
@@ -33,6 +33,7 @@
 #include <linux/tcp.h>
 #include <linux/time_types.h>
 #include <linux/sockios.h>
+#include <linux/compiler.h>
 
 extern int optind;
 
@@ -140,7 +141,7 @@ static void die_usage(void)
 	exit(1);
 }
 
-static void xerror(const char *fmt, ...)
+static void __noreturn xerror(const char *fmt, ...)
 {
 	va_list ap;
 
tools/testing/selftests/net/mptcp/mptcp_inq.c +2 -1
index 8e8f6441ad8b..d4a729814662 100644
@@ -28,6 +28,7 @@
 
 #include <linux/tcp.h>
 #include <linux/sockios.h>
+#include <linux/compiler.h>
 
 #ifndef IPPROTO_MPTCP
 #define IPPROTO_MPTCP 262
@@ -52,7 +53,7 @@ static void die_usage(int r)
 	exit(r);
 }
 
-static void xerror(const char *fmt, ...)
+static void __noreturn xerror(const char *fmt, ...)
 {
 	va_list ap;
 
tools/testing/selftests/net/mptcp/mptcp_sockopt.c +2 -1
index 286164f7246e..15cea5e919b5 100644
@@ -25,6 +25,7 @@
 #include <netinet/in.h>
 
 #include <linux/tcp.h>
+#include <linux/compiler.h>
 
 static int pf = AF_INET;
 
@@ -139,7 +140,7 @@ static void die_usage(int r)
 	exit(r);
 }
 
-static void xerror(const char *fmt, ...)
+static void __noreturn xerror(const char *fmt, ...)
 {
 	va_list ap;
 

--
2.52.0

#1 lore raw

Hi Ankit,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 3 failed test(s): packetdrill_dss selftest_diag selftest_mptcp_connect_sendfile 🔴
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/19779229739

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/871522e929e3
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1028829

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

maintainer
#2 lore raw
In reply to Ankit Khushwaha

Hi Ankit,

Quoted 14 lines · Ankit Khushwaha

Compiler reports potential uses of uninitialized variables in mptcp_connect.c when xerror() is called from failure paths.

mptcp_connect.c:1262:11: warning: variable 'raw_addr' is used
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

xerror() terminates execution by calling exit(), but it is not visible to the compiler & assumes control flow may continue past the call.

Annotate xerror() with __noreturn so the compiler can correctly reason about control flow and avoid false-positive uninitialized variable warnings.

Quoted 6 lines

---
changelog:
v2:
- annotate 'xerror()' with __noreturn
- remove defining 'raw_addr' to NULL

Thank you for the new version!

Note: this patch can target 'net' instead of 'net-next'.

Quoted 5 lines
---
 tools/testing/selftests/net/mptcp/Makefile        | 4 ++++
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ++-
 tools/testing/selftests/net/mptcp/mptcp_inq.c     | 3 ++-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 3 ++-

Good idea to fix the other tools too!

Quoted 7 lines
 4 files changed, 10 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/Makefile +0 -0
index 15d144a25d82..4c94c01b893a 100644

tools/testing/selftests/net/mptcp/Makefile TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh) · line 41

Quoted 7 lines
tools/testing/selftests/net/mptcp/Makefile +4 -0
@@ -35,3 +35,7 @@ TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh)
 EXTRA_CLEAN := *.pcap
 
 include ../../lib.mk
+
+$(OUTPUT)/mptcp_connect: CFLAGS += -I$(top_srcdir)/tools/include
+$(OUTPUT)/mptcp_sockopt: CFLAGS += -I$(top_srcdir)/tools/include
+$(OUTPUT)/mptcp_inq: CFLAGS += -I$(top_srcdir)/tools/include

Small detail: I think you can simply append the "main" CFLAGS at the top of the file instead of adding specific rules per tool.

Note: because the CFLAGS variable is already long, please split it like it is done in tools/testing/selftests/net/Makefile.

While at it, do you mind adding __noreturn to die_perror() in mptcp_diag.c mptcp_inq.c mptcp_sockopt.c as well please?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#3 lore raw
Quoted 3 lines · On Sat, 29 Nov 2025 19:13:08 +0100 Matthieu Baerts wrote:
Quoted 3 lines

+$(OUTPUT)/mptcp_connect: CFLAGS += -I$(top_srcdir)/tools/include +$(OUTPUT)/mptcp_sockopt: CFLAGS += -I$(top_srcdir)/tools/include +$(OUTPUT)/mptcp_inq: CFLAGS += -I$(top_srcdir)/tools/include

I believe this is being added via MM or kselftest tree at level of the main ksft makefile. Since this is a false positive, maybe let's defer fixing the issue until after the merge window? When the -I.. flag will be implicitly in place?

maintainer
#4 lore raw

Hi Jakub, Ankit,

Quoted 9 lines · Jakub Kicinski
Quoted 3 lines · On Sat, 29 Nov 2025 19:13:08 +0100 Matthieu Baerts wrote:
Quoted 3 lines

+$(OUTPUT)/mptcp_connect: CFLAGS += -I$(top_srcdir)/tools/include +$(OUTPUT)/mptcp_sockopt: CFLAGS += -I$(top_srcdir)/tools/include +$(OUTPUT)/mptcp_inq: CFLAGS += -I$(top_srcdir)/tools/include

I believe this is being added via MM or kselftest tree at level of the main ksft makefile. Since this is a false positive, maybe let's defer fixing the issue until after the merge window? When the -I.. flag will be implicitly in place?

@Jakub: Thank you for sharing this, I didn't know about that. That makes sense to wait.

@Ankit: do you mind sending a v3 without the modifications of the Makefile, and supporting die_perror() in a bit more than 2 weeks or later, please?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#5 lore raw

Hi Matthieu, Jakub,

Quoted 8 lines · Matthieu Baerts

Hi Jakub, Ankit,

Quoted 5 lines · Jakub Kicinski
Quoted 3 lines · On Sat, 29 Nov 2025 19:13:08 +0100 Matthieu Baerts wrote:
Quoted 3 lines

+$(OUTPUT)/mptcp_connect: CFLAGS += -I$(top_srcdir)/tools/include +$(OUTPUT)/mptcp_sockopt: CFLAGS += -I$(top_srcdir)/tools/include +$(OUTPUT)/mptcp_inq: CFLAGS += -I$(top_srcdir)/tools/include

Quoted 8 lines
Quoted 4 lines

I believe this is being added via MM or kselftest tree at level of the main ksft makefile. Since this is a false positive, maybe let's defer fixing the issue until after the merge window? When the -I.. flag will be implicitly in place?

@Ankit: do you mind sending a v3 without the modifications of the Makefile, and supporting die_perror() in a bit more than 2 weeks or later, please?

I will surely send v3 patch after merge window with the requested changes.

Thanks,
-- Ankit