diff --git a/src/common/netif.cpp b/src/common/netif.cpp index 7424f977c7e..276be8e2f6a 100644 --- a/src/common/netif.cpp +++ b/src/common/netif.cpp @@ -29,6 +29,8 @@ #include #endif +#include + namespace { // Linux and FreeBSD 14.0+. For FreeBSD 13.2 the code can be compiled but @@ -93,7 +95,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)) { rtmsg* r = (rtmsg*)NLMSG_DATA(hdr); int remaining_len = RTM_PAYLOAD(hdr);