Skip to content

Commit

Permalink
sched/timer: Simplify setitimer implementation.
Browse files Browse the repository at this point in the history
This commit simplified setitmer implementation by eliminating a redundant conditional branch.

Signed-off-by: ouyangxiangzhen <[email protected]>
  • Loading branch information
Fix-Point authored and xiaoxiang781216 committed Oct 18, 2024
1 parent 541f308 commit 8ecca52
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions sched/timer/timer_setitimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
int setitimer(int which, FAR const struct itimerval *value,
FAR struct itimerval *ovalue)
{
FAR struct tcb_s *rtcb = this_task();
FAR struct tcb_s *rtcb;
struct itimerspec spec;
struct itimerspec ospec;
irqstate_t flags;
Expand All @@ -101,20 +101,20 @@ int setitimer(int which, FAR const struct itimerval *value,
return ERROR;
}

rtcb = this_task();

flags = enter_critical_section();

if (!rtcb->group->itimer)
{
flags = enter_critical_section();
if (!rtcb->group->itimer)
{
ret = timer_create(CLOCK_REALTIME, NULL, &rtcb->group->itimer);
}

leave_critical_section(flags);

if (ret != OK)
{
return ret;
}
ret = timer_create(CLOCK_REALTIME, NULL, &rtcb->group->itimer);
}

leave_critical_section(flags);

if (ret != OK)
{
return ret;
}

TIMEVAL_TO_TIMESPEC(&value->it_value, &spec.it_value);
Expand Down

0 comments on commit 8ecca52

Please sign in to comment.