Skip to content

Commit ce340fa

Browse files
Lucme-no-dev
Luc
authored andcommitted
Clean warnings when all warning enabled (espressif#2112)
* Clean warnings when all warning enabled Not used variables / functions due to debug log Dual define with different values : cores\esp32/binary.h #define B110 6 #define B1000000 64 tools/sdk/include/newlib/sys/termios.h #define B110 3 #define B1000000 23 Local variable returned in WiFiclient Secure * change due to deprecated function * Update with proper variable and label * Update esp32-hal-i2c.c * Apply changes requested * Fix warnings due to #define conflict thanks @atanisoft
1 parent b69b04c commit ce340fa

File tree

7 files changed

+33
-23
lines changed

7 files changed

+33
-23
lines changed

Diff for: cores/esp32/Esp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static uint32_t sketchSize(sketchSize_t response) {
156156
.size = running->size,
157157
};
158158
data.start_addr = running_pos.offset;
159-
esp_image_load(ESP_IMAGE_VERIFY, &running_pos, &data);
159+
esp_image_verify(ESP_IMAGE_VERIFY, &running_pos, &data);
160160
if (response) {
161161
return running_pos.size - data.image_len;
162162
} else {

Diff for: cores/esp32/esp32-hal-i2c.c

+14-8
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,10 @@ static void IRAM_ATTR i2cDumpCmdQueue(i2c_t *i2c)
248248

249249
/* Stickbreaker ISR mode debug support
250250
*/
251+
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)
251252
static void i2cDumpDqData(i2c_t * i2c)
252253
{
253-
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)&&(defined ENABLE_I2C_DEBUG_BUFFER)
254+
#if defined (ENABLE_I2C_DEBUG_BUFFER)
254255
uint16_t a=0;
255256
char buff[140];
256257
I2C_DATA_QUEUE_t *tdq;
@@ -306,9 +307,12 @@ static void i2cDumpDqData(i2c_t * i2c)
306307
}
307308
a++;
308309
}
310+
#else
311+
log_i("Debug Buffer not Enabled");
309312
#endif
310313
}
311-
314+
#endif
315+
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO
312316
static void i2cDumpI2c(i2c_t * i2c)
313317
{
314318
log_e("i2c=%p",i2c);
@@ -332,11 +336,12 @@ static void i2cDumpI2c(i2c_t * i2c)
332336
i2cDumpDqData(i2c);
333337
}
334338
}
339+
#endif
335340

341+
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)
336342
static void i2cDumpInts(uint8_t num)
337343
{
338-
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO) && (defined ENABLE_I2C_DEBUG_BUFFER)
339-
344+
#if defined (ENABLE_I2C_DEBUG_BUFFER)
340345
uint32_t b;
341346
log_i("%u row\tcount\tINTR\tTX\tRX\tTick ",num);
342347
for(uint32_t a=1; a<=INTBUFFMAX; a++) {
@@ -349,9 +354,10 @@ static void i2cDumpInts(uint8_t num)
349354
log_i("Debug Buffer not Enabled");
350355
#endif
351356
}
357+
#endif
352358

353-
static void IRAM_ATTR i2cDumpStatus(i2c_t * i2c){
354359
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)&&(defined ENABLE_I2C_DEBUG_BUFFER)
360+
static void IRAM_ATTR i2cDumpStatus(i2c_t * i2c){
355361
typedef union {
356362
struct {
357363
uint32_t ack_rec: 1; /*This register stores the value of ACK bit.*/
@@ -377,11 +383,11 @@ static void IRAM_ATTR i2cDumpStatus(i2c_t * i2c){
377383
sr.val= i2c->dev->status_reg.val;
378384

379385
log_i("ack(%d) sl_rw(%d) to(%d) arb(%d) busy(%d) sl(%d) trans(%d) rx(%d) tx(%d) sclMain(%d) scl(%d)",sr.ack_rec,sr.slave_rw,sr.time_out,sr.arb_lost,sr.bus_busy,sr.slave_addressed,sr.byte_trans, sr.rx_fifo_cnt, sr.tx_fifo_cnt,sr.scl_main_state_last, sr.scl_state_last);
380-
#endif
381386
}
387+
#endif
382388

383-
static void i2cDumpFifo(i2c_t * i2c){
384389
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)&&(defined ENABLE_I2C_DEBUG_BUFFER)
390+
static void i2cDumpFifo(i2c_t * i2c){
385391
char buf[64];
386392
uint16_t k = 0;
387393
uint16_t i = fifoPos+1;
@@ -422,8 +428,8 @@ if(i != fifoPos){// actual data
422428
}
423429
}while( i!= fifoPos);
424430
}
425-
#endif
426431
}
432+
#endif
427433

428434
static void IRAM_ATTR i2cTriggerDumps(i2c_t * i2c, uint8_t trigger, const char locus[]){
429435
#if (ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO)&&(defined ENABLE_I2C_DEBUG_BUFFER)

Diff for: libraries/SD/src/sd_diskio.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616
#include "diskio.h"
1717
#include "ffconf.h"
1818
#include "ff.h"
19-
#include "esp_vfs.h"
19+
//#include "esp_vfs.h"
2020
#include "esp_vfs_fat.h"
2121
char CRC7(const char* data, int length);
2222
unsigned short CRC16(const char* data, int length);

Diff for: libraries/WiFi/src/WiFiClient.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ uint8_t WiFiClient::connected()
439439
if (_connected) {
440440
uint8_t dummy;
441441
int res = recv(fd(), &dummy, 0, MSG_DONTWAIT);
442+
if(res < 0) {
443+
log_e("RES: %d", res);
444+
}
442445
switch (errno) {
443446
case EWOULDBLOCK:
444447
case ENOENT: //caused by vfs

Diff for: libraries/WiFi/src/WiFiMulti.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,12 @@ uint8_t WiFiMulti::run(uint32_t connectTimeout)
118118
status = WiFi.status();
119119
}
120120

121-
IPAddress ip;
122-
uint8_t * mac;
123121
switch(status) {
124122
case 3:
125-
ip = WiFi.localIP();
126-
mac = WiFi.BSSID();
127123
log_i("[WIFI] Connecting done.");
128124
log_d("[WIFI] SSID: %s", WiFi.SSID().c_str());
129-
log_d("[WIFI] IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
130-
log_d("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
125+
log_d("[WIFI] IP: %s", WiFi.localIP().toString().c_str());
126+
log_d("[WIFI] MAC: %s", WiFi.BSSID().toString().c_str());
131127
log_d("[WIFI] Channel: %d", WiFi.channel());
132128
break;
133129
case 1:

Diff for: libraries/WiFi/src/WiFiSTA.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,10 @@ void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
683683
smartconfig_status_t status = (smartconfig_status_t) st;
684684
log_d("Status: %s", sc_status_strings[st % 5]);
685685
if (status == SC_STATUS_GETTING_SSID_PSWD) {
686+
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
686687
smartconfig_type_t * type = (smartconfig_type_t *)result;
687688
log_d("Type: %s", sc_type_strings[*type % 3]);
689+
#endif
688690
} else if (status == SC_STATUS_LINK) {
689691
wifi_sta_config_t *sta_conf = reinterpret_cast<wifi_sta_config_t *>(result);
690692
log_d("SSID: %s", (char *)(sta_conf->ssid));
@@ -694,8 +696,10 @@ void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
694696
_smartConfigDone = true;
695697
} else if (status == SC_STATUS_LINK_OVER) {
696698
if(result){
699+
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
697700
ip4_addr_t * ip = (ip4_addr_t *)result;
698701
log_d("Sender IP: " IPSTR, IP2STR(ip));
702+
#endif
699703
}
700704
WiFi.stopSmartConfig();
701705
}

Diff for: libraries/WiFiClientSecure/src/WiFiClientSecure.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,19 @@ bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
232232
}
233233

234234
char *WiFiClientSecure::_streamLoad(Stream& stream, size_t size) {
235-
char *dest = (char*)malloc(size);
235+
static char *dest = nullptr;
236+
if(dest) {
237+
free(dest);
238+
}
239+
dest = (char*)malloc(size);
236240
if (!dest) {
237241
return nullptr;
238242
}
239243
if (size != stream.readBytes(dest, size)) {
240244
free(dest);
241-
return nullptr;
245+
dest = nullptr;
242246
}
243-
char ret[size+1];
244-
snprintf(ret, size, "%s", dest);
245-
free(dest);
246-
return ret;
247+
return dest;
247248
}
248249

249250
bool WiFiClientSecure::loadCACert(Stream& stream, size_t size) {
@@ -290,4 +291,4 @@ int WiFiClientSecure::lastError(char *buf, const size_t size)
290291
void WiFiClientSecure::setHandshakeTimeout(unsigned long handshake_timeout)
291292
{
292293
sslclient->handshake_timeout = handshake_timeout * 1000;
293-
}
294+
}

0 commit comments

Comments
 (0)