sched: remove space in task name

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2023-08-11 10:31:03 +08:00 committed by Xiang Xiao
parent 84799d15ac
commit 63252af054
2 changed files with 19 additions and 3 deletions

View File

@ -278,9 +278,9 @@ static struct task_tcb_s g_idletcb[CONFIG_SMP_NCPUS];
#if CONFIG_TASK_NAME_SIZE <= 0 || !defined(CONFIG_SMP) #if CONFIG_TASK_NAME_SIZE <= 0 || !defined(CONFIG_SMP)
# ifdef CONFIG_SMP # ifdef CONFIG_SMP
static const char g_idlename[] = "CPU Idle"; static const char g_idlename[] = "CPU_Idle";
# else # else
static const char g_idlename[] = "Idle Task"; static const char g_idlename[] = "Idle_Task";
# endif # endif
#endif #endif

View File

@ -25,6 +25,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h>
#include <stdint.h> #include <stdint.h>
#include <sched.h> #include <sched.h>
#include <string.h> #include <string.h>
@ -484,9 +485,24 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, int priority,
static void nxtask_setup_name(FAR struct task_tcb_s *tcb, static void nxtask_setup_name(FAR struct task_tcb_s *tcb,
FAR const char *name) FAR const char *name)
{ {
FAR char *dst = tcb->cmn.name;
int i;
/* Copy the name into the TCB */ /* Copy the name into the TCB */
strlcpy(tcb->cmn.name, name, sizeof(tcb->cmn.name)); for (i = 0; i < CONFIG_TASK_NAME_SIZE; i++)
{
char c = *name++;
if (c == '\0')
{
break;
}
*dst++ = isspace(c) ? '_' : c;
}
*dst = '\0';
} }
#else #else
# define nxtask_setup_name(t,n) # define nxtask_setup_name(t,n)