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 d2b87c7189a16ba1b3128e4364f632acf7c249c7 Author: fangxinyong <[email protected]> AuthorDate: Fri Aug 15 10:06:44 2025 +0800 task_getpid.c:coverity HIS_metric_violation: RETURN Use a local ret variable and return once at the end. This keeps the IDLE_PROCESS_ID fallback behavior unchanged. Addresses Coverity HIS_metric_violation: RETURN. Signed-off-by: fangxinyong <[email protected]> --- sched/task/task_getpid.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sched/task/task_getpid.c b/sched/task/task_getpid.c index 0cf46d8ac21..4bf57a5f5c9 100644 --- a/sched/task/task_getpid.c +++ b/sched/task/task_getpid.c @@ -56,6 +56,7 @@ pid_t nxsched_getpid(void) { FAR struct tcb_s *rtcb; + pid_t ret = IDLE_PROCESS_ID; /* Get the TCB at the head of the ready-to-run task list. That * will usually be the currently executing task. There is are two @@ -71,12 +72,8 @@ pid_t nxsched_getpid(void) { /* Yes.. Return the Process ID */ - return rtcb->group->tg_pid; + ret = rtcb->group->tg_pid; } - /* We must have been called earlier in the start up sequence from the - * start-up/IDLE thread before the ready-to-run list has been initialized. - */ - - return IDLE_PROCESS_ID; + return ret; }
