This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 3ec45774fb1 sched_get_stateinfo.c: misra_c_2012_rule_8_9_violation
3ec45774fb1 is described below
commit 3ec45774fb17b317b6f0f743ed5ea224e4bf0790
Author: hujun5 <[email protected]>
AuthorDate: Wed Jan 28 15:01:10 2026 +0800
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 <[email protected]>
---
sched/sched/sched_get_stateinfo.c | 55 ++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 29 deletions(-)
diff --git a/sched/sched/sched_get_stateinfo.c
b/sched/sched/sched_get_stateinfo.c
index 024a7afa169..dde18093175 100644
--- a/sched/sched/sched_get_stateinfo.c
+++ b/sched/sched/sched_get_stateinfo.c
@@ -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;