Build the UDP relay with Clang on musl

musl's CMSG_NXTHDR compares a size_t with a ptrdiff_t, which Clang's
-Wsign-compare rejects in C++. Call it from one helper that suppresses
the warning there.
This commit is contained in:
Max Lv
2026-10-14 22:53:10 +08:00
parent 1a7b11e2b8
commit b30ae18a0b
+12 -1
View File
@@ -45,6 +45,17 @@ using event::Flow;
namespace {
#ifdef __linux__
// musl's CMSG_NXTHDR compares a size_t with a ptrdiff_t.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
cmsghdr *next_cmsg(msghdr *msg, cmsghdr *c) noexcept
{
return CMSG_NXTHDR(msg, c);
}
#pragma GCC diagnostic pop
#endif
constexpr int kQosTos = 46 << 2; // DSCP EF, as udprelay.cpp
constexpr int kReceiveBurst = 64;
constexpr std::uint64_t kTtl2022 = 600; // seconds an idle AEAD-2022 client session is kept
@@ -339,7 +350,7 @@ void UdpRelay::receive(Listener &listener) noexcept
msg.msg_iovlen = 1;
r = recvmsg(listener.poll.fd(), &msg, 0);
if (r >= 0) {
for (cmsghdr *c = CMSG_FIRSTHDR(&msg); c != nullptr; c = CMSG_NXTHDR(&msg, c)) {
for (cmsghdr *c = CMSG_FIRSTHDR(&msg); c != nullptr; c = next_cmsg(&msg, c)) {
if (c->cmsg_level == SOL_IP && c->cmsg_type == IP_RECVORIGDSTADDR) {
std::memcpy(&original, CMSG_DATA(c), sizeof(sockaddr_in));
original.ss_family = AF_INET;