From bca6bc70b2f256eaf78fb2dbe586c81831d86dd6 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Tue, 27 May 2025 13:48:29 -0700 Subject: [PATCH] Silence -Wnontrivial-memcall warning in ConnKey methods --- src/IPAddr.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/IPAddr.cc b/src/IPAddr.cc index 1df6e26a4e..a8517daaa9 100644 --- a/src/IPAddr.cc +++ b/src/IPAddr.cc @@ -33,8 +33,9 @@ ConnKey& ConnKey::operator=(const ConnKey& rhs) { // Because of padding in the object, this needs to memset to clear out // the extra memory used by padding. Otherwise, the session key stuff - // doesn't work quite right. - memset(this, 0, sizeof(ConnKey)); + // doesn't work quite right. The static_cast is to silence a + // -Wnontrival-memcall warning from clang++ 17 and later. + memset(static_cast(this), 0, sizeof(ConnKey)); memcpy(&ip1, &rhs.ip1, sizeof(in6_addr)); memcpy(&ip2, &rhs.ip2, sizeof(in6_addr)); @@ -104,8 +105,9 @@ void ConnKey::Init(const IPAddr& src, const IPAddr& dst, uint16_t src_port, uint bool one_way) { // Because of padding in the object, this needs to memset to clear out // the extra memory used by padding. Otherwise, the session key stuff - // doesn't work quite right. - memset(this, 0, sizeof(ConnKey)); + // doesn't work quite right. The static_cast is to silence a + // -Wnontrival-memcall warning from clang++ 17 and later. + memset(static_cast(this), 0, sizeof(ConnKey)); // Lookup up connection based on canonical ordering, which is // the smaller of and