Skip to content
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

Minor tweak, NULL=>nullptr #844

Merged
merged 1 commit into from
Sep 7, 2022
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
2 changes: 1 addition & 1 deletion cores/rp2040/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class FS {
}
time_t (*_timeCallback)(void) = nullptr;
static time_t _defaultTimeCB(void) {
return time(NULL);
return time(nullptr);
}
};

Expand Down
6 changes: 3 additions & 3 deletions cores/rp2040/RP2040USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}


Expand Down
4 changes: 2 additions & 2 deletions cores/rp2040/lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/ArduinoOTA/src/ArduinoOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libraries/DNSServer/src/DNSServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ 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();
}

void DNSServer::replyWithError(DNSHeader *dnsHeader,
DNSReplyCode rcode) {
replyWithError(dnsHeader, rcode, NULL, 0);
replyWithError(dnsHeader, rcode, nullptr, 0);
}
2 changes: 1 addition & 1 deletion libraries/HTTPClient/src/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libraries/HTTPClient/src/HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libraries/HTTPUpdateServer/src/HTTPUpdateServer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static const char successResponse[] PROGMEM =
template <typename ServerType, int ServerPort>
HTTPUpdateServerTemplate<ServerType, ServerPort>::HTTPUpdateServerTemplate(bool serial_debug) {
_serial_output = serial_debug;
_server = NULL;
_server = nullptr;
_username = "";
_password = "";
_authenticated = false;
Expand Down
4 changes: 2 additions & 2 deletions libraries/SPI/src/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/SPI/src/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions libraries/WebServer/src/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/WebServer/src/HTTPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(void)> 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

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libraries/WebServer/src/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 = ' ';
Expand Down
14 changes: 7 additions & 7 deletions libraries/WiFi/src/StackThunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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();
}
}
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiClientSecureBearSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions libraries/WiFi/src/WiFiClientSecureBearSSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<uint16_t> _cipher_list;
uint8_t _cipher_cnt;

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiMulti.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/WiFiServerSecureBearSSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
28 changes: 14 additions & 14 deletions libraries/WiFi/src/include/ClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/lwIP_CYW43/src/utility/CYW43shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down