All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 Jason Xing <kernelxing@tencent.com>,
	 "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>,  Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	 Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Subject: Re: [PATCH] selftests/net: initialize char variable to null
Date: Mon, 24 Nov 2025 12:46:52 -0500	[thread overview]
Message-ID: <willemdebruijn.kernel.6edcbeb29a45@gmail.com> (raw)
In-Reply-To: <20251124161324.16901-1-ankitkhushwaha.linux@gmail.com>

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
> 



  reply	other threads:[~2025-11-24 17:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 16:13 [PATCH] selftests/net: initialize char variable to null Ankit Khushwaha
2025-11-24 17:46 ` Willem de Bruijn [this message]
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

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=willemdebruijn.kernel.6edcbeb29a45@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=ankitkhushwaha.linux@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernelxing@tencent.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.