Simplify prvInitialiseNewTask() (#417)

Memset newly allocated TCB structures to zero, and remove code
that set individual structure members to zero.
diff --git a/tasks.c b/tasks.c
index 1d997d5..5702e4e 100644
--- a/tasks.c
+++ b/tasks.c
@@ -602,6 +602,7 @@
             /* The memory used for the task's TCB and stack are passed into this

              * function - use them. */

             pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */

+            memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) );

             pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer;

 

             #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */

@@ -643,6 +644,7 @@
              * on the implementation of the port malloc function and whether or

              * not static allocation is being used. */

             pxNewTCB = ( TCB_t * ) pxTaskDefinition->pxTaskBuffer;

+            memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) );

 

             /* Store the stack location in the TCB. */

             pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer;

@@ -692,6 +694,8 @@
 

             if( pxNewTCB != NULL )

             {

+                memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) );

+

                 /* Store the stack location in the TCB. */

                 pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer;

 

@@ -747,6 +751,8 @@
 

                 if( pxNewTCB != NULL )

                 {

+                    memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) );

+

                     /* Allocate space for the stack used by the task being created.

                      * The base of the stack memory stored in the TCB so the task can

                      * be deleted later if required. */

@@ -774,6 +780,8 @@
 

                     if( pxNewTCB != NULL )

                     {

+                        memset( ( void * ) pxNewTCB, 0x00, sizeof( TCB_t ) );

+

                         /* Store the stack location in the TCB. */

                         pxNewTCB->pxStack = pxStack;

                     }

@@ -910,9 +918,7 @@
     }

     else

     {

-        /* The task has not been given a name, so just ensure there is a NULL

-         * terminator when it is read out. */

-        pxNewTCB->pcTaskName[ 0 ] = 0x00;

+        mtCOVERAGE_TEST_MARKER();

     }

 

     /* This is used as an array index so must ensure it's not too large. */

@@ -931,7 +937,6 @@
     #if ( configUSE_MUTEXES == 1 )

         {

             pxNewTCB->uxBasePriority = uxPriority;

-            pxNewTCB->uxMutexesHeld = 0;

         }

     #endif /* configUSE_MUTEXES */

 

@@ -946,24 +951,6 @@
     listSET_LIST_ITEM_VALUE( &( pxNewTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */

     listSET_LIST_ITEM_OWNER( &( pxNewTCB->xEventListItem ), pxNewTCB );

 

-    #if ( portCRITICAL_NESTING_IN_TCB == 1 )

-        {

-            pxNewTCB->uxCriticalNesting = ( UBaseType_t ) 0U;

-        }

-    #endif /* portCRITICAL_NESTING_IN_TCB */

-

-    #if ( configUSE_APPLICATION_TASK_TAG == 1 )

-        {

-            pxNewTCB->pxTaskTag = NULL;

-        }

-    #endif /* configUSE_APPLICATION_TASK_TAG */

-

-    #if ( configGENERATE_RUN_TIME_STATS == 1 )

-        {

-            pxNewTCB->ulRunTimeCounter = ( configRUN_TIME_COUNTER_TYPE ) 0;

-        }

-    #endif /* configGENERATE_RUN_TIME_STATS */

-

     #if ( portUSING_MPU_WRAPPERS == 1 )

         {

             vPortStoreTaskMPUSettings( &( pxNewTCB->xMPUSettings ), xRegions, pxNewTCB->pxStack, ulStackDepth );

@@ -975,19 +962,6 @@
         }

     #endif

 

-    #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )

-        {

-            memset( ( void * ) &( pxNewTCB->pvThreadLocalStoragePointers[ 0 ] ), 0x00, sizeof( pxNewTCB->pvThreadLocalStoragePointers ) );

-        }

-    #endif

-

-    #if ( configUSE_TASK_NOTIFICATIONS == 1 )

-        {

-            memset( ( void * ) &( pxNewTCB->ulNotifiedValue[ 0 ] ), 0x00, sizeof( pxNewTCB->ulNotifiedValue ) );

-            memset( ( void * ) &( pxNewTCB->ucNotifyState[ 0 ] ), 0x00, sizeof( pxNewTCB->ucNotifyState ) );

-        }

-    #endif

-

     #if ( configUSE_NEWLIB_REENTRANT == 1 )

         {

             /* Initialise this task's Newlib reent structure.

@@ -997,12 +971,6 @@
         }

     #endif

 

-    #if ( INCLUDE_xTaskAbortDelay == 1 )

-        {

-            pxNewTCB->ucDelayAborted = pdFALSE;

-        }

-    #endif

-

     /* Initialize the TCB stack to look as if the task was already running,

      * but had been interrupted by the scheduler.  The return address is set

      * to the start of the task function. Once the stack has been initialised

@@ -1122,10 +1090,6 @@
             {

                 /* Add a counter into the TCB for tracing only. */

                 pxNewTCB->uxTCBNumber = uxTaskNumber;

-

-                /* Initialize the uxTaskNumber member to zero. It is utilized by the

-                 * application using vTaskSetTaskNumber and uxTaskGetTaskNumber APIs. */

-                pxNewTCB->uxTaskNumber = 0;

             }

         #endif /* configUSE_TRACE_FACILITY */

         traceTASK_CREATE( pxNewTCB );