From 3d2ffed8ae1117e2faf98e515d1e3b8ad1b96d83 Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Tue, 13 Dec 2022 09:26:28 +0800 Subject: [PATCH] Revert "pthread: Change the default name from to <0xyyyyyyyy>" This reverts commit 092d23b25db6d83a850a8d3b57f2d54201bff898. Signed-off-by: zhangyuan21 --- sched/pthread/pthread_create.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 648a852938..cd9868a671 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -59,6 +58,16 @@ const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER; +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_TASK_NAME_SIZE > 0 +/* This is the name for name-less pthreads */ + +static const char g_pthreadname[] = ""; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -92,8 +101,8 @@ static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb, #if CONFIG_TASK_NAME_SIZE > 0 /* Copy the pthread name into the TCB */ - snprintf(ptcb->cmn.name, CONFIG_TASK_NAME_SIZE, - "pt-%p", ptcb->cmn.entry.pthread); + strncpy(ptcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE); + ptcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; #endif /* CONFIG_TASK_NAME_SIZE */ /* For pthreads, args are strictly pass-by-value; that actual