Skip to contentSkip to conversation

Net: psock_tpacket: Fix null argument warning in walk_tx

PATCH In review Wake Liu 2 participants 2 messages Sep 24, 2025

Subsystems (3)
lore
Share & tools
lore

Wake Liu

author
#0 lore raw

PATCH 1/1 Net: psock_tpacket: Fix null argument warning in walk_tx

The sendto() call in walk_tx() was passing NULL as the buffer argument, which can trigger a -Wnonnull warning with some compilers.

Although the size is 0 and no data is actually sent, passing a null pointer is technically incorrect.

This commit changes NULL to an empty string literal ("") to satisfy the non-null argument requirement and fix the compiler warning.

---
 tools/testing/selftests/net/psock_tpacket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/psock_tpacket.c +1 -1
index 221270cee3ea..0c24adbb292e 100644
@@ -470,7 +470,7 @@ static void walk_tx(int sock, struct ring *ring)
 
 	bug_on(total_packets != 0);
 
-	ret = sendto(sock, NULL, 0, 0, NULL, 0);
+	ret = sendto(sock, "", 0, 0, NULL, 0);
 	if (ret == -1) {
 		perror("sendto");
 		exit(1);
Signature · 1 line
2.51.0.534.gc79095c0ca-goog
#1 lore raw

[PATCH net-next]

Quoted 8 lines · Wake Liu

The sendto() call in walk_tx() was passing NULL as the buffer argument, which can trigger a -Wnonnull warning with some compilers.

Although the size is 0 and no data is actually sent, passing a null pointer is technically incorrect.

This commit changes NULL to an empty string literal ("") to satisfy the non-null argument requirement and fix the compiler warning.

Which library defines this argument as nonnull?

I'm not aware of this restriction in the POSIX standard. This pattern is quite common.

Quoted 22 lines
---
 tools/testing/selftests/net/psock_tpacket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/psock_tpacket.c +1 -1
index 221270cee3ea..0c24adbb292e 100644
@@ -470,7 +470,7 @@ static void walk_tx(int sock, struct ring *ring)
 
 	bug_on(total_packets != 0);
 
-	ret = sendto(sock, NULL, 0, 0, NULL, 0);
+	ret = sendto(sock, "", 0, 0, NULL, 0);
 	if (ret == -1) {
 		perror("sendto");
 		exit(1);
Signature · 1 line
2.51.0.534.gc79095c0ca-goog