Skip to content

Commit 66fdd39

Browse files
ycsincarlescufi
authored andcommitted
posix: pthread: fix zephyr_to_posix_priority assert test
If `z_prio` is negative and we want to make sure that it is within `[-CONFIG_NUM_COOP_PRIORITIES, -1]`, we should invert its sign and make sure that it is `<=` `CONFIG_NUM_COOP_PRIORITIES` instead of `<`. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 45c554d commit 66fdd39

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/posix/pthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static bool is_posix_policy_prio_valid(uint32_t priority, int policy)
230230
static uint32_t zephyr_to_posix_priority(int32_t z_prio, int *policy)
231231
{
232232
if (z_prio < 0) {
233-
__ASSERT_NO_MSG(z_prio < CONFIG_NUM_COOP_PRIORITIES);
233+
__ASSERT_NO_MSG(-z_prio <= CONFIG_NUM_COOP_PRIORITIES);
234234
} else {
235235
__ASSERT_NO_MSG(z_prio < CONFIG_NUM_PREEMPT_PRIORITIES);
236236
}

0 commit comments

Comments
 (0)