diff --git a/kernel/Makefile b/kernel/Makefile index 61923e91..8f62835f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -3,7 +3,7 @@ MOON_SRC := $(MOON_DIR)/src MOON_OBJ := $(MOON_DIR)/lib MOON_BIN := $(MOON_DIR)/bin -CFLAGS := -Wall -Wextra -Werror -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 +CFLAGS := -pedantic -Wall -Wextra -Werror -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -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 ASMFLAGS := -felf64 LDFLAGS := -T$(MOON_DIR)/moon.ld -nostdlib -lgcc -Wl,--build-id=none -z max-page-size=0x1000 diff --git a/kernel/include/memory/VMM.h b/kernel/include/memory/VMM.h index eaf1cded..ce12e765 100644 --- a/kernel/include/memory/VMM.h +++ b/kernel/include/memory/VMM.h @@ -13,7 +13,7 @@ namespace Paging { public: void init(); // fetch page table from cr3 - void init(PageTable* PML4); + void init(PageTable* cr3); void map(uint64_t virtualAddress, uint64_t physicalAddress, int flags); void remap(uint64_t virtualAddress, int flags); diff --git a/kernel/src/memory/PMM.cpp b/kernel/src/memory/PMM.cpp index 459c6133..bc48fc0c 100644 --- a/kernel/src/memory/PMM.cpp +++ b/kernel/src/memory/PMM.cpp @@ -62,7 +62,7 @@ void PMM::init() else { free_mem += MMapEnt_Size(ptr); - for (uint64_t i = 0; i < (MMapEnt_Size(ptr) / 4096); i++) { bitmap_set(index + i, false); } + for (uint64_t j = 0; j < (MMapEnt_Size(ptr) / 4096); j++) { bitmap_set(index + j, false); } } ptr++; } diff --git a/kernel/src/memory/VMM.cpp b/kernel/src/memory/VMM.cpp index 1f8155fc..4ee7fb8d 100644 --- a/kernel/src/memory/VMM.cpp +++ b/kernel/src/memory/VMM.cpp @@ -12,9 +12,9 @@ namespace Paging asm volatile("mov %%cr3, %0" : "=r"(PML4)); } - void VirtualMemoryManager::init(PageTable* PML4) + void VirtualMemoryManager::init(PageTable* cr3) { - this->PML4 = PML4; + PML4 = cr3; } void VirtualMemoryManager::unmap(uint64_t virtualAddress) diff --git a/kernel/src/memory/liballoc/liballoc.c b/kernel/src/memory/liballoc/liballoc.c index f9be652d..737221ee 100644 --- a/kernel/src/memory/liballoc/liballoc.c +++ b/kernel/src/memory/liballoc/liballoc.c @@ -24,22 +24,22 @@ #define ALIGN(ptr) \ if (ALIGNMENT > 1) \ { \ - uintptr_t diff; \ + uintptr_t align_diff; \ ptr = (void*)((uintptr_t)ptr + ALIGN_INFO); \ - diff = (uintptr_t)ptr & (ALIGNMENT - 1); \ - if (diff != 0) \ + align_diff = (uintptr_t)ptr & (ALIGNMENT - 1); \ + if (align_diff != 0) \ { \ - diff = ALIGNMENT - diff; \ - ptr = (void*)((uintptr_t)ptr + diff); \ + align_diff = ALIGNMENT - align_diff; \ + ptr = (void*)((uintptr_t)ptr + align_diff); \ } \ - *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)) = diff + ALIGN_INFO; \ + *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)) = align_diff + ALIGN_INFO; \ } #define UNALIGN(ptr) \ if (ALIGNMENT > 1) \ { \ - uintptr_t diff = *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)); \ - if (diff < (ALIGNMENT + ALIGN_INFO)) { ptr = (void*)((uintptr_t)ptr - diff); } \ + uintptr_t align_diff = *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)); \ + if (align_diff < (ALIGNMENT + ALIGN_INFO)) { ptr = (void*)((uintptr_t)ptr - align_diff); } \ } #define LIBALLOC_MAGIC 0xc001c0de diff --git a/libs/libc/Makefile b/libs/libc/Makefile index 3d3a08ed..e770a79e 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -5,7 +5,7 @@ LIBC_BIN := $(LIBC_DIR)/bin DESTDIR ?= $(LUNA_BASE)/usr/lib -CFLAGS := -Wall -Wextra -Werror -Os -nostdlib -fno-omit-frame-pointer +CFLAGS := -Wall -Wextra -Werror -Os -nostdlib -fno-omit-frame-pointer -pedantic -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow CXXFLAGS := -fno-rtti -fno-exceptions ASMFLAGS := -felf64 diff --git a/libs/libc/src/bits/liballoc.c b/libs/libc/src/bits/liballoc.c index 824084f9..48d48631 100644 --- a/libs/libc/src/bits/liballoc.c +++ b/libs/libc/src/bits/liballoc.c @@ -25,22 +25,22 @@ #define ALIGN(ptr) \ if (ALIGNMENT > 1) \ { \ - uintptr_t diff; \ + uintptr_t align_diff; \ ptr = (void*)((uintptr_t)ptr + ALIGN_INFO); \ - diff = (uintptr_t)ptr & (ALIGNMENT - 1); \ - if (diff != 0) \ + align_diff = (uintptr_t)ptr & (ALIGNMENT - 1); \ + if (align_diff != 0) \ { \ - diff = ALIGNMENT - diff; \ - ptr = (void*)((uintptr_t)ptr + diff); \ + align_diff = ALIGNMENT - align_diff; \ + ptr = (void*)((uintptr_t)ptr + align_diff); \ } \ - *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)) = diff + ALIGN_INFO; \ + *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)) = align_diff + ALIGN_INFO; \ } #define UNALIGN(ptr) \ if (ALIGNMENT > 1) \ { \ - uintptr_t diff = *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)); \ - if (diff < (ALIGNMENT + ALIGN_INFO)) { ptr = (void*)((uintptr_t)ptr - diff); } \ + uintptr_t align_diff = *((ALIGN_TYPE*)((uintptr_t)ptr - ALIGN_INFO)); \ + if (align_diff < (ALIGNMENT + ALIGN_INFO)) { ptr = (void*)((uintptr_t)ptr - align_diff); } \ } #define LIBALLOC_MAGIC 0xc001c0de