Skip to content

Commit

Permalink
kernel: stack: Fix k_stack_pop api
Browse files Browse the repository at this point in the history
_pend_current_thread can return any arbitrary value set by
_set_thred_return_value(), it happens that most cases set 0. This
function can not rely on this behavior otherwise it may return an
invalid value and/or not set data's value.

Signed-off-by: Flavio Ceolin <[email protected]>
  • Loading branch information
Flavio Ceolin authored and nashif committed Sep 18, 2018
1 parent c806ac3 commit 8f488ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kernel/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ int _impl_k_stack_pop(struct k_stack *stack, u32_t *data, s32_t timeout)
}

result = _pend_current_thread(key, &stack->wait_q, timeout);
if (result == -EAGAIN)
return -EAGAIN;

if (result == 0) {
*data = (u32_t)_current->base.swap_data;
}
return result;
*data = (u32_t)_current->base.swap_data;
return 0;
}

#ifdef CONFIG_USERSPACE
Expand Down

0 comments on commit 8f488ff

Please sign in to comment.