Skip to content

Commit 67ced12

Browse files
dok-netmcspr
andcommitted
Apply suggestions from code review
Co-authored-by: Max Prokhorov <[email protected]>
1 parent 3be70a4 commit 67ced12

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

cores/esp8266/core_esp8266_main.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,11 @@ extern "C" void __esp_delay(unsigned long ms) {
163163
extern "C" void esp_delay(unsigned long ms) __attribute__((weak, alias("__esp_delay")));
164164

165165
bool try_esp_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uint32_t intvl_ms) {
166-
decltype(millis()) expired;
167-
168-
if ((expired = millis() - start_ms) >= timeout_ms) {
166+
uint32_t expired = millis() - start_ms;
167+
if (expired >= timeout_ms) {
169168
return true;
170169
}
171-
const auto remaining = timeout_ms - expired;
172-
esp_delay(remaining <= intvl_ms ? remaining : intvl_ms);
170+
esp_delay(std::min((timeout_ms - expired), intvl_ms));
173171
return false;
174172
}
175173

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,10 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
630630
if(err == ERR_OK) {
631631
DEBUG_WIFI_GENERIC("[hostByName] Host: %s IP: %s\n", aHostname, aResult.toString().c_str());
632632
return 1;
633-
} else {
634-
DEBUG_WIFI_GENERIC("[hostByName] Host: %s lookup error: %d!\n", aHostname, (int)err);
635-
return 0;
636633
}
634+
635+
DEBUG_WIFI_GENERIC("[hostByName] Host: %s lookup error: %s (%d)!\n", aHostname, lwip_strerr(err), (int)err);
636+
return 0;
637637
}
638638

639639
#if LWIP_IPV4 && LWIP_IPV6
@@ -680,10 +680,10 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
680680
if(err == ERR_OK) {
681681
DEBUG_WIFI_GENERIC("[hostByName] Host: %s IP: %s\n", aHostname, aResult.toString().c_str());
682682
return 1;
683-
} else {
684-
DEBUG_WIFI_GENERIC("[hostByName] Host: %s lookup error: %d!\n", aHostname, (int)err);
685-
return 0;
686683
}
684+
685+
DEBUG_WIFI_GENERIC("[hostByName] Host: %s lookup error: %d!\n", aHostname, (int)err);
686+
return 0;
687687
}
688688
#endif
689689

0 commit comments

Comments
 (0)