Skip to content

Commit 2c72e6f

Browse files
authored
Libraries - fix some warnings with gcc ≥12 (#9244)
* ESP8266WebServer - unused templated code throws out unused statics currently, only w/ mock build because it is using gcc>=12 > ../../libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h:14:15: warning: ‘String esp8266webserver::calcETag(fs::FS&, const String&)’ defined but not used [-Wunused-function] > 14 | static String calcETag(FS &fs, const String &path) { > | ^~~~~~~~ * ESP8266WiFiMesh - fix classes used as aggregates > error: designated initializers cannot be used with a non-aggregate type '...' gcc10.3 allowed this construct for some reason * LEAmDNS - consistent const <-> non-const accessors > error: infinite recursion detected [-Werror=infinite-recursion]
1 parent 606324c commit 2c72e6f

File tree

6 files changed

+44
-36
lines changed

6 files changed

+44
-36
lines changed

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,7 @@
99

1010
namespace esp8266webserver {
1111

12-
// calculate an ETag for a file in filesystem based on md5 checksum
13-
// that can be used in the http headers - include quotes.
14-
static String calcETag(FS &fs, const String &path) {
15-
String result;
16-
17-
// calculate eTag using md5 checksum
18-
uint8_t md5_buf[16];
19-
File f = fs.open(path, "r");
20-
MD5Builder calcMD5;
21-
calcMD5.begin();
22-
calcMD5.addStream(f, f.size());
23-
calcMD5.calculate();
24-
calcMD5.getBytes(md5_buf);
25-
f.close();
26-
// create a minimal-length eTag using base64 byte[]->text encoding.
27-
result = "\"" + base64::encode(md5_buf, 16, false) + "\"";
28-
return(result);
29-
} // calcETag
30-
12+
String calcETag(FS &, const String &);
3113

3214
template<typename ServerType>
3315
class FunctionRequestHandler : public RequestHandler<ServerType> {
@@ -310,4 +292,4 @@ public StaticRequestHandler<ServerType> {
310292

311293
} // namespace
312294

313-
#endif //REQUESTHANDLERSIMPL_H
295+
#endif //REQUESTHANDLERSIMPL_H
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <ESP8266WebServer.h>
2+
3+
namespace esp8266webserver {
4+
5+
// calculate an ETag for a file in filesystem based on md5 checksum
6+
// that can be used in the http headers - include quotes.
7+
String calcETag(FS &fs, const String &path) {
8+
String result;
9+
10+
// calculate eTag using md5 checksum
11+
uint8_t md5_buf[16];
12+
File f = fs.open(path, "r");
13+
MD5Builder calcMD5;
14+
calcMD5.begin();
15+
calcMD5.addStream(f, f.size());
16+
calcMD5.calculate();
17+
calcMD5.getBytes(md5_buf);
18+
f.close();
19+
// create a minimal-length eTag using base64 byte[]->text encoding.
20+
result = "\"" + base64::encode(md5_buf, 16, false) + "\"";
21+
return(result);
22+
}
23+
24+
} // namespace esp8266webserver

libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ void ESP8266WiFiMesh::attemptTransmission(const String &message, bool concluding
535535
if(WiFi.status() == WL_CONNECTED)
536536
{
537537
transmission_status_t transmissionResult = attemptDataTransfer();
538-
latestTransmissionOutcomes.push_back(TransmissionResult(connectionQueue.back(), transmissionResult));
538+
latestTransmissionOutcomes.emplace_back(connectionQueue.back(), transmissionResult);
539539
}
540540
else
541541
{
@@ -600,7 +600,7 @@ void ESP8266WiFiMesh::attemptTransmission(const String &message, bool concluding
600600

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

603-
latestTransmissionOutcomes.push_back(TransmissionResult{.origin = currentNetwork, .transmissionStatus = transmissionResult});
603+
latestTransmissionOutcomes.emplace_back(currentNetwork, transmissionResult);
604604
}
605605
}
606606

libraries/ESP8266WiFiMesh/src/EspnowMeshBackend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ void EspnowMeshBackend::attemptTransmission(const String &message, const bool sc
826826
{
827827
TransmissionStatusType transmissionResult = initiateTransmission(getMessage(), currentNetwork);
828828

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

831831
if(!getTransmissionOutcomesUpdateHook()(*this))
832832
break;
@@ -897,7 +897,7 @@ void EspnowMeshBackend::attemptAutoEncryptingTransmission(const String &message,
897897

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

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

902902
_encryptionBroker.finalizeAutoEncryptingConnection(currentBSSID, existingEncryptedConnection, requestPermanentConnections);
903903

libraries/ESP8266WiFiMesh/src/TcpIpMeshBackend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void TcpIpMeshBackend::attemptTransmission(const String &message, const bool sca
451451
if(WiFi.status() == WL_CONNECTED)
452452
{
453453
TransmissionStatusType transmissionResult = attemptDataTransfer();
454-
latestTransmissionOutcomes().push_back(TransmissionOutcome(constConnectionQueue().back(), transmissionResult));
454+
latestTransmissionOutcomes().emplace_back(constConnectionQueue().back(), transmissionResult);
455455

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

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

479479
if(!getTransmissionOutcomesUpdateHook()(*this))
480480
break;

libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,15 +1735,6 @@ namespace MDNSImplementation
17351735
const MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address*
17361736
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address(
17371737
const IPAddress& p_IPAddress) const
1738-
{
1739-
return (stcIP4Address*)(((const stcAnswer*)this)->findIP4Address(p_IPAddress));
1740-
}
1741-
1742-
/*
1743-
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address
1744-
*/
1745-
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address*
1746-
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address(const IPAddress& p_IPAddress)
17471738
{
17481739
stcIP4Address* pIP4Address = m_pIP4Addresses;
17491740
while (pIP4Address)
@@ -1757,6 +1748,16 @@ namespace MDNSImplementation
17571748
return pIP4Address;
17581749
}
17591750

1751+
/*
1752+
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address
1753+
*/
1754+
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address*
1755+
MDNSResponder::stcMDNSServiceQuery::stcAnswer::findIP4Address(const IPAddress& p_IPAddress)
1756+
{
1757+
const auto& cref = static_cast<const decltype(*this)>(*this);
1758+
return const_cast<stcIP4Address*>(cref.findIP4Address(p_IPAddress));
1759+
}
1760+
17601761
/*
17611762
MDNSResponder::stcMDNSServiceQuery::stcAnswer::IP4AddressCount
17621763
*/
@@ -2033,7 +2034,8 @@ namespace MDNSImplementation
20332034
MDNSResponder::stcMDNSServiceQuery::stcAnswer*
20342035
MDNSResponder::stcMDNSServiceQuery::answerAtIndex(uint32_t p_u32Index)
20352036
{
2036-
return (stcAnswer*)(((const stcMDNSServiceQuery*)this)->answerAtIndex(p_u32Index));
2037+
const auto& cref = static_cast<const decltype(*this)>(*this);
2038+
return const_cast<stcAnswer*>(cref.answerAtIndex(p_u32Index));
20372039
}
20382040

20392041
/*

0 commit comments

Comments
 (0)