Skip to content

Commit 2ed1cf9

Browse files
authored
move addr
1 parent a641d3f commit 2ed1cf9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/common/network/NetworkUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ StatusOr<std::vector<std::pair<std::string, std::string>>> NetworkUtils::listDev
6565
return Status::Error("%s", ::strerror(errno));
6666
}
6767
for (auto* ifa = iflist; ifa != nullptr; ifa = ifa->ifa_next) {
68-
auto* addr = ifa->ifa_addr;
68+
auto* addr = reinterpret_cast<struct sockaddr_in*>(ifa->ifa_addr);
6969
// Skip non-IPv4 devices
7070
if (nullptr == addr || addr->sa_family != AF_INET) {
7171
continue;
7272
}
73-
auto* addr = reinterpret_cast<struct sockaddr_in*>(ifa->ifa_addr);
7473
// inet_ntoa is thread safe but not re-entrant,
7574
// we could use inet_ntop instead when we need support for IPv6
7675
dev2ipv4s.emplace_back(ifa->ifa_name, ::inet_ntoa(addr->sin_addr));

0 commit comments

Comments
 (0)