Skip to content

Commit

Permalink
kernel: swap: Fix __swap signature
Browse files Browse the repository at this point in the history
__swap function was returning -EAGAIN in some case, though its return
value was declared as unsigned int.

This commit changes this function to return int since it can return a
negative value and its return was already been propagate as int.

Signed-off-by: Flavio Ceolin <[email protected]>
  • Loading branch information
Flavio Ceolin authored and nashif committed Sep 14, 2018
1 parent 91b6123 commit 8a9ba10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions arch/arm/core/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ extern const int _k_neg_eagain;
* On ARMv6-M, the intlock key is represented by the PRIMASK register,
* as BASEPRI is not available.
*
* @return may contain a return value setup by a call to
* @return -EAGAIN, or a return value set by a call to
* _set_thread_return_value()
*
*/
unsigned int __swap(int key)
int __swap(int key)
{
#ifdef CONFIG_USERSPACE
/* Save off current privilege mode */
Expand Down
2 changes: 1 addition & 1 deletion arch/posix/core/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/

unsigned int __swap(unsigned int key)
int __swap(unsigned int key)
{
/*
* struct k_thread * _kernel.current is the currently runnig thread
Expand Down
8 changes: 4 additions & 4 deletions kernel/include/kswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void _smp_release_global_lock(struct k_thread *thread);
* Needed for SMP, where the scheduler requires spinlocking that we
* don't want to have to do in per-architecture assembly.
*/
static inline unsigned int _Swap(unsigned int key)
static inline int _Swap(unsigned int key)
{
struct k_thread *new_thread, *old_thread;
int ret = 0;
Expand Down Expand Up @@ -90,11 +90,11 @@ static inline unsigned int _Swap(unsigned int key)

#else /* !CONFIG_USE_SWITCH */

extern unsigned int __swap(unsigned int key);
extern int __swap(unsigned int key);

static inline unsigned int _Swap(unsigned int key)
static inline int _Swap(unsigned int key)
{
unsigned int ret;
int ret;
_check_stack_sentinel();
_update_time_slice_before_swap();

Expand Down

0 comments on commit 8a9ba10

Please sign in to comment.