Skip to content

Commit 47803e3

Browse files
committed
Applying suggestions from reviewers.
1 parent becab1c commit 47803e3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,24 @@ bool lldb_private::HostSupportsLocalhostToIPv4() {
120120
if (!HostSupportsIPv4())
121121
return false;
122122

123-
auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET,
124-
SOCK_STREAM, IPPROTO_TCP);
125-
return !addresses.empty();
123+
auto addresses = SocketAddress::GetAddressInfo(
124+
"localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
125+
return std::find_if(addresses.begin(), addresses.end(),
126+
[](SocketAddress &addr) {
127+
return addr.GetFamily() == AF_INET;
128+
}) != addresses.end();
126129
}
127130

128131
bool lldb_private::HostSupportsLocalhostToIPv6() {
129132
if (!HostSupportsIPv6())
130133
return false;
131134

132-
auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET6,
133-
SOCK_STREAM, IPPROTO_TCP);
134-
return !addresses.empty();
135+
auto addresses = SocketAddress::GetAddressInfo(
136+
"localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
137+
return std::find_if(addresses.begin(), addresses.end(),
138+
[](SocketAddress &addr) {
139+
return addr.GetFamily() == AF_INET6;
140+
}) != addresses.end();
135141
}
136142

137143
llvm::Expected<std::string> lldb_private::GetLocalhostIP() {

0 commit comments

Comments
 (0)