mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-10 08:07:46 -04:00
Adding SMP coverity example
This commit is contained in:
parent
c6487d9472
commit
141548b03f
7 changed files with 69 additions and 4 deletions
9
MISRA.md
9
MISRA.md
|
@ -18,6 +18,15 @@ with ( Assuming rule 8.4 violation; with justification in point 1 ):
|
||||||
grep 'MISRA Ref 8.4.1' . -rI
|
grep 'MISRA Ref 8.4.1' . -rI
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Dir 4.7
|
||||||
|
MISRA C:2012 Dir 4.7: If a function returns error information, then that error
|
||||||
|
information shall be tested.
|
||||||
|
|
||||||
|
_Ref 4.7.1_
|
||||||
|
- The return value of `taskENTER_CRITICAL_FROM_ISR` is the interrupt mask of the
|
||||||
|
port. Error information won't be returned by this function and no need to perform
|
||||||
|
a check on the return value.
|
||||||
|
|
||||||
#### Rule 8.4
|
#### Rule 8.4
|
||||||
|
|
||||||
MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an
|
MISRA C:2012 Rule 8.4: A compatible declaration shall be visible when an
|
||||||
|
|
|
@ -529,6 +529,9 @@
|
||||||
|
|
||||||
traceENTER_xEventGroupGetBitsFromISR( xEventGroup );
|
traceENTER_xEventGroupGetBitsFromISR( xEventGroup );
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
uxReturn = pxEventBits->uxEventBits;
|
uxReturn = pxEventBits->uxEventBits;
|
||||||
|
|
|
@ -23,6 +23,12 @@ target_include_directories(freertos_config
|
||||||
INTERFACE
|
INTERFACE
|
||||||
./)
|
./)
|
||||||
|
|
||||||
|
if (DEFINED FREERTOS_SMP_EXAMPLE AND FREERTOS_SMP_EXAMPLE STREQUAL "1")
|
||||||
|
message(STATUS "Build FreeRTOS SMP example")
|
||||||
|
# Adding the following configurations to build SMP template port
|
||||||
|
add_compile_options( -DconfigNUMBER_OF_CORES=2 -DconfigUSE_PASSIVE_IDLE_HOOK=0 )
|
||||||
|
endif()
|
||||||
|
|
||||||
# Select the heap. Values between 1-5 will pick a heap.
|
# Select the heap. Values between 1-5 will pick a heap.
|
||||||
set(FREERTOS_HEAP "3" CACHE STRING "" FORCE)
|
set(FREERTOS_HEAP "3" CACHE STRING "" FORCE)
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,14 @@ commands in a terminal:
|
||||||
cov-configure --force --compiler cc --comptype gcc
|
cov-configure --force --compiler cc --comptype gcc
|
||||||
~~~
|
~~~
|
||||||
2. Create the build files using CMake in a `build` directory:
|
2. Create the build files using CMake in a `build` directory:
|
||||||
|
Singe core FreeRTOS:
|
||||||
~~~
|
~~~
|
||||||
cmake -B build -S examples/coverity
|
cmake -B build -S examples/coverity
|
||||||
~~~
|
~~~
|
||||||
|
SMP FreeRTOS:
|
||||||
|
~~~
|
||||||
|
cmake -B build -S examples/coverity -DFREERTOS_SMP_EXAMPLE=1
|
||||||
|
~~~
|
||||||
3. Build the (pseudo) application:
|
3. Build the (pseudo) application:
|
||||||
~~~
|
~~~
|
||||||
cd build/
|
cd build/
|
||||||
|
@ -47,7 +52,7 @@ commands in a terminal:
|
||||||
~~~
|
~~~
|
||||||
cov-analyze --dir ./cov-out \
|
cov-analyze --dir ./cov-out \
|
||||||
--coding-standard-config ../examples/coverity/coverity_misra.config \
|
--coding-standard-config ../examples/coverity/coverity_misra.config \
|
||||||
--tu-pattern "file('[A-Za-z_]+\.c')"
|
--tu-pattern "file('[A-Za-z_]+\.c') && ( ! file('main.c') ) && ( ! file('port.c') )"
|
||||||
~~~
|
~~~
|
||||||
5. Generate the HTML report:
|
5. Generate the HTML report:
|
||||||
~~~
|
~~~
|
||||||
|
|
12
queue.c
12
queue.c
|
@ -1190,6 +1190,9 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
|
||||||
* read, instead return a flag to say whether a context switch is required or
|
* read, instead return a flag to say whether a context switch is required or
|
||||||
* not (i.e. has a task with a higher priority than us been woken by this
|
* not (i.e. has a task with a higher priority than us been woken by this
|
||||||
* post). */
|
* post). */
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
|
if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )
|
||||||
|
@ -1365,6 +1368,9 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
|
||||||
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
|
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
|
||||||
|
@ -2055,6 +2061,9 @@ BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
|
||||||
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
|
const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting;
|
||||||
|
@ -2153,6 +2162,9 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,
|
||||||
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
* link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
/* Cannot block in an ISR, so check there is data available. */
|
/* Cannot block in an ISR, so check there is data available. */
|
||||||
|
|
|
@ -676,6 +676,9 @@ BaseType_t xStreamBufferResetFromISR( StreamBufferHandle_t xStreamBuffer )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Can only reset a message buffer if there are no tasks blocked on it. */
|
/* Can only reset a message buffer if there are no tasks blocked on it. */
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
if( ( pxStreamBuffer->xTaskWaitingToReceive == NULL ) && ( pxStreamBuffer->xTaskWaitingToSend == NULL ) )
|
if( ( pxStreamBuffer->xTaskWaitingToReceive == NULL ) && ( pxStreamBuffer->xTaskWaitingToSend == NULL ) )
|
||||||
|
@ -972,6 +975,9 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
|
||||||
/* Was a task waiting for the data? */
|
/* Was a task waiting for the data? */
|
||||||
if( prvBytesInBuffer( pxStreamBuffer ) >= pxStreamBuffer->xTriggerLevelBytes )
|
if( prvBytesInBuffer( pxStreamBuffer ) >= pxStreamBuffer->xTriggerLevelBytes )
|
||||||
{
|
{
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
prvSEND_COMPLETE_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken );
|
prvSEND_COMPLETE_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1245,6 +1251,9 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
|
||||||
/* Was a task waiting for space in the buffer? */
|
/* Was a task waiting for space in the buffer? */
|
||||||
if( xReceivedLength != ( size_t ) 0 )
|
if( xReceivedLength != ( size_t ) 0 )
|
||||||
{
|
{
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
prvRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken );
|
prvRECEIVE_COMPLETED_FROM_ISR( pxStreamBuffer, pxHigherPriorityTaskWoken );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1397,6 +1406,9 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer
|
||||||
|
|
||||||
configASSERT( pxStreamBuffer );
|
configASSERT( pxStreamBuffer );
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL )
|
if( ( pxStreamBuffer )->xTaskWaitingToReceive != NULL )
|
||||||
|
@ -1433,6 +1445,9 @@ BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuf
|
||||||
|
|
||||||
configASSERT( pxStreamBuffer );
|
configASSERT( pxStreamBuffer );
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL )
|
if( ( pxStreamBuffer )->xTaskWaitingToSend != NULL )
|
||||||
|
|
21
tasks.c
21
tasks.c
|
@ -881,7 +881,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
||||||
configASSERT( portGET_CRITICAL_NESTING_COUNT() > 0U );
|
configASSERT( portGET_CRITICAL_NESTING_COUNT() > 0U );
|
||||||
|
|
||||||
#if ( configRUN_MULTIPLE_PRIORITIES == 0 )
|
#if ( configRUN_MULTIPLE_PRIORITIES == 0 )
|
||||||
|
|
||||||
/* No task should yield for this one if it is a lower priority
|
/* No task should yield for this one if it is a lower priority
|
||||||
* than priority level of currently ready tasks. */
|
* than priority level of currently ready tasks. */
|
||||||
if( pxTCB->uxPriority >= uxTopReadyPriority )
|
if( pxTCB->uxPriority >= uxTopReadyPriority )
|
||||||
|
@ -2666,6 +2665,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
/* If null is passed in here then it is the priority of the calling
|
/* If null is passed in here then it is the priority of the calling
|
||||||
|
@ -2737,6 +2739,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
/* If null is passed in here then it is the base priority of the calling
|
/* If null is passed in here then it is the base priority of the calling
|
||||||
|
@ -3354,12 +3359,10 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
configASSERT( xTaskToResume );
|
configASSERT( xTaskToResume );
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
|
|
||||||
/* The parameter cannot be NULL as it is impossible to resume the
|
/* The parameter cannot be NULL as it is impossible to resume the
|
||||||
* currently executing task. */
|
* currently executing task. */
|
||||||
if( ( pxTCB != pxCurrentTCB ) && ( pxTCB != NULL ) )
|
if( ( pxTCB != pxCurrentTCB ) && ( pxTCB != NULL ) )
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* The parameter cannot be NULL as it is impossible to resume the
|
/* The parameter cannot be NULL as it is impossible to resume the
|
||||||
* currently executing task. It is also impossible to resume a task
|
* currently executing task. It is also impossible to resume a task
|
||||||
* that is actively running on another core but it is not safe
|
* that is actively running on another core but it is not safe
|
||||||
|
@ -3433,6 +3436,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
if( prvTaskIsTaskSuspended( pxTCB ) != pdFALSE )
|
if( prvTaskIsTaskSuspended( pxTCB ) != pdFALSE )
|
||||||
|
@ -4989,6 +4995,9 @@ BaseType_t xTaskIncrementTick( void )
|
||||||
|
|
||||||
/* Save the hook function in the TCB. A critical section is required as
|
/* Save the hook function in the TCB. A critical section is required as
|
||||||
* the value can be accessed from an interrupt. */
|
* the value can be accessed from an interrupt. */
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
xReturn = pxTCB->pxTaskTag;
|
xReturn = pxTCB->pxTaskTag;
|
||||||
|
@ -7974,6 +7983,9 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
|
|
||||||
pxTCB = xTaskToNotify;
|
pxTCB = xTaskToNotify;
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
if( pulPreviousNotificationValue != NULL )
|
if( pulPreviousNotificationValue != NULL )
|
||||||
|
@ -8133,6 +8145,9 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
|
|
||||||
pxTCB = xTaskToNotify;
|
pxTCB = xTaskToNotify;
|
||||||
|
|
||||||
|
/* MISRA Ref 4.7.1 [Return value shall be checked] */
|
||||||
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
|
||||||
|
/* coverity[misra_c_2012_directive_4_7_violation] */
|
||||||
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
|
||||||
{
|
{
|
||||||
ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ];
|
ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue