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

This commit is contained in:
J. Nick Koston
2026-02-09 04:30:15 -06:00
parent 441ec35d9f
commit dd07e25a8f
2 changed files with 6 additions and 2 deletions
@@ -30,8 +30,10 @@ void MR60BHA2Component::dump_config() {
// main loop
void MR60BHA2Component::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;
}
@@ -49,8 +49,10 @@ void MR60FDA2Component::setup() {
// main loop
void MR60FDA2Component::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;
}