From ea1144630dcc173e39d1df1fc11ba5a238b3c855 Mon Sep 17 00:00:00 2001 From: Juha Niskanen Date: Mon, 7 Jun 2021 15:21:19 +0300 Subject: [PATCH] sched/task/task_spawn.c: initialize variables explicitly 'pid' cannot really be used uninitialized, but Clang analyzer does not see it. Add initializer to silence it and also make debugging slightly easier. Explicitly set pid's address to NULL to fix this complaint: "Address of stack memory associated with local variable 'pid' is still referred to by the global variable 'g_spawn_parms' upon returning to the caller." No functional change. Signed-off-by: Juha Niskanen --- sched/task/task_spawn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sched/task/task_spawn.c b/sched/task/task_spawn.c index 8c974c093b..d5740c1eb7 100644 --- a/sched/task/task_spawn.c +++ b/sched/task/task_spawn.c @@ -312,7 +312,7 @@ int task_spawn(FAR const char *name, main_t entry, { struct sched_param param; pid_t proxy; - pid_t pid; + pid_t pid = INVALID_PROCESS_ID; #ifdef CONFIG_SCHED_WAITPID int status; #endif @@ -374,6 +374,7 @@ int task_spawn(FAR const char *name, main_t entry, if (ret < 0) { serr("ERROR: nxsched_get_param failed: %d\n", ret); + g_spawn_parms.pid = NULL; spawn_semgive(&g_spawn_parmsem); return ret; } @@ -442,6 +443,7 @@ errout_with_lock: #ifdef CONFIG_SCHED_WAITPID sched_unlock(); #endif + g_spawn_parms.pid = NULL; spawn_semgive(&g_spawn_parmsem); return ret; }