From 3359f266891636d2b10a40d4bd976584df40461a Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 26 Apr 2024 14:07:24 +0200 Subject: [PATCH] core/assert: move common code to inline function --- core/lib/assert.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/lib/assert.c b/core/lib/assert.c index 002aed0bda..fb4ff644bf 100644 --- a/core/lib/assert.c +++ b/core/lib/assert.c @@ -24,11 +24,12 @@ #include "backtrace.h" #endif -__NORETURN void _assert_failure(const char *file, unsigned line) +__NORETURN static inline void _assert_common(void) { - printf("%s:%u => ", file, line); #if IS_USED(MODULE_BACKTRACE) +#ifdef DEBUG_ASSERT_VERBOSE printf("failed assertion. Backtrace:\n"); +#endif backtrace_print(); #endif #ifdef DEBUG_ASSERT_BREAKPOINT @@ -37,16 +38,16 @@ __NORETURN void _assert_failure(const char *file, unsigned line) core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); } +__NORETURN void _assert_failure(const char *file, unsigned line) +{ + printf("%s:%u => ", file, line); + _assert_common(); +} + __NORETURN void _assert_panic(void) { printf("%" PRIxTXTPTR "\n", cpu_get_caller_pc()); -#if IS_USED(MODULE_BACKTRACE) - backtrace_print(); -#endif -#ifdef DEBUG_ASSERT_BREAKPOINT - DEBUG_BREAKPOINT(1); -#endif - core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); + _assert_common(); } /** @} */