From: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
To: Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, mptcp@lists.linux.dev,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Subject: [PATCH net v3] selftests: mptcp: Mark xerror and die_perror __noreturn
Date: Thu, 1 Jan 2026 22:58:40 +0530 [thread overview]
Message-ID: <20260101172840.90186-1-ankitkhushwaha.linux@gmail.com> (raw)
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:
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/20251129043808.16714-1-ankitkhushwaha.linux@gmail.com/
- annotate 'xerror()' with __noreturn
- remove defining 'raw_addr' to NULL
v1: https://lore.kernel.org/all/20251126163046.58615-1-ankitkhushwaha.linux@gmail.com/
---
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(-)
diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
index 15d144a25d82..4dd6278cd3dd 100644
--- a/tools/testing/selftests/net/mptcp/Makefile
+++ b/tools/testing/selftests/net/mptcp/Makefile
@@ -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 \
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_diag.c b/tools/testing/selftests/net/mptcp/mptcp_diag.c
index e084796e804d..8e0b1b8d84b6 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_diag.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_diag.c
@@ -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);
diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/selftests/net/mptcp/mptcp_inq.c
index 8e8f6441ad8b..5716998da192 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
@@ -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;
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index 286164f7246e..b6e58d936ebe 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;
@@ -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
next reply other threads:[~2026-01-01 17:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-01 17:28 Ankit Khushwaha [this message]
2026-01-06 0:30 ` [PATCH net v3] selftests: mptcp: Mark xerror and die_perror __noreturn patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260101172840.90186-1-ankitkhushwaha.linux@gmail.com \
--to=ankitkhushwaha.linux@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).