From dfa48f988dc6e59a7327cffb3f5100bac5a8105a Mon Sep 17 00:00:00 2001 From: Perre Date: Tue, 3 Dec 2024 17:14:09 +0100 Subject: [PATCH] ESC check: Avoid unsigned timestamp underflow in telemtry timeout (#24069) * Avoid unsigned integer underflow * ESC check: add brackets to timeout for readability --------- Co-authored-by: Matthias Grob --- src/modules/commander/HealthAndArmingChecks/checks/escCheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/commander/HealthAndArmingChecks/checks/escCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/escCheck.cpp index 9554c57a4f..9b35c80992 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/escCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/escCheck.cpp @@ -77,7 +77,7 @@ void EscChecks::checkAndReport(const Context &context, Report &reporter) esc_status_s esc_status; - if (_esc_status_sub.copy(&esc_status) && now - esc_status.timestamp < esc_telemetry_timeout) { + if (_esc_status_sub.copy(&esc_status) && (now < esc_status.timestamp + esc_telemetry_timeout)) { checkEscStatus(context, reporter, esc_status); reporter.setIsPresent(health_component_t::motors_escs);