Skip to contentSkip to conversation

selftests/net: initialize char variable to null

PATCH Applied Ankit Khushwaha 3 participants 3 messages Nov 25, 2025 – Nov 27, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/net: initialize char variable to null

char variable in 'so_txtime.c' & 'txtimestamp.c' were left uninitilized when switch default case taken. which 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]

initializing these variables to NULL to fix this.

---
changelog:
v2:
change patch name to net-next.

v1:
https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/net/so_txtime.c   | 2 +-
 tools/testing/selftests/net/txtimestamp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/so_txtime.c +1 -1
index 8457b7ccbc09..b76df1efc2ef 100644
@@ -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)
tools/testing/selftests/net/txtimestamp.c +1 -1
index dae91eb97d69..bcc14688661d 100644
@@ -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

maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Ankit Khushwaha

char variable in 'so_txtime.c' & 'txtimestamp.c' were left uninitilized when switch default case taken. which raises following warning.

txtimestamp.c:240:2: warning: variable 'tsname' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

Quoted 6 lines

so_txtime.c:210:3: warning: variable 'reason' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]

initializing these variables to NULL to fix this.

minor typo in the first sentence, and there is somewhat interesting context in the v1. But no need to respin just for that.

Quoted 41 lines

---
changelog:
v2:
change patch name to net-next.

v1:
https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/net/so_txtime.c   | 2 +-
 tools/testing/selftests/net/txtimestamp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/so_txtime.c +1 -1
index 8457b7ccbc09..b76df1efc2ef 100644
@@ -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)
tools/testing/selftests/net/txtimestamp.c +1 -2
index dae91eb97d69..bcc14688661d 100644
@@ -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

#2 lore raw
In reply to Ankit Khushwaha
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 25 Nov 2025 22:23:02 +0530 you wrote:

char variable in 'so_txtime.c' & 'txtimestamp.c' were left uninitilized when switch default case taken. which 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]

[...]

Here is the summary with links:
- [net-next,v2] selftests/net: initialize char variable to null

    https://git.kernel.org/netdev/net-next/c/af7273cc7ae0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html