mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Remove reliance on strncpy() function.
This commit is contained in:
parent
a7c47131fa
commit
f11635ed91
|
@ -2249,14 +2249,25 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
|
||||||
|
|
||||||
static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth )
|
static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth )
|
||||||
{
|
{
|
||||||
/* Store the function name in the TCB. */
|
portBASE_TYPE x;
|
||||||
#if configMAX_TASK_NAME_LEN > 1
|
|
||||||
|
/* Store the task name in the TCB. */
|
||||||
|
for( x = 0; x < configMAX_TASK_NAME_LEN; x++ )
|
||||||
{
|
{
|
||||||
/* Don't bring strncpy into the build unnecessarily. */
|
pxTCB->pcTaskName[ x ] = pcName[ x ];
|
||||||
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );
|
|
||||||
|
/* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than
|
||||||
|
configMAX_TASK_NAME_LEN characters just in case the memory after the
|
||||||
|
string is not accessible (extremely unlikely). */
|
||||||
|
if( pcName[ x ] == 0x00 )
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif /* configMAX_TASK_NAME_LEN */
|
}
|
||||||
pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = ( signed char ) '\0';
|
|
||||||
|
/* Ensure the name string is terminated in the case that the string length
|
||||||
|
was greater or equal to configMAX_TASK_NAME_LEN. */
|
||||||
|
pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = ( signed char ) '\0';
|
||||||
|
|
||||||
/* This is used as an array index so must ensure it's not too large. First
|
/* This is used as an array index so must ensure it's not too large. First
|
||||||
remove the privilege bit if one is present. */
|
remove the privilege bit if one is present. */
|
||||||
|
|
Loading…
Reference in a new issue