Skip to content

Commit

Permalink
Update nasa#199, limit kernel name length
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Oct 28, 2020
1 parent 5ae12c4 commit 99740d1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fsw/pc-linux/src/cfe_psp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
#define CFE_PSP_CPU_NAME_LENGTH 32
#define CFE_PSP_RESET_NAME_LENGTH 10

/*
* Limits for task name length in kernel (fixed by Linux/glibc)
* For reference see manpage for "pthread_setname_np".
*/
#define CFE_PSP_KERNEL_NAME_LENGTH_MAX 16

/*
** Typedefs for this module
*/
Expand Down Expand Up @@ -170,6 +176,16 @@ int32 CFE_PSP_OS_EventHandler(OS_Event_t event, osal_id_t object_id, void *data)
/* Get the name from OSAL and propagate to the pthread/system layer */
if (OS_GetResourceName(object_id, taskname, sizeof(taskname)) == OS_SUCCESS)
{
/*
* glibc/kernel has an internal limit for this name.
* If the OSAL name is longer, just truncate it.
* Otherwise the name isn't set at all - this assumes the first
* chars of the name is better for debug than none of it.
*/
if (strlen(taskname) >= CFE_PSP_KERNEL_NAME_LENGTH_MAX)
{
taskname[CFE_PSP_KERNEL_NAME_LENGTH_MAX-1] = 0;
}
pthread_setname_np(pthread_self(), taskname);
}
break;
Expand Down

0 comments on commit 99740d1

Please sign in to comment.