inet_net_test: Compare pointers against nullptr

GCC does not like passing NULL (__null) to std::ostringstream::operator<<
inside of ATF_REQUIRE_EQ:

lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_ntop_invalid::body() const':
lib/libc/tests/net/inet_net_test.cc:306:9: error: passing NULL to non-pointer argument 1 of 'std::__1::basic_ostream<_CharT, _Traits>& std::__1::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::__1::char_traits<char>]' [-Werror=conversion-null]
  306 |         ATF_REQUIRE_EQ(ret, NULL);
      |         ^~~~~~~~~~~~~~
In file included from /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/sstream:317,
                 from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++/macros.hpp:29,
                 from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++.hpp:29,
                 from lib/libc/tests/net/inet_net_test.cc:33:
/usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__ostream/basic_ostream.h:338:81: note:   declared here
  338 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
      |                                                                            ~~~~~^~~
...

Fixes:		8f4a0d2f7b ("libc: Import OpenBSD's inet_net_{ntop,pton}")
This commit is contained in:
John Baldwin 2025-10-20 14:31:41 -04:00
parent e1aeb58cbb
commit aa358ce3ca

View file

@ -303,25 +303,25 @@ ATF_TEST_CASE_BODY(inet_net_ntop_invalid)
std::ranges::fill(strbuf, 'Z');
auto ret = inet_net_ntop(AF_INET6, &addr6, 128, strbuf.data(), 1);
ATF_REQUIRE_EQ(ret, NULL);
ATF_REQUIRE_EQ(ret, nullptr);
ATF_REQUIRE_EQ(strbuf[1], 'Z');
std::ranges::fill(strbuf, 'Z');
ret = inet_net_ntop(AF_INET, &addr4, 32, strbuf.data(), 1);
ATF_REQUIRE_EQ(ret, NULL);
ATF_REQUIRE_EQ(ret, nullptr);
ATF_REQUIRE_EQ(strbuf[1], 'Z');
/* Check that invalid prefix lengths return an error */
ret = inet_net_ntop(AF_INET6, &addr6, 129, strbuf.data(), strbuf.size());
ATF_REQUIRE_EQ(ret, NULL);
ATF_REQUIRE_EQ(ret, nullptr);
ret = inet_net_ntop(AF_INET6, &addr6, -1, strbuf.data(), strbuf.size());
ATF_REQUIRE_EQ(ret, NULL);
ATF_REQUIRE_EQ(ret, nullptr);
ret = inet_net_ntop(AF_INET, &addr4, 33, strbuf.data(), strbuf.size());
ATF_REQUIRE_EQ(ret, NULL);
ATF_REQUIRE_EQ(ret, nullptr);
ret = inet_net_ntop(AF_INET, &addr4, -1, strbuf.data(), strbuf.size());
ATF_REQUIRE_EQ(ret, NULL);
ATF_REQUIRE_EQ(ret, nullptr);
}
ATF_INIT_TEST_CASES(tcs)