|
156 | 156 | #define configIDLE_TASK_NAME "IDLE"
|
157 | 157 | #endif
|
158 | 158 |
|
| 159 | +#if ( configNUMBER_OF_CORES > 1 ) |
| 160 | + /* Reserve space for Core ID and null termination */ |
| 161 | + #if ( configMAX_TASK_NAME_LEN < 2U ) |
| 162 | + #error Minimum required task name length is 2. Please increase configMAX_TASK_NAME_LEN. |
| 163 | + #endif |
| 164 | + #define taskRESERVED_TASK_NAME_LENGTH 2U |
| 165 | + |
| 166 | +#elif ( configNUMBER_OF_CORES > 10 ) |
| 167 | + #warning Please increase taskRESERVED_TASK_NAME_LENGTH. 1 character is insufficient to store the core ID. |
| 168 | +#else |
| 169 | + /* Reserve space for null termination */ |
| 170 | + #if ( configMAX_TASK_NAME_LEN < 1U ) |
| 171 | + #error Minimum required task name length is 1. Please increase configMAX_TASK_NAME_LEN. |
| 172 | + #endif |
| 173 | + #define taskRESERVED_TASK_NAME_LENGTH 1U |
| 174 | +#endif /* if ( ( configNUMBER_OF_CORES > 1 ) */ |
| 175 | + |
159 | 176 | #if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
|
160 | 177 |
|
161 | 178 | /* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 0 then task selection is
|
@@ -3531,17 +3548,27 @@ static BaseType_t prvCreateIdleTasks( void )
|
3531 | 3548 | BaseType_t xIdleNameLen;
|
3532 | 3549 | BaseType_t xCopyLen;
|
3533 | 3550 |
|
3534 |
| - configASSERT( ( configIDLE_TASK_NAME != NULL ) && ( configMAX_TASK_NAME_LEN > 3 ) ); |
3535 |
| - |
3536 | 3551 | /* The length of the idle task name is limited to the minimum of the length
|
3537 | 3552 | * of configIDLE_TASK_NAME and configMAX_TASK_NAME_LEN - 2, keeping space
|
3538 | 3553 | * for the core ID suffix and the null-terminator. */
|
3539 | 3554 | xIdleNameLen = strlen( configIDLE_TASK_NAME );
|
3540 | 3555 | xCopyLen = xIdleNameLen < ( configMAX_TASK_NAME_LEN - 2 ) ? xIdleNameLen : ( configMAX_TASK_NAME_LEN - 2 );
|
3541 | 3556 |
|
3542 |
| - for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < xCopyLen; xIdleTaskNameIndex++ ) |
| 3557 | + for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < ( configMAX_TASK_NAME_LEN - taskRESERVED_TASK_NAME_LENGTH ); xIdleTaskNameIndex++ ) |
3543 | 3558 | {
|
3544 | 3559 | cIdleName[ xIdleTaskNameIndex ] = configIDLE_TASK_NAME[ xIdleTaskNameIndex ];
|
| 3560 | + |
| 3561 | + /* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than |
| 3562 | + * configMAX_TASK_NAME_LEN characters just in case the memory after the |
| 3563 | + * string is not accessible (extremely unlikely). */ |
| 3564 | + if( cIdleName[ xIdleTaskNameIndex ] == ( char ) 0x00 ) |
| 3565 | + { |
| 3566 | + break; |
| 3567 | + } |
| 3568 | + else |
| 3569 | + { |
| 3570 | + mtCOVERAGE_TEST_MARKER(); |
| 3571 | + } |
3545 | 3572 | }
|
3546 | 3573 |
|
3547 | 3574 | /* Ensure null termination. */
|
|
0 commit comments