Skip to content

Commit

Permalink
sched: finalize_cancel_locked can early return
Browse files Browse the repository at this point in the history
The code `SYS_SLIST_FOR_EACH_CONTAINER_SAFE` just for remove work
from `pending_cancels`.
After removing work successfully, the function can return early.
It is unnecessary to iterate continuously.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
  • Loading branch information
TaiJuWu authored and cfriedt committed Mar 8, 2024
1 parent 03fce7d commit 39f7101
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ static void finalize_cancel_locked(struct k_work *work)
if (wc->work == work) {
sys_slist_remove(&pending_cancels, prev, &wc->node);
k_sem_give(&wc->sem);
} else {
prev = &wc->node;
break;
}
prev = &wc->node;
}
}

Expand Down

0 comments on commit 39f7101

Please sign in to comment.