[sprinkler][pn532] Fix bugprone-unchecked-optional-access (#16102)

This commit is contained in:
Jonathan Swoboda
2026-04-28 21:04:19 -04:00
committed by GitHub
parent 9768380856
commit 1a57d9bc2f
2 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -317,6 +317,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
if (!this->rd_start_time_.has_value()) {
this->rd_start_time_ = millis();
}
const uint32_t rd_start_time = *this->rd_start_time_;
while (true) {
if (this->is_read_ready()) {
@@ -324,7 +325,7 @@ enum PN532ReadReady PN532::read_ready_(bool block) {
break;
}
if (millis() - *this->rd_start_time_ > 100) {
if (millis() - rd_start_time > 100) {
ESP_LOGV(TAG, "Timed out waiting for readiness from PN532!");
this->rd_ready_ = TIMEOUT;
break;
+5 -4
View File
@@ -897,11 +897,12 @@ void Sprinkler::resume() {
}
if (this->paused_valve_.has_value() && (this->resume_duration_.has_value())) {
const size_t paused_valve = *this->paused_valve_;
const uint32_t resume_duration = *this->resume_duration_;
// Resume only if valve has not been completed yet
if (!this->valve_cycle_complete_(this->paused_valve_.value())) {
ESP_LOGD(TAG, "Resuming valve %zu with %" PRIu32 " seconds remaining", this->paused_valve_.value_or(0),
this->resume_duration_.value_or(0));
this->fsm_request_(this->paused_valve_.value(), this->resume_duration_.value());
if (!this->valve_cycle_complete_(paused_valve)) {
ESP_LOGD(TAG, "Resuming valve %zu with %" PRIu32 " seconds remaining", paused_valve, resume_duration);
this->fsm_request_(paused_valve, resume_duration);
}
this->reset_resume();
} else {