1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-28 05:01:28 +03:00

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]
This commit is contained in:
Max Prokhorov
2025-05-20 19:40:21 +03:00
committed by GitHub
parent 606324ccf8
commit 2c72e6f015
6 changed files with 44 additions and 36 deletions

View File

@ -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> {
@ -310,4 +292,4 @@ protected:
} // namespace
#endif //REQUESTHANDLERSIMPL_H
#endif //REQUESTHANDLERSIMPL_H

View File

@ -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