From dc6c799dad28bad7b466c0fc682d0bed2bfd82b2 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 13 Dec 2024 10:32:59 +1100 Subject: [PATCH] AP_HAL_ChibiOS: factor panic code to remove duplication the code inside and above the loop are the same, it's just the delay which changes --- libraries/AP_HAL_ChibiOS/system.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/system.cpp b/libraries/AP_HAL_ChibiOS/system.cpp index 09cb666821..dda37c5e2f 100644 --- a/libraries/AP_HAL_ChibiOS/system.cpp +++ b/libraries/AP_HAL_ChibiOS/system.cpp @@ -330,16 +330,13 @@ void panic(const char *errormsg, ...) INTERNAL_ERROR(AP_InternalError::error_t::panic); va_list ap; - va_start(ap, errormsg); - vprintf(errormsg, ap); - va_end(ap); - - hal.scheduler->delay_microseconds(10000); + uint16_t delay_ms = 10000; while (1) { va_start(ap, errormsg); vprintf(errormsg, ap); va_end(ap); - hal.scheduler->delay(500); + hal.scheduler->delay(delay_ms); + delay_ms = 500; } #else // we don't support variable args in bootlaoder