Skip to content

Commit 0ee51f0

Browse files
committed
fix: silence warnings pointed in issue #11917, minor performance fixes
1 parent b20655a commit 0ee51f0

File tree

13 files changed

+37
-19
lines changed

13 files changed

+37
-19
lines changed

libraries/AsyncUDP/src/AsyncUDP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static QueueHandle_t _udp_queue;
164164
static volatile TaskHandle_t _udp_task_handle = NULL;
165165

166166
static void _udp_task(void *pvParameters) {
167+
(void)pvParameters;
167168
lwip_event_packet_t *e = NULL;
168169
for (;;) {
169170
if (xQueueReceive(_udp_queue, &e, portMAX_DELAY) == pdTRUE) {

libraries/DNSServer/src/DNSServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool DNSServer::requestIncludesOnlyOneQuestion(DNSHeader &dnsHeader) {
132132
String DNSServer::getDomainNameWithoutWwwPrefix(const unsigned char *start, size_t len) {
133133
String parsedDomainName(start, --len); // exclude trailing null byte from labels length, String constructor will add it anyway
134134

135-
int pos = 0;
135+
size_t pos = 0;
136136
while (pos < len) {
137137
parsedDomainName.setCharAt(pos, 0x2e); // replace label len byte with dot char "."
138138
pos += *(start + pos);

libraries/Ethernet/src/ETH.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static ETHClass *_ethernets[NUM_SUPPORTED_ETH_PORTS] = {NULL, NULL, NULL};
5353
static esp_event_handler_instance_t _eth_ev_instance = NULL;
5454

5555
static void _eth_event_cb(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
56-
56+
(void)arg;
5757
if (event_base == ETH_EVENT) {
5858
esp_eth_handle_t eth_handle = *((esp_eth_handle_t *)event_data);
5959
for (int i = 0; i < NUM_SUPPORTED_ETH_PORTS; ++i) {
@@ -146,6 +146,9 @@ ETHClass::ETHClass(uint8_t eth_index)
146146
ETHClass::~ETHClass() {}
147147

148148
bool ETHClass::ethDetachBus(void *bus_pointer) {
149+
if (!bus_pointer) {
150+
return true;
151+
}
149152
ETHClass *bus = (ETHClass *)bus_pointer;
150153
bus->end();
151154
return true;

libraries/Hash/src/PBKDF2_HMACBuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void PBKDF2_HMACBuilder::add(const uint8_t *data, size_t len) {
111111

112112
bool PBKDF2_HMACBuilder::addStream(Stream &stream, const size_t maxLen) {
113113
log_e("PBKDF2_HMACBuilder does not support addStream. Use setPassword() and setSalt() instead.");
114+
(void)stream;
115+
(void)maxLen;
114116
return false;
115117
}
116118

libraries/LittleFS/src/LittleFS.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ LittleFSFS::~LittleFSFS() {
4444
}
4545

4646
bool LittleFSFS::begin(bool formatOnFail, const char *basePath, uint8_t maxOpenFiles, const char *partitionLabel) {
47+
(void)maxOpenFiles;
4748

4849
if (partitionLabel_) {
4950
free(partitionLabel_);

libraries/Network/src/NetworkInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ extern "C" int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp) {
4747
#endif
4848

4949
static void _ip_event_cb(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
50+
(void)arg;
5051
if (event_base == IP_EVENT) {
5152
NetworkInterface *netif = NULL;
5253
if (event_id == IP_EVENT_STA_GOT_IP || event_id == IP_EVENT_ETH_GOT_IP || event_id == IP_EVENT_PPP_GOT_IP) {

libraries/NetworkClientSecure/src/ssl_client.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ int start_ssl_client(
223223
log_e("pre-shared key not valid hex or too long");
224224
return -1;
225225
}
226-
unsigned char psk[MBEDTLS_PSK_MAX_LEN];
227-
size_t psk_len = strlen(psKey) / 2;
228-
for (int j = 0; j < strlen(psKey); j += 2) {
226+
unsigned char pskBytes[MBEDTLS_PSK_MAX_LEN];
227+
size_t pskStrLen = strlen(psKey);
228+
size_t pskByteLen = pskStrLen / 2;
229+
for (int j = 0; j < pskStrLen; j += 2) {
229230
char c = psKey[j];
230231
if (c >= '0' && c <= '9') {
231232
c -= '0';
@@ -236,7 +237,7 @@ int start_ssl_client(
236237
} else {
237238
return -1;
238239
}
239-
psk[j / 2] = c << 4;
240+
pskBytes[j / 2] = c << 4;
240241
c = psKey[j + 1];
241242
if (c >= '0' && c <= '9') {
242243
c -= '0';
@@ -247,10 +248,10 @@ int start_ssl_client(
247248
} else {
248249
return -1;
249250
}
250-
psk[j / 2] |= c;
251+
pskBytes[j / 2] |= c;
251252
}
252253
// set mbedtls config
253-
ret = mbedtls_ssl_conf_psk(&ssl_client->ssl_conf, psk, psk_len, (const unsigned char *)pskIdent, strlen(pskIdent));
254+
ret = mbedtls_ssl_conf_psk(&ssl_client->ssl_conf, pskBytes, pskByteLen, (const unsigned char *)pskIdent, strlen(pskIdent));
254255
if (ret != 0) {
255256
log_e("mbedtls_ssl_conf_psk returned %d", ret);
256257
return handle_error(ret);

libraries/Update/src/Updater.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@ bool UpdateClass::rollBack() {
128128
}
129129

130130
bool UpdateClass::begin(size_t size, int command, int ledPin, uint8_t ledOn, const char *label) {
131+
(void)label;
132+
131133
if (_size > 0) {
132134
log_w("already running");
133135
return false;
134136
}
135-
137+
136138
_ledPin = ledPin;
137139
_ledOn = !!ledOn; // 0(LOW) or 1(HIGH)
138140

libraries/WebServer/src/Parsing.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ bool WebServer::_parseRequest(NetworkClient &client) {
189189
_currentHandler->raw(*this, _currentUri, *_currentRaw);
190190
_currentRaw->status = RAW_WRITE;
191191

192-
while (_currentRaw->totalSize < _clientContentLength) {
193-
size_t read_len = std::min(_clientContentLength - _currentRaw->totalSize, (size_t)HTTP_RAW_BUFLEN);
192+
while (_currentRaw->totalSize < (size_t)_clientContentLength) {
193+
size_t read_len = std::min((size_t)_clientContentLength - _currentRaw->totalSize, (size_t)HTTP_RAW_BUFLEN);
194194
_currentRaw->currentSize = client.readBytes(_currentRaw->buf, read_len);
195195
_currentRaw->totalSize += _currentRaw->currentSize;
196196
if (_currentRaw->currentSize == 0) {
@@ -205,8 +205,8 @@ bool WebServer::_parseRequest(NetworkClient &client) {
205205
log_v("Finish Raw");
206206
} else if (!isForm) {
207207
size_t plainLength;
208-
char *plainBuf = readBytesWithTimeout(client, _clientContentLength, plainLength, HTTP_MAX_POST_WAIT);
209-
if (plainLength < _clientContentLength) {
208+
char *plainBuf = readBytesWithTimeout(client, _clientContentLength, plainLength, HTTP_MAX_POST_WAIT);
209+
if (plainLength < (size_t)_clientContentLength) {
210210
free(plainBuf);
211211
return false;
212212
}
@@ -407,7 +407,7 @@ int WebServer::_uploadReadByte(NetworkClient &client) {
407407

408408
bool WebServer::_parseForm(NetworkClient &client, const String &boundary, uint32_t len) {
409409
(void)len;
410-
log_v("Parse Form: Boundary: %s Length: %d", boundary.c_str(), len);
410+
log_v("Parse Form: Boundary: %s Length: %u", boundary.c_str(), len);
411411
String line;
412412
int retry = 0;
413413
do {
@@ -432,7 +432,7 @@ bool WebServer::_parseForm(NetworkClient &client, const String &boundary, uint32
432432

433433
line = client.readStringUntil('\r');
434434
client.readStringUntil('\n');
435-
if (line.length() > 19 && line.substring(0, 19).equalsIgnoreCase(F("Content-Disposition"))) {
435+
if (line.length() > (size_t)19 && line.substring(0, 19).equalsIgnoreCase(F("Content-Disposition"))) {
436436
int nameStart = line.indexOf('=');
437437
if (nameStart != -1) {
438438
argName = line.substring(nameStart + 2);
@@ -455,7 +455,7 @@ bool WebServer::_parseForm(NetworkClient &client, const String &boundary, uint32
455455
line = client.readStringUntil('\r');
456456
client.readStringUntil('\n');
457457
while (line.length() > 0) {
458-
if (line.length() > 12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))) {
458+
if (line.length() > (size_t)12 && line.substring(0, 12).equalsIgnoreCase(FPSTR(Content_Type))) {
459459
argType = line.substring(line.indexOf(':') + 2);
460460
}
461461
//skip over any other headers
@@ -470,7 +470,7 @@ bool WebServer::_parseForm(NetworkClient &client, const String &boundary, uint32
470470
if (line.startsWith("--" + boundary)) {
471471
break;
472472
}
473-
if (argValue.length() > 0) {
473+
if (argValue.length() > (size_t)0) {
474474
argValue += "\n";
475475
}
476476
argValue += line;

libraries/WebServer/src/WebServer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ bool WebServer::authenticateBasicSHA1(const char *_username, const char *_sha1Ba
143143

144144
bool WebServer::authenticate(const char *_username, const char *_password) {
145145
return WebServer::authenticate([_username, _password](HTTPAuthMethod mode, String username, String params[]) -> String * {
146+
(void)mode;
147+
(void)params;
146148
return username.equalsConstantTime(_username) ? new String(_password) : NULL;
147149
});
148150
}
@@ -612,8 +614,8 @@ void WebServer::chunkResponseEnd() {
612614
if (_chunkedClient.write("0\r\n\r\n", 5) != 5) {
613615
log_e("Failed to write terminating chunk");
614616
}
615-
616-
_chunkedClient.flush();
617+
/* NetworkClient::flush() is deprecated; use clear() to drop buffered data */
618+
_chunkedClient.clear();
617619
_chunkedResponseActive = false;
618620
_chunked = false;
619621
_chunkedClient = NetworkClient();

0 commit comments

Comments
 (0)