Unverified Commit e2b04e74 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Minor tweak, NULL=>nullptr (#844)

parent f79b0867
......@@ -240,7 +240,7 @@ protected:
}
time_t (*_timeCallback)(void) = nullptr;
static time_t _defaultTimeCB(void) {
return time(NULL);
return time(nullptr);
}
};
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -59,10 +59,10 @@ public:
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
......
......@@ -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);
}
......@@ -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);
......
......@@ -205,7 +205,7 @@ public:
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);
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -35,7 +35,7 @@ public:
// 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
......
......@@ -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);
}
......
......@@ -75,14 +75,14 @@ public:
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
......@@ -131,7 +131,7 @@ public:
// 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);
......
......@@ -522,7 +522,7 @@ readfile:
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 = ' ';
......
......@@ -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;
}
}
......
......@@ -92,7 +92,7 @@ public:
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;
......
......@@ -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;
......
......@@ -125,7 +125,7 @@ public:
}
// 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 @@ private:
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;
......@@ -490,7 +490,7 @@ public:
}
// 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);
}
......
......@@ -30,7 +30,7 @@ public:
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);
......
......@@ -79,7 +79,7 @@ public:
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():
......
......@@ -65,7 +65,7 @@ public:
// 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;
......
......@@ -63,11 +63,11 @@ public:
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 @@ public:
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 @@ protected:
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();
}
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment