From 7a9a41f3eb7ef89697f9750b1f9722127f9df8a1 Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Thu, 1 Feb 2024 14:20:07 -0800 Subject: [PATCH 01/12] Fix violations of MISRA rule 13.2 --- tasks.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 38a80e2de9..422992726a 100644 --- a/tasks.c +++ b/tasks.c @@ -3188,7 +3188,13 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, /* The scheduler is not running, but the task that was pointed * to by pxCurrentTCB has just been suspended and pxCurrentTCB * must be adjusted to point to a different task. */ - if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) + + /* Use temp variable as distinct sequence points for reading + * volatile variables prior to a comparison, per the coding guidelines */ + UBaseType_t uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); + UBaseType_T uxCurrentNumOfTasks = uxCurrentNumberOfTasks; + + if( uxCurrentListLength == uxCurrentNumOfTasks ) { /* No other tasks are ready, so set pxCurrentTCB back to * NULL so when the next task is created pxCurrentTCB will From ef23fb8fae5ecfc6807337b19341a785f4b507e1 Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Thu, 1 Feb 2024 14:31:57 -0800 Subject: [PATCH 02/12] Fix typo in UBaseType_t --- tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 422992726a..13c9fb0e13 100644 --- a/tasks.c +++ b/tasks.c @@ -3192,7 +3192,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, /* Use temp variable as distinct sequence points for reading * volatile variables prior to a comparison, per the coding guidelines */ UBaseType_t uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); - UBaseType_T uxCurrentNumOfTasks = uxCurrentNumberOfTasks; + UBaseType_t uxCurrentNumOfTasks = uxCurrentNumberOfTasks; if( uxCurrentListLength == uxCurrentNumOfTasks ) { From 19b8be39bdc10203c345f09fb76acbb449d0c9c8 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 1 Feb 2024 22:36:49 +0000 Subject: [PATCH 03/12] Uncrustify: triggered by comment. --- tasks.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks.c b/tasks.c index 13c9fb0e13..b54ccd66c8 100644 --- a/tasks.c +++ b/tasks.c @@ -3189,10 +3189,10 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, * to by pxCurrentTCB has just been suspended and pxCurrentTCB * must be adjusted to point to a different task. */ - /* Use temp variable as distinct sequence points for reading - * volatile variables prior to a comparison, per the coding guidelines */ - UBaseType_t uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); - UBaseType_t uxCurrentNumOfTasks = uxCurrentNumberOfTasks; + /* Use temp variable as distinct sequence points for reading + * volatile variables prior to a comparison, per the coding guidelines */ + UBaseType_t uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); + UBaseType_t uxCurrentNumOfTasks = uxCurrentNumberOfTasks; if( uxCurrentListLength == uxCurrentNumOfTasks ) { From 232a93cb6d9a2525085b639c24920b8a80464919 Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Thu, 1 Feb 2024 14:31:57 -0800 Subject: [PATCH 04/12] Run Github Actions. From 53b05de491440ab13c347dede820c783acfce6b1 Mon Sep 17 00:00:00 2001 From: bradleysmith23 <74752142+bradleysmith23@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:00:46 -0800 Subject: [PATCH 05/12] Remove temp variable for uxCurrentNumberOfTasks Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> --- tasks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasks.c b/tasks.c index 7cb68e8090..975d6703cf 100644 --- a/tasks.c +++ b/tasks.c @@ -3192,9 +3192,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, /* Use temp variable as distinct sequence points for reading * volatile variables prior to a comparison, per the coding guidelines */ UBaseType_t uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); - UBaseType_t uxCurrentNumOfTasks = uxCurrentNumberOfTasks; - if( uxCurrentListLength == uxCurrentNumOfTasks ) + if( uxCurrentListLength == uxCurrentNumberOfTasks ) { /* No other tasks are ready, so set pxCurrentTCB back to * NULL so when the next task is created pxCurrentTCB will From 52559f478bbf00dcd346c0162527526409b9c476 Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Mon, 5 Feb 2024 10:55:00 -0800 Subject: [PATCH 06/12] Declare uxCurrentListLength at top of function, update comment. --- tasks.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks.c b/tasks.c index 1487b1f8d2..4091bf75c5 100644 --- a/tasks.c +++ b/tasks.c @@ -3106,6 +3106,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, void vTaskSuspend( TaskHandle_t xTaskToSuspend ) { TCB_t * pxTCB; + UBaseType_t uxCurrentListLength; traceENTER_vTaskSuspend( xTaskToSuspend ); @@ -3190,8 +3191,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, * must be adjusted to point to a different task. */ /* Use temp variable as distinct sequence points for reading - * volatile variables prior to a comparison, per the coding guidelines */ - UBaseType_t uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); + * volatile variables prior to a comparison to ensure compliance + * with MISRA C 2012 Rule 13.2. */ + uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList ); if( uxCurrentListLength == uxCurrentNumberOfTasks ) { From 6ee152dd945dc008f7c5646acf03cd6ec5ba9d2e Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Mon, 5 Feb 2024 11:06:58 -0800 Subject: [PATCH 07/12] Update location of uxCurrentListLength Declaration --- tasks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 4091bf75c5..598f0018ed 100644 --- a/tasks.c +++ b/tasks.c @@ -3106,7 +3106,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, void vTaskSuspend( TaskHandle_t xTaskToSuspend ) { TCB_t * pxTCB; - UBaseType_t uxCurrentListLength; traceENTER_vTaskSuspend( xTaskToSuspend ); @@ -3176,6 +3175,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, #if ( configNUMBER_OF_CORES == 1 ) { + UBaseType_t uxCurrentListLength; + if( pxTCB == pxCurrentTCB ) { if( xSchedulerRunning != pdFALSE ) From 0856d68e30933f829798c3de31fb6951e05fc1ce Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 5 Feb 2024 19:08:22 +0000 Subject: [PATCH 08/12] Uncrustify: triggered by comment. --- tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 598f0018ed..64b0a88c56 100644 --- a/tasks.c +++ b/tasks.c @@ -3176,7 +3176,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, #if ( configNUMBER_OF_CORES == 1 ) { UBaseType_t uxCurrentListLength; - + if( pxTCB == pxCurrentTCB ) { if( xSchedulerRunning != pdFALSE ) From 7bad0edb125ac39e391f5989c87b00911f4c2763 Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Mon, 5 Feb 2024 11:09:44 -0800 Subject: [PATCH 09/12] Run Github Actions From 19075e216e7f8044ffa7122f3f5ccde35c427e4b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 6 Feb 2024 22:59:04 +0000 Subject: [PATCH 10/12] Uncrustify: triggered by comment. --- tasks.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tasks.c b/tasks.c index d548155174..99f43eaeba 100644 --- a/tasks.c +++ b/tasks.c @@ -3208,7 +3208,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, #if ( configNUMBER_OF_CORES == 1 ) { - UBaseType_t uxCurrentListLength; if( xSchedulerRunning != pdFALSE ) @@ -3226,7 +3225,6 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, mtCOVERAGE_TEST_MARKER(); } - if( pxTCB == pxCurrentTCB ) { if( xSchedulerRunning != pdFALSE ) From b6f11b6b2ce4540b0c200b2476c66ae5ce3b1914 Mon Sep 17 00:00:00 2001 From: bradleysmith23 Date: Tue, 6 Feb 2024 15:00:07 -0800 Subject: [PATCH 11/12] Run Github Actions. From 2b1b1fe5dcfb4d635eae7cc9a506a169ce3b606f Mon Sep 17 00:00:00 2001 From: bradleysmith23 <74752142+bradleysmith23@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:34:02 -0800 Subject: [PATCH 12/12] Update comment explaining use of temp variable --- tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 302d2f2ef2..95f60b1fb6 100644 --- a/tasks.c +++ b/tasks.c @@ -3239,7 +3239,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, * to by pxCurrentTCB has just been suspended and pxCurrentTCB * must be adjusted to point to a different task. */ - /* Use temp variable as distinct sequence points for reading + /* Use a temp variable as a distinct sequence point for reading * volatile variables prior to a comparison to ensure compliance * with MISRA C 2012 Rule 13.2. */ uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList );