diff --git a/Kernel/Keyboard.cpp b/Kernel/Keyboard.cpp index 7251ead12d..2c41efb2a7 100644 --- a/Kernel/Keyboard.cpp +++ b/Kernel/Keyboard.cpp @@ -113,7 +113,6 @@ Keyboard::Keyboard() Keyboard::~Keyboard() { - ASSERT_NOT_REACHED(); } bool Keyboard::hasDataAvailableForRead() const @@ -124,7 +123,7 @@ bool Keyboard::hasDataAvailableForRead() const ssize_t Keyboard::read(byte* buffer, size_t size) { ssize_t nread = 0; - while (nread < size) { + while ((size_t)nread < size) { if (m_queue.isEmpty()) break; buffer[nread++] = m_queue.dequeue().character; @@ -132,7 +131,7 @@ ssize_t Keyboard::read(byte* buffer, size_t size) return nread; } -ssize_t Keyboard::write(const byte* data, size_t size) +ssize_t Keyboard::write(const byte*, size_t) { return 0; } diff --git a/Kernel/Makefile b/Kernel/Makefile index 0b001661e1..71eae660db 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -60,7 +60,7 @@ WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings FLAVOR_FLAGS = -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -SUGGEST_FLAGS = -Wsuggest-attribute=noreturn -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override +SUGGEST_FLAGS = -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override #-Wsuggest-attribute=noreturn DEFINES = -DSERENITY -DKERNEL -DSANITIZE_PTRS diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index d384870033..0223f2f4b8 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -111,7 +111,6 @@ Region* Process::allocate_file_backed_region(LinearAddress laddr, size_t size, R m_nextRegion = m_nextRegion.offset(size).offset(PAGE_SIZE); } laddr.mask(0xfffff000); - unsigned page_count = ceilDiv(size, PAGE_SIZE); m_regions.append(adopt(*new Region(laddr, size, move(vnode), move(name), is_readable, is_writable))); MM.mapRegion(*this, *m_regions.last()); return m_regions.last().ptr(); @@ -336,12 +335,14 @@ int Process::exec(const String& path, Vector&& arguments, Vector ELFLoader loader(region->linearAddress.asPtr()); loader.map_section_hook = [&] (LinearAddress laddr, size_t size, size_t alignment, size_t offset_in_image, bool is_readable, bool is_writable, const String& name) { ASSERT(size); + ASSERT(alignment == PAGE_SIZE); size = ((size / 4096) + 1) * 4096; // FIXME: Use ceil_div? (void) allocate_region_with_vmo(laddr, size, vmo.copyRef(), offset_in_image, String(name), is_readable, is_writable); return laddr.asPtr(); }; loader.alloc_section_hook = [&] (LinearAddress laddr, size_t size, size_t alignment, bool is_readable, bool is_writable, const String& name) { ASSERT(size); + ASSERT(alignment == PAGE_SIZE); size = ((size / 4096) + 1) * 4096; // FIXME: Use ceil_div? (void) allocate_region(laddr, size, String(name), is_readable, is_writable); return laddr.asPtr(); @@ -1149,7 +1150,7 @@ int Process::sys$open(const char* path, int options) return -ENOTDIR; // FIXME: This should be handled by VFS::open. int fd = 0; - for (; fd < m_max_open_file_descriptors; ++fd) { + for (; fd < (int)m_max_open_file_descriptors; ++fd) { if (!m_file_descriptors[fd]) break; } @@ -1268,6 +1269,8 @@ void Process::reap(Process& process) pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options) { + // FIXME: Respect options + (void) options; if (wstatus) VALIDATE_USER_WRITE(wstatus, sizeof(int)); @@ -1466,7 +1469,7 @@ int Process::sys$dup(int old_fd) if (number_of_open_file_descriptors() == m_max_open_file_descriptors) return -EMFILE; int new_fd = 0; - for (; new_fd < m_max_open_file_descriptors; ++new_fd) { + for (; new_fd < (int)m_max_open_file_descriptors; ++new_fd) { if (!m_file_descriptors[new_fd]) break; } @@ -1521,7 +1524,7 @@ int Process::sys$getgroups(int count, gid_t* gids) ASSERT(m_gids.size() < MAX_PROCESS_GIDS); if (!count) return m_gids.size(); - if (count != m_gids.size()) + if (count != (int)m_gids.size()) return -EINVAL; VALIDATE_USER_WRITE(gids, sizeof(gid_t) * count); size_t i = 0; diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index bbdf421c63..be71de1f1d 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -30,7 +30,7 @@ char* strrchr(const char* str, int ch) char c; for (; (c = *str); ++str) { if (c == ch) - last = (char*)str; + last = const_cast(str); } return last; } @@ -71,6 +71,7 @@ int memcmp(const void* v1, const void* v2, size_t n) return 0; } +extern "C" void __cxa_pure_virtual() NORETURN; extern "C" void __cxa_pure_virtual() { ASSERT_NOT_REACHED(); diff --git a/Kernel/TTY.cpp b/Kernel/TTY.cpp index 2ad8c50a72..7aa0dd0db8 100644 --- a/Kernel/TTY.cpp +++ b/Kernel/TTY.cpp @@ -15,7 +15,7 @@ ssize_t TTY::read(byte* buffer, size_t size) { ssize_t nread = min(m_buffer.size(), size); memcpy(buffer, m_buffer.data(), nread); - if (nread == m_buffer.size()) + if (nread == (ssize_t)m_buffer.size()) m_buffer.clear(); else { dbgprintf("had %u, read %u\n", m_buffer.size(), nread); diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp index fd74ff90e2..13a9addf71 100644 --- a/Kernel/i386.cpp +++ b/Kernel/i386.cpp @@ -138,6 +138,7 @@ void exception_6_handler(RegisterDump& regs) } kprintf("pc=%w:%x ds=%w es=%w fs=%w gs=%w\n", regs.cs, regs.eip, regs.ds, regs.es, regs.fs, regs.gs); + kprintf("stk=%w:%x\n", ss, esp); kprintf("eax=%x ebx=%x ecx=%x edx=%x\n", regs.eax, regs.ebx, regs.ecx, regs.edx); kprintf("ebp=%x esp=%x esi=%x edi=%x\n", regs.ebp, esp, regs.esi, regs.edi); @@ -168,6 +169,7 @@ void exception_13_handler(RegisterDumpWithExceptionCode& regs) kprintf("exception code: %w\n", regs.exception_code); kprintf("pc=%w:%x ds=%w es=%w fs=%w gs=%w\n", regs.cs, regs.eip, regs.ds, regs.es, regs.fs, regs.gs); + kprintf("stk=%w:%x\n", ss, esp); kprintf("eax=%x ebx=%x ecx=%x edx=%x\n", regs.eax, regs.ebx, regs.ecx, regs.edx); kprintf("ebp=%x esp=%x esi=%x edi=%x\n", regs.ebp, esp, regs.esi, regs.edi); @@ -276,15 +278,12 @@ EH(2, "Unknown error") EH(3, "Breakpoint") EH(4, "Overflow") EH(5, "Bounds check") -EH(6, "Invalid opcode") EH(7, "Coprocessor not available") EH(8, "Double fault") EH(9, "Coprocessor segment overrun") EH(10, "Invalid TSS") EH(11, "Segment not present") EH(12, "Stack exception") -EH(13, "General protection fault") -EH(14, "Page fault") EH(15, "Unknown error") EH(16, "Coprocessor error") @@ -442,7 +441,7 @@ void handleIRQ() return; } - byte irq; + byte irq = 0; for (byte i = 0; i < 16; ++i) { if (isr & (1 << i)) { irq = i; @@ -460,4 +459,5 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const asm volatile("cli"); kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func); asm volatile("hlt"); + for (;;); } diff --git a/Kernel/init.cpp b/Kernel/init.cpp index fdea163f6f..216e93983c 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -59,7 +59,7 @@ Vector& ksyms() return *s_ksyms; } -volatile bool ksyms_ready() +bool ksyms_ready() { return s_ksyms_ready; } @@ -107,7 +107,6 @@ void dump_backtrace(bool use_ksyms) HANG; return; } - extern volatile bool ksyms_ready(); if (use_ksyms && !ksyms_ready()) { HANG; return; @@ -141,6 +140,7 @@ void dump_backtrace(bool use_ksyms) } #endif +#ifdef STRESS_TEST_SPAWNING static void spawn_stress() NORETURN; static void spawn_stress() { @@ -158,6 +158,7 @@ static void spawn_stress() asm volatile("hlt"); } } +#endif static void init_stage2() NORETURN; static void init_stage2() @@ -247,6 +248,7 @@ static void init_stage2() ASSERT_NOT_REACHED(); } +void init() NORETURN; void init() { cli(); diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index 71123c537e..7f8446e34c 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -47,7 +47,7 @@ bool is_kmalloc_address(void* ptr) return true; if (ptr >= (byte*)PAGE_ALIGNED_BASE_PHYSICAL && ptr < s_next_page_aligned_ptr) return true; - return ptr >= (void*)BASE_PHYS && ptr <= ((void*)BASE_PHYS + POOL_SIZE); + return (dword)ptr >= BASE_PHYS && (dword)ptr <= (BASE_PHYS + POOL_SIZE); } void kmalloc_init() diff --git a/VirtualFileSystem/FileSystem.cpp b/VirtualFileSystem/FileSystem.cpp index 3260f76662..84bb76b8ac 100644 --- a/VirtualFileSystem/FileSystem.cpp +++ b/VirtualFileSystem/FileSystem.cpp @@ -84,13 +84,13 @@ ByteBuffer FileSystem::readEntireInode(InodeIdentifier inode, FileDescriptor* ha for (;;) { nread = readInodeBytes(inode, offset, sizeof(buffer), buffer, handle); //kprintf("nread: %u, bufsiz: %u, initialSize: %u\n", nread, sizeof(buffer), initialSize); - ASSERT(nread <= sizeof(buffer)); + ASSERT(nread <= (Unix::ssize_t)sizeof(buffer)); if (nread <= 0) break; memcpy(out, buffer, nread); out += nread; offset += nread; - ASSERT(offset <= initialSize); // FIXME: Support dynamically growing the buffer. + ASSERT(offset <= (Unix::ssize_t)initialSize); // FIXME: Support dynamically growing the buffer. } if (nread < 0) { kprintf("[fs] readInode: ERROR: %d\n", nread); diff --git a/VirtualFileSystem/VirtualFileSystem.cpp b/VirtualFileSystem/VirtualFileSystem.cpp index 31cdf58d2e..18acf73d46 100644 --- a/VirtualFileSystem/VirtualFileSystem.cpp +++ b/VirtualFileSystem/VirtualFileSystem.cpp @@ -398,6 +398,8 @@ bool VirtualFileSystem::touch(const String& path) RetainPtr VirtualFileSystem::open(CharacterDevice& device, int options) { + // FIXME: Respect options. + (void) options; auto vnode = getOrCreateNode(device); if (!vnode) return nullptr; @@ -419,6 +421,7 @@ RetainPtr VirtualFileSystem::create(const String& path, InodeIde { // FIXME: Do the real thing, not just this fake thing! (void) path; + (void) base; m_rootNode->fileSystem()->createInode(m_rootNode->fileSystem()->rootInode(), "empty", 0100644, 0); return nullptr; } @@ -427,6 +430,7 @@ RetainPtr VirtualFileSystem::mkdir(const String& path, InodeIden { // FIXME: Do the real thing, not just this fake thing! (void) path; + (void) base; m_rootNode->fileSystem()->makeDirectory(m_rootNode->fileSystem()->rootInode(), "mydir", 0400755); return nullptr; }