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 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2025-08-14 20:15:34 +08:00 committed by Xiang Xiao
parent dde0d7405d
commit c7bb7ece8e

View file

@ -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;