kernel: Explicitly comparing pointer with NULL
MISRA-C rule: 14.4 Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
92ea2f9189
commit
ea716bf023
11 changed files with 17 additions and 16 deletions
|
@ -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();
|
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 */
|
/* all fields reset to 0, reference counter to 1 */
|
||||||
msg->hdr.ref_cnt = 1;
|
msg->hdr.ref_cnt = 1;
|
||||||
msg->hdr.params.raw = 0;
|
msg->hdr.params.raw = 0;
|
||||||
|
|
|
@ -240,7 +240,7 @@ static inline void _ready_one_thread(_wait_q_t *wq)
|
||||||
{
|
{
|
||||||
struct k_thread *th = _unpend_first_thread(wq);
|
struct k_thread *th = _unpend_first_thread(wq);
|
||||||
|
|
||||||
if (th) {
|
if (th != NULL) {
|
||||||
_ready_thread(th);
|
_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);
|
struct k_thread *thread = _find_first_thread_to_unpend(wait_q, NULL);
|
||||||
|
|
||||||
if (thread) {
|
if (thread != NULL) {
|
||||||
_unpend_thread_no_timeout(thread);
|
_unpend_thread_no_timeout(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ _init_thread_timeout(struct _thread_base *thread_base)
|
||||||
static inline void _unpend_thread_timing_out(struct k_thread *thread,
|
static inline void _unpend_thread_timing_out(struct k_thread *thread,
|
||||||
struct _timeout *timeout_obj)
|
struct _timeout *timeout_obj)
|
||||||
{
|
{
|
||||||
if (timeout_obj->wait_q) {
|
if (timeout_obj->wait_q != NULL) {
|
||||||
_unpend_thread_no_timeout(thread);
|
_unpend_thread_no_timeout(thread);
|
||||||
thread->base.timeout.wait_q = NULL;
|
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;
|
timeout->delta_ticks_from_prev = _INACTIVE;
|
||||||
|
|
||||||
K_DEBUG("timeout %p\n", timeout);
|
K_DEBUG("timeout %p\n", timeout);
|
||||||
if (thread) {
|
if (thread != NULL) {
|
||||||
_unpend_thread_timing_out(thread, timeout);
|
_unpend_thread_timing_out(thread, timeout);
|
||||||
_mark_thread_as_started(thread);
|
_mark_thread_as_started(thread);
|
||||||
_ready_thread(thread);
|
_ready_thread(thread);
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
} else {
|
} else {
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
if (timeout->func) {
|
if (timeout->func != NULL) {
|
||||||
timeout->func(timeout);
|
timeout->func(timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ void k_mem_slab_free(struct k_mem_slab *slab, void **mem)
|
||||||
int key = irq_lock();
|
int key = irq_lock();
|
||||||
struct k_thread *pending_thread = _unpend_first_thread(&slab->wait_q);
|
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);
|
_set_thread_return_value_with_data(pending_thread, 0, *mem);
|
||||||
_ready_thread(pending_thread);
|
_ready_thread(pending_thread);
|
||||||
_reschedule(key);
|
_reschedule(key);
|
||||||
|
|
|
@ -209,7 +209,7 @@ void *z_thread_malloc(size_t size)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
if (_current->resource_pool) {
|
if (_current->resource_pool != NULL) {
|
||||||
ret = k_mem_pool_malloc(_current->resource_pool, size);
|
ret = k_mem_pool_malloc(_current->resource_pool, size);
|
||||||
} else {
|
} else {
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
|
|
@ -76,7 +76,7 @@ int _impl_k_msgq_alloc_init(struct k_msgq *q, size_t msg_size,
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
} else {
|
} else {
|
||||||
buffer = z_thread_malloc(total_size);
|
buffer = z_thread_malloc(total_size);
|
||||||
if (buffer) {
|
if (buffer != NULL) {
|
||||||
k_msgq_init(q, buffer, msg_size, max_msgs);
|
k_msgq_init(q, buffer, msg_size, max_msgs);
|
||||||
q->flags = K_MSGQ_FLAG_ALLOC;
|
q->flags = K_MSGQ_FLAG_ALLOC;
|
||||||
ret = 0;
|
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) {
|
if (q->used_msgs < q->max_msgs) {
|
||||||
/* message queue isn't full */
|
/* message queue isn't full */
|
||||||
pending_thread = _unpend_first_thread(&q->wait_q);
|
pending_thread = _unpend_first_thread(&q->wait_q);
|
||||||
if (pending_thread) {
|
if (pending_thread != NULL) {
|
||||||
/* give message to waiting thread */
|
/* give message to waiting thread */
|
||||||
(void)memcpy(pending_thread->base.swap_data, data,
|
(void)memcpy(pending_thread->base.swap_data, data,
|
||||||
q->msg_size);
|
q->msg_size);
|
||||||
|
|
|
@ -347,7 +347,7 @@ static bool pipe_xfer_prepare(sys_dlist_t *xfer_list,
|
||||||
sys_dlist_init(xfer_list);
|
sys_dlist_init(xfer_list);
|
||||||
num_bytes = 0;
|
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;
|
desc = (struct k_pipe_desc *)thread->base.swap_data;
|
||||||
num_bytes += desc->bytes_to_xfer;
|
num_bytes += desc->bytes_to_xfer;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ static void do_sem_give(struct k_sem *sem)
|
||||||
{
|
{
|
||||||
struct k_thread *thread = _unpend_first_thread(&sem->wait_q);
|
struct k_thread *thread = _unpend_first_thread(&sem->wait_q);
|
||||||
|
|
||||||
if (thread) {
|
if (thread != NULL) {
|
||||||
_ready_thread(thread);
|
_ready_thread(thread);
|
||||||
_set_thread_return_value(thread, 0);
|
_set_thread_return_value(thread, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -62,7 +62,7 @@ int _impl_k_stack_alloc_init(struct k_stack *stack, unsigned int num_entries)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
buffer = z_thread_malloc(num_entries);
|
buffer = z_thread_malloc(num_entries);
|
||||||
if (buffer) {
|
if (buffer != NULL) {
|
||||||
k_stack_init(stack, buffer, num_entries);
|
k_stack_init(stack, buffer, num_entries);
|
||||||
stack->flags = K_STACK_FLAG_ALLOC;
|
stack->flags = K_STACK_FLAG_ALLOC;
|
||||||
ret = 0;
|
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);
|
first_pending_thread = _unpend_first_thread(&stack->wait_q);
|
||||||
|
|
||||||
if (first_pending_thread) {
|
if (first_pending_thread != NULL) {
|
||||||
_ready_thread(first_pending_thread);
|
_ready_thread(first_pending_thread);
|
||||||
|
|
||||||
_set_thread_return_value_with_data(first_pending_thread,
|
_set_thread_return_value_with_data(first_pending_thread,
|
||||||
|
|
|
@ -394,7 +394,7 @@ void _setup_new_thread(struct k_thread *new_thread,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
/* New threads inherit any memory domain membership by the parent */
|
/* 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,
|
k_mem_domain_add_thread(_current->mem_domain_info.mem_domain,
|
||||||
new_thread);
|
new_thread);
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,8 @@ void k_object_access_all_grant(void *object)
|
||||||
int _k_object_validate(struct _k_object *ko, enum k_objects otype,
|
int _k_object_validate(struct _k_object *ko, enum k_objects otype,
|
||||||
enum _obj_init_check init)
|
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;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue