Re: git: e1aeb58cbbc3 - main - inet_net_test: Use int to hold expected return values from inet_net_pton

From: Ryan Libby <rlibby_at_freebsd.org>
Date: Sat, 25 Oct 2025 20:28:05 UTC
On Mon, Oct 20, 2025 at 11:32 AM John Baldwin <jhb@freebsd.org> wrote:
>
> The branch main has been updated by jhb:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=e1aeb58cbbc3839db93ec38ce491b7b9383d5649
>
> commit e1aeb58cbbc3839db93ec38ce491b7b9383d5649
> Author:     John Baldwin <jhb@FreeBSD.org>
> AuthorDate: 2025-10-20 18:31:41 +0000
> Commit:     John Baldwin <jhb@FreeBSD.org>
> CommitDate: 2025-10-20 18:31:41 +0000
>
>     inet_net_test: Use int to hold expected return values from inet_net_pton
>
>     GCC warns about the sign mismatch in comparisons:
>
>     lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet4::body() const':
>     lib/libc/tests/net/inet_net_test.cc:86:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
>        86 |                 ATF_REQUIRE_EQ(bits, addr.bits);
>           |                 ^~~~~~~~~~~~~~
>     lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet6::body() const':
>     lib/libc/tests/net/inet_net_test.cc:205:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
>       205 |                 ATF_REQUIRE_EQ(bits, addr.bits);
>           |                 ^~~~~~~~~~~~~~
>
>     Fixes:          8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
> ---
>  lib/libc/tests/net/inet_net_test.cc | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/libc/tests/net/inet_net_test.cc b/lib/libc/tests/net/inet_net_test.cc
> index 4ecf5a3de492..c4411373165e 100644
> --- a/lib/libc/tests/net/inet_net_test.cc
> +++ b/lib/libc/tests/net/inet_net_test.cc
> @@ -50,7 +50,7 @@ ATF_TEST_CASE_BODY(inet_net_inet4)
>
>         struct test_addr {
>                 std::string input;
> -               unsigned bits;
> +               int bits;
>                 std::string output;
>         };
>
> @@ -134,7 +134,7 @@ ATF_TEST_CASE_BODY(inet_net_inet6)
>
>         struct test_addr {
>                 std::string input;
> -               unsigned bits;
> +               int bits;
>                 std::string output;
>         };
>
>

Could you MFC e1aeb58cbbc3 and aa358ce3ca8e to stable/15 to fix the gcc
build there, or would you mind if I did?

Thanks,

Ryan