Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to avoid uninitialized variables #26

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions components/LD2450/LD2450.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ namespace esphome::ld2450
{
// Try to read the header and abort on mismatch
const uint8_t *header;
bool skip = false;
uint8_t message_type;
uint8_t first_byte = read();
if (first_byte == update_header[0])
Expand All @@ -173,16 +172,20 @@ namespace esphome::ld2450
}
else
{
skip = true;
continue;
}

for (int i = 1; i < 4 && !skip; i++)
bool header_match = true;
for (int i = 1; i < 4; i++)
{
if (read() != header[i])
skip = true;
{
header_match = false;
break;
}
}

if (!skip)
if (header_match)
// Flag successful header reading
peek_status_ = message_type;
}
Expand Down Expand Up @@ -496,4 +499,4 @@ namespace esphome::ld2450

flush();
}
} // namespace esphome::ld2450
} // namespace esphome::ld2450
Loading