kernel: sched: Change boolean APIs to return bool
Change APIs that essentially return a boolean expression - 0 for false and 1 for true - to return a bool. MISRA-C rule 14.4 Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
420bb62071
commit
02ed85bd82
7 changed files with 42 additions and 40 deletions
|
@ -65,12 +65,12 @@ static ALWAYS_INLINE struct k_thread *_get_next_ready_thread(void)
|
|||
#endif
|
||||
|
||||
|
||||
static inline int _is_idle_thread(void *entry_point)
|
||||
static inline bool _is_idle_thread(void *entry_point)
|
||||
{
|
||||
return entry_point == idle;
|
||||
}
|
||||
|
||||
static inline int _is_thread_pending(struct k_thread *thread)
|
||||
static inline bool _is_thread_pending(struct k_thread *thread)
|
||||
{
|
||||
return !!(thread->base.thread_state & _THREAD_PENDING);
|
||||
}
|
||||
|
@ -84,32 +84,32 @@ static inline int _is_thread_prevented_from_running(struct k_thread *thread)
|
|||
|
||||
}
|
||||
|
||||
static inline int _is_thread_timeout_active(struct k_thread *thread)
|
||||
static inline bool _is_thread_timeout_active(struct k_thread *thread)
|
||||
{
|
||||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
||||
return thread->base.timeout.delta_ticks_from_prev != _INACTIVE;
|
||||
#else
|
||||
return 0;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int _is_thread_ready(struct k_thread *thread)
|
||||
static inline bool _is_thread_ready(struct k_thread *thread)
|
||||
{
|
||||
return !(_is_thread_prevented_from_running(thread) ||
|
||||
return !((_is_thread_prevented_from_running(thread)) != 0 ||
|
||||
_is_thread_timeout_active(thread));
|
||||
}
|
||||
|
||||
static inline int _has_thread_started(struct k_thread *thread)
|
||||
static inline bool _has_thread_started(struct k_thread *thread)
|
||||
{
|
||||
return !(thread->base.thread_state & _THREAD_PRESTART);
|
||||
return (thread->base.thread_state & _THREAD_PRESTART) == 0;
|
||||
}
|
||||
|
||||
static inline int _is_thread_state_set(struct k_thread *thread, u32_t state)
|
||||
static inline bool _is_thread_state_set(struct k_thread *thread, u32_t state)
|
||||
{
|
||||
return !!(thread->base.thread_state & state);
|
||||
}
|
||||
|
||||
static inline int _is_thread_queued(struct k_thread *thread)
|
||||
static inline bool _is_thread_queued(struct k_thread *thread)
|
||||
{
|
||||
return _is_thread_state_set(thread, _THREAD_QUEUED);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ static inline void _mark_thread_as_not_queued(struct k_thread *thread)
|
|||
_reset_thread_states(thread, _THREAD_QUEUED);
|
||||
}
|
||||
|
||||
static inline int _is_under_prio_ceiling(int prio)
|
||||
static inline bool _is_under_prio_ceiling(int prio)
|
||||
{
|
||||
return prio >= CONFIG_PRIORITY_CEILING;
|
||||
}
|
||||
|
@ -170,55 +170,55 @@ static inline int _get_new_prio_with_ceiling(int prio)
|
|||
return _is_under_prio_ceiling(prio) ? prio : CONFIG_PRIORITY_CEILING;
|
||||
}
|
||||
|
||||
static inline int _is_prio1_higher_than_or_equal_to_prio2(int prio1, int prio2)
|
||||
static inline bool _is_prio1_higher_than_or_equal_to_prio2(int prio1, int prio2)
|
||||
{
|
||||
return prio1 <= prio2;
|
||||
}
|
||||
|
||||
static inline int _is_prio_higher_or_equal(int prio1, int prio2)
|
||||
static inline bool _is_prio_higher_or_equal(int prio1, int prio2)
|
||||
{
|
||||
return _is_prio1_higher_than_or_equal_to_prio2(prio1, prio2);
|
||||
}
|
||||
|
||||
static inline int _is_prio1_lower_than_or_equal_to_prio2(int prio1, int prio2)
|
||||
static inline bool _is_prio1_lower_than_or_equal_to_prio2(int prio1, int prio2)
|
||||
{
|
||||
return prio1 >= prio2;
|
||||
}
|
||||
|
||||
static inline int _is_prio1_higher_than_prio2(int prio1, int prio2)
|
||||
static inline bool _is_prio1_higher_than_prio2(int prio1, int prio2)
|
||||
{
|
||||
return prio1 < prio2;
|
||||
}
|
||||
|
||||
static inline int _is_prio_higher(int prio, int test_prio)
|
||||
static inline bool _is_prio_higher(int prio, int test_prio)
|
||||
{
|
||||
return _is_prio1_higher_than_prio2(prio, test_prio);
|
||||
}
|
||||
|
||||
static inline int _is_prio_lower_or_equal(int prio1, int prio2)
|
||||
static inline bool _is_prio_lower_or_equal(int prio1, int prio2)
|
||||
{
|
||||
return _is_prio1_lower_than_or_equal_to_prio2(prio1, prio2);
|
||||
}
|
||||
|
||||
int _is_t1_higher_prio_than_t2(struct k_thread *t1, struct k_thread *t2);
|
||||
bool _is_t1_higher_prio_than_t2(struct k_thread *t1, struct k_thread *t2);
|
||||
|
||||
static inline int _is_valid_prio(int prio, void *entry_point)
|
||||
static inline bool _is_valid_prio(int prio, void *entry_point)
|
||||
{
|
||||
if (prio == K_IDLE_PRIO && _is_idle_thread(entry_point)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_is_prio_higher_or_equal(prio,
|
||||
K_LOWEST_APPLICATION_THREAD_PRIO)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_is_prio_lower_or_equal(prio,
|
||||
K_HIGHEST_APPLICATION_THREAD_PRIO)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void _ready_thread(struct k_thread *thread)
|
||||
|
@ -272,7 +272,7 @@ static ALWAYS_INLINE void _sched_unlock_no_reschedule(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE int _is_thread_timeout_expired(struct k_thread *thread)
|
||||
static ALWAYS_INLINE bool _is_thread_timeout_expired(struct k_thread *thread)
|
||||
{
|
||||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
||||
return thread->base.timeout.delta_ticks_from_prev == _EXPIRED;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue