From 0e949a36ee104b8ace10eedaa1fcd83a00e3265a Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Wed, 29 May 2019 21:58:18 -0400 Subject: [PATCH] task_stack_info increase task_name length to match NuttX CONFIG_TASK_NAME_SIZE --- msg/task_stack_info.msg | 4 +--- src/modules/load_mon/load_mon.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/msg/task_stack_info.msg b/msg/task_stack_info.msg index 7ec7a3191a..c142a9a752 100644 --- a/msg/task_stack_info.msg +++ b/msg/task_stack_info.msg @@ -2,7 +2,5 @@ uint64 timestamp # time since system start (microseconds) -uint8 MAX_REPORT_TASK_NAME_LEN = 16 - uint16 stack_free -char[16] task_name +char[24] task_name diff --git a/src/modules/load_mon/load_mon.cpp b/src/modules/load_mon/load_mon.cpp index e561927f53..7781ffc71f 100644 --- a/src/modules/load_mon/load_mon.cpp +++ b/src/modules/load_mon/load_mon.cpp @@ -247,12 +247,14 @@ void LoadMon::_stack_usage() task_stack_info_s task_stack_info = {}; - if (system_load.tasks[task_index].valid && system_load.tasks[task_index].tcb->pid > 0) { + if (system_load.tasks[task_index].valid && (system_load.tasks[task_index].tcb->pid > 0)) { stack_free = up_check_tcbstack_remain(system_load.tasks[task_index].tcb); - strncpy((char *)task_stack_info.task_name, system_load.tasks[task_index].tcb->name, - task_stack_info_s::MAX_REPORT_TASK_NAME_LEN); + static_assert(sizeof(task_stack_info.task_name) == CONFIG_TASK_NAME_SIZE, + "task_stack_info.task_name must match NuttX CONFIG_TASK_NAME_SIZE"); + strncpy((char *)task_stack_info.task_name, system_load.tasks[task_index].tcb->name, CONFIG_TASK_NAME_SIZE - 1); + task_stack_info.task_name[CONFIG_TASK_NAME_SIZE - 1] = '\0'; #if CONFIG_NFILE_DESCRIPTORS > 0 FAR struct task_group_s *group = system_load.tasks[task_index].tcb->group; @@ -269,7 +271,7 @@ void LoadMon::_stack_usage() fds_free = CONFIG_NFILE_DESCRIPTORS - tcb_num_used_fds; } -#endif +#endif // CONFIG_NFILE_DESCRIPTORS checked_task = true; }