diff --git a/cores/rp2040/FS.h b/cores/rp2040/FS.h index 9576bf04d..0ea617aaa 100644 --- a/cores/rp2040/FS.h +++ b/cores/rp2040/FS.h @@ -240,7 +240,7 @@ class FS { } time_t (*_timeCallback)(void) = nullptr; static time_t _defaultTimeCB(void) { - return time(NULL); + return time(nullptr); } }; diff --git a/cores/rp2040/RP2040USB.cpp b/cores/rp2040/RP2040USB.cpp index 8c67370ca..dbc05fac7 100644 --- a/cores/rp2040/RP2040USB.cpp +++ b/cores/rp2040/RP2040USB.cpp @@ -289,7 +289,7 @@ const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) { len = 1; } else { if (index >= sizeof(usbd_desc_str) / sizeof(usbd_desc_str[0])) { - return NULL; + return nullptr; } const char *str = usbd_desc_str[index]; for (len = 0; len < DESC_STR_MAX - 1 && str[len]; ++len) { @@ -308,7 +308,7 @@ static void usb_irq() { // if the mutex is already owned, then we are in user code // in this file which will do a tud_task itself, so we'll just do nothing // until the next tick; we won't starve - if (mutex_try_enter(&__usb_mutex, NULL)) { + if (mutex_try_enter(&__usb_mutex, nullptr)) { tud_task(); mutex_exit(&__usb_mutex); } @@ -338,7 +338,7 @@ void __USBStart() { irq_set_exclusive_handler(__usb_task_irq, usb_irq); irq_set_enabled(__usb_task_irq, true); - add_alarm_in_us(USB_TASK_INTERVAL, timer_task, NULL, true); + add_alarm_in_us(USB_TASK_INTERVAL, timer_task, nullptr, true); } diff --git a/cores/rp2040/lock.cpp b/cores/rp2040/lock.cpp index 2bbf5dc48..bb325a9a2 100644 --- a/cores/rp2040/lock.cpp +++ b/cores/rp2040/lock.cpp @@ -147,7 +147,7 @@ int __retarget_lock_try_acquire(_LOCK_T lock) { auto mtx = __getFreeRTOSMutex(lock); ret = __freertos_mutex_try_take(mtx); } else { - ret = mutex_try_enter((mutex_t *)lock, NULL); + ret = mutex_try_enter((mutex_t *)lock, nullptr); } return ret; } @@ -158,7 +158,7 @@ int __retarget_lock_try_acquire_recursive(_LOCK_T lock) { auto mtx = __getFreeRTOSRecursiveMutex(lock); ret = __freertos_recursive_mutex_try_take(mtx); } else { - ret = recursive_mutex_try_enter((recursive_mutex_t*)lock, NULL); + ret = recursive_mutex_try_enter((recursive_mutex_t*)lock, nullptr); } return ret; } diff --git a/libraries/ArduinoOTA/src/ArduinoOTA.h b/libraries/ArduinoOTA/src/ArduinoOTA.h index aa1e0eee9..5d3804f98 100644 --- a/libraries/ArduinoOTA/src/ArduinoOTA.h +++ b/libraries/ArduinoOTA/src/ArduinoOTA.h @@ -59,10 +59,10 @@ class ArduinoOTAClass { void setHostname(const char *hostname); String getHostname(); - //Sets the password that will be required for OTA. Default NULL + //Sets the password that will be required for OTA. Default nullptr void setPassword(const char *password); - //Sets the password as above but in the form MD5(password). Default NULL + //Sets the password as above but in the form MD5(password). Default nullptr void setPasswordHash(const char *password); //Sets if the device should be rebooted after successful update. Default true diff --git a/libraries/DNSServer/src/DNSServer.cpp b/libraries/DNSServer/src/DNSServer.cpp index 8410ed8fc..f18d3076f 100644 --- a/libraries/DNSServer/src/DNSServer.cpp +++ b/libraries/DNSServer/src/DNSServer.cpp @@ -444,7 +444,7 @@ void DNSServer::replyWithError(DNSHeader *dnsHeader, _udp.beginPacket(_udp.remoteIP(), _udp.remotePort()); _udp.write((unsigned char *)dnsHeader, sizeof(DNSHeader)); - if (query != NULL) { + if (query != nullptr) { _udp.write(query, queryLength); } _udp.endPacket(); @@ -452,5 +452,5 @@ void DNSServer::replyWithError(DNSHeader *dnsHeader, void DNSServer::replyWithError(DNSHeader *dnsHeader, DNSReplyCode rcode) { - replyWithError(dnsHeader, rcode, NULL, 0); + replyWithError(dnsHeader, rcode, nullptr, 0); } diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index f30dba058..0d1cd1f47 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -807,7 +807,7 @@ int HTTPClient::writeToPrint(Print * print) { DEBUG_HTTPCLIENT("[HTTP-Client] chunk header: '%s'\n", chunkHeader.c_str()); // read size of chunk - len = (uint32_t) strtol((const char *) chunkHeader.c_str(), NULL, 16); + len = (uint32_t) strtol((const char *) chunkHeader.c_str(), nullptr, 16); size += len; DEBUG_HTTPCLIENT("[HTTP-Client] read chunk len: %d\n", len); diff --git a/libraries/HTTPClient/src/HTTPClient.h b/libraries/HTTPClient/src/HTTPClient.h index 05953a7f8..e1d154ca5 100644 --- a/libraries/HTTPClient/src/HTTPClient.h +++ b/libraries/HTTPClient/src/HTTPClient.h @@ -205,7 +205,7 @@ class HTTPClient { int PATCH(const uint8_t* payload, size_t size); int PATCH(const String& payload); int sendRequest(const char* type, const String& payload); - int sendRequest(const char* type, const uint8_t* payload = NULL, size_t size = 0); + int sendRequest(const char* type, const uint8_t* payload = nullptr, size_t size = 0); int sendRequest(const char* type, Stream * stream, size_t size = 0); void addHeader(const String& name, const String& value, bool first = false, bool replace = true); diff --git a/libraries/HTTPUpdateServer/src/HTTPUpdateServer-impl.h b/libraries/HTTPUpdateServer/src/HTTPUpdateServer-impl.h index 85d93244c..2e1b5f4a6 100644 --- a/libraries/HTTPUpdateServer/src/HTTPUpdateServer-impl.h +++ b/libraries/HTTPUpdateServer/src/HTTPUpdateServer-impl.h @@ -60,7 +60,7 @@ static const char successResponse[] PROGMEM = template HTTPUpdateServerTemplate::HTTPUpdateServerTemplate(bool serial_debug) { _serial_output = serial_debug; - _server = NULL; + _server = nullptr; _username = ""; _password = ""; _authenticated = false; diff --git a/libraries/SPI/src/SPI.cpp b/libraries/SPI/src/SPI.cpp index 6d1106884..f64505fae 100644 --- a/libraries/SPI/src/SPI.cpp +++ b/libraries/SPI/src/SPI.cpp @@ -154,11 +154,11 @@ void SPIClassRP2040::transfer(const void *txbuf, void *rxbuf, size_t count) { if (_spis.getBitOrder() == MSBFIRST) { spi_set_format(_spi, 8, cpol(), cpha(), SPI_MSB_FIRST); - if (rxbuf == NULL) { // transmit only! + if (rxbuf == nullptr) { // transmit only! spi_write_blocking(_spi, txbuff, count); return; } - if (txbuf == NULL) { // receive only! + if (txbuf == nullptr) { // receive only! spi_read_blocking(_spi, 0xFF, rxbuff, count); return; } diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index 9c88604b8..44b1e8648 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -35,7 +35,7 @@ class SPIClassRP2040 : public arduino::HardwareSPI { // Sends buffer in 8 bit chunks. Overwrites buffer with read data void transfer(void *buf, size_t count) override; - // Sends one buffer and receives into another, much faster! can set rx or txbuf to NULL + // Sends one buffer and receives into another, much faster! can set rx or txbuf to nullptr void transfer(const void *txbuf, void *rxbuf, size_t count) override; // Call before/after every complete transaction diff --git a/libraries/WebServer/src/HTTPServer.cpp b/libraries/WebServer/src/HTTPServer.cpp index e1be12958..a23aee82e 100644 --- a/libraries/WebServer/src/HTTPServer.cpp +++ b/libraries/WebServer/src/HTTPServer.cpp @@ -109,11 +109,11 @@ bool HTTPServer::authenticate(const char * username, const char * password) { authReq.trim(); char toencodeLen = strlen(username) + strlen(password) + 1; char *toencode = new char[toencodeLen + 1]; - if (toencode == NULL) { + if (toencode == nullptr) { return false; } char *encoded = new char[base64_encode_expected_len(toencodeLen) + 1]; - if (encoded == NULL) { + if (encoded == nullptr) { delete[] toencode; return false; } @@ -191,7 +191,7 @@ String HTTPServer::_getRandomHexString() { } void HTTPServer::requestAuthentication(HTTPAuthMethod mode, const char* realm, const String& authFailMsg) { - if (realm == NULL) { + if (realm == nullptr) { _srealm = String(F("Login Required")); } else { _srealm = String(realm); @@ -400,7 +400,7 @@ void HTTPServer::send(int code, const char* content_type, const char* content, s void HTTPServer::send_P(int code, PGM_P content_type, PGM_P content) { size_t contentLength = 0; - if (content != NULL) { + if (content != nullptr) { contentLength = strlen_P(content); } diff --git a/libraries/WebServer/src/HTTPServer.h b/libraries/WebServer/src/HTTPServer.h index 6d1de5a0a..02493e79f 100644 --- a/libraries/WebServer/src/HTTPServer.h +++ b/libraries/WebServer/src/HTTPServer.h @@ -75,14 +75,14 @@ class HTTPServer { virtual void httpHandleClient(); bool authenticate(const char * username, const char * password); - void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = NULL, const String& authFailMsg = String("")); + void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = nullptr, const String& authFailMsg = String("")); typedef std::function THandlerFunction; void on(const Uri &uri, THandlerFunction fn); void on(const Uri &uri, HTTPMethod method, THandlerFunction fn); void on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn); //ufn handles file uploads void addHandler(RequestHandler* handler); - void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL); + void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = nullptr); void onNotFound(THandlerFunction fn); //called when handler is not assigned void onFileUpload(THandlerFunction ufn); //handle file uploads @@ -131,7 +131,7 @@ class HTTPServer { // code - HTTP response code, can be 200 or 404 // content_type - HTTP content type, like "text/plain" or "image/png" // content - actual content body - void send(int code, const char* content_type = NULL, const String& content = String("")); + void send(int code, const char* content_type = nullptr, const String& content = String("")); void send(int code, char* content_type, const String& content); void send(int code, const String& content_type, const String& content); void send(int code, const char* content_type, const char* content); diff --git a/libraries/WebServer/src/Parsing.cpp b/libraries/WebServer/src/Parsing.cpp index 4d0be9603..87d0fc882 100644 --- a/libraries/WebServer/src/Parsing.cpp +++ b/libraries/WebServer/src/Parsing.cpp @@ -522,7 +522,7 @@ bool HTTPServer::_parseForm(WiFiClient* client, String boundary, uint32_t len) { endBuf[i++] = (uint8_t)argByte; } - if (strstr((const char*)endBuf, boundary.c_str()) != NULL) { + if (strstr((const char*)endBuf, boundary.c_str()) != nullptr) { if (_currentHandler && _currentHandler->canUpload(_currentUri)) { _currentHandler->upload(*this, _currentUri, *_currentUpload); } @@ -600,7 +600,7 @@ String HTTPServer::urlDecode(const String& text) { temp[2] = text.charAt(i++); temp[3] = text.charAt(i++); - decodedChar = strtol(temp, NULL, 16); + decodedChar = strtol(temp, nullptr, 16); } else { if (encodedChar == '+') { decodedChar = ' '; diff --git a/libraries/WiFi/src/StackThunk.cpp b/libraries/WiFi/src/StackThunk.cpp index d807fbf4f..062ad7e94 100644 --- a/libraries/WiFi/src/StackThunk.cpp +++ b/libraries/WiFi/src/StackThunk.cpp @@ -24,9 +24,9 @@ extern "C" { - uint32_t *stack_thunk_ptr = NULL; - uint32_t *stack_thunk_top = NULL; - uint32_t *stack_thunk_save = NULL; /* Saved A1 while in BearSSL */ + uint32_t *stack_thunk_ptr = nullptr; + uint32_t *stack_thunk_top = nullptr; + uint32_t *stack_thunk_save = nullptr; /* Saved A1 while in BearSSL */ uint32_t stack_thunk_refcnt = 0; /* Largest stack usage seen in the wild at 6120 */ @@ -47,7 +47,7 @@ extern "C" { abort(); } stack_thunk_top = stack_thunk_ptr + _stackSize - 1; - stack_thunk_save = NULL; + stack_thunk_save = nullptr; stack_thunk_repaint(); } } @@ -61,9 +61,9 @@ extern "C" { stack_thunk_refcnt--; if (!stack_thunk_refcnt) { free(stack_thunk_ptr); - stack_thunk_ptr = NULL; - stack_thunk_top = NULL; - stack_thunk_save = NULL; + stack_thunk_ptr = nullptr; + stack_thunk_top = nullptr; + stack_thunk_save = nullptr; } } diff --git a/libraries/WiFi/src/WiFiClass.h b/libraries/WiFi/src/WiFiClass.h index b1e78eba9..d5eb7948d 100644 --- a/libraries/WiFi/src/WiFiClass.h +++ b/libraries/WiFi/src/WiFiClass.h @@ -92,7 +92,7 @@ class WiFiClass { uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel); // ESP8266 compatible calls - bool softAP(const char* ssid, const char* psk = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4) { + bool softAP(const char* ssid, const char* psk = nullptr, int channel = 1, int ssid_hidden = 0, int max_connection = 4) { (void) ssid_hidden; (void) max_connection; return beginAP(ssid, psk, channel) == WL_CONNECTED; diff --git a/libraries/WiFi/src/WiFiClientSecureBearSSL.cpp b/libraries/WiFi/src/WiFiClientSecureBearSSL.cpp index 2b33c286f..8d951dca7 100644 --- a/libraries/WiFi/src/WiFiClientSecureBearSSL.cpp +++ b/libraries/WiFi/src/WiFiClientSecureBearSSL.cpp @@ -784,7 +784,7 @@ extern "C" { // Return the public key from the validator (set by x509_minimal) static const br_x509_pkey *insecure_get_pkey(const br_x509_class *const *ctx, unsigned *usages) { const br_x509_insecure_context *xc = (const br_x509_insecure_context *)ctx; - if (usages != NULL) { + if (usages != nullptr) { *usages = BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN; // I said we were insecure! } return &xc->ctx.pkey; diff --git a/libraries/WiFi/src/WiFiClientSecureBearSSL.h b/libraries/WiFi/src/WiFiClientSecureBearSSL.h index d94789637..eff716e1f 100644 --- a/libraries/WiFi/src/WiFiClientSecureBearSSL.h +++ b/libraries/WiFi/src/WiFiClientSecureBearSSL.h @@ -125,7 +125,7 @@ class WiFiClientSecureCtx : public WiFiClient { } // Return an error code and possibly a text string in a passed-in buffer with last SSL failure - int getLastSSLError(char *dest = NULL, size_t len = 0); + int getLastSSLError(char *dest = nullptr, size_t len = 0); // Attach a preconfigured certificate store void setCertStore(CertStoreBase *certStore) { @@ -291,7 +291,7 @@ class WiFiClientSecureCtx : public WiFiClient { const PublicKey *_knownkey; unsigned _knownkey_usages; - // Custom cipher list pointer or NULL if default + // Custom cipher list pointer or nullptr if default std::shared_ptr _cipher_list; uint8_t _cipher_cnt; @@ -490,7 +490,7 @@ class WiFiClientSecure : public WiFiClient { } // Return an error code and possibly a text string in a passed-in buffer with last SSL failure - int getLastSSLError(char *dest = NULL, size_t len = 0) { + int getLastSSLError(char *dest = nullptr, size_t len = 0) { return _ctx->getLastSSLError(dest, len); } diff --git a/libraries/WiFi/src/WiFiMulti.h b/libraries/WiFi/src/WiFiMulti.h index 839a88141..5fea2aee2 100644 --- a/libraries/WiFi/src/WiFiMulti.h +++ b/libraries/WiFi/src/WiFiMulti.h @@ -30,7 +30,7 @@ class WiFiMulti { WiFiMulti(); ~WiFiMulti(); - bool addAP(const char *ssid, const char *pass = NULL); + bool addAP(const char *ssid, const char *pass = nullptr); uint8_t run(uint32_t to = 10000); diff --git a/libraries/WiFi/src/WiFiServer.h b/libraries/WiFi/src/WiFiServer.h index bb8040091..04b90fe55 100644 --- a/libraries/WiFi/src/WiFiServer.h +++ b/libraries/WiFi/src/WiFiServer.h @@ -79,7 +79,7 @@ class WiFiServer { WiFiServer(uint16_t port); virtual ~WiFiServer() {} WiFiClient accept(); // https://www.arduino.cc/en/Reference/EthernetServerAccept - WiFiClient available(uint8_t* status = NULL); + WiFiClient available(uint8_t* status = nullptr); bool hasClient(); // hasClientData(): diff --git a/libraries/WiFi/src/WiFiServerSecureBearSSL.h b/libraries/WiFi/src/WiFiServerSecureBearSSL.h index 518d8f67b..511ebd13d 100644 --- a/libraries/WiFi/src/WiFiServerSecureBearSSL.h +++ b/libraries/WiFi/src/WiFiServerSecureBearSSL.h @@ -65,7 +65,7 @@ class WiFiServerSecure : public WiFiServer { // If awaiting connection available and authenticated (i.e. client cert), return it. WiFiClientSecure accept(); // https://www.arduino.cc/en/Reference/EthernetServerAccept - WiFiClientSecure available(uint8_t* status = NULL); + WiFiClientSecure available(uint8_t* status = nullptr); WiFiServerSecure& operator=(const WiFiServerSecure&) = default; diff --git a/libraries/WiFi/src/include/ClientContext.h b/libraries/WiFi/src/include/ClientContext.h index 6972af76e..5d40ba1dd 100644 --- a/libraries/WiFi/src/include/ClientContext.h +++ b/libraries/WiFi/src/include/ClientContext.h @@ -63,11 +63,11 @@ class ClientContext { err_t abort() { if (_pcb) { DEBUGV(":abort\r\n"); - tcp_arg(_pcb, NULL); - tcp_sent(_pcb, NULL); - tcp_recv(_pcb, NULL); - tcp_err(_pcb, NULL); - tcp_poll(_pcb, NULL, 0); + tcp_arg(_pcb, nullptr); + tcp_sent(_pcb, nullptr); + tcp_recv(_pcb, nullptr); + tcp_err(_pcb, nullptr); + tcp_poll(_pcb, nullptr, 0); LWIPMutex m; // Block the timer sys_check_timeouts call tcp_abort(_pcb); _pcb = nullptr; @@ -79,11 +79,11 @@ class ClientContext { err_t err = ERR_OK; if (_pcb) { DEBUGV(":close\r\n"); - tcp_arg(_pcb, NULL); - tcp_sent(_pcb, NULL); - tcp_recv(_pcb, NULL); - tcp_err(_pcb, NULL); - tcp_poll(_pcb, NULL, 0); + tcp_arg(_pcb, nullptr); + tcp_sent(_pcb, nullptr); + tcp_recv(_pcb, nullptr); + tcp_err(_pcb, nullptr); + tcp_poll(_pcb, nullptr, 0); LWIPMutex m; // Block the timer sys_check_timeouts call err = tcp_close(_pcb); if (err != ERR_OK) { @@ -651,10 +651,10 @@ class ClientContext { void _error(err_t err) { (void) err; DEBUGV(":er %d 0x%08x\r\n", (int) err, (uint32_t) _datasource); - tcp_arg(_pcb, NULL); - tcp_sent(_pcb, NULL); - tcp_recv(_pcb, NULL); - tcp_err(_pcb, NULL); + tcp_arg(_pcb, nullptr); + tcp_sent(_pcb, nullptr); + tcp_recv(_pcb, nullptr); + tcp_err(_pcb, nullptr); _pcb = nullptr; _notify_error(); } diff --git a/libraries/lwIP_CYW43/src/utility/CYW43shim.cpp b/libraries/lwIP_CYW43/src/utility/CYW43shim.cpp index cb1625e45..39a4a7780 100644 --- a/libraries/lwIP_CYW43/src/utility/CYW43shim.cpp +++ b/libraries/lwIP_CYW43/src/utility/CYW43shim.cpp @@ -112,7 +112,7 @@ extern "C" void cyw43_cb_process_ethernet(void *cb_data, int itf, size_t len, co #endif if (netif->flags & NETIF_FLAG_LINK_UP) { struct pbuf *p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); - if (p != NULL) { + if (p != nullptr) { pbuf_take(p, buf, len); if (netif->input(p, netif) != ERR_OK) { pbuf_free(p);