git: 42cf7ea8dca0 - releng/15.0 - inet_net_test: Use int to hold expected return values from inet_net_pton

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sun, 26 Oct 2025 04:13:47 UTC
The branch releng/15.0 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=42cf7ea8dca0abd507965a6fe63ac07fb62060fd

commit 42cf7ea8dca0abd507965a6fe63ac07fb62060fd
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-10-20 18:31:41 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-26 04:13:26 +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);
          |                 ^~~~~~~~~~~~~~
    
    Approved by:    re (cperciva)
    Fixes:          8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
    (cherry picked from commit e1aeb58cbbc3839db93ec38ce491b7b9383d5649)
    (cherry picked from commit 7ffd190ae9c82e4359d8a6f6ae2d1b82e8eb6453)
---
 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 50687cac006a..60b60b152eca 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;
 	};