|
29 | 29 | /* Standard includes. */ |
30 | 30 | #include <stdlib.h> |
31 | 31 | #include <string.h> |
| 32 | +#include <stdio.h> |
32 | 33 |
|
33 | 34 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining |
34 | 35 | * all the API functions to use the MPU wrappers. That should only be done when |
@@ -3521,26 +3522,12 @@ static BaseType_t prvCreateIdleTasks( void ) |
3521 | 3522 | { |
3522 | 3523 | BaseType_t xReturn = pdPASS; |
3523 | 3524 | BaseType_t xCoreID; |
3524 | | - char cIdleName[ configMAX_TASK_NAME_LEN ]; |
| 3525 | + char cIdleName[ configMAX_TASK_NAME_LEN ] = { 0 }; |
3525 | 3526 | TaskFunction_t pxIdleTaskFunction = NULL; |
3526 | | - BaseType_t xIdleTaskNameIndex; |
3527 | 3527 |
|
3528 | | - for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < ( BaseType_t ) configMAX_TASK_NAME_LEN; xIdleTaskNameIndex++ ) |
3529 | | - { |
3530 | | - cIdleName[ xIdleTaskNameIndex ] = configIDLE_TASK_NAME[ xIdleTaskNameIndex ]; |
3531 | | - |
3532 | | - /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than |
3533 | | - * configMAX_TASK_NAME_LEN characters just in case the memory after the |
3534 | | - * string is not accessible (extremely unlikely). */ |
3535 | | - if( cIdleName[ xIdleTaskNameIndex ] == ( char ) 0x00 ) |
3536 | | - { |
3537 | | - break; |
3538 | | - } |
3539 | | - else |
3540 | | - { |
3541 | | - mtCOVERAGE_TEST_MARKER(); |
3542 | | - } |
3543 | | - } |
| 3528 | + /* Copy the name of the idle task up to configMAX_TASK_NAME_LEN - 1 characters, leaving room for the null-terminator */ |
| 3529 | + strncpy( cIdleName, configIDLE_TASK_NAME, configMAX_TASK_NAME_LEN - 1 ); |
| 3530 | + cIdleName[ configMAX_TASK_NAME_LEN - 1 ] = '\0'; |
3544 | 3531 |
|
3545 | 3532 | /* Add each idle task at the lowest priority. */ |
3546 | 3533 | for( xCoreID = ( BaseType_t ) 0; xCoreID < ( BaseType_t ) configNUMBER_OF_CORES; xCoreID++ ) |
@@ -3570,20 +3557,20 @@ static BaseType_t prvCreateIdleTasks( void ) |
3570 | 3557 | * only one idle task. */ |
3571 | 3558 | #if ( configNUMBER_OF_CORES > 1 ) |
3572 | 3559 | { |
| 3560 | + size_t uxIdleNameLength; |
| 3561 | + size_t uxCoreIDStrLength; |
| 3562 | + char cCoreIDStr[ 11 ]; |
| 3563 | + |
| 3564 | + uxIdleNameLength = strlen( cIdleName ); |
| 3565 | + |
| 3566 | + /* Convert the core ID to a string. */ |
| 3567 | + snprintf( cCoreIDStr, sizeof( cCoreIDStr ), "%u", ( unsigned int ) xCoreID ); |
| 3568 | + uxCoreIDStrLength = strlen( cCoreIDStr ); |
| 3569 | + |
3573 | 3570 | /* Append the idle task number to the end of the name if there is space. */ |
3574 | | - if( xIdleTaskNameIndex < ( BaseType_t ) configMAX_TASK_NAME_LEN ) |
| 3571 | + if( uxIdleNameLength + uxCoreIDStrLength < ( BaseType_t ) configMAX_TASK_NAME_LEN ) |
3575 | 3572 | { |
3576 | | - cIdleName[ xIdleTaskNameIndex ] = ( char ) ( xCoreID + '0' ); |
3577 | | - |
3578 | | - /* And append a null character if there is space. */ |
3579 | | - if( ( xIdleTaskNameIndex + 1 ) < ( BaseType_t ) configMAX_TASK_NAME_LEN ) |
3580 | | - { |
3581 | | - cIdleName[ xIdleTaskNameIndex + 1 ] = '\0'; |
3582 | | - } |
3583 | | - else |
3584 | | - { |
3585 | | - mtCOVERAGE_TEST_MARKER(); |
3586 | | - } |
| 3573 | + strncat( cIdleName, cCoreIDStr, configMAX_TASK_NAME_LEN - uxIdleNameLength - 1 ); |
3587 | 3574 | } |
3588 | 3575 | else |
3589 | 3576 | { |
|
0 commit comments