* [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn
@ 2025-11-29 4:38 Ankit Khushwaha
2025-11-29 18:13 ` Matthieu Baerts
0 siblings, 1 reply; 5+ messages in thread
From: Ankit Khushwaha @ 2025-11-29 4:38 UTC (permalink / raw)
To: Matthieu Baerts, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: Shuah Khan, netdev, mptcp, linux-kselftest, linux-kernel,
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.
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@gmail.com/
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn
2025-11-29 4:38 [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn Ankit Khushwaha
@ 2025-11-29 18:13 ` Matthieu Baerts
2025-11-30 1:41 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Baerts @ 2025-11-29 18:13 UTC (permalink / raw)
To: Ankit Khushwaha, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: Shuah Khan, netdev, mptcp, linux-kselftest, linux-kernel
Hi Ankit,
On 29/11/2025 05:38, Ankit Khushwaha wrote:
> 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
Thank you for the new version!
Note: this patch can target 'net' instead of 'net-next'.
> ---
> 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!
> 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
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
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn
2025-11-29 18:13 ` Matthieu Baerts
@ 2025-11-30 1:41 ` Jakub Kicinski
2025-11-30 17:09 ` Matthieu Baerts
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-11-30 1:41 UTC (permalink / raw)
To: Matthieu Baerts
Cc: Ankit Khushwaha, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, Shuah Khan, netdev,
mptcp, linux-kselftest, linux-kernel
On Sat, 29 Nov 2025 19:13:08 +0100 Matthieu Baerts wrote:
> > +$(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?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn
2025-11-30 1:41 ` Jakub Kicinski
@ 2025-11-30 17:09 ` Matthieu Baerts
2025-12-01 4:07 ` Ankit Khushwaha
0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Baerts @ 2025-11-30 17:09 UTC (permalink / raw)
To: Jakub Kicinski, Ankit Khushwaha
Cc: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Shuah Khan, netdev, mptcp,
linux-kselftest, linux-kernel
Hi Jakub, Ankit,
On 30/11/2025 02:41, Jakub Kicinski wrote:
> On Sat, 29 Nov 2025 19:13:08 +0100 Matthieu Baerts wrote:
>>> +$(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
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn
2025-11-30 17:09 ` Matthieu Baerts
@ 2025-12-01 4:07 ` Ankit Khushwaha
0 siblings, 0 replies; 5+ messages in thread
From: Ankit Khushwaha @ 2025-12-01 4:07 UTC (permalink / raw)
To: Matthieu Baerts
Cc: Jakub Kicinski, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, Shuah Khan, netdev,
mptcp, linux-kselftest, linux-kernel
Hi Matthieu, Jakub,
On Sun, Nov 30, 2025 at 06:09:18PM +0100, Matthieu Baerts wrote:
> Hi Jakub, Ankit,
>
> On 30/11/2025 02:41, Jakub Kicinski wrote:
> > On Sat, 29 Nov 2025 19:13:08 +0100 Matthieu Baerts wrote:
> >>> +$(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?
>
> @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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-01 4:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-29 4:38 [PATCH net-next v2] selftests: mptcp: Mark xerror __noreturn Ankit Khushwaha
2025-11-29 18:13 ` Matthieu Baerts
2025-11-30 1:41 ` Jakub Kicinski
2025-11-30 17:09 ` Matthieu Baerts
2025-12-01 4:07 ` Ankit Khushwaha
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).