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 <fangxinyong@xiaomi.com>
This commit is contained in:
fangxinyong
2025-08-15 10:06:44 +08:00
committed by Xiang Xiao
parent bb8d16f422
commit d2b87c7189

View File

@@ -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;
}