selftests: mptcp: Mark xerror and die_perror __noreturn
Subsystems (4)
PATCH v3 1/1 selftests: mptcp: Mark xerror and die_perror __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:
v3:
- also annotate 'die_perror()' with __noreturn
- add CFLAGS at top of makefile
- target this patch to net instead of net-next as suggested by Matthieu
v2: https://lore.kernel.org/all/[email protected]/
- annotate 'xerror()' with __noreturn
- remove defining 'raw_addr' to NULL
v1: https://lore.kernel.org/all/[email protected]/
--- tools/testing/selftests/net/mptcp/Makefile | 1 + tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ++- tools/testing/selftests/net/mptcp/mptcp_diag.c | 3 ++- tools/testing/selftests/net/mptcp/mptcp_inq.c | 5 +++-- tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 5 +++-- 5 files changed, 11 insertions(+), 6 deletions(-)
tools/testing/selftests/net/mptcp/Makefile +1 -0
@@ -3,6 +3,7 @@ top_srcdir = ../../../../.. CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) +CFLAGS += -I$(top_srcdir)/tools/include TEST_PROGS := \ diag.sh \
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -1
@@ -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_diag.c +2 -1
@@ -5,6 +5,7 @@#include <linux/rtnetlink.h> #include <linux/inet_diag.h> #include <linux/netlink.h> +#include <linux/compiler.h> #include <sys/socket.h> #include <netinet/in.h> #include <linux/tcp.h>
@@ -87,7 +88,7 @@ enum {#define rta_getattr (type, value) (*(type *)RTA_DATA(value)) -static void die_perror (const char *msg) +static void __noreturn die_perror (const char *msg) {perror (msg);exit (1 );
tools/testing/selftests/net/mptcp/mptcp_inq.c +3 -2
@@ -28,6 +28,7 @@#include <linux/tcp.h> #include <linux/sockios.h> +#include <linux/compiler.h> #ifndef IPPROTO_MPTCP #define IPPROTO_MPTCP 262
@@ -40,7 +41,7 @@ static int pf = AF_INET;static int proto_tx =IPPROTO_MPTCP ;static int proto_rx =IPPROTO_MPTCP ; -static void die_perror (const char *msg) +static void __noreturn die_perror (const char *msg) {perror (msg);exit (1 );
@@ -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 +3 -2
@@ -25,6 +25,7 @@#include <netinet/in.h> #include <linux/tcp.h> +#include <linux/compiler.h> static int pf =AF_INET ;
@@ -127,7 +128,7 @@ struct so_state {#define MIN (a, b) ((a) < (b) ? (a) : (b))#endif -static void die_perror (const char *msg) +static void __noreturn die_perror (const char *msg) {perror (msg);exit (1 );
@@ -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
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): Success! ✅
- 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/20642822498
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/4b6275a5aee6
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1037823
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-normalFor 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)
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 1 Jan 2026 22:58:40 +0530 you wrote:
Compiler reports potential uses of uninitialized variables in
mptcp_connect.cwhenxerror()is called from failure paths.mptcp_connect.c:1262:11: warning: variable '
raw_addr' is used
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized][...]
Here is the summary with links:
- [net,v3] selftests: mptcp: Mark xerror and die_perror __noreturn
https://git.kernel.org/netdev/net/c/2fa98059fd5a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html