Skip to content

Commit 4b419bf

Browse files
authored
Merge pull request PowerDNS#17463 from rgacogne/ddist-lua-offsetof-warnings
dnsdist: Fix warnings about the use of `offsetof` on non-POD types
2 parents 0cca2e3 + cab0626 commit 4b419bf

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pdns/dnsdistdist/dnsdist-lua-ffi.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct dnsdist_ffi_dnsquestion_t
6161
{
6262
}
6363

64+
// these two fields (pointer to DNSQuestion, then objectType) should remain at the same offset
65+
// here and in dnsdist_ffi_dnsresponse_t
6466
DNSQuestion* dq{nullptr};
6567
const dnsdist::lua::ffi::ObjectType objectType{dnsdist::lua::ffi::ObjectType::Question};
6668
ComboAddress maskedRemote;
@@ -103,6 +105,8 @@ struct dnsdist_ffi_dnsresponse_t
103105
{
104106
}
105107

108+
// these two fields (pointer to DNSResponse, then objectType) should remain at the same offset
109+
// here and in dnsdist_ffi_dnsquestion_t
106110
DNSResponse* dr{nullptr};
107111
const dnsdist::lua::ffi::ObjectType objectType{dnsdist::lua::ffi::ObjectType::Response};
108112
std::optional<std::string> result{std::nullopt};
@@ -113,9 +117,6 @@ struct dnsdist_ffi_dnsresponse_t
113117
#endif /* DISABLE_PROTOBUF */
114118
};
115119

116-
static_assert(offsetof(dnsdist_ffi_dnsresponse_t, dr) == offsetof(dnsdist_ffi_dnsquestion_t, dq), "The DNSQuestion object in dnsdist_ffi_dnsquestion_t and DNSResponse object in dnsdist_ffi_dnsresponse_t must be located at the same offset");
117-
static_assert(offsetof(dnsdist_ffi_dnsresponse_t, objectType) == offsetof(dnsdist_ffi_dnsquestion_t, objectType), "The object type in dnsdist_ffi_dnsquestion_t and dnsdist_ffi_dnsresponse_t must be located at the same offset");
118-
119120
// dnsdist_ffi_server_t is a lightuserdata
120121
template <>
121122
struct LuaContext::Pusher<dnsdist_ffi_server_t*>

0 commit comments

Comments
 (0)