From 8a9ba10c2cfb1b0c73dfd30a4e1e5988be0abcab Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Tue, 11 Sep 2018 18:33:37 -0700 Subject: [PATCH] kernel: swap: Fix __swap signature __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 --- arch/arm/core/swap.c | 4 ++-- arch/posix/core/swap.c | 2 +- kernel/include/kswap.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm/core/swap.c b/arch/arm/core/swap.c index 204fe263cf5..f0de57d22f8 100644 --- a/arch/arm/core/swap.c +++ b/arch/arm/core/swap.c @@ -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 */ diff --git a/arch/posix/core/swap.c b/arch/posix/core/swap.c index 6278764be9f..3240e7bbba5 100644 --- a/arch/posix/core/swap.c +++ b/arch/posix/core/swap.c @@ -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 diff --git a/kernel/include/kswap.h b/kernel/include/kswap.h index a838498df87..01ac1f07533 100644 --- a/kernel/include/kswap.h +++ b/kernel/include/kswap.h @@ -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; @@ -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();