kernel: Make if/iteration evaluate boolean operands
Controlling expression of if and iteration statements must have a boolean type. MISRA-C rule 14.4 Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
3306a5862f
commit
2df02cc8db
6 changed files with 11 additions and 11 deletions
|
@ -87,7 +87,7 @@ static inline bool z_is_idle_thread(void *entry_point)
|
|||
|
||||
static inline bool z_is_thread_pending(struct k_thread *thread)
|
||||
{
|
||||
return !!(thread->base.thread_state & _THREAD_PENDING);
|
||||
return (thread->base.thread_state & _THREAD_PENDING) != 0;
|
||||
}
|
||||
|
||||
static inline bool z_is_thread_prevented_from_running(struct k_thread *thread)
|
||||
|
@ -117,7 +117,7 @@ static inline bool z_has_thread_started(struct k_thread *thread)
|
|||
|
||||
static inline bool z_is_thread_state_set(struct k_thread *thread, u32_t state)
|
||||
{
|
||||
return !!(thread->base.thread_state & state);
|
||||
return (thread->base.thread_state & state) != 0;
|
||||
}
|
||||
|
||||
static inline bool z_is_thread_queued(struct k_thread *thread)
|
||||
|
|
|
@ -101,7 +101,7 @@ Z_SYSCALL_HANDLER(k_msgq_alloc_init, q, msg_size, max_msgs)
|
|||
|
||||
void k_msgq_cleanup(struct k_msgq *q)
|
||||
{
|
||||
__ASSERT_NO_MSG(!z_waitq_head(&q->wait_q));
|
||||
__ASSERT_NO_MSG(z_waitq_head(&q->wait_q) == NULL);
|
||||
|
||||
if ((q->flags & K_MSGQ_FLAG_ALLOC) != 0) {
|
||||
k_free(q->buffer_start);
|
||||
|
|
|
@ -73,9 +73,9 @@ static inline int is_metairq(struct k_thread *thread)
|
|||
}
|
||||
|
||||
#if CONFIG_ASSERT
|
||||
static inline int is_thread_dummy(struct k_thread *thread)
|
||||
static inline bool is_thread_dummy(struct k_thread *thread)
|
||||
{
|
||||
return !!(thread->base.thread_state & _THREAD_DUMMY);
|
||||
return (thread->base.thread_state & _THREAD_DUMMY) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#define LOCKED(lck) for (k_spinlock_key_t __i = {}, \
|
||||
__key = k_spin_lock(lck); \
|
||||
!__i.key; \
|
||||
__i.key == 0; \
|
||||
k_spin_unlock(lck, __key), __i.key = 1)
|
||||
|
||||
static u64_t curr_tick;
|
||||
|
|
|
@ -558,19 +558,19 @@ int z_object_validate(struct _k_object *ko, enum k_objects otype,
|
|||
/* Manipulation of any kernel objects by a user thread requires that
|
||||
* thread be granted access first, even for uninitialized objects
|
||||
*/
|
||||
if (unlikely(!thread_perms_test(ko))) {
|
||||
if (unlikely(thread_perms_test(ko) == 0)) {
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/* Initialization state checks. _OBJ_INIT_ANY, we don't care */
|
||||
if (likely(init == _OBJ_INIT_TRUE)) {
|
||||
/* Object MUST be intialized */
|
||||
if (unlikely(!(ko->flags & K_OBJ_FLAG_INITIALIZED))) {
|
||||
if (unlikely((ko->flags & K_OBJ_FLAG_INITIALIZED) == 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
} else if (init < _OBJ_INIT_TRUE) { /* _OBJ_INIT_FALSE case */
|
||||
/* Object MUST NOT be initialized */
|
||||
if (unlikely(ko->flags & K_OBJ_FLAG_INITIALIZED)) {
|
||||
if (unlikely((ko->flags & K_OBJ_FLAG_INITIALIZED) != 0)) {
|
||||
return -EADDRINUSE;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -79,7 +79,7 @@ int k_delayed_work_submit_to_queue(struct k_work_q *work_q,
|
|||
int err = 0;
|
||||
|
||||
/* Work cannot be active in multiple queues */
|
||||
if (work->work_q && work->work_q != work_q) {
|
||||
if (work->work_q != NULL && work->work_q != work_q) {
|
||||
err = -EADDRINUSE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ int k_delayed_work_submit_to_queue(struct k_work_q *work_q,
|
|||
/* Submit work directly if no delay. Note that this is a
|
||||
* blocking operation, so release the lock first.
|
||||
*/
|
||||
if (!delay) {
|
||||
if (delay == 0) {
|
||||
k_spin_unlock(&lock, key);
|
||||
k_work_submit_to_queue(work_q, &work->work);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue