diff --git a/sortix/ata.cpp b/sortix/ata.cpp index 5e49dcec..8fd9d5d0 100644 --- a/sortix/ata.cpp +++ b/sortix/ata.cpp @@ -118,7 +118,7 @@ ATABus::~ATABus() ATADrive* ATABus::Instatiate(unsigned driveid) { - if ( 1 < driveid ) { errno = EINVAL; return false; } + if ( 1 < driveid ) { errno = EINVAL; return NULL; } curdriveid = 0; uint8_t drivemagic = 0xA0 | (driveid << 4); @@ -132,12 +132,12 @@ ATADrive* ATABus::Instatiate(unsigned driveid) while ( true ) { status = CPU::InPortB(iobase + STATUS); - if ( !status || status == 0xFF ) { errno = ENODEV; return false; } + if ( !status || status == 0xFF ) { errno = ENODEV; return NULL; } if ( !(status & STATUS_BUSY) ) { break; } } if ( CPU::InPortB(iobase + LBA_MID) || CPU::InPortB(iobase + LBA_MID) ) { - errno = ENODEV; return false; // ATAPI device not following spec. + errno = ENODEV; return NULL; // ATAPI device not following spec. } while ( !(status & STATUS_DATAREADY) && !(status & STATUS_ERROR) ) { @@ -164,7 +164,7 @@ ATADrive* ATABus::Instatiate(unsigned driveid) //Log::PrintF("Error status during identify\n"); } errno = EIO; - return false; + return NULL; } ATADrive* drive = new ATADrive(this, driveid, iobase, altport); return drive; @@ -198,13 +198,24 @@ ATADrive::ATADrive(ATABus* bus, unsigned driveid, uint16_t portoffset, uint16_t meta[i] = CPU::InPortW(iobase + DATA); } lba48 = meta[META_FLAGS] & FLAG_LBA48; + numsectors = 0; if ( lba48 ) { - numsectors = *((uint64_t*) (meta + META_LBA48)); + numsectors = (uint64_t) meta[META_LBA48 + 0] << 0 + | (uint64_t) meta[META_LBA48 + 1] << 8 + | (uint64_t) meta[META_LBA48 + 2] << 16 + | (uint64_t) meta[META_LBA48 + 3] << 24 + | (uint64_t) meta[META_LBA48 + 4] << 32 + | (uint64_t) meta[META_LBA48 + 5] << 40 + | (uint64_t) meta[META_LBA48 + 6] << 48 + | (uint64_t) meta[META_LBA48 + 7] << 56; } else { - numsectors = *((uint32_t*) (meta + META_LBA28)); + numsectors = meta[META_LBA28 + 0] << 0 + | meta[META_LBA28 + 1] << 8 + | meta[META_LBA28 + 2] << 16 + | meta[META_LBA28 + 3] << 24; } sectorsize = 512; // TODO: Detect this! Initialize(); @@ -275,7 +286,7 @@ bool ATADrive::ReadSector(off_t sector, uint8_t* dest) destword[i] = CPU::InPortW(iobase + DATA); } Wait400NSecs(iobase); - uint8_t status = CPU::InPortB(iobase + STATUS); + CPU::InPortB(iobase + STATUS); return true; } diff --git a/sortix/descriptors.cpp b/sortix/descriptors.cpp index aa1f99f6..55ec36fc 100644 --- a/sortix/descriptors.cpp +++ b/sortix/descriptors.cpp @@ -88,8 +88,7 @@ namespace Sortix memcpy(newlist, devices, sizeof(*devices) * numdevices); } - size_t numpadded = newlistlength-numdevices; - for ( size_t i = numdevices; i < newlistlength; i++ ) + for ( int i = numdevices; i < newlistlength; i++ ) newlist[i].dev = NULL, newlist[i].path = NULL, newlist[i].flags = 0; diff --git a/sortix/elf.cpp b/sortix/elf.cpp index 0a9c2e21..d1060e32 100644 --- a/sortix/elf.cpp +++ b/sortix/elf.cpp @@ -140,6 +140,9 @@ namespace Sortix addr_t Construct64(Process* process, const void* file, size_t filelen) { #ifndef PLATFORM_X64 + (void) process; + (void) file; + (void) filelen; errno = ENOEXEC; return 0; #else diff --git a/sortix/initrd.cpp b/sortix/initrd.cpp index 0ab08543..ff88d97e 100644 --- a/sortix/initrd.cpp +++ b/sortix/initrd.cpp @@ -41,6 +41,7 @@ uint8_t* initrd; size_t initrdsize; const initrd_superblock_t* sb; +__attribute__((unused)) static uint32_t HostModeToInitRD(mode_t mode) { uint32_t result = mode & 0777; // Lower 9 bits per POSIX and tradition. @@ -55,6 +56,7 @@ static uint32_t HostModeToInitRD(mode_t mode) return result; } +__attribute__((unused)) static mode_t InitRDModeToHost(uint32_t mode) { mode_t result = mode & 0777; // Lower 9 bits per POSIX and tradition. diff --git a/sortix/kb/layout/us.cpp b/sortix/kb/layout/us.cpp index d4cb5973..f8ee9542 100644 --- a/sortix/kb/layout/us.cpp +++ b/sortix/kb/layout/us.cpp @@ -145,7 +145,7 @@ namespace Sortix // Check if the kbkey is outside the layout structure (not printable). size_t numchars = sizeof(LAYOUT_US) / 4UL / sizeof(uint32_t); - if ( numchars < abskbkey ) { return 0; } + if ( numchars < (size_t) abskbkey ) { return 0; } return LAYOUT_US[index]; } diff --git a/sortix/kernel.cpp b/sortix/kernel.cpp index 7271cfbf..9a64de31 100644 --- a/sortix/kernel.cpp +++ b/sortix/kernel.cpp @@ -122,6 +122,8 @@ static size_t TextTermHeight(void* user) extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo) { + (void) magic; + // Initialize system calls. Syscall::Init(); @@ -179,7 +181,7 @@ extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo) "multiboot compliant?"); } - addr_t initrd = NULL; + addr_t initrd = 0; size_t initrdsize = 0; uint32_t* modules = (uint32_t*) (addr_t) bootinfo->mods_addr; diff --git a/sortix/kthread.cpp b/sortix/kthread.cpp index be5076b1..1a478aeb 100644 --- a/sortix/kthread.cpp +++ b/sortix/kthread.cpp @@ -45,6 +45,7 @@ extern "C" void kthread_exit(void* /*param*/) { Worker::Schedule(kthread_do_kill_thread, CurrentThread()); Scheduler::ExitThread(); + __builtin_unreachable(); } struct kthread_cond_elem diff --git a/sortix/panic.cpp b/sortix/panic.cpp index bb44e297..b1d18e5e 100644 --- a/sortix/panic.cpp +++ b/sortix/panic.cpp @@ -94,12 +94,14 @@ namespace Sortix if ( ENABLE_CALLTRACE ) { PanicCalltrace(); } } + __attribute__((noreturn)) void PanicHalt() { #ifdef JSSORTIX JSSortix::Exit(); #endif HaltKernel(); + __builtin_unreachable(); } extern "C" void Panic(const char* Error) diff --git a/sortix/process.cpp b/sortix/process.cpp index 1bbf14ed..2408b708 100644 --- a/sortix/process.cpp +++ b/sortix/process.cpp @@ -510,6 +510,7 @@ namespace Sortix int envc, const char* const* envp, CPU::InterruptRegisters* regs) { + (void) programname; assert(CurrentProcess() == this); addr_t entry = ELF::Construct(CurrentProcess(), program, programsize); @@ -568,6 +569,8 @@ namespace Sortix DevBuffer* OpenProgramImage(const char* progname, const char* wd, const char* path) { + (void) wd; + (void) path; char* abs = Directory::MakeAbsolute("/", progname); if ( !abs ) { errno = ENOMEM; return NULL; } diff --git a/sortix/serialterminal.cpp b/sortix/serialterminal.cpp index 3642712f..e4295ac9 100644 --- a/sortix/serialterminal.cpp +++ b/sortix/serialterminal.cpp @@ -64,7 +64,7 @@ namespace Sortix int c; while ( (c=UART::TryPopChar()) != -1 ) { - #warning Support for hooking the serial input up against the keyboard API have broken + // TODO: Support for hooking the serial input up against the keyboard API have broken #if 0 // TODO: This is no longer compatible with the keyboard API, so // it has been commented out. Besides, JSSortix isn't really @@ -140,7 +140,7 @@ namespace Sortix size_t Print(void* /*user*/, const char* string, size_t stringlen) { - #warning Echoing to the VGA terminal is broken + // TODO: Echoing to the VGA terminal is broken #if 0 if ( ECHO_TO_VGA ) { VGATerminal::Print(NULL, string, stringlen); } #endif diff --git a/sortix/string.cpp b/sortix/string.cpp index 64fee9b0..698b5831 100644 --- a/sortix/string.cpp +++ b/sortix/string.cpp @@ -45,7 +45,6 @@ char* Clone(const char* Input) char* Substring(const char* src, size_t offset, size_t length) { - size_t srclen = strlen(src); char* dest = new char[length + 1]; if ( !dest ) { return NULL; } memcpy(dest, src + offset, length * sizeof(char)); diff --git a/sortix/x64/memorymanagement.cpp b/sortix/x64/memorymanagement.cpp index dc94cd96..7761599f 100644 --- a/sortix/x64/memorymanagement.cpp +++ b/sortix/x64/memorymanagement.cpp @@ -149,7 +149,7 @@ namespace Sortix Page::Lock(); // In case any pages wasn't cleaned at this point. -#warning Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet + // TODO: Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet RecursiveFreeUserspacePages(TOPPMLLEVEL, 0); // Switch to the address space from when the world was originally diff --git a/sortix/x86-family/gdt.cpp b/sortix/x86-family/gdt.cpp index 12dc797c..cff71250 100644 --- a/sortix/x86-family/gdt.cpp +++ b/sortix/x86-family/gdt.cpp @@ -136,6 +136,7 @@ namespace Sortix tss_entry.cs = 0x08 | 0x3; tss_entry.ss = tss_entry.ds = tss_entry.es = tss_entry.fs = tss_entry.gs = 0x10 | 0x3; #elif defined(PLATFORM_X64) + (void) ss0; tss_entry.stack0 = stack0; #endif } @@ -143,8 +144,12 @@ namespace Sortix void SetKernelStack(addr_t stacklower, size_t stacksize, addr_t stackhigher) { #ifdef PLATFORM_X86 + (void) stacklower; + (void) stacksize; tss_entry.esp0 = (uint32_t) stackhigher; #elif defined(PLATFORM_X64) + (void) stacklower; + (void) stacksize; tss_entry.stack0 = (uint64_t) stackhigher; #else #warning "TSS is not yet supported on this arch!" diff --git a/sortix/x86-family/memorymanagement.cpp b/sortix/x86-family/memorymanagement.cpp index a8352a10..4f39a8d2 100644 --- a/sortix/x86-family/memorymanagement.cpp +++ b/sortix/x86-family/memorymanagement.cpp @@ -136,8 +136,8 @@ namespace Sortix // Give all the physical memory to the physical memory allocator // but make sure not to give it things we already use. - addr_t regionstart = mmap->addr; - addr_t regionend = mmap->addr + mmap->len; + addr_t regionstart = base; + addr_t regionend = base + length; addr_t processed = regionstart; while ( processed < regionend ) { diff --git a/sortix/x86/memorymanagement.cpp b/sortix/x86/memorymanagement.cpp index aef26ebe..1019860a 100644 --- a/sortix/x86/memorymanagement.cpp +++ b/sortix/x86/memorymanagement.cpp @@ -46,7 +46,7 @@ namespace Sortix { PML* const BOOTPML2 = (PML* const) 0x11000UL; PML* const BOOTPML1 = (PML* const) 0x12000UL; - PML* const FORKPML1 = (PML* const) 0x13000UL; + //PML* const FORKPML1 = (PML* const) 0x13000UL; PML* const IDENPML1 = (PML* const) 0x14000UL; // Initialize the memory structures with zeroes. @@ -139,7 +139,7 @@ namespace Sortix Page::Lock(); // In case any pages wasn't cleaned at this point. -#warning Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet + // TODO: Page::Put calls may internally Page::Get and then reusing pages we are not done with just yet RecursiveFreeUserspacePages(TOPPMLLEVEL, 0); // Switch to the address space from when the world was originally