diff --git a/cores/esp8266/Print.h b/cores/esp8266/Print.h index e49332b31e..5517553999 100644 --- a/cores/esp8266/Print.h +++ b/cores/esp8266/Print.h @@ -35,17 +35,15 @@ class Print { private: - int write_error; + int write_error = 0; template size_t printNumber(T n, uint8_t base); template inline size_t _println(T v, P... args); -protected: + protected: void setWriteError(int err = 1) { write_error = err; } public: - Print() : - write_error(0) { - } + Print() {} int getWriteError() { return write_error; diff --git a/cores/esp8266/Stream.h b/cores/esp8266/Stream.h index fa786dddc3..6dcb508d22 100644 --- a/cores/esp8266/Stream.h +++ b/cores/esp8266/Stream.h @@ -37,7 +37,7 @@ class Stream: public Print { protected: - unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read + unsigned long _timeout = 1000; // number of milliseconds to wait for the next char before aborting timed read unsigned long _startMillis; // used for timeout measurement int timedRead(); // private method to read stream with timeout int timedPeek(); // private method to peek stream with timeout @@ -48,9 +48,7 @@ class Stream: public Print { virtual int read() = 0; virtual int peek() = 0; - Stream() { - _timeout = 1000; - } + Stream() {} // parsing methods diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index 93149033c7..fd6a7d2d49 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -27,18 +27,6 @@ extern "C" uint32_t _FS_start; extern "C" uint32_t _FS_end; UpdaterClass::UpdaterClass() -: _async(false) -, _error(0) -, _buffer(0) -, _bufferLen(0) -, _size(0) -, _startAddress(0) -, _currentAddress(0) -, _command(U_FLASH) -, _ledPin(-1) -, _hash(nullptr) -, _verify(nullptr) -, _progress_callback(nullptr) { #if ARDUINO_SIGNING installSignature(&esp8266::updaterSigningHash, &esp8266::updaterSigningVerifier); diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index f51edc5b7d..30c4a0071f 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -182,27 +182,27 @@ class UpdaterClass { void _setError(int error); - bool _async; - uint8_t _error; - uint8_t *_buffer; - size_t _bufferLen; // amount of data written into _buffer - size_t _bufferSize; // total size of _buffer - size_t _size; - uint32_t _startAddress; - uint32_t _currentAddress; - uint32_t _command; + bool _async = false; + uint8_t _error = 0; + uint8_t *_buffer = nullptr; + size_t _bufferLen = 0; // amount of data written into _buffer + size_t _bufferSize = 0; // total size of _buffer + size_t _size = 0; + uint32_t _startAddress = 0; + uint32_t _currentAddress = 0; + uint32_t _command = U_FLASH; String _target_md5; MD5Builder _md5; - int _ledPin; + int _ledPin = -1; uint8_t _ledOn; // Optional signed binary verification - UpdaterHashClass *_hash; - UpdaterVerifyClass *_verify; + UpdaterHashClass *_hash = nullptr; + UpdaterVerifyClass *_verify = nullptr; // Optional progress callback function - THandlerFunction_Progress _progress_callback; + THandlerFunction_Progress _progress_callback = nullptr; }; extern UpdaterClass Update; diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp index 90bbf8ca52..0ea72ceca8 100644 --- a/libraries/EEPROM/EEPROM.cpp +++ b/libraries/EEPROM/EEPROM.cpp @@ -35,17 +35,11 @@ extern "C" uint32_t _EEPROM_start; EEPROMClass::EEPROMClass(uint32_t sector) : _sector(sector) -, _data(0) -, _size(0) -, _dirty(false) { } EEPROMClass::EEPROMClass(void) : _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE)) -, _data(0) -, _size(0) -, _dirty(false) { } diff --git a/libraries/EEPROM/EEPROM.h b/libraries/EEPROM/EEPROM.h index 54a9c1e336..e1d8044253 100644 --- a/libraries/EEPROM/EEPROM.h +++ b/libraries/EEPROM/EEPROM.h @@ -68,9 +68,9 @@ class EEPROMClass { protected: uint32_t _sector; - uint8_t* _data; - size_t _size; - bool _dirty; + uint8_t* _data = nullptr; + size_t _size = 0; + bool _dirty = false; }; #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM) diff --git a/libraries/ESP8266SSDP/ESP8266SSDP.cpp b/libraries/ESP8266SSDP/ESP8266SSDP.cpp index 93121ffc8c..2f9ff11149 100644 --- a/libraries/ESP8266SSDP/ESP8266SSDP.cpp +++ b/libraries/ESP8266SSDP/ESP8266SSDP.cpp @@ -47,12 +47,10 @@ extern "C" { #include "include/UdpContext.h" //#define DEBUG_SSDP Serial -#define SSDP_INTERVAL 1200 #define SSDP_PORT 1900 #define SSDP_METHOD_SIZE 10 #define SSDP_URI_SIZE 2 #define SSDP_BUFFER_SIZE 64 -#define SSDP_MULTICAST_TTL 2 // ssdp ipv6 is FF05::C // lwip-v2's igmp_joingroup only supports IPv4 @@ -125,19 +123,8 @@ struct SSDPTimer { ETSTimer timer; }; -SSDPClass::SSDPClass() : - _server(0), - _timer(0), - _port(80), - _ttl(SSDP_MULTICAST_TTL), - _interval(SSDP_INTERVAL), - _respondToAddr(0,0,0,0), - _respondToPort(0), - _pending(false), - _st_is_uuid(false), - _delay(0), - _process_time(0), - _notify_time(0) +SSDPClass::SSDPClass() +: _respondToAddr(0,0,0,0) { _uuid[0] = '\0'; _modelNumber[0] = '\0'; diff --git a/libraries/ESP8266SSDP/ESP8266SSDP.h b/libraries/ESP8266SSDP/ESP8266SSDP.h index 527822f6dc..0b310c08e1 100644 --- a/libraries/ESP8266SSDP/ESP8266SSDP.h +++ b/libraries/ESP8266SSDP/ESP8266SSDP.h @@ -46,6 +46,9 @@ class UdpContext; #define SSDP_MODEL_VERSION_SIZE 32 #define SSDP_MANUFACTURER_SIZE 64 #define SSDP_MANUFACTURER_URL_SIZE 128 +#define SSDP_INTERVAL_SECONDS 1200 +#define SSDP_MULTICAST_TTL 2 +#define SSDP_HTTP_PORT 80 typedef enum { NONE, @@ -101,20 +104,20 @@ class SSDPClass{ void _stopTimer(); static void _onTimerStatic(SSDPClass* self); - UdpContext* _server; - SSDPTimer* _timer; - uint16_t _port; - uint8_t _ttl; - uint32_t _interval; + UdpContext* _server = nullptr; + SSDPTimer* _timer = nullptr; + uint16_t _port = SSDP_HTTP_PORT; + uint8_t _ttl = SSDP_MULTICAST_TTL; + uint32_t _interval = SSDP_INTERVAL_SECONDS; IPAddress _respondToAddr; - uint16_t _respondToPort; + uint16_t _respondToPort = 0; - bool _pending; - bool _st_is_uuid; - unsigned short _delay; - unsigned long _process_time; - unsigned long _notify_time; + bool _pending = false; + bool _st_is_uuid = false; + unsigned short _delay = 0; + unsigned long _process_time = 0; + unsigned long _notify_time = 0; char _schemaURL[SSDP_SCHEMA_URL_SIZE]; char _uuid[SSDP_UUID_SIZE]; diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h b/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h index bc094b1b6e..eed9cb945a 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h @@ -39,47 +39,12 @@ namespace esp8266webserver { template ESP8266WebServerTemplate::ESP8266WebServerTemplate(IPAddress addr, int port) : _server(addr, port) -, _currentMethod(HTTP_ANY) -, _currentVersion(0) -, _currentStatus(HC_NONE) -, _statusChange(0) -, _keepAlive(false) -, _currentHandler(nullptr) -, _firstHandler(nullptr) -, _lastHandler(nullptr) -, _currentArgCount(0) -, _currentArgs(nullptr) -, _currentArgsHavePlain(0) -, _postArgsLen(0) -, _postArgs(nullptr) -, _headerKeysCount(0) -, _currentHeaders(nullptr) -, _contentLength(0) -, _chunked(false) -, _corsEnabled(false) { } template ESP8266WebServerTemplate::ESP8266WebServerTemplate(int port) : _server(port) -, _currentMethod(HTTP_ANY) -, _currentVersion(0) -, _currentStatus(HC_NONE) -, _statusChange(0) -, _currentHandler(nullptr) -, _firstHandler(nullptr) -, _lastHandler(nullptr) -, _currentArgCount(0) -, _currentArgs(nullptr) -, _currentArgsHavePlain(0) -, _postArgsLen(0) -, _postArgs(nullptr) -, _headerKeysCount(0) -, _currentHeaders(nullptr) -, _contentLength(0) -, _chunked(false) -, _corsEnabled(false) { } diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.h b/libraries/ESP8266WebServer/src/ESP8266WebServer.h index 3c08f72a32..23b5b328aa 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.h +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.h @@ -263,35 +263,35 @@ class ESP8266WebServerTemplate ServerType _server; ClientType _currentClient; - HTTPMethod _currentMethod; + HTTPMethod _currentMethod = HTTP_ANY; String _currentUri; - uint8_t _currentVersion; - HTTPClientStatus _currentStatus; - unsigned long _statusChange; - bool _keepAlive; - - RequestHandlerType* _currentHandler; - RequestHandlerType* _firstHandler; - RequestHandlerType* _lastHandler; + uint8_t _currentVersion = 0; + HTTPClientStatus _currentStatus = HC_NONE; + unsigned long _statusChange = 0; + + RequestHandlerType* _currentHandler = nullptr; + RequestHandlerType* _firstHandler = nullptr; + RequestHandlerType* _lastHandler = nullptr; THandlerFunction _notFoundHandler; THandlerFunction _fileUploadHandler; - int _currentArgCount; - RequestArgument* _currentArgs; - int _currentArgsHavePlain; + int _currentArgCount = 0; + RequestArgument* _currentArgs = nullptr; + int _currentArgsHavePlain = 0; std::unique_ptr _currentUpload; - int _postArgsLen; - RequestArgument* _postArgs; + int _postArgsLen = 0; + RequestArgument* _postArgs = nullptr; - int _headerKeysCount; - RequestArgument* _currentHeaders; + int _headerKeysCount = 0; + RequestArgument* _currentHeaders = nullptr; - size_t _contentLength; + size_t _contentLength = 0; String _responseHeaders; String _hostHeader; - bool _chunked; - bool _corsEnabled; + bool _chunked = false; + bool _corsEnabled = false; + bool _keepAlive = false; String _snonce; // Store noance and opaque for future comparison String _sopaque; diff --git a/libraries/ESP8266WiFi/src/WiFiServer.cpp b/libraries/ESP8266WiFi/src/WiFiServer.cpp index 2ee09f85fe..10e72b3ea8 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.cpp +++ b/libraries/ESP8266WiFi/src/WiFiServer.cpp @@ -44,18 +44,12 @@ extern "C" { WiFiServer::WiFiServer(const IPAddress& addr, uint16_t port) : _port(port) , _addr(addr) -, _listen_pcb(nullptr) -, _unclaimed(nullptr) -, _discarded(nullptr) { } WiFiServer::WiFiServer(uint16_t port) : _port(port) , _addr(IP_ANY_TYPE) -, _listen_pcb(nullptr) -, _unclaimed(nullptr) -, _discarded(nullptr) { } diff --git a/libraries/ESP8266WiFi/src/WiFiServer.h b/libraries/ESP8266WiFi/src/WiFiServer.h index 9df758bf05..2023840545 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.h +++ b/libraries/ESP8266WiFi/src/WiFiServer.h @@ -70,10 +70,10 @@ class WiFiServer : public Server { protected: uint16_t _port; IPAddress _addr; - tcp_pcb* _listen_pcb; + tcp_pcb* _listen_pcb = nullptr; - ClientContext* _unclaimed; - ClientContext* _discarded; + ClientContext* _unclaimed = nullptr; + ClientContext* _discarded = nullptr; enum { _ndDefault, _ndFalse, _ndTrue } _noDelay = _ndDefault; public: