Future-proof available() check to handle negative return values

This commit is contained in:
J. Nick Koston
2026-02-09 04:34:49 -06:00
parent 836bfc625d
commit 21f270677b
+3 -1
View File
@@ -541,8 +541,10 @@ void LD2420Component::handle_simple_mode_(const uint8_t *inbuf, int len) {
}
void LD2420Component::read_batch_(std::span<uint8_t, MAX_LINE_LENGTH> buffer) {
// All current UART available() implementations return >= 0,
// use <= 0 to future-proof against any that may return negative on error.
int avail = this->available();
if (avail == 0) {
if (avail <= 0) {
return;
}