From 8fa26944f7e62d1ad82a7e4460ed6cd7e4c70475 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 6 Mar 2022 19:58:44 +0800 Subject: [PATCH] sched/init: Fix the compiler warning /github/workspace/sources/nuttx/include/nuttx/init.h: In function 'nx_start': Error: init/nx_start.c:439:7: error: 'strncpy' output truncated copying 8 bytes from a string of length 9 [-Werror=stringop-truncation] 439 | strncpy(g_idletcb[i].cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Xiang Xiao --- sched/init/nx_start.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 60d580fc8b..c9e7c454f5 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -436,8 +436,7 @@ void nx_start(void) snprintf(g_idletcb[i].cmn.name, CONFIG_TASK_NAME_SIZE, "CPU%d IDLE", i); # else - strncpy(g_idletcb[i].cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE); - g_idletcb[i].cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; + strlcpy(g_idletcb[i].cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE); # endif /* Configure the task name in the argument list. The IDLE task does