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
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 2 additions & 20 deletions libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,7 @@

namespace esp8266webserver {

// calculate an ETag for a file in filesystem based on md5 checksum
// that can be used in the http headers - include quotes.
static String calcETag(FS &fs, const String &path) {
String result;

// calculate eTag using md5 checksum
uint8_t md5_buf[16];
File f = fs.open(path, "r");
MD5Builder calcMD5;
calcMD5.begin();
calcMD5.addStream(f, f.size());
calcMD5.calculate();
calcMD5.getBytes(md5_buf);
f.close();
// create a minimal-length eTag using base64 byte[]->text encoding.
result = "\"" + base64::encode(md5_buf, 16, false) + "\"";
return(result);
} // calcETag

String calcETag(FS &, const String &);

template<typename ServerType>
class FunctionRequestHandler : public RequestHandler<ServerType> {
Expand Down Expand Up @@ -310,4 +292,4 @@ public StaticRequestHandler<ServerType> {

} // namespace

#endif //REQUESTHANDLERSIMPL_H
#endif //REQUESTHANDLERSIMPL_H
24 changes: 24 additions & 0 deletions libraries/ESP8266WebServer/src/detail/etag.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <ESP8266WebServer.h>

namespace esp8266webserver {

// calculate an ETag for a file in filesystem based on md5 checksum
// that can be used in the http headers - include quotes.
String calcETag(FS &fs, const String &path) {
String result;

// calculate eTag using md5 checksum
uint8_t md5_buf[16];
File f = fs.open(path, "r");
MD5Builder calcMD5;
calcMD5.begin();
calcMD5.addStream(f, f.size());
calcMD5.calculate();
calcMD5.getBytes(md5_buf);
f.close();
// create a minimal-length eTag using base64 byte[]->text encoding.
result = "\"" + base64::encode(md5_buf, 16, false) + "\"";
return(result);
}

} // namespace esp8266webserver
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void ESP8266WiFiMesh::attemptTransmission(const String &message, bool concluding
if(WiFi.status() == WL_CONNECTED)
{
transmission_status_t transmissionResult = attemptDataTransfer();
latestTransmissionOutcomes.push_back(TransmissionResult(connectionQueue.back(), transmissionResult));
latestTransmissionOutcomes.emplace_back(connectionQueue.back(), transmissionResult);
}
else
{
Expand Down Expand Up @@ -600,7 +600,7 @@ void ESP8266WiFiMesh::attemptTransmission(const String &message, bool concluding

transmission_status_t transmissionResult = connectToNode(currentSSID, currentWiFiChannel, currentBSSID);

latestTransmissionOutcomes.push_back(TransmissionResult{.origin = currentNetwork, .transmissionStatus = transmissionResult});
latestTransmissionOutcomes.emplace_back(currentNetwork, transmissionResult);
}
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFiMesh/src/EspnowMeshBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ void EspnowMeshBackend::attemptTransmission(const String &message, const bool sc
{
TransmissionStatusType transmissionResult = initiateTransmission(getMessage(), currentNetwork);

latestTransmissionOutcomes().push_back(TransmissionOutcome{.origin = currentNetwork, .transmissionStatus = transmissionResult});
latestTransmissionOutcomes().emplace_back(currentNetwork, transmissionResult);

if(!getTransmissionOutcomesUpdateHook()(*this))
break;
Expand Down Expand Up @@ -897,7 +897,7 @@ void EspnowMeshBackend::attemptAutoEncryptingTransmission(const String &message,

TransmissionStatusType transmissionResult = initiateAutoEncryptingTransmission(getMessage(), currentBSSID, connectionStatus);

latestTransmissionOutcomes().push_back(TransmissionOutcome{.origin = currentNetwork, .transmissionStatus = transmissionResult});
latestTransmissionOutcomes().emplace_back(currentNetwork, transmissionResult);

_encryptionBroker.finalizeAutoEncryptingConnection(currentBSSID, existingEncryptedConnection, requestPermanentConnections);

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFiMesh/src/TcpIpMeshBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void TcpIpMeshBackend::attemptTransmission(const String &message, const bool sca
if(WiFi.status() == WL_CONNECTED)
{
TransmissionStatusType transmissionResult = attemptDataTransfer();
latestTransmissionOutcomes().push_back(TransmissionOutcome(constConnectionQueue().back(), transmissionResult));
latestTransmissionOutcomes().emplace_back(constConnectionQueue().back(), transmissionResult);

getTransmissionOutcomesUpdateHook()(*this);
}
Expand All @@ -474,7 +474,7 @@ void TcpIpMeshBackend::attemptTransmission(const String &message, const bool sca
{
TransmissionStatusType transmissionResult = initiateTransmission(currentNetwork);

latestTransmissionOutcomes().push_back(TransmissionOutcome{.origin = currentNetwork, .transmissionStatus = transmissionResult});
latestTransmissionOutcomes().emplace_back(currentNetwork, transmissionResult);

if(!getTransmissionOutcomesUpdateHook()(*this))
break;
Expand Down
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