Skip to content

Commit 5c36fab

Browse files
author
Jeppe Odgaard
committed
sys: util: remove extra call in WAIT_FOR
WAIT_FOR calls `expr` after it has evaluated to true. Store `expr` in a variable and return it instead to prevent the additional `expr` call. Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
1 parent 45ed9c6 commit 5c36fab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/zephyr/sys/util.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,11 +1092,13 @@ static inline size_t sys_count_bits(const void *value, size_t len)
10921092
({ \
10931093
uint32_t _wf_cycle_count = k_us_to_cyc_ceil32(timeout); \
10941094
uint32_t _wf_start = k_cycle_get_32(); \
1095-
while (!(expr) && (_wf_cycle_count > (k_cycle_get_32() - _wf_start))) { \
1095+
bool _wf_ret; \
1096+
while (!(_wf_ret = (expr)) && \
1097+
(_wf_cycle_count > (k_cycle_get_32() - _wf_start))) { \
10961098
delay_stmt; \
10971099
Z_SPIN_DELAY(10); \
10981100
} \
1099-
(expr); \
1101+
(_wf_ret); \
11001102
})
11011103

11021104
/**

0 commit comments

Comments
 (0)