aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libk/stdio/vfprintf.c2
-rw-r--r--lib/libk/stdlib/linked_list_allocator.c4
-rw-r--r--lib/libk/string.h5
-rw-r--r--lib/libk/string/itoa.c6
4 files changed, 9 insertions, 8 deletions
diff --git a/lib/libk/stdio/vfprintf.c b/lib/libk/stdio/vfprintf.c
index a48600b..807c26a 100644
--- a/lib/libk/stdio/vfprintf.c
+++ b/lib/libk/stdio/vfprintf.c
@@ -23,7 +23,7 @@ vfprintf(FILE *__restrict__ stream, const char *__restrict__ format, va_list par
written += stream->puts(stream, arg, -1);
} break;
case 'c': {
- const int arg = va_arg(params, int);
+ const char arg = (char)va_arg(params, int);
stream->putc(stream, arg);
++written;
} break;
diff --git a/lib/libk/stdlib/linked_list_allocator.c b/lib/libk/stdlib/linked_list_allocator.c
index 898fd89..bcec580 100644
--- a/lib/libk/stdlib/linked_list_allocator.c
+++ b/lib/libk/stdlib/linked_list_allocator.c
@@ -58,8 +58,10 @@ malloc(size_t size)
void
free(void *ptr)
{
+ struct Chunk *chunk;
if (ptr == NULL) return;
- struct Chunk *chunk = (struct Chunk *)((uintptr_t)ptr - sizeof(struct Chunk));
+
+ chunk = (struct Chunk *)((uintptr_t)ptr - sizeof(struct Chunk));
chunk->used = 0;
/* merge next chunk */
diff --git a/lib/libk/string.h b/lib/libk/string.h
index 46d8636..45b05a5 100644
--- a/lib/libk/string.h
+++ b/lib/libk/string.h
@@ -7,9 +7,8 @@
/**
* Convert int into a string
*/
-char *itoa(char *p, int x, int base);
+char *itoa(char *p, int x, unsigned base);
/**
* Convert unsigned int into a string
*/
-char *utoa(char *p, unsigned x, int base);
-
+char *utoa(char *p, unsigned x, unsigned base);
diff --git a/lib/libk/string/itoa.c b/lib/libk/string/itoa.c
index 2db9768..0997345 100644
--- a/lib/libk/string/itoa.c
+++ b/lib/libk/string/itoa.c
@@ -4,7 +4,7 @@
static const char *numbers = "0123456789abcdef";
char *
-utoa(char *p, unsigned x, int base)
+utoa(char *p, unsigned x, unsigned base)
{
p += 3 * sizeof(unsigned);
*--p = '\0';
@@ -18,12 +18,12 @@ utoa(char *p, unsigned x, int base)
}
char *
-itoa(char *p, int x, int base)
+itoa(char *p, int x, unsigned base)
{
const bool is_negative = (x < 0);
if (is_negative) x = -x;
- p = utoa(p, x, base);
+ p = utoa(p, (unsigned)x, base);
if (is_negative) *--p = '-';
return p;