From b7ee746da34a74bd7e5498844be5eaad9c450542 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 7 Oct 2022 18:10:20 +0200 Subject: [PATCH] Kernel: Enable even more warnings --- kernel/Makefile | 4 ++-- kernel/src/main.cpp | 1 + kernel/src/memory/liballoc/liballoc.c | 6 +++--- kernel/src/std/string.cpp | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 2c97a286..c1f25d5e 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -3,8 +3,8 @@ MOON_SRC := $(MOON_DIR)/src MOON_OBJ := $(MOON_DIR)/lib MOON_BIN := $(MOON_DIR)/bin -CFLAGS := -pedantic -Wall -Wextra -Werror -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion -Os -ffreestanding -fstack-protector-all -fno-omit-frame-pointer -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fshort-wchar -mcmodel=kernel -I$(MOON_DIR)/include -isystem $(MOON_DIR)/include/std -CXXFLAGS := -fno-rtti -fno-exceptions +CFLAGS := -pedantic -Wall -Wextra -Werror -Wfloat-equal -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion -Os -ffreestanding -fstack-protector-all -fno-omit-frame-pointer -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fshort-wchar -mcmodel=kernel -I$(MOON_DIR)/include -isystem $(MOON_DIR)/include/std +CXXFLAGS := -fno-rtti -fno-exceptions -Wsign-promo -Wstrict-null-sentinel -Wctor-dtor-privacy ASMFLAGS := -felf64 LDFLAGS := -T$(MOON_DIR)/moon.ld -nostdlib -lgcc -Wl,--build-id=none -z max-page-size=0x1000 diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index baec78d6..fde65f46 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -148,6 +148,7 @@ extern "C" void _start() kinfoln("Loading demo: memory eating program"); Scheduler::load_user_task("bin/memeater"); break; + default: break; } kinfoln("Prepared scheduler tasks"); diff --git a/kernel/src/memory/liballoc/liballoc.c b/kernel/src/memory/liballoc/liballoc.c index 90c9f2b4..65ca1e5f 100644 --- a/kernel/src/memory/liballoc/liballoc.c +++ b/kernel/src/memory/liballoc/liballoc.c @@ -108,9 +108,9 @@ static void* liballoc_memset(void* s, int c, size_t n) static void* liballoc_memcpy(void* s1, const void* s2, size_t n) { char* cdest; - char* csrc; + const char* csrc; unsigned int* ldest = (unsigned int*)s1; - unsigned int* lsrc = (unsigned int*)s2; + const unsigned int* lsrc = (const unsigned int*)s2; while (n >= sizeof(unsigned int)) { @@ -119,7 +119,7 @@ static void* liballoc_memcpy(void* s1, const void* s2, size_t n) } cdest = (char*)ldest; - csrc = (char*)lsrc; + csrc = (const char*)lsrc; while (n > 0) { diff --git a/kernel/src/std/string.cpp b/kernel/src/std/string.cpp index b861aa6e..e2661aac 100644 --- a/kernel/src/std/string.cpp +++ b/kernel/src/std/string.cpp @@ -47,7 +47,7 @@ char* strncat(char* dest, const char* src, size_t n) size_t dest_len = strlen(dest); size_t i; - for (i = 0; i < n && *(src + i); i++) *(char*)(dest + dest_len + i) = *(char*)(src + i); + for (i = 0; i < n && *(src + i); i++) *(char*)(dest + dest_len + i) = *(const char*)(src + i); *(char*)(dest + dest_len + i) = '\0'; @@ -59,7 +59,7 @@ char* strcat(char* dest, const char* src) size_t dest_len = strlen(dest); size_t i; - for (i = 0; *(src + i); i++) *(char*)(dest + dest_len + i) = *(char*)(src + i); + for (i = 0; *(src + i); i++) *(char*)(dest + dest_len + i) = *(const char*)(src + i); *(char*)(dest + dest_len + i) = '\0'; @@ -88,7 +88,7 @@ char* strstr(char* haystack, const char* needle) void* memcpy(void* dest, const void* src, size_t n) { - for (size_t i = 0; i < n; ++i) { *((char*)dest + i) = *((char*)src + i); } + for (size_t i = 0; i < n; ++i) { *((char*)dest + i) = *((const char*)src + i); } return dest; }