sched_get_stateinfo.c: misra_c_2012_rule_8_9_violation

Move the static g_statenames array from file scope to block scope within the
nxsched_get_stateinfo() function. This resolves MISRA C 2012 Rule 8.9 violation
which requires static variables to be used at block scope when only one function accesses them.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2026-01-28 15:01:10 +08:00
committed by Xiang Xiao
parent 2860333552
commit 3ec45774fb
+26 -29
View File
@@ -37,35 +37,6 @@
* Pre-processor types
****************************************************************************/
/* This is the state info of the task_state field of the TCB */
static FAR const char * const g_statenames[] =
{
"Invalid",
"Waiting,Unlock",
"Ready",
#ifdef CONFIG_SMP
"Assigned",
#endif
"Running",
"Inactive",
"Waiting,Semaphore",
"Waiting,Signal"
#ifdef CONFIG_SCHED_EVENTS
, "Waiting,Event"
#endif
#if !defined(CONFIG_DISABLE_MQUEUE) || !defined(CONFIG_DISABLE_MQUEUE_SYSV)
, "Waiting,MQ empty"
, "Waiting,MQ full"
#endif
#ifdef CONFIG_LEGACY_PAGING
, "Waiting,Paging fill"
#endif
#ifdef CONFIG_SIG_SIGSTOP_ACTION
, "Stopped"
#endif
};
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -87,6 +58,32 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state,
size_t length)
{
irqstate_t flags;
static FAR const char * const g_statenames[] =
{
"Invalid",
"Waiting,Unlock",
"Ready",
#ifdef CONFIG_SMP
"Assigned",
#endif
"Running",
"Inactive",
"Waiting,Semaphore",
"Waiting,Signal"
#ifdef CONFIG_SCHED_EVENTS
, "Waiting,Event"
#endif
#if !defined(CONFIG_DISABLE_MQUEUE) || !defined(CONFIG_DISABLE_MQUEUE_SYSV)
, "Waiting,MQ empty"
, "Waiting,MQ full"
#endif
#ifdef CONFIG_LEGACY_PAGING
, "Waiting,Paging fill"
#endif
#ifdef CONFIG_SIG_SIGSTOP_ACTION
, "Stopped"
#endif
};
#ifdef CONFIG_ARCH_ADDRENV
FAR struct addrenv_s *oldenv;