From fa9bf63faf8aee025b3f880ea9079c34140fcdf3 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 15 Nov 2024 19:45:58 +0100 Subject: [PATCH] sched/misc/assert.c: don't compile dump_assert_info logic if CONFIG_DEBUG_ALERT=n Don't compile dump_assert_info logic if CONFIG_DEBUG_ALERT=n With _alert() disabled this logic does nothing, but the compiler is not smart enough to optimize this code. on minimal stm32f3 configuration it saves 220B of flash. --- sched/misc/assert.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sched/misc/assert.c b/sched/misc/assert.c index c04f452d07..96b6a2a683 100644 --- a/sched/misc/assert.c +++ b/sched/misc/assert.c @@ -643,6 +643,11 @@ static void pause_all_cpu(void) } #endif +#ifdef CONFIG_DEBUG_ALERT +/**************************************************************************** + * Name: dump_running_task + ****************************************************************************/ + static void dump_running_task(FAR struct tcb_s *rtcb, FAR void *regs) { /* Register dump */ @@ -665,6 +670,7 @@ static void dump_running_task(FAR struct tcb_s *rtcb, FAR void *regs) * * Description: * Dump basic information of assertion + * ****************************************************************************/ static void dump_assert_info(FAR struct tcb_s *rtcb, @@ -710,6 +716,7 @@ static void dump_assert_info(FAR struct tcb_s *rtcb, syslog_flush(); } +#endif /* CONFIG_DEBUG_ALERT */ /**************************************************************************** * Name: dump_fatal_info @@ -719,7 +726,7 @@ static void dump_fatal_info(FAR struct tcb_s *rtcb, FAR const char *filename, int linenum, FAR const char *msg, FAR void *regs) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && defined(CONFIG_DEBUG_ALERT) int cpu; /* Dump other CPUs registers, running task stack and backtrace. */ @@ -887,9 +894,11 @@ void _assert(FAR const char *filename, int linenum, syslog_flush(); +#ifdef CONFIG_DEBUG_ALERT /* Dump basic info of assertion. */ dump_assert_info(rtcb, filename, linenum, msg, regs); +#endif if (g_nx_initstate == OSINIT_PANIC) {