kernel: queue: MISRA C compliance.
This patch fixes few issues in queue.c. This patch also changes the return type of k_queue_alloc_append and k_queue_alloc_prepend from int to s32_t. Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
parent
8feda92abc
commit
2a78b8d86f
2 changed files with 10 additions and 10 deletions
|
@ -1755,7 +1755,7 @@ extern void k_queue_append(struct k_queue *queue, void *data);
|
||||||
* @retval 0 on success
|
* @retval 0 on success
|
||||||
* @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
|
* @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
|
||||||
*/
|
*/
|
||||||
__syscall int k_queue_alloc_append(struct k_queue *queue, void *data);
|
__syscall s32_t k_queue_alloc_append(struct k_queue *queue, void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prepend an element to a queue.
|
* @brief Prepend an element to a queue.
|
||||||
|
@ -1788,7 +1788,7 @@ extern void k_queue_prepend(struct k_queue *queue, void *data);
|
||||||
* @retval 0 on success
|
* @retval 0 on success
|
||||||
* @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
|
* @retval -ENOMEM if there isn't sufficient RAM in the caller's resource pool
|
||||||
*/
|
*/
|
||||||
__syscall int k_queue_alloc_prepend(struct k_queue *queue, void *data);
|
__syscall s32_t k_queue_alloc_prepend(struct k_queue *queue, void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Inserts an element to a queue.
|
* @brief Inserts an element to a queue.
|
||||||
|
|
|
@ -34,7 +34,7 @@ void *z_queue_node_peek(sys_sfnode_t *node, bool needs_free)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
if (node && sys_sfnode_flags_get(node)) {
|
if ((node != NULL) && (sys_sfnode_flags_get(node) != (u8_t)0)) {
|
||||||
/* If the flag is set, then the enqueue operation for this item
|
/* If the flag is set, then the enqueue operation for this item
|
||||||
* did a behind-the scenes memory allocation of an alloc_node
|
* did a behind-the scenes memory allocation of an alloc_node
|
||||||
* struct, which is what got put in the queue. Free it and pass
|
* struct, which is what got put in the queue. Free it and pass
|
||||||
|
@ -121,7 +121,7 @@ static inline void handle_poll_events(struct k_queue *queue, u32_t state)
|
||||||
|
|
||||||
void _impl_k_queue_cancel_wait(struct k_queue *queue)
|
void _impl_k_queue_cancel_wait(struct k_queue *queue)
|
||||||
{
|
{
|
||||||
unsigned int key = irq_lock();
|
u32_t key = irq_lock();
|
||||||
#if !defined(CONFIG_POLL)
|
#if !defined(CONFIG_POLL)
|
||||||
struct k_thread *first_pending_thread;
|
struct k_thread *first_pending_thread;
|
||||||
|
|
||||||
|
@ -142,10 +142,10 @@ Z_SYSCALL_HANDLER1_SIMPLE_VOID(k_queue_cancel_wait, K_OBJ_QUEUE,
|
||||||
struct k_queue *);
|
struct k_queue *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int queue_insert(struct k_queue *queue, void *prev, void *data,
|
static s32_t queue_insert(struct k_queue *queue, void *prev, void *data,
|
||||||
bool alloc)
|
bool alloc)
|
||||||
{
|
{
|
||||||
unsigned int key = irq_lock();
|
u32_t key = irq_lock();
|
||||||
#if !defined(CONFIG_POLL)
|
#if !defined(CONFIG_POLL)
|
||||||
struct k_thread *first_pending_thread;
|
struct k_thread *first_pending_thread;
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ void k_queue_prepend(struct k_queue *queue, void *data)
|
||||||
(void)queue_insert(queue, NULL, data, false);
|
(void)queue_insert(queue, NULL, data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _impl_k_queue_alloc_append(struct k_queue *queue, void *data)
|
s32_t _impl_k_queue_alloc_append(struct k_queue *queue, void *data)
|
||||||
{
|
{
|
||||||
return queue_insert(queue, sys_sflist_peek_tail(&queue->data_q), data,
|
return queue_insert(queue, sys_sflist_peek_tail(&queue->data_q), data,
|
||||||
true);
|
true);
|
||||||
|
@ -214,7 +214,7 @@ Z_SYSCALL_HANDLER(k_queue_alloc_append, queue, data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int _impl_k_queue_alloc_prepend(struct k_queue *queue, void *data)
|
s32_t _impl_k_queue_alloc_prepend(struct k_queue *queue, void *data)
|
||||||
{
|
{
|
||||||
return queue_insert(queue, NULL, data, true);
|
return queue_insert(queue, NULL, data, true);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ void *_impl_k_queue_get(struct k_queue *queue, s32_t timeout)
|
||||||
#else
|
#else
|
||||||
int ret = _pend_current_thread(key, &queue->wait_q, timeout);
|
int ret = _pend_current_thread(key, &queue->wait_q, timeout);
|
||||||
|
|
||||||
return ret ? NULL : _current->base.swap_data;
|
return (ret != 0) ? NULL : _current->base.swap_data;
|
||||||
#endif /* CONFIG_POLL */
|
#endif /* CONFIG_POLL */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue