linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test
@ 2025-10-28 17:29 Ankit Khushwaha
  2025-10-28 17:41 ` Ankit Khushwaha
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ankit Khushwaha @ 2025-10-28 17:29 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Shuah Khan
  Cc: netfilter-devel, coreteam, netdev, linux-kselftest, linux-kernel,
	Ankit Khushwaha, Muhammad Usama Anjum

Socket APIs like recvfrom(), accept(), and getsockname() expect socklen_t*
arg, but tests were using int variables. This causes -Wpointer-sign 
warnings on platforms where socklen_t is unsigned.

Change the variable type from int to socklen_t to resolve the warning and
ensure type safety across platforms.

warning fixed:

sctp_collision.c:62:70: warning: passing 'int *' to parameter of 
type 'socklen_t *' (aka 'unsigned int *') converts between pointers to 
integer types with different sign [-Wpointer-sign]
   62 |                 ret = recvfrom(sd, buf, sizeof(buf), 
									0, (struct sockaddr *)&daddr, &len);
      |                                                           ^~~~
/usr/include/sys/socket.h:165:27: note: passing argument to 
parameter '__addr_len' here
  165 |                          socklen_t *__restrict __addr_len);
      |                                                ^

Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
---
 tools/testing/selftests/net/netfilter/sctp_collision.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/netfilter/sctp_collision.c b/tools/testing/selftests/net/netfilter/sctp_collision.c
index 21bb1cfd8a85..91df996367e9 100644
--- a/tools/testing/selftests/net/netfilter/sctp_collision.c
+++ b/tools/testing/selftests/net/netfilter/sctp_collision.c
@@ -9,7 +9,8 @@
 int main(int argc, char *argv[])
 {
 	struct sockaddr_in saddr = {}, daddr = {};
-	int sd, ret, len = sizeof(daddr);
+	socklen_t len = sizeof(daddr);
 	struct timeval tv = {25, 0};
 	char buf[] = "hello";
+	int sd, ret;
 
-- 
2.51.0


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

* Re: [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test
  2025-10-28 17:29 [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test Ankit Khushwaha
@ 2025-10-28 17:41 ` Ankit Khushwaha
  2025-10-29 16:50 ` Simon Horman
  2025-10-30  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ankit Khushwaha @ 2025-10-28 17:41 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Shuah Khan
  Cc: netfilter-devel, coreteam, netdev, linux-kselftest, linux-kernel,
	Muhammad Usama Anjum

Hi, 
Forgot to include changelog section in v2. 

Changelog:
v2: 
- formatting fixes compared to v1

v1: https://lore.kernel.org/linux-kselftest/20251026174649.276515-1-ankitkhushwaha.linux@gmail.com/

Thanks
--
Ankit

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

* Re: [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test
  2025-10-28 17:29 [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test Ankit Khushwaha
  2025-10-28 17:41 ` Ankit Khushwaha
@ 2025-10-29 16:50 ` Simon Horman
  2025-10-30  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-10-29 16:50 UTC (permalink / raw)
  To: Ankit Khushwaha
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Shuah Khan, netfilter-devel, coreteam, netdev,
	linux-kselftest, linux-kernel, Muhammad Usama Anjum

On Tue, Oct 28, 2025 at 10:59:47PM +0530, Ankit Khushwaha wrote:
> Socket APIs like recvfrom(), accept(), and getsockname() expect socklen_t*
> arg, but tests were using int variables. This causes -Wpointer-sign 
> warnings on platforms where socklen_t is unsigned.
> 
> Change the variable type from int to socklen_t to resolve the warning and
> ensure type safety across platforms.
> 
> warning fixed:
> 
> sctp_collision.c:62:70: warning: passing 'int *' to parameter of 
> type 'socklen_t *' (aka 'unsigned int *') converts between pointers to 
> integer types with different sign [-Wpointer-sign]
>    62 |                 ret = recvfrom(sd, buf, sizeof(buf), 
> 									0, (struct sockaddr *)&daddr, &len);
>       |                                                           ^~~~
> /usr/include/sys/socket.h:165:27: note: passing argument to 
> parameter '__addr_len' here
>   165 |                          socklen_t *__restrict __addr_len);
>       |                                                ^
> 
> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test
  2025-10-28 17:29 [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test Ankit Khushwaha
  2025-10-28 17:41 ` Ankit Khushwaha
  2025-10-29 16:50 ` Simon Horman
@ 2025-10-30  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-30  0:50 UTC (permalink / raw)
  To: Ankit Khushwaha
  Cc: pablo, kadlec, fw, phil, davem, edumazet, kuba, pabeni, horms,
	shuah, netfilter-devel, coreteam, netdev, linux-kselftest,
	linux-kernel, usama.anjum

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 28 Oct 2025 22:59:47 +0530 you wrote:
> Socket APIs like recvfrom(), accept(), and getsockname() expect socklen_t*
> arg, but tests were using int variables. This causes -Wpointer-sign
> warnings on platforms where socklen_t is unsigned.
> 
> Change the variable type from int to socklen_t to resolve the warning and
> ensure type safety across platforms.
> 
> [...]

Here is the summary with links:
  - [v2] selftest: net: fix socklen_t type mismatch in sctp_collision test
    https://git.kernel.org/netdev/net-next/c/afb8f6567a5b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-10-30  0:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 17:29 [PATCH v2] selftest: net: fix socklen_t type mismatch in sctp_collision test Ankit Khushwaha
2025-10-28 17:41 ` Ankit Khushwaha
2025-10-29 16:50 ` Simon Horman
2025-10-30  0:50 ` patchwork-bot+netdevbpf

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).