This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 63252af054ef551da8549eba917182a71f6a480a
Author: yinshengkai <[email protected]>
AuthorDate: Fri Aug 11 10:31:03 2023 +0800

    sched: remove space in task name
    
    Signed-off-by: yinshengkai <[email protected]>
---
 sched/init/nx_start.c   |  4 ++--
 sched/task/task_setup.c | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index d4bc7f1bc4..f912e57c48 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -278,9 +278,9 @@ static struct task_tcb_s g_idletcb[CONFIG_SMP_NCPUS];
 
 #if CONFIG_TASK_NAME_SIZE <= 0 || !defined(CONFIG_SMP)
 #  ifdef CONFIG_SMP
-static const char g_idlename[] = "CPU Idle";
+static const char g_idlename[] = "CPU_Idle";
 #  else
-static const char g_idlename[] = "Idle Task";
+static const char g_idlename[] = "Idle_Task";
 #  endif
 #endif
 
diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c
index 157d0def9d..3adf7df257 100644
--- a/sched/task/task_setup.c
+++ b/sched/task/task_setup.c
@@ -25,6 +25,7 @@
 #include <nuttx/config.h>
 
 #include <sys/types.h>
+#include <ctype.h>
 #include <stdint.h>
 #include <sched.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,
                               FAR const char *name)
 {
+  FAR char *dst = tcb->cmn.name;
+  int i;
+
   /* 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
 #  define nxtask_setup_name(t,n)

Reply via email to