Skip to content

Commit 8cfa715

Browse files
bradleysmith23actions-userchinglee-iotkar-rahul-aws
authored
Fix MISRA C 2012 Rule 13.2 Violations (#979)
* Fix violations of MISRA rule 13.2 * Fix typo in UBaseType_t * Uncrustify: triggered by comment. * Run Github Actions. * Remove temp variable for uxCurrentNumberOfTasks Co-authored-by: chinglee-iot <[email protected]> * Declare uxCurrentListLength at top of function, update comment. * Update location of uxCurrentListLength Declaration * Uncrustify: triggered by comment. * Run Github Actions * Uncrustify: triggered by comment. * Run Github Actions. * Update comment explaining use of temp variable --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: chinglee-iot <[email protected]> Co-authored-by: Rahul Kar <[email protected]>
1 parent bd65223 commit 8cfa715

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tasks.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3208,6 +3208,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
32083208

32093209
#if ( configNUMBER_OF_CORES == 1 )
32103210
{
3211+
UBaseType_t uxCurrentListLength;
3212+
32113213
if( xSchedulerRunning != pdFALSE )
32123214
{
32133215
/* Reset the next expected unblock time in case it referred to the
@@ -3236,7 +3238,13 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
32363238
/* The scheduler is not running, but the task that was pointed
32373239
* to by pxCurrentTCB has just been suspended and pxCurrentTCB
32383240
* must be adjusted to point to a different task. */
3239-
if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks )
3241+
3242+
/* Use a temp variable as a distinct sequence point for reading
3243+
* volatile variables prior to a comparison to ensure compliance
3244+
* with MISRA C 2012 Rule 13.2. */
3245+
uxCurrentListLength = listCURRENT_LIST_LENGTH( &xSuspendedTaskList );
3246+
3247+
if( uxCurrentListLength == uxCurrentNumberOfTasks )
32403248
{
32413249
/* No other tasks are ready, so set pxCurrentTCB back to
32423250
* NULL so when the next task is created pxCurrentTCB will

0 commit comments

Comments
 (0)