sched_cpuload.c: misra_c_2012_rule_8_9_violation

Move the static g_cpuload_wdog watchdog timer from file scope to block scope
within the cpuload_init() function. This resolves MISRA C 2012 Rule 8.9 violation
which requires static variables used by a single function to be scoped at block level.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2025-08-21 14:21:38 +08:00
committed by Alan C. Assis
parent 27542b3b09
commit 926f5de541
+4 -6
View File
@@ -90,10 +90,6 @@ volatile clock_t g_cpuload_total;
* Private Data
****************************************************************************/
#ifdef CONFIG_SCHED_CPULOAD_SYSCLK
static struct wdog_s g_cpuload_wdog;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -287,7 +283,9 @@ int clock_cpuload(int pid, FAR struct cpuload_s *cpuload)
#ifdef CONFIG_SCHED_CPULOAD_SYSCLK
void cpuload_init(void)
{
wd_start(&g_cpuload_wdog, CPULOAD_SAMPLING_PERIOD, cpuload_callback,
(wdparm_t)&g_cpuload_wdog);
static struct wdog_s cpuload_wdog;
wd_start(&cpuload_wdog, CPULOAD_SAMPLING_PERIOD, cpuload_callback,
(wdparm_t)&cpuload_wdog);
}
#endif