From c7bb7ece8ef9838ff49aa1152eeb377e9192eccb Mon Sep 17 00:00:00 2001 From: hujun5 Date: Thu, 14 Aug 2025 20:15:34 +0800 Subject: [PATCH] sched_profil.c: misra_c_2012_rule_8_9_violation Move static g_prof variable declaration into block scope for the profil() function when CONFIG_SMP is disabled, following MISRA C 2012 Rule 8.9 which requires objects used by only one function to be declared within that function's scope. Signed-off-by: hujun5 --- sched/sched/sched_profil.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sched/sched/sched_profil.c b/sched/sched/sched_profil.c index 5a07af9678f..8088b9322af 100644 --- a/sched/sched/sched_profil.c +++ b/sched/sched/sched_profil.c @@ -58,9 +58,8 @@ static int profil_timer_handler_cpu(FAR void *arg); * Private Data ****************************************************************************/ -static struct profinfo_s g_prof; - #ifdef CONFIG_SMP +static struct profinfo_s g_prof; static struct smp_call_data_s g_call_data = SMP_CALL_INITIALIZER(profil_timer_handler_cpu, &g_prof); #endif @@ -137,6 +136,9 @@ static void profil_timer_handler(wdparm_t arg) int profil(FAR unsigned short *buf, size_t bufsiz, size_t offset, unsigned int scale) { +#ifndef CONFIG_SMP + static struct profinfo_s g_prof; +#endif FAR struct profinfo_s *prof = &g_prof; irqstate_t flags; uintptr_t highpc;