From 2f13288a23da4dfaf6c40e1e943f83d8fa43145a Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 14 Jul 2016 11:45:11 +0200 Subject: Fix sme warnings... --- src/lib/libkogata/draw.c | 6 +++--- src/lib/libkogata/malloc.c | 10 ++++++++++ src/lib/libkogata/unistd.c | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/lib/libkogata') diff --git a/src/lib/libkogata/draw.c b/src/lib/libkogata/draw.c index 53070ad..2806df4 100644 --- a/src/lib/libkogata/draw.c +++ b/src/lib/libkogata/draw.c @@ -88,7 +88,7 @@ void g_hline(fb_t *fb, int x, int y, int w, color_t c) { for (int u = x; u < x + w; u++) { fb->data[y * fb->geom.pitch + u] = (c & 0xFF); } - } else if (fb->geom.bpp == 15 || fb->geom.bpp == 15) { + } else if (fb->geom.bpp == 15 || fb->geom.bpp == 16) { for (int u = x; u < x + w; u++) { uint16_t *p = (uint16_t*)(fb->data + y * fb->geom.pitch + 2 * u); *p = (c & 0xFFFF); @@ -110,7 +110,7 @@ void g_vline(fb_t *fb, int x, int y, int h, color_t c) { for (int v = y; v < y + h; v++) { fb->data[v * fb->geom.pitch + x] = (c & 0xFF); } - } else if (fb->geom.bpp == 15 || fb->geom.bpp == 15) { + } else if (fb->geom.bpp == 15 || fb->geom.bpp == 16) { for (int v = y; v < y + h; v++) { uint16_t *p = (uint16_t*)(fb->data + v * fb->geom.pitch + 2 * x); *p = (c & 0xFFFF); @@ -145,7 +145,7 @@ void g_fillrect(fb_t *fb, int x, int y, int w, int h, color_t c) { fb->data[v * fb->geom.pitch + u] = (c & 0xFF); } } - } else if (fb->geom.bpp == 15 || fb->geom.bpp == 15) { + } else if (fb->geom.bpp == 15 || fb->geom.bpp == 16) { for (int v = y; v < y + h; v++) { for (int u = x; u < x + w; u++) { uint16_t *p = (uint16_t*)(fb->data + v * fb->geom.pitch + 2 * u); diff --git a/src/lib/libkogata/malloc.c b/src/lib/libkogata/malloc.c index 2a3345f..3777123 100644 --- a/src/lib/libkogata/malloc.c +++ b/src/lib/libkogata/malloc.c @@ -1,6 +1,8 @@ #include #include +#include + #include #include @@ -50,9 +52,17 @@ void malloc_setup() { } void* malloc(size_t size) { + if (size == 0) return 0; + return slab_alloc(mem_allocator, size); } +void* calloc(size_t nmemb, size_t sz) { + void* r = malloc(nmemb * sz); + if (r != 0) memset(r, 0, nmemb * sz); + return r; +} + void free(void* ptr) { slab_free(mem_allocator, ptr); } diff --git a/src/lib/libkogata/unistd.c b/src/lib/libkogata/unistd.c index 80a32e4..101e02e 100644 --- a/src/lib/libkogata/unistd.c +++ b/src/lib/libkogata/unistd.c @@ -24,7 +24,7 @@ int chdir(const char* path) { stat_t st; if (!stat(cwd_buf2, &st)) return -1; - if (!st.type & FT_DIR) return -1; + if (!(st.type & FT_DIR)) return -1; strcpy(cwd_buf, cwd_buf2); return 0; -- cgit v1.2.3