diff --git a/src/common/netif.cpp b/src/common/netif.cpp index ed891f122c91..d78b1c501dad 100644 --- a/src/common/netif.cpp +++ b/src/common/netif.cpp @@ -134,7 +134,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; }