kernel: MISRA C: Fixes a few MISRA C issues.

MISRA C guideline compliance for various rules.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
Adithya Baglody 2018-10-15 11:48:51 +05:30 committed by Anas Nashif
commit 28080d3896
2 changed files with 14 additions and 13 deletions

View file

@ -2300,7 +2300,7 @@ struct k_lifo {
/**
* @cond INTERNAL_HIDDEN
*/
#define K_STACK_FLAG_ALLOC BIT(0) /* Buffer was allocated */
#define K_STACK_FLAG_ALLOC ((u8_t)1) /* Buffer was allocated */
struct k_stack {
_wait_q_t wait_q;
@ -2344,7 +2344,7 @@ struct k_stack {
* @req K-STACK-001
*/
void k_stack_init(struct k_stack *stack,
u32_t *buffer, unsigned int num_entries);
u32_t *buffer, u32_t num_entries);
/**
@ -2362,8 +2362,8 @@ void k_stack_init(struct k_stack *stack,
* @req K-STACK-001
*/
__syscall int k_stack_alloc_init(struct k_stack *stack,
unsigned int num_entries);
__syscall s32_t k_stack_alloc_init(struct k_stack *stack,
u32_t num_entries);
/**
* @brief Release a stack's allocated buffer

View file

@ -46,26 +46,27 @@ SYS_INIT(init_stack_module, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
#endif /* CONFIG_OBJECT_TRACING */
void k_stack_init(struct k_stack *stack, u32_t *buffer,
unsigned int num_entries)
u32_t num_entries)
{
_waitq_init(&stack->wait_q);
stack->next = stack->base = buffer;
stack->base = buffer;
stack->next = buffer;
stack->top = stack->base + num_entries;
SYS_TRACING_OBJ_INIT(k_stack, stack);
_k_object_init(stack);
}
int _impl_k_stack_alloc_init(struct k_stack *stack, unsigned int num_entries)
s32_t _impl_k_stack_alloc_init(struct k_stack *stack, u32_t num_entries)
{
void *buffer;
int ret;
s32_t ret;
buffer = z_thread_malloc(num_entries);
if (buffer != NULL) {
k_stack_init(stack, buffer, num_entries);
stack->flags = K_STACK_FLAG_ALLOC;
ret = 0;
ret = (s32_t)0;
} else {
ret = -ENOMEM;
}
@ -85,9 +86,9 @@ Z_SYSCALL_HANDLER(k_stack_alloc_init, stack, num_entries)
void k_stack_cleanup(struct k_stack *stack)
{
__ASSERT_NO_MSG(!_waitq_head(&stack->wait_q));
__ASSERT_NO_MSG(_waitq_head(&stack->wait_q) == NULL);
if (stack->flags & K_STACK_FLAG_ALLOC) {
if ((stack->flags & K_STACK_FLAG_ALLOC) != (u8_t)0) {
k_free(stack->base);
stack->base = NULL;
stack->flags &= ~K_STACK_FLAG_ALLOC;
@ -97,7 +98,7 @@ void k_stack_cleanup(struct k_stack *stack)
void _impl_k_stack_push(struct k_stack *stack, u32_t data)
{
struct k_thread *first_pending_thread;
unsigned int key;
u32_t key;
__ASSERT(stack->next != stack->top, "stack is full");
@ -136,7 +137,7 @@ Z_SYSCALL_HANDLER(k_stack_push, stack_p, data)
int _impl_k_stack_pop(struct k_stack *stack, u32_t *data, s32_t timeout)
{
unsigned int key;
u32_t key;
int result;
key = irq_lock();