diff options
Diffstat (limited to 'libs/libc')
-rw-r--r-- | libs/libc/conv.c | 4 | ||||
-rw-r--r-- | libs/libc/inc/print.h | 2 | ||||
-rw-r--r-- | libs/libc/list.c | 7 | ||||
-rw-r--r-- | libs/libc/sanitize.c | 2 | ||||
-rw-r--r-- | libs/libc/stack.c | 7 |
5 files changed, 12 insertions, 10 deletions
diff --git a/libs/libc/conv.c b/libs/libc/conv.c index bb68d7b..668069c 100644 --- a/libs/libc/conv.c +++ b/libs/libc/conv.c @@ -123,7 +123,7 @@ char *conv_base(int value, char *result, int base, int is_signed) return result; } - char *ptr = result, *ptr1 = result, tmp_char; + char *ptr = result, *ptr1 = result; int tmp_value; do { @@ -137,7 +137,7 @@ char *conv_base(int value, char *result, int base, int is_signed) *ptr++ = '-'; *ptr-- = '\0'; while (ptr1 < ptr) { - tmp_char = *ptr; + char tmp_char = *ptr; *ptr-- = *ptr1; *ptr1++ = tmp_char; } diff --git a/libs/libc/inc/print.h b/libs/libc/inc/print.h index 6d959c3..bc1b7b0 100644 --- a/libs/libc/inc/print.h +++ b/libs/libc/inc/print.h @@ -20,7 +20,7 @@ int viprintf(enum io_type io, const char *format, va_list ap) NONNULL; int fprintf(const char *path, const char *format, ...) NONNULL; int iprintf(enum io_type io, const char *format, ...) NONNULL; int log(const char *format, ...) NONNULL; -void err(int code, const char *format, ...) NONNULL; +NORETURN void err(int code, const char *format, ...) NONNULL; #else #include <proc.h> int print_prefix(void); diff --git a/libs/libc/list.c b/libs/libc/list.c index 53bfa08..bda9e20 100644 --- a/libs/libc/list.c +++ b/libs/libc/list.c @@ -22,11 +22,12 @@ void list_destroy(struct list *list) break; } iterator = iterator->next; - free(iterator->prev); + + if (iterator && iterator->prev) + free(iterator->prev); } - list->head = NULL; + memset(list, 0, sizeof(*list)); free(list); - list = NULL; } static struct node *list_new_node(void) diff --git a/libs/libc/sanitize.c b/libs/libc/sanitize.c index d31c20c..00c9032 100644 --- a/libs/libc/sanitize.c +++ b/libs/libc/sanitize.c @@ -183,7 +183,7 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch *data, u32 ptr) }; struct source_location *loc = &data->location; - const char *msg = ""; + const char *msg; if (ptr == 0) { msg = "null pointer"; } else if (data->alignment != 0 && is_aligned(ptr, data->alignment)) diff --git a/libs/libc/stack.c b/libs/libc/stack.c index 6f16709..81c76a2 100644 --- a/libs/libc/stack.c +++ b/libs/libc/stack.c @@ -22,11 +22,12 @@ void stack_destroy(struct stack *stack) break; } iterator = iterator->prev; - free(iterator->next); + + if (iterator && iterator->prev) + free(iterator->prev); } - stack->tail = NULL; + memset(stack, 0, sizeof(*stack)); free(stack); - stack = NULL; } static struct stack_node *stack_new_node(void) |