netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Net: psock_tpacket: Fix null argument warning in walk_tx
@ 2025-09-24  4:41 Wake Liu
  2025-09-24 20:21 ` Willem de Bruijn
  0 siblings, 1 reply; 2+ messages in thread
From: Wake Liu @ 2025-09-24  4:41 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Shuah Khan, netdev, linux-kselftest, linux-kernel
  Cc: Simon Horman, 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.

Signed-off-by: Wake Liu <wakel@google.com>
---
 tools/testing/selftests/net/psock_tpacket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index 221270cee3ea..0c24adbb292e 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -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);
-- 
2.51.0.534.gc79095c0ca-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Net: psock_tpacket: Fix null argument warning in walk_tx
  2025-09-24  4:41 [PATCH] Net: psock_tpacket: Fix null argument warning in walk_tx Wake Liu
@ 2025-09-24 20:21 ` Willem de Bruijn
  0 siblings, 0 replies; 2+ messages in thread
From: Willem de Bruijn @ 2025-09-24 20:21 UTC (permalink / raw)
  To: Wake Liu, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Shuah Khan, netdev, linux-kselftest, linux-kernel
  Cc: Simon Horman, Wake Liu

[PATCH net-next]

Wake Liu wrote:
> 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.

> 
> Signed-off-by: Wake Liu <wakel@google.com>
> ---
>  tools/testing/selftests/net/psock_tpacket.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
> index 221270cee3ea..0c24adbb292e 100644
> --- a/tools/testing/selftests/net/psock_tpacket.c
> +++ b/tools/testing/selftests/net/psock_tpacket.c
> @@ -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);
> -- 
> 2.51.0.534.gc79095c0ca-goog
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-24 20:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24  4:41 [PATCH] Net: psock_tpacket: Fix null argument warning in walk_tx Wake Liu
2025-09-24 20:21 ` 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).