From ac8eccd7ca93abc04887f214ccb265830d07dfcc Mon Sep 17 00:00:00 2001 From: Spencer Yan Date: Thu, 24 Oct 2024 15:32:29 +0800 Subject: [PATCH] fix(mr60fda2): variable is used uninitialized whenever 'if' condition is false --- esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp index b000f81fc3..fa4d803977 100644 --- a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +++ b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp @@ -251,14 +251,12 @@ void MR60FDA2Component::process_frame_() { this->current_frame_locate_ = LOCATE_FRAME_HEADER; break; case RESULT_PARAMETERS: - float install_height_float; - float height_threshold_float; if (this->install_height_select_ != nullptr) { this->current_install_height_int_ = encode_uint32(current_data_buf_[3], current_data_buf_[2], current_data_buf_[1], current_data_buf_[0]); - install_height_float = bit_cast(current_install_height_int_); + float install_height_float = bit_cast(current_install_height_int_); select_index_ = find_nearest_index(install_height_float, INSTALL_HEIGHT, 7); this->install_height_select_->publish_state(this->install_height_select_->at(select_index_).value()); } @@ -267,7 +265,7 @@ void MR60FDA2Component::process_frame_() { this->current_height_threshold_int_ = encode_uint32(current_data_buf_[7], current_data_buf_[6], current_data_buf_[5], current_data_buf_[4]); - height_threshold_float = bit_cast(current_height_threshold_int_); + float height_threshold_float = bit_cast(current_height_threshold_int_); select_index_ = find_nearest_index(height_threshold_float, HEIGHT_THRESHOLD, 7); this->height_threshold_select_->publish_state(this->height_threshold_select_->at(select_index_).value()); }