Skip to content

Commit fb512b6

Browse files
earlephilhowerhasenradball
authored andcommitted
Remove warnings, errors during host tests in CI (esp8266#8358)
* Remove warnings, errors during host tests in CI Debug strings often included format parameters which did not exactly match the passed in format parameters, resulting in warnings in the host test build process like ```` /home/runner/work/Arduino/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp:107:20: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 107 | DEBUG_WIFI("[AP] SSID length %u, too long or missing!\n", ssid_len); | ~~~~~~~~ | | | size_t {aka long unsigned int} ```` Fix by applying casting or PRxxx macros as appropriate. Also, fix one debug message which was trying to use a `String` as a `char *`: ```` /home/runner/work/Arduino/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp: In member function ‘wl_status_t ESP8266WiFiMulti::connectWiFiMulti(uint32_t)’: /home/runner/work/Arduino/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp:331:34: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘String’ [-Wformat=] 331 | DEBUG_WIFI_MULTI("[WIFIM] Connecting %s\n", ssid); ```` * Clean up SpeedTest.ino host build
1 parent ebc7f10 commit fb512b6

File tree

12 files changed

+21
-21
lines changed

12 files changed

+21
-21
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
556556
size_t transferred = stream->sendSize(_client.get(), size);
557557
if (transferred != size)
558558
{
559-
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] short write, asked for %d but got %d failed.\n", size, transferred);
559+
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] short write, asked for %zu but got %zu failed.\n", size, transferred);
560560
esp_yield();
561561
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
562562
}

libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ void ESP8266WebServerTemplate<ServerType>::sendContent(Stream* content, ssize_t
515515
ssize_t sent = content->sendSize(&_currentClient, content_length);
516516
if (sent != content_length)
517517
{
518-
DBGWS("HTTPServer: error: short send after timeout (%d<%d)\n", sent, content_length);
518+
DBGWS("HTTPServer: error: short send after timeout (%zu < %zu)\n", sent, content_length);
519519
}
520520
if(_chunked) {
521521
_currentClient.printf_P(PSTR("\r\n"));

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ void ESP8266WiFiClass::printDiag(Print& p) {
7575
char ssid[33]; //ssid can be up to 32chars, => plus null term
7676
memcpy(ssid, conf.ssid, sizeof(conf.ssid));
7777
ssid[32] = 0; //nullterm in case of 32 char ssid
78-
p.printf_P(PSTR("SSID (%d): %s\n"), strlen(ssid), ssid);
78+
p.printf_P(PSTR("SSID (%zu): %s\n"), strlen(ssid), ssid);
7979

8080
char passphrase[65];
8181
memcpy(passphrase, conf.password, sizeof(conf.password));
8282
passphrase[64] = 0;
83-
p.printf_P(PSTR("Passphrase (%d): %s\n"), strlen(passphrase), passphrase);
83+
p.printf_P(PSTR("Passphrase (%zu): %s\n"), strlen(passphrase), passphrase);
8484

8585
p.print(F("BSSID set: "));
8686
p.println(conf.bssid_set);

libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* psk, int channel,
104104

105105
size_t ssid_len = ssid ? strlen(ssid) : 0;
106106
if(ssid_len == 0 || ssid_len > 32) {
107-
DEBUG_WIFI("[AP] SSID length %u, too long or missing!\n", ssid_len);
107+
DEBUG_WIFI("[AP] SSID length %zu, too long or missing!\n", ssid_len);
108108
return false;
109109
}
110110

111111
size_t psk_len = psk ? strlen(psk) : 0;
112112
if(psk_len > 0 && (psk_len > 64 || psk_len < 8)) {
113-
DEBUG_WIFI("[AP] fail psk length %u, too long or short!\n", psk_len);
113+
DEBUG_WIFI("[AP] fail psk length %zu, too long or short!\n", psk_len);
114114
return false;
115115
}
116116

libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ wl_status_t ESP8266WiFiMulti::connectWiFiMulti(uint32_t connectTimeoutMs)
328328

329329
// Check SSID
330330
if (ssid == entry.ssid) {
331-
DEBUG_WIFI_MULTI("[WIFIM] Connecting %s\n", ssid);
331+
DEBUG_WIFI_MULTI("[WIFIM] Connecting %s\n", ssid.c_str());
332332

333333
// Connect to WiFi
334334
WiFi.begin(ssid, entry.passphrase, channel, bssid);
@@ -361,7 +361,7 @@ wl_status_t ESP8266WiFiMulti::connectWiFiMulti(uint32_t connectTimeoutMs)
361361
}
362362
}
363363

364-
DEBUG_WIFI_MULTI("[WIFIM] Could not connect\n", ssid);
364+
DEBUG_WIFI_MULTI("[WIFIM] Could not connect\n");
365365

366366
// Could not connect to any WiFi network
367367
return WL_CONNECT_FAILED;

libraries/ESP8266mDNS/src/LEAmDNS_Helpers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ bool MDNSResponder::_printRRAnswer(const MDNSResponder::stcMDNS_RRAnswer& p_RRAn
768768
if (pTxts)
769769
{
770770
((/*const c_str()!!*/stcMDNS_RRAnswerTXT*)&p_RRAnswer)->m_Txts.c_str(pTxts);
771-
DEBUG_OUTPUT.printf_P(PSTR("TXT(%u) %s"), stTxtLength, pTxts);
771+
DEBUG_OUTPUT.printf_P(PSTR("TXT(%zu) %s"), stTxtLength, pTxts);
772772
delete[] pTxts;
773773
}
774774
break;

libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1666,19 +1666,19 @@ bool MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::finalTimeoutLevel(vo
16661666
unsigned long MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout(void) const
16671667
{
16681668

1669-
uint32_t u32Timeout = esp8266::polledTimeout::oneShotMs::neverExpires;
1669+
unsigned long timeout = esp8266::polledTimeout::oneShotMs::neverExpires;
16701670

16711671
if (TIMEOUTLEVEL_BASE == m_timeoutLevel) // 80%
16721672
{
1673-
u32Timeout = (m_u32TTL * 800); // to milliseconds
1673+
timeout = (m_u32TTL * 800L); // to milliseconds
16741674
}
16751675
else if ((TIMEOUTLEVEL_BASE < m_timeoutLevel) && // >80% AND
16761676
(TIMEOUTLEVEL_FINAL >= m_timeoutLevel)) // <= 100%
16771677
{
16781678

1679-
u32Timeout = (m_u32TTL * 50);
1679+
timeout = (m_u32TTL * 50L);
16801680
} // else: invalid
1681-
return u32Timeout;
1681+
return timeout;
16821682
}
16831683

16841684

libraries/ESP8266mDNS/src/LEAmDNS_Transfer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ bool MDNSResponder::_readRRAnswer(MDNSResponder::stcMDNS_RRAnswer*& p_rpRRAnswer
532532
if (pTxts)
533533
{
534534
((stcMDNS_RRAnswerTXT*&)p_rpRRAnswer)->m_Txts.c_str(pTxts);
535-
DEBUG_OUTPUT.printf_P(PSTR("TXT(%u) %s"), stTxtLength, pTxts);
535+
DEBUG_OUTPUT.printf_P(PSTR("TXT(%zu) %s"), stTxtLength, pTxts);
536536
delete[] pTxts;
537537
}
538538
break;

libraries/LittleFS/examples/SpeedTest/SpeedTest.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void DoTest(FS *fs) {
6565
Serial.printf("==> Time to write %dKB in 256b chunks = %lu milliseconds\n", TESTSIZEKB, stop - start);
6666

6767
f = fs->open("/testwrite.bin", "r");
68-
Serial.printf("==> Created file size = %d\n", f.size());
68+
Serial.printf("==> Created file size = %zu\n", f.size());
6969
f.close();
7070

7171
Serial.printf("Reading %dKB file sequentially in 256b chunks\n", TESTSIZEKB);

libraries/LittleFS/src/LittleFS.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,14 @@ class LittleFSFileImpl : public FileImpl
467467
if (_creation) {
468468
int rc = lfs_setattr(_fs->getFS(), _name.get(), 'c', (const void *)&_creation, sizeof(_creation));
469469
if (rc < 0) {
470-
DEBUGV("Unable to set creation time on '%s' to %d\n", _name.get(), _creation);
470+
DEBUGV("Unable to set creation time on '%s' to %ld\n", _name.get(), (long)_creation);
471471
}
472472
}
473473
// Add metadata with last write time
474474
time_t now = _timeCallback();
475475
int rc = lfs_setattr(_fs->getFS(), _name.get(), 't', (const void *)&now, sizeof(now));
476476
if (rc < 0) {
477-
DEBUGV("Unable to set last write time on '%s' to %d\n", _name.get(), now);
477+
DEBUGV("Unable to set last write time on '%s' to %ld\n", _name.get(), (long)now);
478478
}
479479
}
480480
}

libraries/SD/src/SD.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ class SDClass {
135135
size_t size() {
136136
uint64_t sz = size64();
137137
#ifdef DEBUG_ESP_PORT
138-
if (sz > (uint64_t)SIZE_MAX) {
139-
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use size64().\n"), sz);
138+
if (sz > std::numeric_limits<uint32_t>::max()) {
139+
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use size64().\n"), (long long)sz);
140140
}
141141
#endif
142142
return (size_t)sz;

libraries/SDFS/src/SDFS.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ class SDFSImpl : public FSImpl
115115
info.maxOpenFiles = i.maxOpenFiles;
116116
info.maxPathLength = i.maxPathLength;
117117
#ifdef DEBUG_ESP_PORT
118-
if (i.totalBytes > (uint64_t)SIZE_MAX) {
118+
if (i.totalBytes > std::numeric_limits<uint32_t>::max()) {
119119
// This catches both total and used cases, since used must always be < total.
120-
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use info64().\n"), i.totalBytes);
120+
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use info64().\n"), (long long)i.totalBytes);
121121
}
122122
#endif
123123
info.totalBytes = (size_t)i.totalBytes;

0 commit comments

Comments
 (0)