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.
Signed-off-by: Ankit Khushwaha ankitkhushwaha.linux@gmail.com --- changelog: v2: - annotate 'xerror()' with __noreturn - remove defining 'raw_addr' to NULL
v1: https://lore.kernel.org/all/20251126163046.58615-1-ankitkhushwaha.linux@gmai... --- 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(-)
diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile index 15d144a25d82..4c94c01b893a 100644 --- a/tools/testing/selftests/net/mptcp/Makefile +++ b/tools/testing/selftests/net/mptcp/Makefile @@ -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 diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index 404a77bf366a..10f6f99cfd4e 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -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;
diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/selftests/net/mptcp/mptcp_inq.c index 8e8f6441ad8b..d4a729814662 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_inq.c +++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c @@ -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;
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c index 286164f7246e..15cea5e919b5 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -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