Skip to content

Libraries - fix some warnings with gcc ≥12 #9244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
LEAmDNS - consistent const <-> non-const accessors
> error: infinite recursion detected [-Werror=infinite-recursion]
  • Loading branch information
mcspr committed May 20, 2025
commit 6c7c4c70e1e1c0b699f0ed7151c24947a9d0202c
22 changes: 12 additions & 10 deletions libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,15 +1735,6 @@ namespace MDNSImplementation
const MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address(
const IPAddress& p_IPAddress) const
{
return (stcIP4Address*)(((const stcAnswer*)this)->findIP4Address(p_IPAddress));
}

/*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address
*/
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address(const IPAddress& p_IPAddress)
{
stcIP4Address* pIP4Address = m_pIP4Addresses;
while (pIP4Address)
Expand All @@ -1757,6 +1748,16 @@ namespace MDNSImplementation
return pIP4Address;
}

/*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address
*/
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address(const IPAddress& p_IPAddress)
{
const auto& cref = static_cast<const decltype(*this)>(*this);
return const_cast<stcIP4Address*>(cref.findIP4Address(p_IPAddress));
}

/*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::IP4AddressCount
*/
Expand Down Expand Up @@ -2033,7 +2034,8 @@ namespace MDNSImplementation
MDNSResponder::stcMDNSServiceQuery::stcAnswer*
MDNSResponder::stcMDNSServiceQuery::answerAtIndex(uint32_t p_u32Index)
{
return (stcAnswer*)(((const stcMDNSServiceQuery*)this)->answerAtIndex(p_u32Index));
const auto& cref = static_cast<const decltype(*this)>(*this);
return const_cast<stcAnswer*>(cref.answerAtIndex(p_u32Index));
}

/*
Expand Down