From a875a2fb9b704870a447d22eca51d9fb22fe120d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 9 Feb 2026 04:29:37 -0600 Subject: [PATCH] Future-proof available() check to handle negative return values --- esphome/components/ld2412/ld2412.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/ld2412/ld2412.cpp b/esphome/components/ld2412/ld2412.cpp index e5d35b7ffb..972229b7c8 100644 --- a/esphome/components/ld2412/ld2412.cpp +++ b/esphome/components/ld2412/ld2412.cpp @@ -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; }