diff --git a/MISRA.md b/MISRA.md index 33e966817..72103a0dc 100644 --- a/MISRA.md +++ b/MISRA.md @@ -24,14 +24,15 @@ MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an object or function with external linkage is defined. _Ref 8.4.1_ - -- This rule requires that a compatible declaration is made available - in a header file when an object with external linkage is defined. - pxCurrentTCB(s) is defined with external linkage but it is only - referenced from the assembly code in the port files. Therefore, adding - a declaration in header file is not useful as the assembly code will - still need to declare it separately. - + - pxCurrentTCB(s) is defined with external linkage but it is only referenced + from the assembly code in the port files. Therefore, adding a declaration in + header file is not useful as the assembly code will still need to declare it + separately. + +_Ref 8.4.2_ + - xQueueRegistry is defined with external linkage because it is accessed by the + kernel unit tests. It is not meant to be directly accessed by the application + and therefore, not declared in a header file. #### Rule 11.3 diff --git a/queue.c b/queue.c index 1aabc9f31..a6fe52eac 100644 --- a/queue.c +++ b/queue.c @@ -165,6 +165,10 @@ typedef xQUEUE Queue_t; /* The queue registry is simply an array of QueueRegistryItem_t structures. * The pcQueueName member of a structure being NULL is indicative of the * array position being vacant. */ + +/* MISRA Ref 8.4.2 [Declaration shall be visible] */ +/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-84 */ +/* coverity[misra_c_2012_rule_8_4_violation] */ PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; #endif /* configQUEUE_REGISTRY_SIZE */ diff --git a/tasks.c b/tasks.c index f5d031227..697be9c99 100644 --- a/tasks.c +++ b/tasks.c @@ -436,6 +436,9 @@ typedef tskTCB TCB_t; /*lint -save -e956 A manual analysis and inspection has been used to determine * which static variables must be declared volatile. */ #if ( configNUMBER_OF_CORES == 1 ) + /* MISRA Ref 8.4.1 [Declaration shall be visible] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-84 */ + /* coverity[misra_c_2012_rule_8_4_violation] */ portDONT_DISCARD PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL; #else /* MISRA Ref 8.4.1 [Declaration shall be visible] */ @@ -490,7 +493,7 @@ PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandles[ configNUMBER_OF_CORES ]; /* Improve support for OpenOCD. The kernel tracks Ready tasks via priority lists. * For tracking the state of remote threads, OpenOCD uses uxTopUsedPriority * to determine the number of priority lists to read back from the remote target. */ -const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U; +static const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U; /* Context switches are held pending while the scheduler is suspended. Also, * interrupts must not manipulate the xStateListItem of a TCB, or any of the