From cddf0426e31d8359a267954069eba7853526c719 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 21 Dec 2022 20:05:57 +0200 Subject: [PATCH] Fixed compiler warnings --- ...dvancedProgrammableInterruptController.cpp | 2 +- .../amd64/cpu/GlobalDescriptorTable.cpp | 1 + .../amd64/cpu/InterruptDescriptorTable.cpp | 1 + Architecture/amd64/runtime/crt1.c | 1 + Core/Crash/CrashDetails.cpp | 99 ++++- Core/Crash/KBDrv.cpp | 1 + Core/Crash/Screens/Console.cpp | 1 + Core/Debugger.cpp | 2 +- Core/Driver/Driver.cpp | 1 + Core/Driver/DriverAPI.cpp | 10 + Core/Driver/DriverLoading/BindInput.cpp | 2 + Core/Driver/DriverLoading/BindInterrupt.cpp | 1 + Core/Driver/DriverLoading/BindPCI.cpp | 1 + Core/Driver/DriverLoading/BindProcess.cpp | 3 + Core/Memory/Memory.cpp | 2 + Core/UndefinedBehaviorSanitization.c | 347 +++++++++++++++--- FileSystem/Filesystem.cpp | 2 - KConfig.cpp | 7 +- Library/printf.c | 2 +- Profiling/cyg.cpp | 2 +- Profiling/gcov.cpp | 6 +- Profiling/gprof.cpp | 4 +- SystemCalls/Native.cpp | 9 + Tasking/InterProcessCommunication.cpp | 3 + Tasking/Security.cpp | 2 + include/cpu.hpp | 12 +- include/disk.hpp | 36 +- include/uart.hpp | 4 +- 28 files changed, 483 insertions(+), 81 deletions(-) diff --git a/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp b/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp index f4e25f9..31da043 100644 --- a/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp +++ b/Architecture/amd64/cpu/AdvancedProgrammableInterruptController.cpp @@ -301,7 +301,7 @@ namespace APIC APIC::~APIC() {} - void Timer::OnInterruptReceived(TrapFrame *Frame) {} + void Timer::OnInterruptReceived(TrapFrame *Frame) { UNUSED(Frame); } void Timer::OneShot(uint32_t Vector, uint64_t Miliseconds) { diff --git a/Architecture/amd64/cpu/GlobalDescriptorTable.cpp b/Architecture/amd64/cpu/GlobalDescriptorTable.cpp index 0628182..77fc100 100644 --- a/Architecture/amd64/cpu/GlobalDescriptorTable.cpp +++ b/Architecture/amd64/cpu/GlobalDescriptorTable.cpp @@ -85,6 +85,7 @@ namespace GlobalDescriptorTable {0, 0, 0, 0, 0, 0, 0}, 0, 0, + 0, }; void *CPUStackPointer[MAX_CPU]; diff --git a/Architecture/amd64/cpu/InterruptDescriptorTable.cpp b/Architecture/amd64/cpu/InterruptDescriptorTable.cpp index 794b96e..e14f2ab 100644 --- a/Architecture/amd64/cpu/InterruptDescriptorTable.cpp +++ b/Architecture/amd64/cpu/InterruptDescriptorTable.cpp @@ -487,6 +487,7 @@ namespace InterruptDescriptorTable void Init(int Core) { + UNUSED(Core); static int once = 0; if (!once++) { diff --git a/Architecture/amd64/runtime/crt1.c b/Architecture/amd64/runtime/crt1.c index 5238647..17a6144 100644 --- a/Architecture/amd64/runtime/crt1.c +++ b/Architecture/amd64/runtime/crt1.c @@ -6,6 +6,7 @@ int Entry(void *Info); void _start(void *Raw) { + UNUSED(Raw); error("ERROR! INVALID BOOT PROTOCOL!"); while (1) asmv("hlt"); diff --git a/Core/Crash/CrashDetails.cpp b/Core/Crash/CrashDetails.cpp index 63e7a05..e25b80e 100644 --- a/Core/Crash/CrashDetails.cpp +++ b/Core/Crash/CrashDetails.cpp @@ -28,26 +28,65 @@ static const char *PageFaultDescriptions[8] = { SafeFunction void DivideByZeroExceptionHandler(CHArchTrapFrame *Frame) { fixme("Divide by zero exception\n"); + UNUSED(Frame); } SafeFunction void DebugExceptionHandler(CHArchTrapFrame *Frame) { CrashHandler::EHPrint("\eDD2920System crashed!\n"); CrashHandler::EHPrint("Kernel triggered debug exception.\n"); + UNUSED(Frame); +} +SafeFunction void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("NMI exception"); + UNUSED(Frame); +} +SafeFunction void BreakpointExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Breakpoint exception"); + UNUSED(Frame); +} +SafeFunction void OverflowExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Overflow exception"); + UNUSED(Frame); +} +SafeFunction void BoundRangeExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Bound range exception"); + UNUSED(Frame); } -SafeFunction void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame) { fixme("NMI exception"); } -SafeFunction void BreakpointExceptionHandler(CHArchTrapFrame *Frame) { fixme("Breakpoint exception"); } -SafeFunction void OverflowExceptionHandler(CHArchTrapFrame *Frame) { fixme("Overflow exception"); } -SafeFunction void BoundRangeExceptionHandler(CHArchTrapFrame *Frame) { fixme("Bound range exception"); } SafeFunction void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame) { CrashHandler::EHPrint("\eDD2920System crashed!\n"); CrashHandler::EHPrint("Kernel tried to execute an invalid opcode.\n"); + UNUSED(Frame); +} +SafeFunction void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Device not available exception"); + UNUSED(Frame); +} +SafeFunction void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Double fault exception"); + UNUSED(Frame); +} +SafeFunction void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Coprocessor segment overrun exception"); + UNUSED(Frame); +} +SafeFunction void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Invalid TSS exception"); + UNUSED(Frame); +} +SafeFunction void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Segment not present exception"); + UNUSED(Frame); } -SafeFunction void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame) { fixme("Device not available exception"); } -SafeFunction void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame) { fixme("Double fault exception"); } -SafeFunction void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame) { fixme("Coprocessor segment overrun exception"); } -SafeFunction void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame) { fixme("Invalid TSS exception"); } -SafeFunction void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame) { fixme("Segment not present exception"); } SafeFunction void StackFaultExceptionHandler(CHArchTrapFrame *Frame) { CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode}; @@ -229,10 +268,38 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame) } #endif } -SafeFunction void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame) { fixme("x87 floating point exception"); } -SafeFunction void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame) { fixme("Alignment check exception"); } -SafeFunction void MachineCheckExceptionHandler(CHArchTrapFrame *Frame) { fixme("Machine check exception"); } -SafeFunction void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame) { fixme("SIMD floating point exception"); } -SafeFunction void VirtualizationExceptionHandler(CHArchTrapFrame *Frame) { fixme("Virtualization exception"); } -SafeFunction void SecurityExceptionHandler(CHArchTrapFrame *Frame) { fixme("Security exception"); } -SafeFunction void UnknownExceptionHandler(CHArchTrapFrame *Frame) { fixme("Unknown exception"); } +SafeFunction void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("x87 floating point exception"); + UNUSED(Frame); +} +SafeFunction void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Alignment check exception"); + UNUSED(Frame); +} +SafeFunction void MachineCheckExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Machine check exception"); + UNUSED(Frame); +} +SafeFunction void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("SIMD floating point exception"); + UNUSED(Frame); +} +SafeFunction void VirtualizationExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Virtualization exception"); + UNUSED(Frame); +} +SafeFunction void SecurityExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Security exception"); + UNUSED(Frame); +} +SafeFunction void UnknownExceptionHandler(CHArchTrapFrame *Frame) +{ + fixme("Unknown exception"); + UNUSED(Frame); +} diff --git a/Core/Crash/KBDrv.cpp b/Core/Crash/KBDrv.cpp index ad0c6e9..fb159e1 100644 --- a/Core/Crash/KBDrv.cpp +++ b/Core/Crash/KBDrv.cpp @@ -110,6 +110,7 @@ namespace CrashHandler SafeFunction void CrashKeyboardDriver::OnInterruptReceived(void *Frame) #endif { + UNUSED(Frame); uint8_t scanCode = inb(0x60); if (scanCode == KEY_D_TAB || scanCode == KEY_D_LCTRL || diff --git a/Core/Crash/Screens/Console.cpp b/Core/Crash/Screens/Console.cpp index af3df4e..df99509 100644 --- a/Core/Crash/Screens/Console.cpp +++ b/Core/Crash/Screens/Console.cpp @@ -20,5 +20,6 @@ namespace CrashHandler SafeFunction void DisplayConsoleScreen(CRData data) { EHPrint("TODO"); + UNUSED(data); } } \ No newline at end of file diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index fad3c04..4b20527 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -11,7 +11,7 @@ using namespace UniversalAsynchronousReceiverTransmitter; static inline __no_instrument_function void uart_wrapper(char c, void *unused) { UART(COM1).Write(c); - (void)unused; + UNUSED(unused); } static inline __no_instrument_function void WritePrefix(DebugLevel Level, const char *File, int Line, const char *Function) diff --git a/Core/Driver/Driver.cpp b/Core/Driver/Driver.cpp index 41971d5..44be611 100644 --- a/Core/Driver/Driver.cpp +++ b/Core/Driver/Driver.cpp @@ -197,6 +197,7 @@ namespace Driver { SmartCriticalSection(DriverInterruptLock); ((int (*)(void *))(Handle))(Data); + UNUSED(Frame); } DriverInterruptHook::DriverInterruptHook(int Interrupt, void *Address, void *ParamData) : Interrupts::Handler(Interrupt) diff --git a/Core/Driver/DriverAPI.cpp b/Core/Driver/DriverAPI.cpp index 6f11546..8bda3c7 100644 --- a/Core/Driver/DriverAPI.cpp +++ b/Core/Driver/DriverAPI.cpp @@ -69,25 +69,35 @@ void *Drivermemset(void *Destination, int Value, unsigned long Size) void DriverNetSend(unsigned int DriverID, unsigned char *Data, unsigned short Size) { DumpData("DriverNetSend", Data, Size); + UNUSED(DriverID); } void DriverNetReceive(unsigned int DriverID, unsigned char *Data, unsigned short Size) { DumpData("DriverNetReceive", Data, Size); + UNUSED(DriverID); } void DriverAHCIDiskRead(unsigned int DriverID, unsigned long Sector, unsigned char *Data, unsigned int SectorCount, unsigned char Port) { DumpData("DriverDiskRead", Data, SectorCount * 512); + UNUSED(DriverID); + UNUSED(Sector); + UNUSED(Port); } void DriverAHCIDiskWrite(unsigned int DriverID, unsigned long Sector, unsigned char *Data, unsigned int SectorCount, unsigned char Port) { DumpData("DriverDiskWrite", Data, SectorCount * 512); + UNUSED(DriverID); + UNUSED(Sector); + UNUSED(Port); } char *DriverPCIGetDeviceName(unsigned int VendorID, unsigned int DeviceID) { + UNUSED(VendorID); + UNUSED(DeviceID); return (char *)"Unknown"; } diff --git a/Core/Driver/DriverLoading/BindInput.cpp b/Core/Driver/DriverLoading/BindInput.cpp index fc43eb2..efd31e3 100644 --- a/Core/Driver/DriverLoading/BindInput.cpp +++ b/Core/Driver/DriverLoading/BindInput.cpp @@ -16,6 +16,8 @@ namespace Driver { DriverCode Driver::DriverLoadBindInput(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf) { + UNUSED(DrvExtHdr); + UNUSED(IsElf); Memory::Tracker *Tracker = new Memory::Tracker; Fex *fex = (Fex *)Tracker->RequestPages(TO_PAGES(Size)); memcpy(fex, (void *)DriverAddress, Size); diff --git a/Core/Driver/DriverLoading/BindInterrupt.cpp b/Core/Driver/DriverLoading/BindInterrupt.cpp index a498c91..6feceab 100644 --- a/Core/Driver/DriverLoading/BindInterrupt.cpp +++ b/Core/Driver/DriverLoading/BindInterrupt.cpp @@ -16,6 +16,7 @@ namespace Driver { DriverCode Driver::DriverLoadBindInterrupt(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf) { + UNUSED(IsElf); Memory::Tracker *Tracker = new Memory::Tracker; Fex *fex = (Fex *)Tracker->RequestPages(TO_PAGES(Size)); memcpy(fex, (void *)DriverAddress, Size); diff --git a/Core/Driver/DriverLoading/BindPCI.cpp b/Core/Driver/DriverLoading/BindPCI.cpp index 5deba70..832211d 100644 --- a/Core/Driver/DriverLoading/BindPCI.cpp +++ b/Core/Driver/DriverLoading/BindPCI.cpp @@ -16,6 +16,7 @@ namespace Driver { DriverCode Driver::DriverLoadBindPCI(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf) { + UNUSED(IsElf); for (unsigned long Vidx = 0; Vidx < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID[0]); Vidx++) for (unsigned long Didx = 0; Didx < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID[0]); Didx++) { diff --git a/Core/Driver/DriverLoading/BindProcess.cpp b/Core/Driver/DriverLoading/BindProcess.cpp index f4b61c3..abd6593 100644 --- a/Core/Driver/DriverLoading/BindProcess.cpp +++ b/Core/Driver/DriverLoading/BindProcess.cpp @@ -17,6 +17,9 @@ namespace Driver DriverCode Driver::DriverLoadBindProcess(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf) { fixme("Process driver: %s", ((FexExtended *)DrvExtHdr)->Driver.Name); + UNUSED(Size); + UNUSED(DriverAddress); + UNUSED(IsElf); return DriverCode::NOT_IMPLEMENTED; } } diff --git a/Core/Memory/Memory.cpp b/Core/Memory/Memory.cpp index fd1dc24..1b473d1 100644 --- a/Core/Memory/Memory.cpp +++ b/Core/Memory/Memory.cpp @@ -346,8 +346,10 @@ void operator delete[](void *Pointer) void operator delete(void *Pointer, long unsigned int Size) { HeapFree(Pointer); + UNUSED(Size); } void operator delete[](void *Pointer, long unsigned int Size) { HeapFree(Pointer); + UNUSED(Size); } diff --git a/Core/UndefinedBehaviorSanitization.c b/Core/UndefinedBehaviorSanitization.c index 3708094..16e65e9 100644 --- a/Core/UndefinedBehaviorSanitization.c +++ b/Core/UndefinedBehaviorSanitization.c @@ -30,63 +30,313 @@ __ubsan_handle_pointer_overflow_abort __ubsan_handle_cfi_check_fail */ -extern void __asan_report_load1(void *unknown) { ubsan("load1"); } -extern void __asan_report_load2(void *unknown) { ubsan("load2"); } -extern void __asan_report_load4(void *unknown) { ubsan("load4"); } -extern void __asan_report_load8(void *unknown) { ubsan("load8"); } -extern void __asan_report_load16(void *unknown) { ubsan("load16"); } -extern void __asan_report_load_n(void *unknown, uintptr_t size) { ubsan("loadn"); } +extern void __asan_report_load1(void *unknown) +{ + ubsan("load1"); + UNUSED(unknown); +} -extern void __asan_report_store1(void *unknown) { ubsan("store1"); } -extern void __asan_report_store2(void *unknown) { ubsan("store2"); } -extern void __asan_report_store4(void *unknown) { ubsan("store4"); } -extern void __asan_report_store8(void *unknown) { ubsan("store8"); } -extern void __asan_report_store16(void *unknown) { ubsan("store16"); } -extern void __asan_report_store_n(void *unknown, uintptr_t size) { ubsan("storen"); } +extern void __asan_report_load2(void *unknown) +{ + ubsan("load2"); + UNUSED(unknown); +} -extern void __asan_report_load1_noabort(void *unknown) { ubsan("load1"); } -extern void __asan_report_load2_noabort(void *unknown) { ubsan("load2"); } -extern void __asan_report_load4_noabort(void *unknown) { ubsan("load4"); } -extern void __asan_report_load8_noabort(void *unknown) { ubsan("load8"); } -extern void __asan_report_load16_noabort(void *unknown) { ubsan("load16"); } -extern void __asan_report_load_n_noabort(void *unknown, uintptr_t size) { ubsan("loadn"); } +extern void __asan_report_load4(void *unknown) +{ + ubsan("load4"); + UNUSED(unknown); +} -extern void __asan_report_store1_noabort(void *unknown) { ubsan("store1"); } -extern void __asan_report_store2_noabort(void *unknown) { ubsan("store2"); } -extern void __asan_report_store4_noabort(void *unknown) { ubsan("store4"); } -extern void __asan_report_store8_noabort(void *unknown) { ubsan("store8"); } -extern void __asan_report_store16_noabort(void *unknown) { ubsan("store16"); } -extern void __asan_report_store_n_noabort(void *unknown, uintptr_t size) { ubsan("storen"); } +extern void __asan_report_load8(void *unknown) +{ + ubsan("load8"); + UNUSED(unknown); +} -extern void __asan_stack_malloc_0(uintptr_t size) { ubsan("stack malloc 0"); } -extern void __asan_stack_malloc_1(uintptr_t size) { ubsan("stack malloc 1"); } -extern void __asan_stack_malloc_2(uintptr_t size) { ubsan("stack malloc 2"); } -extern void __asan_stack_malloc_3(uintptr_t size) { ubsan("stack malloc 3"); } -extern void __asan_stack_malloc_4(uintptr_t size) { ubsan("stack malloc 4"); } -extern void __asan_stack_malloc_5(uintptr_t size) { ubsan("stack malloc 5"); } -extern void __asan_stack_malloc_6(uintptr_t size) { ubsan("stack malloc 6"); } -extern void __asan_stack_malloc_7(uintptr_t size) { ubsan("stack malloc 7"); } -extern void __asan_stack_malloc_8(uintptr_t size) { ubsan("stack malloc 8"); } -extern void __asan_stack_malloc_9(uintptr_t size) { ubsan("stack malloc 9"); } +extern void __asan_report_load16(void *unknown) +{ + ubsan("load16"); + UNUSED(unknown); +} -extern void __asan_stack_free_0(void *ptr, uintptr_t size) { ubsan("stack free 0"); } -extern void __asan_stack_free_1(void *ptr, uintptr_t size) { ubsan("stack free 1"); } -extern void __asan_stack_free_2(void *ptr, uintptr_t size) { ubsan("stack free 2"); } -extern void __asan_stack_free_3(void *ptr, uintptr_t size) { ubsan("stack free 3"); } -extern void __asan_stack_free_4(void *ptr, uintptr_t size) { ubsan("stack free 4"); } -extern void __asan_stack_free_5(void *ptr, uintptr_t size) { ubsan("stack free 5"); } -extern void __asan_stack_free_6(void *ptr, uintptr_t size) { ubsan("stack free 6"); } -extern void __asan_stack_free_7(void *ptr, uintptr_t size) { ubsan("stack free 7"); } -extern void __asan_stack_free_8(void *ptr, uintptr_t size) { ubsan("stack free 8"); } -extern void __asan_stack_free_9(void *ptr, uintptr_t size) { ubsan("stack free 9"); } +extern void __asan_report_load_n(void *unknown, uintptr_t size) +{ + ubsan("loadn"); + UNUSED(unknown); + UNUSED(size); +} -extern void __asan_poison_stack_memory(void *addr, uintptr_t size) { ubsan("poison stack memory"); } -extern void __asan_unpoison_stack_memory(void *addr, uintptr_t size) { ubsan("unpoison stack memory"); } +extern void __asan_report_store1(void *unknown) +{ + ubsan("store1"); + UNUSED(unknown); +} + +extern void __asan_report_store2(void *unknown) +{ + ubsan("store2"); + UNUSED(unknown); +} + +extern void __asan_report_store4(void *unknown) +{ + ubsan("store4"); + UNUSED(unknown); +} + +extern void __asan_report_store8(void *unknown) +{ + ubsan("store8"); + UNUSED(unknown); +} + +extern void __asan_report_store16(void *unknown) +{ + ubsan("store16"); + UNUSED(unknown); +} + +extern void __asan_report_store_n(void *unknown, uintptr_t size) +{ + ubsan("storen"); + UNUSED(unknown); + UNUSED(size); +} + +extern void __asan_report_load1_noabort(void *unknown) +{ + ubsan("load1"); + UNUSED(unknown); +} + +extern void __asan_report_load2_noabort(void *unknown) +{ + ubsan("load2"); + UNUSED(unknown); +} + +extern void __asan_report_load4_noabort(void *unknown) +{ + ubsan("load4"); + UNUSED(unknown); +} + +extern void __asan_report_load8_noabort(void *unknown) +{ + ubsan("load8"); + UNUSED(unknown); +} + +extern void __asan_report_load16_noabort(void *unknown) +{ + ubsan("load16"); + UNUSED(unknown); +} + +extern void __asan_report_load_n_noabort(void *unknown, uintptr_t size) +{ + ubsan("loadn"); + UNUSED(unknown); + UNUSED(size); +} + +extern void __asan_report_store1_noabort(void *unknown) +{ + ubsan("store1"); + UNUSED(unknown); +} + +extern void __asan_report_store2_noabort(void *unknown) +{ + ubsan("store2"); + UNUSED(unknown); +} + +extern void __asan_report_store4_noabort(void *unknown) +{ + ubsan("store4"); + UNUSED(unknown); +} + +extern void __asan_report_store8_noabort(void *unknown) +{ + ubsan("store8"); + UNUSED(unknown); +} + +extern void __asan_report_store16_noabort(void *unknown) +{ + ubsan("store16"); + UNUSED(unknown); +} + +extern void __asan_report_store_n_noabort(void *unknown, uintptr_t size) +{ + ubsan("storen"); + UNUSED(unknown); + UNUSED(size); +} + +extern void __asan_stack_malloc_0(uintptr_t size) +{ + ubsan("stack malloc 0"); + UNUSED(size); +} + +extern void __asan_stack_malloc_1(uintptr_t size) +{ + ubsan("stack malloc 1"); + UNUSED(size); +} + +extern void __asan_stack_malloc_2(uintptr_t size) +{ + ubsan("stack malloc 2"); + UNUSED(size); +} + +extern void __asan_stack_malloc_3(uintptr_t size) +{ + ubsan("stack malloc 3"); + UNUSED(size); +} + +extern void __asan_stack_malloc_4(uintptr_t size) +{ + ubsan("stack malloc 4"); + UNUSED(size); +} + +extern void __asan_stack_malloc_5(uintptr_t size) +{ + ubsan("stack malloc 5"); + UNUSED(size); +} + +extern void __asan_stack_malloc_6(uintptr_t size) +{ + ubsan("stack malloc 6"); + UNUSED(size); +} + +extern void __asan_stack_malloc_7(uintptr_t size) +{ + ubsan("stack malloc 7"); + UNUSED(size); +} + +extern void __asan_stack_malloc_8(uintptr_t size) +{ + ubsan("stack malloc 8"); + UNUSED(size); +} + +extern void __asan_stack_malloc_9(uintptr_t size) +{ + ubsan("stack malloc 9"); + UNUSED(size); +} + +extern void __asan_stack_free_0(void *ptr, uintptr_t size) +{ + ubsan("stack free 0"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_1(void *ptr, uintptr_t size) +{ + ubsan("stack free 1"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_2(void *ptr, uintptr_t size) +{ + ubsan("stack free 2"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_3(void *ptr, uintptr_t size) +{ + ubsan("stack free 3"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_4(void *ptr, uintptr_t size) +{ + ubsan("stack free 4"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_5(void *ptr, uintptr_t size) +{ + ubsan("stack free 5"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_6(void *ptr, uintptr_t size) +{ + ubsan("stack free 6"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_7(void *ptr, uintptr_t size) +{ + ubsan("stack free 7"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_8(void *ptr, uintptr_t size) +{ + ubsan("stack free 8"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_stack_free_9(void *ptr, uintptr_t size) +{ + ubsan("stack free 9"); + UNUSED(ptr); + UNUSED(size); +} + +extern void __asan_poison_stack_memory(void *addr, uintptr_t size) +{ + ubsan("poison stack memory"); + UNUSED(addr); + UNUSED(size); +} + +extern void __asan_unpoison_stack_memory(void *addr, uintptr_t size) +{ + ubsan("unpoison stack memory"); + UNUSED(addr); + UNUSED(size); +} + +extern void __asan_before_dynamic_init(const char *module_name) +{ + ubsan("before dynamic init"); + UNUSED(module_name); +} -extern void __asan_before_dynamic_init(const char *module_name) { ubsan("before dynamic init"); } extern void __asan_after_dynamic_init(void) { ubsan("after dynamic init"); } -extern void __asan_register_globals(void *unknown, size_t size) { ubsan("register_globals"); } +extern void __asan_register_globals(void *unknown, size_t size) +{ + ubsan("register_globals"); + UNUSED(unknown); + UNUSED(size); +} + extern void __asan_unregister_globals(void) { ubsan("unregister_globals"); } extern void __asan_init(void) { ubsan("init"); } @@ -291,4 +541,5 @@ void __ubsan_handle_dynamic_type_cache_miss(struct dynamic_type_cache_miss_data { if (UBSANMsg(data->location.file, data->location.line, data->location.column)) ubsan("Dynamic type cache miss."); + UNUSED(ptr); } \ No newline at end of file diff --git a/FileSystem/Filesystem.cpp b/FileSystem/Filesystem.cpp index 40b131b..140cc25 100644 --- a/FileSystem/Filesystem.cpp +++ b/FileSystem/Filesystem.cpp @@ -320,7 +320,6 @@ namespace FileSystem if (strcmp(Path, ".") == 0) { FILE *file = new FILE; - FileStatus filestatus = FileStatus::OK; file->Node = Parent; if (unlikely(!file->Node)) file->Status = FileStatus::NOT_FOUND; @@ -336,7 +335,6 @@ namespace FileSystem Parent = Parent->Parent; FILE *file = new FILE; - FileStatus filestatus = FileStatus::OK; file->Node = Parent; if (!file->Node) file->Status = FileStatus::NOT_FOUND; diff --git a/KConfig.cpp b/KConfig.cpp index 2817e80..dcc4a16 100644 --- a/KConfig.cpp +++ b/KConfig.cpp @@ -13,10 +13,15 @@ EXTERNC void fprintf(FILE *stream, const char *Format, ...) va_start(args, Format); vprintf_(Format, args); va_end(args); + UNUSED(stream); } // TODO: Implement proper fputs -EXTERNC void fputs(const char *s, FILE *stream) { printf_("%s", s); } +EXTERNC void fputs(const char *s, FILE *stream) +{ + printf_("%s", s); + UNUSED(stream); +} static struct cag_option ConfigOptions[] = { {.identifier = 'a', diff --git a/Library/printf.c b/Library/printf.c index e61d33f..db423e0 100644 --- a/Library/printf.c +++ b/Library/printf.c @@ -358,8 +358,8 @@ static inline __no_instrument_function void append_termination_with_gadget(outpu // only takes pointers to functions with an extra argument static inline __no_instrument_function void putchar_wrapper(char c, void *unused) { - (void)unused; putchar(c); + UNUSED(unused); } static inline __no_instrument_function output_gadget_t discarding_gadget(void) diff --git a/Profiling/cyg.cpp b/Profiling/cyg.cpp index 6814edc..909e715 100644 --- a/Profiling/cyg.cpp +++ b/Profiling/cyg.cpp @@ -15,7 +15,7 @@ static inline SafeFunction __no_instrument_function void profiler_uart_wrapper(c bool renable = EnableProfiler; EnableProfiler = false; UART(COM2).Write(c); - (void)unused; + UNUSED(unused); if (renable) EnableProfiler = true; } diff --git a/Profiling/gcov.cpp b/Profiling/gcov.cpp index 7769e8d..ad03c30 100644 --- a/Profiling/gcov.cpp +++ b/Profiling/gcov.cpp @@ -41,7 +41,7 @@ struct gcov_info static inline SafeFunction __no_instrument_function void gcov_uart_wrapper(char c, void *unused) { UART(COM2).Write(c); - (void)unused; + UNUSED(unused); } // TODO: Implement @@ -60,8 +60,12 @@ EXTERNC SafeFunction __no_instrument_function void __gcov_flush(void) EXTERNC SafeFunction __no_instrument_function void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) { + UNUSED(counters); + UNUSED(n_counters); } EXTERNC SafeFunction __no_instrument_function void __gcov_merge_single(gcov_type *counters, unsigned int n_counters) { + UNUSED(counters); + UNUSED(n_counters); } diff --git a/Profiling/gprof.cpp b/Profiling/gprof.cpp index 40f03d7..4a884fd 100644 --- a/Profiling/gprof.cpp +++ b/Profiling/gprof.cpp @@ -9,11 +9,13 @@ using namespace UniversalAsynchronousReceiverTransmitter; static inline SafeFunction __no_instrument_function void gprof_uart_wrapper(char c, void *unused) { UART(COM2).Write(c); - (void)unused; + UNUSED(unused); } EXTERNC SafeFunction __no_instrument_function void mcount(unsigned long frompc, unsigned long selfpc) { // TODO: Implement /* https://docs.kernel.org/trace/ftrace-design.html */ + UNUSED(frompc); + UNUSED(selfpc); } diff --git a/SystemCalls/Native.cpp b/SystemCalls/Native.cpp index abcc4a6..cdaa26f 100644 --- a/SystemCalls/Native.cpp +++ b/SystemCalls/Native.cpp @@ -11,6 +11,7 @@ static int sys_exit(SyscallsFrame *Frame, int code) trace("Userspace thread %s(%lld) exited with code %#llx", TaskManager->GetCurrentThread()->Name, TaskManager->GetCurrentThread()->ID, code); TaskManager->GetCurrentThread()->ExitCode = code; TaskManager->GetCurrentThread()->Status = Tasking::TaskStatus::Terminated; + UNUSED(Frame); return 0; } @@ -20,23 +21,31 @@ static int sys_print(SyscallsFrame *Frame, char Char, int Index) #ifdef DEBUG Display->SetBuffer(Index); #endif + UNUSED(Frame); return ret; } static uintptr_t sys_request_pages(SyscallsFrame *Frame, size_t Count) { + UNUSED(Frame); return (uintptr_t)TaskManager->GetCurrentThread()->Memory->RequestPages(Count); } static int sys_free_pages(SyscallsFrame *Frame, uintptr_t Address, size_t Count) { TaskManager->GetCurrentThread()->Memory->FreePages((void *)Address, Count); + UNUSED(Frame); return 0; } static int sys_kernelctl(SyscallsFrame *Frame, int Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4) { fixme("KernelCTL: %lld", Command); + UNUSED(Arg1); + UNUSED(Arg2); + UNUSED(Arg3); + UNUSED(Arg4); + UNUSED(Frame); return 0; } diff --git a/Tasking/InterProcessCommunication.cpp b/Tasking/InterProcessCommunication.cpp index 4ea3c37..a16c019 100644 --- a/Tasking/InterProcessCommunication.cpp +++ b/Tasking/InterProcessCommunication.cpp @@ -90,6 +90,9 @@ namespace InterProcessCommunication handle->Listening = 1; handle->Error = IPCSuccess; + // FIXME: ID is not used. + UNUSED(ID); + return IPCError{IPCSuccess}; } diff --git a/Tasking/Security.cpp b/Tasking/Security.cpp index e121329..c185f27 100644 --- a/Tasking/Security.cpp +++ b/Tasking/Security.cpp @@ -45,12 +45,14 @@ namespace Tasking bool Security::UntrustToken(Token token) { fixme("UntrustToken->false"); + UNUSED(token); return false; } bool Security::DestroyToken(Token token) { fixme("DestroyToken->false"); + UNUSED(token); return false; } diff --git a/include/cpu.hpp b/include/cpu.hpp index ff28680..ee9a715 100644 --- a/include/cpu.hpp +++ b/include/cpu.hpp @@ -546,6 +546,12 @@ namespace CPU asmv("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "a"(Function)); +#else + UNUSED(Function); + UNUSED(eax); + UNUSED(ebx); + UNUSED(ecx); + UNUSED(edx); #endif } @@ -556,9 +562,11 @@ namespace CPU : : "r"(Address) : "memory"); +#else + UNUSED(Address); #endif } - + /** @brief EXPERIMENTAL IMPLEMENTATION */ namespace Intel { @@ -3066,7 +3074,7 @@ namespace CPU /* @brief Enable Protection Keys for Supervisor Mode Pages */ uint32_t PKS : 1; /** @brief Reserved */ - uint64_t Reserved2 : 7; // TODO: This could be wrong + uint64_t Reserved2 : 7; // TODO: This could be wrong }; uint64_t raw; } CR4; diff --git a/include/disk.hpp b/include/disk.hpp index d1b6e64..c15d947 100644 --- a/include/disk.hpp +++ b/include/disk.hpp @@ -94,8 +94,22 @@ namespace Disk PartitionStyle Style = PartitionStyle::Unknown; size_t Index = 0; - size_t Read(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; } - size_t Write(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; } + size_t Read(size_t Offset, size_t Count, uint8_t *Buffer) + { + return 0; + UNUSED(Offset); + UNUSED(Count); + UNUSED(Buffer); + } + + size_t Write(size_t Offset, size_t Count, uint8_t *Buffer) + { + return 0; + UNUSED(Offset); + UNUSED(Count); + UNUSED(Buffer); + } + Partition() {} ~Partition() {} }; @@ -111,8 +125,22 @@ namespace Disk bool MechanicalDisk = false; size_t UniqueIdentifier = 0xdeadbeef; - size_t Read(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; } - size_t Write(size_t Offset, size_t Count, uint8_t *Buffer) { return 0; } + size_t Read(size_t Offset, size_t Count, uint8_t *Buffer) + { + return 0; + UNUSED(Offset); + UNUSED(Count); + UNUSED(Buffer); + } + + size_t Write(size_t Offset, size_t Count, uint8_t *Buffer) + { + return 0; + UNUSED(Offset); + UNUSED(Count); + UNUSED(Buffer); + } + Drive() { // TODO: Allocate buffer } diff --git a/include/uart.hpp b/include/uart.hpp index c0ad085..832f175 100644 --- a/include/uart.hpp +++ b/include/uart.hpp @@ -58,12 +58,12 @@ namespace UniversalAsynchronousReceiverTransmitter * @param Char the sent character. */ - virtual void OnSent(uint8_t Char) {} + virtual void OnSent(uint8_t Char) { UNUSED(Char); } /** * @brief Called when a character is received. * @param Char the received character. */ - virtual void OnReceived(uint8_t Char) {} + virtual void OnReceived(uint8_t Char) { UNUSED(Char); } }; }