alanswx / ESPAsyncWiFiManager

Port WiFiManager to ESP Async Server
MIT License
219 stars 84 forks source link

PlatformIO compiler warnings: unused variable and signed / unsigned int comparison #71

Closed ba58smith closed 3 years ago

ba58smith commented 3 years ago

PlatformIO compiler gives this warning: "In member function 'void AsyncWiFiManager::copySSIDInfo(wifi_ssid_count_t)': .pio/libdeps/d1_mini/ESPAsyncWiFiManager/ESPAsyncWiFiManager.cpp:312:12: warning: unused variable 'res' [-Wunused-variable] bool res=WiFi.getNetworkInfo(i, wifiSSIDs[i].SSID, wifiSSIDs[i].encryptionType, wifiSSIDs[i].RSSI, wifiSSIDs[i].BSSID, wifiSSIDs[i].channel, wifiSSIDs[i]." The code is below - it appears it can safely be deleted to eliminate this warning.

#if defined(ESP8266)
      bool res=WiFi.getNetworkInfo(i, wifiSSIDs[i].SSID, wifiSSIDs[i].encryptionType, wifiSSIDs[i].RSSI, wifiSSIDs[i].BSSID, wifiSSIDs[i].channel, wifiSSIDs[i].isHidden);
#else
      bool res=WiFi.getNetworkInfo(i, wifiSSIDs[i].SSID, wifiSSIDs[i].encryptionType, wifiSSIDs[i].RSSI, wifiSSIDs[i].BSSID, wifiSSIDs[i].channel);
#endif

And this warning: "In member function 'boolean AsyncWiFiManager::isIp(String)': .pio/libdeps/d1_mini/ESPAsyncWiFiManager/ESPAsyncWiFiManager.cpp:1162:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < str.length(); i++) { " The code for that is:

boolean AsyncWiFiManager::isIp(String str) {
  for (int i = 0; i < str.length(); i++) {

String::length() returns a size_t, which is an unsigned integral type. I think the warning will go away by making i an unsigned int:

boolean AsyncWiFiManager::isIp(String str) {
  for (unsigned int i = 0; i < str.length(); i++) {
hmronline commented 3 years ago

@ba58smith this was fixed, this issue can be closed

ba58smith commented 3 years ago

Fixes look good to me. Thanks!