mirror of
https://github.com/esphome/esphome.git
synced 2025-11-18 15:55:46 +00:00
defensive to make bot happy
This commit is contained in:
@@ -813,7 +813,7 @@ void WiFiComponent::retry_connect() {
|
|||||||
#ifdef USE_WIFI_FAST_CONNECT
|
#ifdef USE_WIFI_FAST_CONNECT
|
||||||
if (this->sta_.empty()) {
|
if (this->sta_.empty()) {
|
||||||
// No configured networks - shouldn't happen in fast_connect mode, but handle defensively
|
// No configured networks - shouldn't happen in fast_connect mode, but handle defensively
|
||||||
ESP_LOGW(TAG, "No configured networks available");
|
ESP_LOGW(TAG, "No configured networks");
|
||||||
this->restart_adapter();
|
this->restart_adapter();
|
||||||
} else if (this->trying_loaded_ap_) {
|
} else if (this->trying_loaded_ap_) {
|
||||||
this->trying_loaded_ap_ = false;
|
this->trying_loaded_ap_ = false;
|
||||||
@@ -896,7 +896,7 @@ bool WiFiComponent::load_fast_connect_settings_() {
|
|||||||
if (this->fast_connect_pref_.load(&fast_connect_save)) {
|
if (this->fast_connect_pref_.load(&fast_connect_save)) {
|
||||||
// Validate saved AP index
|
// Validate saved AP index
|
||||||
if (fast_connect_save.ap_index < 0 || static_cast<size_t>(fast_connect_save.ap_index) >= this->sta_.size()) {
|
if (fast_connect_save.ap_index < 0 || static_cast<size_t>(fast_connect_save.ap_index) >= this->sta_.size()) {
|
||||||
ESP_LOGW(TAG, "Saved AP index out of bounds");
|
ESP_LOGW(TAG, "AP index out of bounds");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ class WiFiComponent : public Component {
|
|||||||
for (size_t i = 0; i < this->sta_.size(); i++) {
|
for (size_t i = 0; i < this->sta_.size(); i++) {
|
||||||
if (scan_res.matches(this->sta_[i])) {
|
if (scan_res.matches(this->sta_[i])) {
|
||||||
if (i > std::numeric_limits<int8_t>::max()) {
|
if (i > std::numeric_limits<int8_t>::max()) {
|
||||||
ESP_LOGE(TAG, "Matched AP index %zu exceeds int8_t range", i);
|
ESP_LOGE(TAG, "AP index %zu too large", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this->selected_sta_index_ = static_cast<int8_t>(i); // Links scan_result_[0] with sta_[i]
|
this->selected_sta_index_ = static_cast<int8_t>(i); // Links scan_result_[0] with sta_[i]
|
||||||
|
|||||||
Reference in New Issue
Block a user