From 73851fb6da6fdc639824246638e5347d25844d10 Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:30:29 +0530 Subject: [PATCH 1/3] Remove unwanted volatile keyword (#1028) * Remove unwanted volatile keyword * Declare variable initially --- tasks.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks.c b/tasks.c index e0db3f9e7..b02616026 100644 --- a/tasks.c +++ b/tasks.c @@ -985,6 +985,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION; UBaseType_t uxCurrentPriority = uxTopReadyPriority; BaseType_t xTaskScheduled = pdFALSE; BaseType_t xDecrementTopPriority = pdTRUE; + TCB_t * pxTCB = NULL; #if ( configUSE_CORE_AFFINITY == 1 ) const TCB_t * pxPreviousTCB = NULL; @@ -1043,7 +1044,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION; /* MISRA Ref 11.5.3 [Void pointer assignment] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */ /* coverity[misra_c_2012_rule_11_5_violation] */ - TCB_t * pxTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); + pxTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); #if ( configRUN_MULTIPLE_PRIORITIES == 0 ) { @@ -4181,6 +4182,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) const char pcNameToQuery[] ) { TCB_t * pxReturn = NULL; + TCB_t * pxTCB = NULL; UBaseType_t x; char cNextChar; BaseType_t xBreakLoop; @@ -4196,7 +4198,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /* MISRA Ref 11.5.3 [Void pointer assignment] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */ /* coverity[misra_c_2012_rule_11_5_violation] */ - TCB_t * pxTCB = listGET_LIST_ITEM_OWNER( pxIterator ); + pxTCB = listGET_LIST_ITEM_OWNER( pxIterator ); /* Check each character in the name looking for a match or * mismatch. */ @@ -6255,10 +6257,10 @@ static void prvCheckTasksWaitingTermination( void ) List_t * pxList, eTaskState eState ) { - configLIST_VOLATILE TCB_t * pxTCB; UBaseType_t uxTask = 0; const ListItem_t * pxEndMarker = listGET_END_MARKER( pxList ); ListItem_t * pxIterator; + TCB_t * pxTCB = NULL; if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 ) { From 4d4f8d0d50bedc37e1d07c96aded7d2bc20f0d6c Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:12:03 +0800 Subject: [PATCH 2/3] Fix vTaskSuspendAll assert for critical nesting count (#1029) * Accessing the critical nesting count in current task's TCB is performed with interrupt disabled to ensure atomicity. --- tasks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks.c b/tasks.c index b02616026..5cec846d0 100644 --- a/tasks.c +++ b/tasks.c @@ -3831,9 +3831,6 @@ void vTaskSuspendAll( void ) if( xSchedulerRunning != pdFALSE ) { - /* This must never be called from inside a critical section. */ - configASSERT( portGET_CRITICAL_NESTING_COUNT() == 0 ); - /* Writes to uxSchedulerSuspended must be protected by both the task AND ISR locks. * We must disable interrupts before we grab the locks in the event that this task is * interrupted and switches context before incrementing uxSchedulerSuspended. @@ -3841,6 +3838,9 @@ void vTaskSuspendAll( void ) * uxSchedulerSuspended since that will prevent context switches. */ ulState = portSET_INTERRUPT_MASK(); + /* This must never be called from inside a critical section. */ + configASSERT( portGET_CRITICAL_NESTING_COUNT() == 0 ); + /* portSOFRWARE_BARRIER() is only implemented for emulated/simulated ports that * do not otherwise exhibit real time behaviour. */ portSOFTWARE_BARRIER(); From 6de0d7a73703e225637ee19030ed981624b1bc49 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Mon, 15 Apr 2024 00:40:10 -0400 Subject: [PATCH 3/3] Fix the pxTopcOfStack typo in the RISC-V ports. (#1030) * Fix the pxTopcOfStack typo in the RISC-V ports. * Add a missing o to to --- portable/GCC/RISC-V/portASM.S | 4 ++-- portable/IAR/RISC-V/portASM.s | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/portable/GCC/RISC-V/portASM.S b/portable/GCC/RISC-V/portASM.S index 12637b06f..b5f054777 100644 --- a/portable/GCC/RISC-V/portASM.S +++ b/portable/GCC/RISC-V/portASM.S @@ -138,7 +138,7 @@ definitions. */ * for the function is as per the other ports: * StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ); * - * As per the standard RISC-V ABI pxTopcOfStack is passed in in a0, pxCode in + * As per the standard RISC-V ABI pxTopOfStack is passed in in a0, pxCode in * a1, and pvParameters in a2. The new top of stack is passed out in a0. * * RISC-V maps registers to ABI names as follows (X1 to X31 integer registers @@ -158,7 +158,7 @@ definitions. */ * x18-27 s2-11 Saved registers Callee * x28-31 t3-6 Temporaries Caller * - * The RISC-V context is saved t FreeRTOS tasks in the following stack frame, + * The RISC-V context is saved to FreeRTOS tasks in the following stack frame, * where the global and thread pointers are currently assumed to be constant so * are not saved: * diff --git a/portable/IAR/RISC-V/portASM.s b/portable/IAR/RISC-V/portASM.s index f32d9e7ac..12a2a6154 100644 --- a/portable/IAR/RISC-V/portASM.s +++ b/portable/IAR/RISC-V/portASM.s @@ -147,7 +147,7 @@ portUPDATE_MTIMER_COMPARE_REGISTER MACRO * for the function is as per the other ports: * StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ); * - * As per the standard RISC-V ABI pxTopcOfStack is passed in in a0, pxCode in + * As per the standard RISC-V ABI pxTopOfStack is passed in in a0, pxCode in * a1, and pvParameters in a2. The new top of stack is passed out in a0. * * RISC-V maps registers to ABI names as follows (X1 to X31 integer registers @@ -167,7 +167,7 @@ portUPDATE_MTIMER_COMPARE_REGISTER MACRO * x18-27 s2-11 Saved registers Callee * x28-31 t3-6 Temporaries Caller * - * The RISC-V context is saved t FreeRTOS tasks in the following stack frame, + * The RISC-V context is saved to FreeRTOS tasks in the following stack frame, * where the global and thread pointers are currently assumed to be constant so * are not saved: *