From: Muhammad Usama Anjum <MUsamaAnjum@gmail.com>
To: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftest: net: fix socklen_t type mismatch in sctp_collision test
Date: Sun, 26 Oct 2025 23:09:38 +0500 [thread overview]
Message-ID: <f7e2974c-5513-4a05-b136-9902ffc31dbc@gmail.com> (raw)
In-Reply-To: <20251026174649.276515-1-ankitkhushwaha.linux@gmail.com>
On 10/26/25 10:46 PM, 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.
Yes, socklen_t must have 32 bits which would be possible by using unsigned
int or better socklen_t type.
>
> 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);
> | ^
>
> Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.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);
> + int sd, ret;
> + socklen_t len = sizeof(daddr);
> struct timeval tv = {25, 0};
> char buf[] = "hello";
>
next prev parent reply other threads:[~2025-10-26 18:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 17:46 [PATCH] selftest: net: fix socklen_t type mismatch in sctp_collision test Ankit Khushwaha
2025-10-26 18:09 ` Muhammad Usama Anjum [this message]
2025-10-28 16:40 ` Simon Horman
2025-10-28 17:10 ` Ankit Khushwaha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7e2974c-5513-4a05-b136-9902ffc31dbc@gmail.com \
--to=musamaanjum@gmail.com \
--cc=ankitkhushwaha.linux@gmail.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).