Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: avoided increments/decrements with side effects #72739

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions kernel/include/priority_q.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ static ALWAYS_INLINE void z_priq_rb_add(struct _priq_rb *pq, struct k_thread *th
{
struct k_thread *t;

thread->base.order_key = pq->next_order_key++;
thread->base.order_key = pq->next_order_key;
++pq->next_order_key;

/* Renumber at wraparound. This is tiny code, and in practice
* will almost never be hit on real systems. BUT on very
Expand All @@ -89,7 +90,8 @@ static ALWAYS_INLINE void z_priq_rb_add(struct _priq_rb *pq, struct k_thread *th
*/
if (!pq->next_order_key) {
RB_FOR_EACH_CONTAINER(&pq->tree, t, base.qnode_rb) {
t->base.order_key = pq->next_order_key++;
t->base.order_key = pq->next_order_key;
++pq->next_order_key;
}
}

Expand Down
3 changes: 2 additions & 1 deletion kernel/mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void k_free(void *ptr)

if (ptr != NULL) {
heap_ref = ptr;
ptr = --heap_ref;
--heap_ref;
ptr = heap_ref;

SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap_sys, k_free, *heap_ref, heap_ref);

Expand Down
Loading