HomeFreeBSD

inet_net_test: Compare pointers against nullptr

Description

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: 8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit aa358ce3ca8e1fcfb305025fd00beb2a119c7c77)

Details

Provenance
jhbAuthored on Mon, Oct 20, 6:31 PM
ivyCommitted on Sun, Oct 26, 2:30 AM
Parents
rG7ffd190ae9c8: inet_net_test: Use int to hold expected return values from inet_net_pton
Branches
Unknown
Tags
Unknown