mirror of
https://github.com/apache/nuttx.git
synced 2026-08-31 22:23:03 +00:00
sched_getscheduler.c: coverity HIS_metric_violation: RETURN
Refactor nxsched_get_scheduler() to consolidate multiple return statements into a single exit point by inverting the null check condition. This improves code structure and resolves Coverity HIS_metric_violation defect for better MISRA HIS standards compliance. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
a4d09a4e25
commit
effdb88710
1 changed files with 10 additions and 8 deletions
|
|
@ -71,6 +71,7 @@
|
|||
int nxsched_get_scheduler(pid_t pid)
|
||||
{
|
||||
FAR struct tcb_s *tcb;
|
||||
int ret = -ESRCH;
|
||||
int policy;
|
||||
|
||||
/* Verify that the PID corresponds to a real task */
|
||||
|
|
@ -84,17 +85,18 @@ int nxsched_get_scheduler(pid_t pid)
|
|||
tcb = nxsched_get_tcb(pid);
|
||||
}
|
||||
|
||||
if (tcb == NULL)
|
||||
if (tcb != NULL)
|
||||
{
|
||||
return -ESRCH;
|
||||
/* Return the scheduling policy from the TCB. NOTE that the user-
|
||||
* interpretable values are 1 based; the TCB values are zero-based.
|
||||
*/
|
||||
|
||||
policy = (tcb->flags & TCB_FLAG_POLICY_MASK) >> TCB_FLAG_POLICY_SHIFT;
|
||||
|
||||
ret = policy + 1;
|
||||
}
|
||||
|
||||
/* Return the scheduling policy from the TCB. NOTE that the user-
|
||||
* interpretable values are 1 based; the TCB values are zero-based.
|
||||
*/
|
||||
|
||||
policy = (tcb->flags & TCB_FLAG_POLICY_MASK) >> TCB_FLAG_POLICY_SHIFT;
|
||||
return policy + 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue