Skip to content

Commit

Permalink
Remove warnings, errors during host tests in CI (#8358)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
earlephilhower committed Nov 2, 2021
1 parent 3f5a76c commit 7d971fa
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
size_t transferred = stream->sendSize(_client.get(), size);
if (transferred != size)
{
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] short write, asked for %d but got %d failed.\n", size, transferred);
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] short write, asked for %zu but got %zu failed.\n", size, transferred);
esp_yield();
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void ESP8266WebServerTemplate<ServerType>::sendContent(Stream* content, ssize_t
ssize_t sent = content->sendSize(&_currentClient, content_length);
if (sent != content_length)
{
DBGWS("HTTPServer: error: short send after timeout (%d<%d)\n", sent, content_length);
DBGWS("HTTPServer: error: short send after timeout (%zu < %zu)\n", sent, content_length);
}
if(_chunked) {
_currentClient.printf_P(PSTR("\r\n"));
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ void ESP8266WiFiClass::printDiag(Print& p) {
char ssid[33]; //ssid can be up to 32chars, => plus null term
memcpy(ssid, conf.ssid, sizeof(conf.ssid));
ssid[32] = 0; //nullterm in case of 32 char ssid
p.printf_P(PSTR("SSID (%d): %s\n"), strlen(ssid), ssid);
p.printf_P(PSTR("SSID (%zu): %s\n"), strlen(ssid), ssid);

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

p.print(F("BSSID set: "));
p.println(conf.bssid_set);
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* psk, int channel,

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

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

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ wl_status_t ESP8266WiFiMulti::connectWiFiMulti(uint32_t connectTimeoutMs)

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

// Connect to WiFi
WiFi.begin(ssid, entry.passphrase, channel, bssid);
Expand Down Expand Up @@ -361,7 +361,7 @@ wl_status_t ESP8266WiFiMulti::connectWiFiMulti(uint32_t connectTimeoutMs)
}
}

DEBUG_WIFI_MULTI("[WIFIM] Could not connect\n", ssid);
DEBUG_WIFI_MULTI("[WIFIM] Could not connect\n");

// Could not connect to any WiFi network
return WL_CONNECT_FAILED;
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266mDNS/src/LEAmDNS_Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ bool MDNSResponder::_printRRAnswer(const MDNSResponder::stcMDNS_RRAnswer& p_RRAn
if (pTxts)
{
((/*const c_str()!!*/stcMDNS_RRAnswerTXT*)&p_RRAnswer)->m_Txts.c_str(pTxts);
DEBUG_OUTPUT.printf_P(PSTR("TXT(%u) %s"), stTxtLength, pTxts);
DEBUG_OUTPUT.printf_P(PSTR("TXT(%zu) %s"), stTxtLength, pTxts);
delete[] pTxts;
}
break;
Expand Down
8 changes: 4 additions & 4 deletions libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1666,19 +1666,19 @@ bool MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::finalTimeoutLevel(vo
unsigned long MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout(void) const
{

uint32_t u32Timeout = esp8266::polledTimeout::oneShotMs::neverExpires;
unsigned long timeout = esp8266::polledTimeout::oneShotMs::neverExpires;

if (TIMEOUTLEVEL_BASE == m_timeoutLevel) // 80%
{
u32Timeout = (m_u32TTL * 800); // to milliseconds
timeout = (m_u32TTL * 800L); // to milliseconds
}
else if ((TIMEOUTLEVEL_BASE < m_timeoutLevel) && // >80% AND
(TIMEOUTLEVEL_FINAL >= m_timeoutLevel)) // <= 100%
{

u32Timeout = (m_u32TTL * 50);
timeout = (m_u32TTL * 50L);
} // else: invalid
return u32Timeout;
return timeout;
}


Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266mDNS/src/LEAmDNS_Transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ bool MDNSResponder::_readRRAnswer(MDNSResponder::stcMDNS_RRAnswer*& p_rpRRAnswer
if (pTxts)
{
((stcMDNS_RRAnswerTXT*&)p_rpRRAnswer)->m_Txts.c_str(pTxts);
DEBUG_OUTPUT.printf_P(PSTR("TXT(%u) %s"), stTxtLength, pTxts);
DEBUG_OUTPUT.printf_P(PSTR("TXT(%zu) %s"), stTxtLength, pTxts);
delete[] pTxts;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion libraries/LittleFS/examples/SpeedTest/SpeedTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void DoTest(FS *fs) {
Serial.printf("==> Time to write %dKB in 256b chunks = %lu milliseconds\n", TESTSIZEKB, stop - start);

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

Serial.printf("Reading %dKB file sequentially in 256b chunks\n", TESTSIZEKB);
Expand Down
4 changes: 2 additions & 2 deletions libraries/LittleFS/src/LittleFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ class LittleFSFileImpl : public FileImpl
if (_creation) {
int rc = lfs_setattr(_fs->getFS(), _name.get(), 'c', (const void *)&_creation, sizeof(_creation));
if (rc < 0) {
DEBUGV("Unable to set creation time on '%s' to %d\n", _name.get(), _creation);
DEBUGV("Unable to set creation time on '%s' to %ld\n", _name.get(), (long)_creation);
}
}
// Add metadata with last write time
time_t now = _timeCallback();
int rc = lfs_setattr(_fs->getFS(), _name.get(), 't', (const void *)&now, sizeof(now));
if (rc < 0) {
DEBUGV("Unable to set last write time on '%s' to %d\n", _name.get(), now);
DEBUGV("Unable to set last write time on '%s' to %ld\n", _name.get(), (long)now);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/SD/src/SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class SDClass {
size_t size() {
uint64_t sz = size64();
#ifdef DEBUG_ESP_PORT
if (sz > (uint64_t)SIZE_MAX) {
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use size64().\n"), sz);
if (sz > std::numeric_limits<uint32_t>::max()) {
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use size64().\n"), (long long)sz);
}
#endif
return (size_t)sz;
Expand Down
4 changes: 2 additions & 2 deletions libraries/SDFS/src/SDFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class SDFSImpl : public FSImpl
info.maxOpenFiles = i.maxOpenFiles;
info.maxPathLength = i.maxPathLength;
#ifdef DEBUG_ESP_PORT
if (i.totalBytes > (uint64_t)SIZE_MAX) {
if (i.totalBytes > std::numeric_limits<uint32_t>::max()) {
// This catches both total and used cases, since used must always be < total.
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use info64().\n"), i.totalBytes);
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld >= 4GB). Please update source to use info64().\n"), (long long)i.totalBytes);
}
#endif
info.totalBytes = (size_t)i.totalBytes;
Expand Down

0 comments on commit 7d971fa

Please sign in to comment.