fix remaining compiler warnings
This commit removes all inline annotations that the compiler does not actually inline, and inserts pragma directives to selectively disable warnings where necessary.
This commit is contained in:
parent
adccbef80d
commit
ad76275721
6 changed files with 38 additions and 23 deletions
|
@ -17,7 +17,7 @@ static void uart_write_sync(const char *s)
|
|||
}
|
||||
|
||||
/** Setup UART to manual byte-by-byte control */
|
||||
static inline void uart_emergency_setup(void)
|
||||
static void uart_emergency_setup(void)
|
||||
{
|
||||
UART->UART_IDR = 0xffffffff;
|
||||
|
||||
|
@ -34,7 +34,7 @@ static inline void uart_emergency_setup(void)
|
|||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
static inline void print_err_msg(enum irqno irqno)
|
||||
static void print_err_msg(enum irqno irqno)
|
||||
{
|
||||
uart_write_sync("\n\n########## SERIOUS BRUH MOMENT! ##########\n");
|
||||
|
||||
|
@ -100,9 +100,9 @@ static void print_regs(struct exc_context *context)
|
|||
print_reg("R10", context->r10);
|
||||
print_reg("R11", context->r11);
|
||||
print_reg("R12", context->sp->r12);
|
||||
print_reg("SP", *(word_t *)&context->sp);
|
||||
print_reg("LR", *(word_t *)&context->sp->lr);
|
||||
print_reg("PC", *(word_t *)&context->sp->pc);
|
||||
print_reg("SP", (word_t)context->sp);
|
||||
print_reg("LR", (word_t)context->sp->lr);
|
||||
print_reg("PC", (word_t)context->sp->pc);
|
||||
print_reg("xPSR", context->sp->psr);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void kevents_init(void)
|
|||
}
|
||||
|
||||
/* called from scheduler context only */
|
||||
static inline void process_single_queue(struct kevent_queue *queue, struct list_head *listeners)
|
||||
static void process_single_queue(struct kevent_queue *queue, struct list_head *listeners)
|
||||
{
|
||||
struct kevent *event, *tmp_event;
|
||||
|
||||
|
|
31
kernel/mm.c
31
kernel/mm.c
|
@ -167,7 +167,7 @@ static struct memblk *blk_slice(struct list_head *heap, struct memblk *bottom, s
|
|||
long sys_malloc(size_t size)
|
||||
{
|
||||
void *ptr = kmalloc(size);
|
||||
return *(long *)&ptr;
|
||||
return (long)ptr;
|
||||
}
|
||||
|
||||
void sys_free(void *ptr)
|
||||
|
@ -348,8 +348,8 @@ static struct memblk *blk_try_merge(struct list_head *heap, struct memblk *blk)
|
|||
}
|
||||
|
||||
static struct memblk *blk_merge(struct list_head *heap,
|
||||
struct memblk *bottom,
|
||||
struct memblk *top)
|
||||
struct memblk *bottom,
|
||||
struct memblk *top)
|
||||
{
|
||||
size_t bottom_size = blk_get_size(bottom);
|
||||
size_t top_size = blk_get_size(top);
|
||||
|
@ -368,7 +368,8 @@ static struct memblk *blk_merge(struct list_head *heap,
|
|||
return bottom;
|
||||
}
|
||||
|
||||
static struct memblk *blk_slice(struct list_head *heap, struct memblk *blk, size_t slice_size)
|
||||
static struct memblk *blk_slice(struct list_head *heap, struct memblk *blk,
|
||||
size_t slice_size)
|
||||
{
|
||||
list_delete(&blk->list);
|
||||
|
||||
|
@ -412,7 +413,7 @@ static struct memblk *blk_slice(struct list_head *heap, struct memblk *blk, size
|
|||
return blk;
|
||||
}
|
||||
|
||||
static inline size_t round_alloc_size_up(size_t size)
|
||||
static size_t round_alloc_size_up(size_t size)
|
||||
{
|
||||
size_t rounded = (size / MIN_SIZE) * MIN_SIZE;
|
||||
if (rounded < size)
|
||||
|
@ -436,7 +437,7 @@ static void blk_set_size(struct memblk *blk, size_t size)
|
|||
blk->endsz[words] |= size;
|
||||
}
|
||||
|
||||
static inline void blk_set_alloc(struct memblk *blk)
|
||||
static void blk_set_alloc(struct memblk *blk)
|
||||
{
|
||||
size_t words = blk->size / sizeof(blk->size);
|
||||
|
||||
|
@ -444,7 +445,7 @@ static inline void blk_set_alloc(struct memblk *blk)
|
|||
blk->endsz[words] |= ALLOC_FLAG;
|
||||
}
|
||||
|
||||
static inline void blk_clear_alloc(struct memblk *blk)
|
||||
static void blk_clear_alloc(struct memblk *blk)
|
||||
{
|
||||
size_t words = blk->size / sizeof(blk->size);
|
||||
|
||||
|
@ -472,32 +473,38 @@ static inline int blk_is_border_start(struct memblk *blk)
|
|||
return blk->size & BORDER_FLAG;
|
||||
}
|
||||
|
||||
static inline void blk_set_border_end(struct memblk *blk)
|
||||
static void blk_set_border_end(struct memblk *blk)
|
||||
{
|
||||
size_t words = blk->size / sizeof(blk->size);
|
||||
blk->endsz[words] |= BORDER_FLAG;
|
||||
}
|
||||
|
||||
static inline void blk_clear_border_end(struct memblk *blk)
|
||||
static void blk_clear_border_end(struct memblk *blk)
|
||||
{
|
||||
size_t words = blk->size / sizeof(blk->size);
|
||||
blk->endsz[words] &= ~BORDER_FLAG;
|
||||
}
|
||||
|
||||
static inline int blk_is_border_end(struct memblk *blk)
|
||||
static int blk_is_border_end(struct memblk *blk)
|
||||
{
|
||||
size_t words = blk->size / sizeof(blk->size);
|
||||
return blk->endsz[words] & BORDER_FLAG;
|
||||
}
|
||||
|
||||
static inline struct memblk *blk_prev(struct memblk *blk)
|
||||
static struct memblk *blk_prev(struct memblk *blk)
|
||||
{
|
||||
if (blk_is_border_start(blk))
|
||||
return NULL;
|
||||
|
||||
/* gcc does not like accessing index -1 of zero-length arrays */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#pragma GCC diagnostic ignored "-Wzero-length-bounds"
|
||||
return (void *)blk - (blk->prevsz[-1] & SIZE_MSK) - OVERHEAD;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
static inline struct memblk *blk_next(struct memblk *blk)
|
||||
static struct memblk *blk_next(struct memblk *blk)
|
||||
{
|
||||
if (blk_is_border_end(blk))
|
||||
return NULL;
|
||||
|
|
|
@ -79,7 +79,11 @@ int sched_init(void)
|
|||
|
||||
memset(&kernel_task.tcb, 0, sizeof(kernel_task.tcb));
|
||||
kernel_task.bottom = &_estack;
|
||||
/* gcc thinks &_estack is an array of size 1 */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
kernel_task.stack = kernel_task.bottom - CONFIG_STACK_SIZE;
|
||||
#pragma GCC diagnostic pop
|
||||
kernel_task.pid = 0;
|
||||
kernel_task.state = TASK_RUNNING;
|
||||
|
||||
|
@ -121,10 +125,14 @@ out:
|
|||
/**
|
||||
* @brief Determine whether the specified task is a candidate for execution.
|
||||
*
|
||||
* This function is only called once from `schedule()` and performance critical,
|
||||
* hence the `__always_inline` attribute.
|
||||
*
|
||||
* @param task The task
|
||||
* @returns whether `task` could be run next
|
||||
*/
|
||||
static inline bool can_run(const struct task *task)
|
||||
__always_inline
|
||||
static bool can_run(const struct task *task)
|
||||
{
|
||||
switch (task->state) {
|
||||
case TASK_SLEEP:
|
||||
|
|
|
@ -135,7 +135,7 @@ static int fmt_handle_uint(struct printf_buf *buf, unsigned int u)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline int fmt_handle_int(struct printf_buf *buf, int i)
|
||||
static int fmt_handle_int(struct printf_buf *buf, int i)
|
||||
{
|
||||
int ret = 0;
|
||||
char minus = '-';
|
||||
|
@ -160,7 +160,7 @@ static inline int fmt_handle_int(struct printf_buf *buf, int i)
|
|||
* @param args: A pointer to the varargs list. Will be manipulated.
|
||||
* @returns The amount of bytes written, or a negative POSIX error code.
|
||||
*/
|
||||
static inline int fmt_handle(struct printf_buf *buf, const char **pos, va_list args)
|
||||
static int fmt_handle(struct printf_buf *buf, const char **pos, va_list args)
|
||||
{
|
||||
int ret = 0;
|
||||
union {
|
||||
|
|
|
@ -19,7 +19,7 @@ void *malloc(size_t size)
|
|||
return NULL;
|
||||
} else {
|
||||
long int intptr = syscall(SYS_malloc, (sysarg_t)size);
|
||||
return *(void **)&intptr;
|
||||
return (void *)intptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ void *calloc(size_t nmemb, size_t size)
|
|||
if (nmemb != 0 && total / nmemb != size)
|
||||
return NULL; /* overflow check as mandated by POSIX.1 */
|
||||
long int intptr = syscall(SYS_malloc, (sysarg_t)total);
|
||||
return *(void **)&intptr;
|
||||
return (void *)intptr;
|
||||
}
|
||||
|
||||
void free(void *ptr)
|
||||
|
|
Loading…
Reference in a new issue