diff --git a/src/common/netif.cpp b/src/common/netif.cpp index ed891f122c9..712188f565e 100644 --- a/src/common/netif.cpp +++ b/src/common/netif.cpp @@ -34,6 +34,8 @@ #include #endif +#include + namespace { //! Return CNetAddr for the specified OS-level network address. @@ -134,7 +136,9 @@ std::optional QueryDefaultGatewayImpl(sa_family_t family) return std::nullopt; } - for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, recv_result); hdr = NLMSG_NEXT(hdr, recv_result)) { + using recv_result_t = std::conditional_t, int64_t, decltype(NLMSG_HDRLEN)>; + + for (nlmsghdr* hdr = (nlmsghdr*)response; NLMSG_OK(hdr, static_cast(recv_result)); hdr = NLMSG_NEXT(hdr, recv_result)) { if (!(hdr->nlmsg_flags & NLM_F_MULTI)) { done = true; }