kernel: avoided increments/decrements with side effects

- moved ++/-- before or after the value use

Signed-off-by: frei tycho <tfrei@baumer.com>
This commit is contained in:
frei tycho 2024-05-14 13:08:17 +00:00 committed by Alberto Escolar
commit d8179401b5
2 changed files with 6 additions and 3 deletions

View file

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

View file

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