diff --git a/include/logging/log_msg.h b/include/logging/log_msg.h index 9292b49dbff..6d99c4a6b5e 100644 --- a/include/logging/log_msg.h +++ b/include/logging/log_msg.h @@ -347,7 +347,7 @@ static inline struct log_msg *_log_msg_std_alloc(void) { struct log_msg *msg = (struct log_msg *)log_msg_chunk_alloc(); - if (msg) { + if (msg != NULL) { /* all fields reset to 0, reference counter to 1 */ msg->hdr.ref_cnt = 1; msg->hdr.params.raw = 0; diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index f93e5bc4596..f950e961c0f 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -240,7 +240,7 @@ static inline void _ready_one_thread(_wait_q_t *wq) { struct k_thread *th = _unpend_first_thread(wq); - if (th) { + if (th != NULL) { _ready_thread(th); } } @@ -285,7 +285,7 @@ static inline struct k_thread *_unpend1_no_timeout(_wait_q_t *wait_q) { struct k_thread *thread = _find_first_thread_to_unpend(wait_q, NULL); - if (thread) { + if (thread != NULL) { _unpend_thread_no_timeout(thread); } diff --git a/kernel/include/timeout_q.h b/kernel/include/timeout_q.h index e40234e12db..ad6cf0b5e61 100644 --- a/kernel/include/timeout_q.h +++ b/kernel/include/timeout_q.h @@ -68,7 +68,7 @@ _init_thread_timeout(struct _thread_base *thread_base) static inline void _unpend_thread_timing_out(struct k_thread *thread, struct _timeout *timeout_obj) { - if (timeout_obj->wait_q) { + if (timeout_obj->wait_q != NULL) { _unpend_thread_no_timeout(thread); thread->base.timeout.wait_q = NULL; } @@ -88,14 +88,14 @@ static inline void _handle_one_expired_timeout(struct _timeout *timeout) timeout->delta_ticks_from_prev = _INACTIVE; K_DEBUG("timeout %p\n", timeout); - if (thread) { + if (thread != NULL) { _unpend_thread_timing_out(thread, timeout); _mark_thread_as_started(thread); _ready_thread(thread); irq_unlock(key); } else { irq_unlock(key); - if (timeout->func) { + if (timeout->func != NULL) { timeout->func(timeout); } } diff --git a/kernel/mem_slab.c b/kernel/mem_slab.c index 8a845219338..76b009aa963 100644 --- a/kernel/mem_slab.c +++ b/kernel/mem_slab.c @@ -117,7 +117,7 @@ void k_mem_slab_free(struct k_mem_slab *slab, void **mem) int key = irq_lock(); struct k_thread *pending_thread = _unpend_first_thread(&slab->wait_q); - if (pending_thread) { + if (pending_thread != NULL) { _set_thread_return_value_with_data(pending_thread, 0, *mem); _ready_thread(pending_thread); _reschedule(key); diff --git a/kernel/mempool.c b/kernel/mempool.c index 6b6a140bf62..61d48c73a71 100644 --- a/kernel/mempool.c +++ b/kernel/mempool.c @@ -209,7 +209,7 @@ void *z_thread_malloc(size_t size) { void *ret; - if (_current->resource_pool) { + if (_current->resource_pool != NULL) { ret = k_mem_pool_malloc(_current->resource_pool, size); } else { ret = NULL; diff --git a/kernel/msg_q.c b/kernel/msg_q.c index 4cbf0a3784a..6b2da3a980d 100644 --- a/kernel/msg_q.c +++ b/kernel/msg_q.c @@ -76,7 +76,7 @@ int _impl_k_msgq_alloc_init(struct k_msgq *q, size_t msg_size, ret = -EINVAL; } else { buffer = z_thread_malloc(total_size); - if (buffer) { + if (buffer != NULL) { k_msgq_init(q, buffer, msg_size, max_msgs); q->flags = K_MSGQ_FLAG_ALLOC; ret = 0; @@ -119,7 +119,7 @@ int _impl_k_msgq_put(struct k_msgq *q, void *data, s32_t timeout) if (q->used_msgs < q->max_msgs) { /* message queue isn't full */ pending_thread = _unpend_first_thread(&q->wait_q); - if (pending_thread) { + if (pending_thread != NULL) { /* give message to waiting thread */ (void)memcpy(pending_thread->base.swap_data, data, q->msg_size); diff --git a/kernel/pipes.c b/kernel/pipes.c index c30e80e0dcc..66333090368 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c @@ -347,7 +347,7 @@ static bool pipe_xfer_prepare(sys_dlist_t *xfer_list, sys_dlist_init(xfer_list); num_bytes = 0; - while ((thread = _waitq_head(wait_q))) { + while ((thread = _waitq_head(wait_q)) != NULL) { desc = (struct k_pipe_desc *)thread->base.swap_data; num_bytes += desc->bytes_to_xfer; diff --git a/kernel/sem.c b/kernel/sem.c index eb32515719e..3a0c38f2d10 100644 --- a/kernel/sem.c +++ b/kernel/sem.c @@ -101,7 +101,7 @@ static void do_sem_give(struct k_sem *sem) { struct k_thread *thread = _unpend_first_thread(&sem->wait_q); - if (thread) { + if (thread != NULL) { _ready_thread(thread); _set_thread_return_value(thread, 0); } else { diff --git a/kernel/stack.c b/kernel/stack.c index 8088659a966..fccb5a8364f 100644 --- a/kernel/stack.c +++ b/kernel/stack.c @@ -62,7 +62,7 @@ int _impl_k_stack_alloc_init(struct k_stack *stack, unsigned int num_entries) int ret; buffer = z_thread_malloc(num_entries); - if (buffer) { + if (buffer != NULL) { k_stack_init(stack, buffer, num_entries); stack->flags = K_STACK_FLAG_ALLOC; ret = 0; @@ -105,7 +105,7 @@ void _impl_k_stack_push(struct k_stack *stack, u32_t data) first_pending_thread = _unpend_first_thread(&stack->wait_q); - if (first_pending_thread) { + if (first_pending_thread != NULL) { _ready_thread(first_pending_thread); _set_thread_return_value_with_data(first_pending_thread, diff --git a/kernel/thread.c b/kernel/thread.c index 9042920e963..606380b2675 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -394,7 +394,7 @@ void _setup_new_thread(struct k_thread *new_thread, #endif #ifdef CONFIG_USERSPACE /* New threads inherit any memory domain membership by the parent */ - if (_current->mem_domain_info.mem_domain) { + if (_current->mem_domain_info.mem_domain != NULL) { k_mem_domain_add_thread(_current->mem_domain_info.mem_domain, new_thread); } diff --git a/kernel/userspace.c b/kernel/userspace.c index f5c45a70e10..a1b6dfc31d1 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -513,7 +513,8 @@ void k_object_access_all_grant(void *object) int _k_object_validate(struct _k_object *ko, enum k_objects otype, enum _obj_init_check init) { - if (unlikely(!ko || (otype != K_OBJ_ANY && ko->type != otype))) { + if (unlikely((ko == NULL) || + (otype != K_OBJ_ANY && ko->type != otype))) { return -EBADF; }