mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
sched/irq: Fix MISRA C-2012 Rule 8.9 - declare objects in block scope
This patch fixes a Coverity issue where static objects that are only referenced within a single function should be declared in block scope rather than file scope. This improves code encapsulation and reduces global namespace pollution. Changes: - Moved 'g_irqchainpool[]' from file-level static variable to function-level static variable within irqchain_initialize() This ensures compliance with MISRA C-2012 Rule 8.9 which states: 'An object should be declared in block scope if its identifier is only referenced within one function.' The change improves code clarity, maintainability, and follows best practices for variable scoping. Benefits: - Reduces file-level namespace pollution - Improves code encapsulation - Makes the scope of the variable immediately obvious - Maintains static storage duration for the array Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
This commit is contained in:
@@ -46,12 +46,6 @@ struct irqchain_s
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* g_irqchainpool is a list of pre-allocated irq chain. The number of irq
|
|
||||||
* chains in the pool is a configuration item.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static struct irqchain_s g_irqchainpool[CONFIG_PREALLOC_IRQCHAIN];
|
|
||||||
|
|
||||||
/* The g_irqchainfreelist data structure is a single linked list of irqchains
|
/* The g_irqchainfreelist data structure is a single linked list of irqchains
|
||||||
* available to the system for delayed function use.
|
* available to the system for delayed function use.
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +103,13 @@ static int irqchain_dispatch(int irq, FAR void *context, FAR void *arg)
|
|||||||
|
|
||||||
void irqchain_initialize(void)
|
void irqchain_initialize(void)
|
||||||
{
|
{
|
||||||
FAR struct irqchain_s *irqchain = g_irqchainpool;
|
/* irqchainpool is a list of pre-allocated irq chain. The number of irq
|
||||||
|
* chains in the pool is a configuration item.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static struct irqchain_s irqchainpool[CONFIG_PREALLOC_IRQCHAIN];
|
||||||
|
|
||||||
|
FAR struct irqchain_s *irqchain = irqchainpool;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Initialize irqchain free lists */
|
/* Initialize irqchain free lists */
|
||||||
|
|||||||
Reference in New Issue
Block a user