* [PATCH] selftests/net: initialize char variable to null
@ 2025-11-24 16:13 Ankit Khushwaha
2025-11-24 17:46 ` Willem de Bruijn
0 siblings, 1 reply; 7+ messages in thread
From: Ankit Khushwaha @ 2025-11-24 16:13 UTC (permalink / raw)
To: Willem de Bruijn, Jason Xing, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan
Cc: netdev, linux-kselftest, linux-kernel, Ankit Khushwaha
char variable in 'so_txtime.c' & 'txtimestamp.c' left uninitilized
by when switch default case taken. raises following warning.
txtimestamp.c:240:2: warning: variable 'tsname' is used uninitialized
whenever switch default is taken [-Wsometimes-uninitialized]
so_txtime.c:210:3: warning: variable 'reason' is used uninitialized
whenever switch default is taken [-Wsometimes-uninitialized]
initialize these variables to NULL to fix this.
Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
---
tools/testing/selftests/net/so_txtime.c | 2 +-
tools/testing/selftests/net/txtimestamp.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
index 8457b7ccbc09..b76df1efc2ef 100644
--- a/tools/testing/selftests/net/so_txtime.c
+++ b/tools/testing/selftests/net/so_txtime.c
@@ -174,7 +174,7 @@ static int do_recv_errqueue_timeout(int fdt)
msg.msg_controllen = sizeof(control);
while (1) {
- const char *reason;
+ const char *reason = NULL;
ret = recvmsg(fdt, &msg, MSG_ERRQUEUE);
if (ret == -1 && errno == EAGAIN)
diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index dae91eb97d69..bcc14688661d 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -217,7 +217,7 @@ static void print_timestamp_usr(void)
static void print_timestamp(struct scm_timestamping *tss, int tstype,
int tskey, int payload_len)
{
- const char *tsname;
+ const char *tsname = NULL;
validate_key(tskey, tstype);
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/net: initialize char variable to null
2025-11-24 16:13 [PATCH] selftests/net: initialize char variable to null Ankit Khushwaha
@ 2025-11-24 17:46 ` Willem de Bruijn
2025-11-24 17:59 ` Ankit Khushwaha
0 siblings, 1 reply; 7+ messages in thread
From: Willem de Bruijn @ 2025-11-24 17:46 UTC (permalink / raw)
To: Ankit Khushwaha, Willem de Bruijn, Jason Xing, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Shuah Khan
Cc: netdev, linux-kselftest, linux-kernel, Ankit Khushwaha
Ankit Khushwaha wrote:
> char variable in 'so_txtime.c' & 'txtimestamp.c' left uninitilized
> by when switch default case taken. raises following warning.
>
> txtimestamp.c:240:2: warning: variable 'tsname' is used uninitialized
> whenever switch default is taken [-Wsometimes-uninitialized]
>
> so_txtime.c:210:3: warning: variable 'reason' is used uninitialized
> whenever switch default is taken [-Wsometimes-uninitialized]
>
> initialize these variables to NULL to fix this.
>
> Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
These are false positives as the default branches in both cases exit
the program with error(..).
Since we do not observe these in normal kernel compilations: are you
enabling non-standard warnings?
> ---
> tools/testing/selftests/net/so_txtime.c | 2 +-
> tools/testing/selftests/net/txtimestamp.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
> index 8457b7ccbc09..b76df1efc2ef 100644
> --- a/tools/testing/selftests/net/so_txtime.c
> +++ b/tools/testing/selftests/net/so_txtime.c
> @@ -174,7 +174,7 @@ static int do_recv_errqueue_timeout(int fdt)
> msg.msg_controllen = sizeof(control);
>
> while (1) {
> - const char *reason;
> + const char *reason = NULL;
>
> ret = recvmsg(fdt, &msg, MSG_ERRQUEUE);
> if (ret == -1 && errno == EAGAIN)
> diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
> index dae91eb97d69..bcc14688661d 100644
> --- a/tools/testing/selftests/net/txtimestamp.c
> +++ b/tools/testing/selftests/net/txtimestamp.c
> @@ -217,7 +217,7 @@ static void print_timestamp_usr(void)
> static void print_timestamp(struct scm_timestamping *tss, int tstype,
> int tskey, int payload_len)
> {
> - const char *tsname;
> + const char *tsname = NULL;
>
> validate_key(tskey, tstype);
>
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/net: initialize char variable to null
2025-11-24 17:46 ` Willem de Bruijn
@ 2025-11-24 17:59 ` Ankit Khushwaha
2025-11-24 18:15 ` Willem de Bruijn
0 siblings, 1 reply; 7+ messages in thread
From: Ankit Khushwaha @ 2025-11-24 17:59 UTC (permalink / raw)
To: Willem de Bruijn
Cc: Jason Xing, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kselftest,
linux-kernel
On Mon, Nov 24, 2025 at 12:46:52PM -0500, Willem de Bruijn wrote:
> Ankit Khushwaha wrote:
> > char variable in 'so_txtime.c' & 'txtimestamp.c' left uninitilized
> > by when switch default case taken. raises following warning.
> >
> > txtimestamp.c:240:2: warning: variable 'tsname' is used uninitialized
> > whenever switch default is taken [-Wsometimes-uninitialized]
> >
> > so_txtime.c:210:3: warning: variable 'reason' is used uninitialized
> > whenever switch default is taken [-Wsometimes-uninitialized]
> >
> > initialize these variables to NULL to fix this.
> >
> > Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
>
> These are false positives as the default branches in both cases exit
> the program with error(..).
>
> Since we do not observe these in normal kernel compilations: are you
> enabling non-standard warnings?
Hi Willem,
this warning appeared while building the 'tools/testing/selftests/net'
multiple times.
Cmd used to build
make -C tools/testing/selftests/net CC=clang V=1 -j8
while test building by "make -C tools/testing/selftests/ CC=clang V=1
-j8" doesn't raises these warning.
Thanks,
-- Ankit
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/net: initialize char variable to null
2025-11-24 17:59 ` Ankit Khushwaha
@ 2025-11-24 18:15 ` Willem de Bruijn
2025-11-25 4:33 ` Ankit Khushwaha
0 siblings, 1 reply; 7+ messages in thread
From: Willem de Bruijn @ 2025-11-24 18:15 UTC (permalink / raw)
To: Ankit Khushwaha, Willem de Bruijn
Cc: Jason Xing, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kselftest,
linux-kernel
Ankit Khushwaha wrote:
> On Mon, Nov 24, 2025 at 12:46:52PM -0500, Willem de Bruijn wrote:
> > Ankit Khushwaha wrote:
> > > char variable in 'so_txtime.c' & 'txtimestamp.c' left uninitilized
> > > by when switch default case taken. raises following warning.
> > >
> > > txtimestamp.c:240:2: warning: variable 'tsname' is used uninitialized
> > > whenever switch default is taken [-Wsometimes-uninitialized]
> > >
> > > so_txtime.c:210:3: warning: variable 'reason' is used uninitialized
> > > whenever switch default is taken [-Wsometimes-uninitialized]
> > >
> > > initialize these variables to NULL to fix this.
> > >
> > > Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
> >
> > These are false positives as the default branches in both cases exit
> > the program with error(..).
> >
> > Since we do not observe these in normal kernel compilations: are you
> > enabling non-standard warnings?
>
> Hi Willem,
>
> this warning appeared while building the 'tools/testing/selftests/net'
> multiple times.
> Cmd used to build
> make -C tools/testing/selftests/net CC=clang V=1 -j8
>
> while test building by "make -C tools/testing/selftests/ CC=clang V=1
> -j8" doesn't raises these warning.
This does not reproduce for me.
Can you share the full clang command that V=1 outputs, as well as the
output oof clang --version.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/net: initialize char variable to null
2025-11-24 18:15 ` Willem de Bruijn
@ 2025-11-25 4:33 ` Ankit Khushwaha
2025-11-25 16:04 ` Willem de Bruijn
0 siblings, 1 reply; 7+ messages in thread
From: Ankit Khushwaha @ 2025-11-25 4:33 UTC (permalink / raw)
To: Willem de Bruijn
Cc: Jason Xing, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kselftest,
linux-kernel
On Mon, Nov 24, 2025 at 01:15:33PM -0500, Willem de Bruijn wrote:
> This does not reproduce for me.
>
> Can you share the full clang command that V=1 outputs, as well as the
> output oof clang --version.
Hi Willem,
I have added clang output in
https://gist.github.com/ankitkhushwaha/8e93e3d37917b3571a7ce0e9c9806f18
Thanks,
Ankit
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/net: initialize char variable to null
2025-11-25 4:33 ` Ankit Khushwaha
@ 2025-11-25 16:04 ` Willem de Bruijn
2025-11-25 16:14 ` Willem de Bruijn
0 siblings, 1 reply; 7+ messages in thread
From: Willem de Bruijn @ 2025-11-25 16:04 UTC (permalink / raw)
To: Ankit Khushwaha, Willem de Bruijn
Cc: Jason Xing, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kselftest,
linux-kernel
Ankit Khushwaha wrote:
> On Mon, Nov 24, 2025 at 01:15:33PM -0500, Willem de Bruijn wrote:
> > This does not reproduce for me.
> >
> > Can you share the full clang command that V=1 outputs, as well as the
> > output oof clang --version.
>
> Hi Willem,
> I have added clang output in
> https://gist.github.com/ankitkhushwaha/8e93e3d37917b3571a7ce0e9c9806f18
>
> Thanks,
> Ankit
I see. This is with clang-21. It did not trigger for me with clang-19.
I was able to reproduce with Ubuntu 25.10.
Okay, good to suppress these false positives with normal builds.
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/net: initialize char variable to null
2025-11-25 16:04 ` Willem de Bruijn
@ 2025-11-25 16:14 ` Willem de Bruijn
0 siblings, 0 replies; 7+ messages in thread
From: Willem de Bruijn @ 2025-11-25 16:14 UTC (permalink / raw)
To: Willem de Bruijn, Ankit Khushwaha, Willem de Bruijn
Cc: Jason Xing, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kselftest,
linux-kernel
Willem de Bruijn wrote:
> Ankit Khushwaha wrote:
> > On Mon, Nov 24, 2025 at 01:15:33PM -0500, Willem de Bruijn wrote:
> > > This does not reproduce for me.
> > >
> > > Can you share the full clang command that V=1 outputs, as well as the
> > > output oof clang --version.
> >
> > Hi Willem,
> > I have added clang output in
> > https://gist.github.com/ankitkhushwaha/8e93e3d37917b3571a7ce0e9c9806f18
> >
> > Thanks,
> > Ankit
>
> I see. This is with clang-21. It did not trigger for me with clang-19.
>
> I was able to reproduce with Ubuntu 25.10.
>
> Okay, good to suppress these false positives with normal builds.
>
> Reviewed-by: Willem de Bruijn <willemb@google.com>
>
The patch status is already changes requested.
Please resubmit and target [PATCH net-next]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-25 16:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-24 16:13 [PATCH] selftests/net: initialize char variable to null Ankit Khushwaha
2025-11-24 17:46 ` Willem de Bruijn
2025-11-24 17:59 ` Ankit Khushwaha
2025-11-24 18:15 ` Willem de Bruijn
2025-11-25 4:33 ` Ankit Khushwaha
2025-11-25 16:04 ` Willem de Bruijn
2025-11-25 16:14 ` Willem de Bruijn
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).