mirror of
https://github.com/esphome/esphome.git
synced 2026-09-02 02:56:01 +00:00
Future-proof available() check to handle negative return values
This commit is contained in:
@@ -310,8 +310,10 @@ void LD2412Component::restart_and_read_all_info() {
|
||||
}
|
||||
|
||||
void LD2412Component::loop() {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user