Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Link: https://patch.msgid.link/20251125165302.20079-1-ankitkhushwaha.linux@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ankit Khushwaha and committed by
Jakub Kicinski
af7273cc ab084f0b

+2 -2
+1 -1
tools/testing/selftests/net/so_txtime.c
··· 174 174 msg.msg_controllen = sizeof(control); 175 175 176 176 while (1) { 177 - const char *reason; 177 + const char *reason = NULL; 178 178 179 179 ret = recvmsg(fdt, &msg, MSG_ERRQUEUE); 180 180 if (ret == -1 && errno == EAGAIN)
+1 -1
tools/testing/selftests/net/txtimestamp.c
··· 217 217 static void print_timestamp(struct scm_timestamping *tss, int tstype, 218 218 int tskey, int payload_len) 219 219 { 220 - const char *tsname; 220 + const char *tsname = NULL; 221 221 222 222 validate_key(tskey, tstype); 223 223