diff --git a/DevTools/UserspaceEmulator/main.cpp b/DevTools/UserspaceEmulator/main.cpp index 330decd867..7afef62b10 100644 --- a/DevTools/UserspaceEmulator/main.cpp +++ b/DevTools/UserspaceEmulator/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char** argv, char** env) auto elf = ELF::Loader::create((const u8*)mapped_file.data(), mapped_file.size()); Vector arguments; - for (auto arg: command) { + for (auto arg : command) { arguments.append(arg); } diff --git a/Kernel/ACPI/DynamicParser.h b/Kernel/ACPI/DynamicParser.h index d3e1ec394f..0a1a4cdccc 100644 --- a/Kernel/ACPI/DynamicParser.h +++ b/Kernel/ACPI/DynamicParser.h @@ -30,8 +30,8 @@ #include #include #include -#include #include +#include namespace Kernel { namespace ACPI { diff --git a/Kernel/ACPI/Parser.h b/Kernel/ACPI/Parser.h index 9a4edd5a6d..6d1717a254 100644 --- a/Kernel/ACPI/Parser.h +++ b/Kernel/ACPI/Parser.h @@ -30,8 +30,8 @@ #include #include #include -#include #include +#include #include namespace Kernel { diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 58de9dee65..7be30ad81c 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -338,7 +338,7 @@ struct SC_create_thread_params { unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE unsigned int m_reported_guard_page_size = 0; // The lie we tell callers unsigned int m_stack_size = 4 * MiB; // Default PTHREAD_STACK_MIN - void* m_stack_location; // nullptr means any, o.w. process virtual address + void* m_stack_location; // nullptr means any, o.w. process virtual address }; struct SC_realpath_params { diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index ca5425cffd..52951f0167 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -415,7 +415,6 @@ void page_fault_handler(TrapFrame* trap) return; } - auto current_thread = Thread::current(); if (!faulted_in_kernel && !MM.validate_user_stack(current_thread->process(), VirtualAddress(regs.userspace_esp))) { dbg() << "Invalid stack pointer: " << VirtualAddress(regs.userspace_esp); @@ -1278,7 +1277,7 @@ bool Processor::get_context_frame_ptr(Thread& thread, u32& frame_ptr, u32& eip) // an IPI to that processor, have it walk the stack and wait // until it returns the data back to us dbg() << "CPU[" << proc.id() << "] getting stack for " - << thread << " on other CPU# " << thread.cpu() << " not yet implemented!"; + << thread << " on other CPU# " << thread.cpu() << " not yet implemented!"; frame_ptr = eip = 0; // TODO return false; } else { @@ -1730,12 +1729,12 @@ void Processor::smp_enable() void Processor::smp_cleanup_message(ProcessorMessage& msg) { switch (msg.type) { - case ProcessorMessage::CallbackWithData: - if (msg.callback_with_data.free) - msg.callback_with_data.free(msg.callback_with_data.data); - break; - default: - break; + case ProcessorMessage::CallbackWithData: + if (msg.callback_with_data.free) + msg.callback_with_data.free(msg.callback_with_data.data); + break; + default: + break; } } @@ -1745,8 +1744,7 @@ bool Processor::smp_process_pending_messages() u32 prev_flags; enter_critical(prev_flags); - if (auto pending_msgs = atomic_exchange(&m_message_queue, nullptr, AK::MemoryOrder::memory_order_acq_rel)) - { + if (auto pending_msgs = atomic_exchange(&m_message_queue, nullptr, AK::MemoryOrder::memory_order_acq_rel)) { // We pulled the stack of pending messages in LIFO order, so we need to reverse the list first auto reverse_list = [](ProcessorMessageEntry* list) -> ProcessorMessageEntry* @@ -1768,21 +1766,21 @@ bool Processor::smp_process_pending_messages() for (auto cur_msg = pending_msgs; cur_msg; cur_msg = next_msg) { next_msg = cur_msg->next; auto msg = cur_msg->msg; - + #ifdef SMP_DEBUG dbg() << "SMP[" << id() << "]: Processing message " << VirtualAddress(msg); #endif switch (msg->type) { - case ProcessorMessage::Callback: - msg->callback.handler(); - break; - case ProcessorMessage::CallbackWithData: - msg->callback_with_data.handler(msg->callback_with_data.data); - break; - case ProcessorMessage::FlushTlb: - flush_tlb_local(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count); - break; + case ProcessorMessage::Callback: + msg->callback.handler(); + break; + case ProcessorMessage::CallbackWithData: + msg->callback_with_data.handler(msg->callback_with_data.data); + break; + case ProcessorMessage::FlushTlb: + flush_tlb_local(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count); + break; } bool is_async = msg->async; // Need to cache this value *before* dropping the ref count! @@ -1833,8 +1831,7 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg, bool async) atomic_store(&msg.refs, count() - 1, AK::MemoryOrder::memory_order_release); ASSERT(msg.refs > 0); for_each( - [&](Processor& proc) -> IterationDecision - { + [&](Processor& proc) -> IterationDecision { if (&proc != &cur_proc) { if (proc.smp_queue_message(msg)) { // TODO: only send IPI to that CPU if we queued the first @@ -1890,8 +1887,7 @@ void Processor::smp_broadcast_halt() // We don't want to use a message, because this could have been triggered // by being out of memory and we might not be able to get a message for_each( - [&](Processor& proc) -> IterationDecision - { + [&](Processor& proc) -> IterationDecision { proc.m_halt_requested = true; return IterationDecision::Continue; }); diff --git a/Kernel/Arch/i386/Interrupts.h b/Kernel/Arch/i386/Interrupts.h index 320e26281e..7d4e4b69ba 100644 --- a/Kernel/Arch/i386/Interrupts.h +++ b/Kernel/Arch/i386/Interrupts.h @@ -26,8 +26,8 @@ #pragma once -#include #include +#include #include extern "C" void interrupt_common_asm_entry(); @@ -40,6 +40,7 @@ extern "C" void interrupt_common_asm_entry(); " pushw $0\n" \ " jmp interrupt_common_asm_entry\n"); +// clang-format off asm( ".globl interrupt_common_asm_entry\n" "interrupt_common_asm_entry: \n" @@ -81,3 +82,4 @@ asm( " addl $0x4, %esp\n" // skip exception_code, isr_number " iret\n" ); +// clang-format on diff --git a/Kernel/Arch/i386/ProcessorInfo.h b/Kernel/Arch/i386/ProcessorInfo.h index c74d74e607..7169184650 100644 --- a/Kernel/Arch/i386/ProcessorInfo.h +++ b/Kernel/Arch/i386/ProcessorInfo.h @@ -32,8 +32,7 @@ namespace Kernel { class Processor; -class ProcessorInfo -{ +class ProcessorInfo { Processor& m_processor; String m_cpuid; String m_brandstr; @@ -46,7 +45,7 @@ class ProcessorInfo public: ProcessorInfo(Processor& processor); - + const String& cpuid() const { return m_cpuid; } const String& brandstr() const { return m_brandstr; } const String& features() const { return m_features; } diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 685dba5aa8..d270001532 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -38,7 +38,7 @@ void CommandLine::early_initialize(const char* cmd_line) return; size_t length = strlen(cmd_line); if (length >= sizeof(s_cmd_line)) - length = sizeof(s_cmd_line) -1; + length = sizeof(s_cmd_line) - 1; memcpy(s_cmd_line, cmd_line, length); s_cmd_line[length] = '\0'; } diff --git a/Kernel/Console.cpp b/Kernel/Console.cpp index b919f4fe08..7c2ff7a383 100644 --- a/Kernel/Console.cpp +++ b/Kernel/Console.cpp @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include // Bytes output to 0xE9 end up on the Bochs console. It's very handy. #define CONSOLE_OUT_TO_E9 diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h index 1d7f60ab7d..d8fd085adc 100644 --- a/Kernel/Devices/KeyboardDevice.h +++ b/Kernel/Devices/KeyboardDevice.h @@ -29,9 +29,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/Kernel/Devices/PCSpeaker.cpp b/Kernel/Devices/PCSpeaker.cpp index cd8ad3e8af..db6d15902a 100644 --- a/Kernel/Devices/PCSpeaker.cpp +++ b/Kernel/Devices/PCSpeaker.cpp @@ -26,8 +26,8 @@ #include #include -#include #include +#include void PCSpeaker::tone_on(int frequency) { diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp index 75ae40524e..b4b9e853b2 100644 --- a/Kernel/Devices/PS2MouseDevice.cpp +++ b/Kernel/Devices/PS2MouseDevice.cpp @@ -72,7 +72,7 @@ PS2MouseDevice::~PS2MouseDevice() void PS2MouseDevice::create() { - s_the.ensure_instance(); + s_the.ensure_instance(); } PS2MouseDevice& PS2MouseDevice::the() diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h index 07cfcc7a61..045537e5d5 100644 --- a/Kernel/Devices/PS2MouseDevice.h +++ b/Kernel/Devices/PS2MouseDevice.h @@ -27,9 +27,9 @@ #pragma once #include +#include #include #include -#include #include namespace Kernel { diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index aab811536d..9cc815f60d 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -28,10 +28,10 @@ #include #include #include +#include #include #include #include -#include //#define SB16_DEBUG diff --git a/Kernel/Devices/SB16.h b/Kernel/Devices/SB16.h index cc18fde5ef..c780618d62 100644 --- a/Kernel/Devices/SB16.h +++ b/Kernel/Devices/SB16.h @@ -28,9 +28,9 @@ #include #include +#include #include #include -#include namespace Kernel { diff --git a/Kernel/Devices/VMWareBackdoor.cpp b/Kernel/Devices/VMWareBackdoor.cpp index d1686da6c5..45d7f6dd88 100644 --- a/Kernel/Devices/VMWareBackdoor.cpp +++ b/Kernel/Devices/VMWareBackdoor.cpp @@ -28,10 +28,10 @@ #include #include #include +#include #include #include #include -#include #include namespace Kernel { @@ -82,8 +82,7 @@ inline void vmware_high_bandwidth_get(VMWareCommand& command) : "+a"(command.ax), "+b"(command.bx), "+c"(command.cx), "+d"(command.dx), "+S"(command.si), "+D"(command.di)); } -class VMWareBackdoorDetector -{ +class VMWareBackdoorDetector { public: VMWareBackdoorDetector() { diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 99a8131ca4..eff1c67ef5 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -78,7 +78,7 @@ public: u8 file_type { 0 }; }; - virtual void flush_writes() {} + virtual void flush_writes() { } size_t block_size() const { return m_block_size; } diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index 544e0faebd..4c6dba79e5 100644 --- a/Kernel/FileSystem/InodeIdentifier.h +++ b/Kernel/FileSystem/InodeIdentifier.h @@ -37,7 +37,7 @@ struct InodeMetadata; class InodeIdentifier { public: - InodeIdentifier() {} + InodeIdentifier() { } InodeIdentifier(u32 fsid, u32 inode) : m_fsid(fsid) , m_index(inode) diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 1cb6beb723..d3ab37c2ad 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -797,10 +797,10 @@ static Optional procfs$cpuinfo(InodeIdentifier) Optional procfs$memstat(InodeIdentifier) { InterruptDisabler disabler; - + kmalloc_stats stats; get_kmalloc_stats(stats); - + KBufferBuilder builder; JsonObjectSerializer json { builder }; json.add("kmalloc_allocated", stats.bytes_allocated); @@ -1206,7 +1206,7 @@ ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& auto* directory_entry = fs().get_directory_entry(identifier()); - Optional(*read_callback)(InodeIdentifier) = nullptr; + Optional (*read_callback)(InodeIdentifier) = nullptr; if (directory_entry) read_callback = directory_entry->read_callback; else @@ -1482,7 +1482,7 @@ ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const UserOrKernelB auto* directory_entry = fs().get_directory_entry(identifier()); - ssize_t(*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr; + ssize_t (*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr; if (directory_entry == nullptr) { if (to_proc_parent_directory(identifier()) == PDI_Root_sys) { diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index 1a9506a508..13ab6f14bc 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -59,7 +59,7 @@ private: struct ProcFSDirectoryEntry { ProcFSDirectoryEntry() { } - ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, bool a_supervisor_only, Optional(*read_callback)(InodeIdentifier) = nullptr, ssize_t(*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr, RefPtr&& a_inode = nullptr) + ProcFSDirectoryEntry(const char* a_name, unsigned a_proc_file_type, bool a_supervisor_only, Optional (*read_callback)(InodeIdentifier) = nullptr, ssize_t (*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t) = nullptr, RefPtr&& a_inode = nullptr) : name(a_name) , proc_file_type(a_proc_file_type) , supervisor_only(a_supervisor_only) @@ -72,8 +72,8 @@ private: const char* name { nullptr }; unsigned proc_file_type { 0 }; bool supervisor_only { false }; - Optional(*read_callback)(InodeIdentifier); - ssize_t(*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t); + Optional (*read_callback)(InodeIdentifier); + ssize_t (*write_callback)(InodeIdentifier, const UserOrKernelBuffer&, size_t); RefPtr inode; InodeIdentifier identifier(unsigned fsid) const; }; diff --git a/Kernel/Heap/SlabAllocator.cpp b/Kernel/Heap/SlabAllocator.cpp index b14785a45a..d8f8210752 100644 --- a/Kernel/Heap/SlabAllocator.cpp +++ b/Kernel/Heap/SlabAllocator.cpp @@ -38,7 +38,7 @@ namespace Kernel { template class SlabAllocator { public: - SlabAllocator() {} + SlabAllocator() { } void init(size_t size) { diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index 247bc55b88..19113958b0 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -100,7 +100,7 @@ struct KmallocGlobalHeap { if (subheap.free_bytes() < allocation_request) { // Looks like we probably need more size_t memory_size = PAGE_ROUND_UP(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request)); - // Add some more to the new heap. We're already using it for other + // Add some more to the new heap. We're already using it for other // allocations not including the original allocation_request // that triggered heap expansion. If we don't allocate memory_size += 1 * MiB; diff --git a/Kernel/Interrupts/APIC.h b/Kernel/Interrupts/APIC.h index 3f9b89ebdc..41a71fc95b 100644 --- a/Kernel/Interrupts/APIC.h +++ b/Kernel/Interrupts/APIC.h @@ -56,7 +56,7 @@ private: class ICRReg { u32 m_low { 0 }; u32 m_high { 0 }; - + public: enum DeliveryMode { Fixed = 0x0, @@ -84,13 +84,13 @@ private: AllIncludingSelf = 0x2, AllExcludingSelf = 0x3, }; - + ICRReg(u8 vector, DeliveryMode delivery_mode, DestinationMode destination_mode, Level level, TriggerMode trigger_mode, DestinationShorthand destinationShort, u8 destination = 0) - : m_low(vector | (delivery_mode << 8) | (destination_mode << 11) | (level << 14) | (static_cast(trigger_mode) << 15) | (destinationShort << 18)), - m_high((u32)destination << 24) + : m_low(vector | (delivery_mode << 8) | (destination_mode << 11) | (level << 14) | (static_cast(trigger_mode) << 15) | (destinationShort << 18)) + , m_high((u32)destination << 24) { } - + u32 low() const { return m_low; } u32 high() const { return m_high; } }; @@ -98,11 +98,11 @@ private: OwnPtr m_apic_base; Vector> m_ap_processor_info; Vector m_ap_idle_threads; - AK::Atomic m_apic_ap_count{0}; - AK::Atomic m_apic_ap_continue{0}; - u32 m_processor_cnt{0}; - u32 m_processor_enabled_cnt{0}; - + AK::Atomic m_apic_ap_count { 0 }; + AK::Atomic m_apic_ap_continue { 0 }; + u32 m_processor_cnt { 0 }; + u32 m_processor_enabled_cnt { 0 }; + static PhysicalAddress get_base(); static void set_base(const PhysicalAddress& base); void write_register(u32 offset, u32 value); diff --git a/Kernel/Interrupts/GenericInterruptHandler.cpp b/Kernel/Interrupts/GenericInterruptHandler.cpp index 609fb5e906..5fbcb3347e 100644 --- a/Kernel/Interrupts/GenericInterruptHandler.cpp +++ b/Kernel/Interrupts/GenericInterruptHandler.cpp @@ -37,8 +37,8 @@ GenericInterruptHandler& GenericInterruptHandler::from(u8 interrupt_number) } GenericInterruptHandler::GenericInterruptHandler(u8 interrupt_number, bool disable_remap) - : m_interrupt_number(interrupt_number), - m_disable_remap(disable_remap) + : m_interrupt_number(interrupt_number) + , m_disable_remap(disable_remap) { if (m_disable_remap) register_generic_interrupt_handler(m_interrupt_number, *this); diff --git a/Kernel/Interrupts/IRQController.h b/Kernel/Interrupts/IRQController.h index b04613a282..35e0fd5276 100644 --- a/Kernel/Interrupts/IRQController.h +++ b/Kernel/Interrupts/IRQController.h @@ -39,7 +39,7 @@ enum class IRQControllerType { class IRQController : public RefCounted { public: - virtual ~IRQController() {} + virtual ~IRQController() { } virtual void enable(const GenericInterruptHandler&) = 0; virtual void disable(const GenericInterruptHandler&) = 0; @@ -57,7 +57,7 @@ public: virtual IRQControllerType type() const = 0; protected: - IRQController() {} + IRQController() { } virtual void initialize() = 0; bool m_hard_disabled { false }; }; diff --git a/Kernel/Interrupts/MSIHandler.h b/Kernel/Interrupts/MSIHandler.h index 2af13fe87e..278a738a24 100644 --- a/Kernel/Interrupts/MSIHandler.h +++ b/Kernel/Interrupts/MSIHandler.h @@ -37,7 +37,7 @@ class MSIHandler final : public GenericInterruptHandler { public: virtual ~MSIHandler(); - virtual void handle_interrupt(RegisterState&) override {} + virtual void handle_interrupt(RegisterState&) override { } void enable_irq(); void disable_irq(); diff --git a/Kernel/Interrupts/PIC.cpp b/Kernel/Interrupts/PIC.cpp index d780f2990c..29bb7e4590 100644 --- a/Kernel/Interrupts/PIC.cpp +++ b/Kernel/Interrupts/PIC.cpp @@ -27,9 +27,9 @@ #include #include #include +#include #include #include -#include namespace Kernel { diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h index 86179200f6..62e4ec7582 100644 --- a/Kernel/KBufferBuilder.h +++ b/Kernel/KBufferBuilder.h @@ -37,7 +37,7 @@ public: using OutputType = KBuffer; explicit KBufferBuilder(); - ~KBufferBuilder() {} + ~KBufferBuilder() { } void append(const StringView&); void append(char); diff --git a/Kernel/KResult.h b/Kernel/KResult.h index 94e86961e9..1399e72dd5 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -35,7 +35,8 @@ enum KSuccessTag { KSuccess }; -class [[nodiscard]] KResult { +class [[nodiscard]] KResult +{ public: ALWAYS_INLINE explicit KResult(int negative_e) : m_error(negative_e) @@ -61,7 +62,8 @@ private: }; template -class alignas(T) [[nodiscard]] KResultOr { +class alignas(T) [[nodiscard]] KResultOr +{ public: KResultOr(KResult error) : m_error(error) @@ -69,20 +71,29 @@ public: { } + // FIXME: clang-format gets confused about T. Why? + // clang-format off ALWAYS_INLINE KResultOr(T&& value) + // clang-format on { new (&m_storage) T(move(value)); m_have_storage = true; } template + // FIXME: clang-format gets confused about U. Why? + // clang-format off ALWAYS_INLINE KResultOr(U&& value) + // clang-format on { new (&m_storage) T(move(value)); m_have_storage = true; } + // FIXME: clang-format gets confused about KResultOr. Why? + // clang-format off KResultOr(KResultOr&& other) + // clang-format on { m_is_error = other.m_is_error; if (m_is_error) diff --git a/Kernel/Lock.cpp b/Kernel/Lock.cpp index 1dd1bf6bf9..1aaad518cb 100644 --- a/Kernel/Lock.cpp +++ b/Kernel/Lock.cpp @@ -67,7 +67,7 @@ void Lock::lock(Mode mode) m_lock.store(false, AK::memory_order_release); return; } - } while (current_thread->wait_on(m_queue, m_name, nullptr, &m_lock, m_holder) == Thread::BlockResult::NotBlocked); + } while (current_thread->wait_on(m_queue, m_name, nullptr, &m_lock, m_holder) == Thread::BlockResult::NotBlocked); } else if (Processor::current().in_critical()) { // If we're in a critical section and trying to lock, no context // switch will happen, so yield. diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h index bf9a2265e0..be65fb5be5 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -39,8 +39,8 @@ struct ICMPType { class [[gnu::packed]] ICMPHeader { public: - ICMPHeader() {} - ~ICMPHeader() {} + ICMPHeader() { } + ~ICMPHeader() { } u8 type() const { return m_type; } void set_type(u8 b) { m_type = b; } diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 2ff4b60001..459a9f2477 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -352,7 +352,7 @@ KResultOr IPv4Socket::receive_packet_buffered(FileDescription& descripti } if (type() == SOCK_RAW) { - size_t bytes_written = min((size_t) ipv4_packet.payload_size(), buffer_length); + size_t bytes_written = min((size_t)ipv4_packet.payload_size(), buffer_length); if (!buffer.write(ipv4_packet.payload(), bytes_written)) return KResult(-EFAULT); return bytes_written; diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp index 2ef8228982..9ac904a4c3 100644 --- a/Kernel/Net/NetworkAdapter.cpp +++ b/Kernel/Net/NetworkAdapter.cpp @@ -125,7 +125,7 @@ int NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Addre ipv4.set_checksum(ipv4.compute_checksum()); m_packets_out++; m_bytes_out += ethernet_frame_size; - + if (!payload.read(ipv4.payload(), payload_size)) return -EFAULT; send_raw({ (const u8*)ð, ethernet_frame_size }); diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h index 84cf2c25c7..b53e869174 100644 --- a/Kernel/Net/TCP.h +++ b/Kernel/Net/TCP.h @@ -44,8 +44,8 @@ struct TCPFlags { class [[gnu::packed]] TCPPacket { public: - TCPPacket() {} - ~TCPPacket() {} + TCPPacket() { } + ~TCPPacket() { } size_t header_size() const { return data_offset() * sizeof(u32); } diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index b3cbc72ca4..928f1c7c5a 100644 --- a/Kernel/Net/UDP.h +++ b/Kernel/Net/UDP.h @@ -33,8 +33,8 @@ namespace Kernel { class [[gnu::packed]] UDPPacket { public: - UDPPacket() {} - ~UDPPacket() {} + UDPPacket() { } + ~UDPPacket() { } u16 source_port() const { return m_source_port; } void set_source_port(u16 port) { m_source_port = port; } diff --git a/Kernel/PCI/IOAccess.cpp b/Kernel/PCI/IOAccess.cpp index dd237eb27e..7b3161135e 100644 --- a/Kernel/PCI/IOAccess.cpp +++ b/Kernel/PCI/IOAccess.cpp @@ -24,8 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include namespace Kernel { namespace PCI { diff --git a/Kernel/PCI/Initializer.cpp b/Kernel/PCI/Initializer.cpp index df76b91f21..a56cf4c937 100644 --- a/Kernel/PCI/Initializer.cpp +++ b/Kernel/PCI/Initializer.cpp @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include #include -#include namespace Kernel { namespace PCI { diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h index eab960f349..ada55c2a33 100644 --- a/Kernel/PhysicalAddress.h +++ b/Kernel/PhysicalAddress.h @@ -31,7 +31,7 @@ class PhysicalAddress { public: - PhysicalAddress() {} + PhysicalAddress() { } explicit PhysicalAddress(FlatPtr address) : m_address(address) { diff --git a/Kernel/Ptrace.h b/Kernel/Ptrace.h index 789b7fc72e..38d86b6830 100644 --- a/Kernel/Ptrace.h +++ b/Kernel/Ptrace.h @@ -26,9 +26,9 @@ #pragma once +#include #include #include -#include #include namespace Ptrace { diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 0d78c75025..bd6d8e7bb0 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -24,10 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include -#include #include #include @@ -36,6 +36,7 @@ namespace Kernel { extern "C" void syscall_handler(TrapFrame*); extern "C" void syscall_asm_entry(); +// clang-format off asm( ".globl syscall_asm_entry\n" "syscall_asm_entry:\n" @@ -63,6 +64,7 @@ asm( " call syscall_handler \n" " movl %ebx, 0(%esp) \n" // push pointer to TrapFrame " jmp common_trap_exit \n"); +// clang-format on namespace Syscall { diff --git a/Kernel/Syscalls/getrandom.cpp b/Kernel/Syscalls/getrandom.cpp index c000c9cf87..64555ab30e 100644 --- a/Kernel/Syscalls/getrandom.cpp +++ b/Kernel/Syscalls/getrandom.cpp @@ -41,8 +41,8 @@ ssize_t Process::sys$getrandom(Userspace buffer, size_t buffer_size, [[ma SmapDisabler disabler; auto data_buffer = UserOrKernelBuffer::for_user_buffer(buffer, buffer_size); - if (!data_buffer.has_value()) - return -EFAULT; + if (!data_buffer.has_value()) + return -EFAULT; ssize_t nwritten = data_buffer.value().write_buffered<1024>(buffer_size, [&](u8* buffer, size_t buffer_bytes) { get_good_random_bytes(buffer, buffer_bytes); return (ssize_t)buffer_bytes; diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp index 8ca71c9860..6a1ea65101 100644 --- a/Kernel/Syscalls/ptrace.cpp +++ b/Kernel/Syscalls/ptrace.cpp @@ -91,8 +91,7 @@ KResult Process::poke_user_data(Userspace address, u32 data) region->set_shared(false); } const bool was_writable = region->is_writable(); - if (!was_writable) - { + if (!was_writable) { region->set_writable(true); region->remap(); } diff --git a/Kernel/Syscalls/select.cpp b/Kernel/Syscalls/select.cpp index c518ae7acb..ff692f01c0 100644 --- a/Kernel/Syscalls/select.cpp +++ b/Kernel/Syscalls/select.cpp @@ -166,7 +166,7 @@ int Process::sys$poll(Userspace user_params) if (!copy_from_user(&fds_copy[0], ¶ms.fds[0], params.nfds * sizeof(pollfd))) return -EFAULT; } - + Thread::SelectBlocker::FDVector rfds; Thread::SelectBlocker::FDVector wfds; diff --git a/Kernel/Syscalls/thread.cpp b/Kernel/Syscalls/thread.cpp index ca7db7b4d4..e718539cb4 100644 --- a/Kernel/Syscalls/thread.cpp +++ b/Kernel/Syscalls/thread.cpp @@ -159,7 +159,7 @@ int Process::sys$join_thread(pid_t tid, Userspace exit_value) thread = nullptr; if (exit_value && !copy_to_user(exit_value, &joinee_exit_value)) - return -EFAULT; + return -EFAULT; return 0; } diff --git a/Kernel/Tasks/FinalizerTask.cpp b/Kernel/Tasks/FinalizerTask.cpp index 4830948e05..c591a2bc84 100644 --- a/Kernel/Tasks/FinalizerTask.cpp +++ b/Kernel/Tasks/FinalizerTask.cpp @@ -35,7 +35,7 @@ void FinalizerTask::spawn() Thread::current()->set_priority(THREAD_PRIORITY_LOW); for (;;) { Thread::current()->wait_on(*g_finalizer_wait_queue, "FinalizerTask"); - + bool expected = true; if (g_finalizer_has_work.compare_exchange_strong(expected, false, AK::MemoryOrder::memory_order_acq_rel)) Thread::finalize_dying_threads(); diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 5a042e5b3b..99692a7b6b 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -510,7 +510,6 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal) klog() << "signal: dispatch signal " << signal << " to " << *this; #endif - if (m_state == Invalid || !is_initialized()) { // Thread has barely been created, we need to wait until it is // at least in Runnable state and is_initialized() returns true, diff --git a/Kernel/Time/PIT.cpp b/Kernel/Time/PIT.cpp index a105af6d46..3234a5cf53 100644 --- a/Kernel/Time/PIT.cpp +++ b/Kernel/Time/PIT.cpp @@ -25,12 +25,12 @@ */ #include +#include #include #include #include #include #include -#include #define IRQ_TIMER 0 namespace Kernel { diff --git a/Kernel/Time/RTC.cpp b/Kernel/Time/RTC.cpp index 7a3f85c987..726c437a64 100644 --- a/Kernel/Time/RTC.cpp +++ b/Kernel/Time/RTC.cpp @@ -26,9 +26,9 @@ #include #include +#include #include #include -#include namespace Kernel { #define IRQ_TIMER 8 diff --git a/Kernel/Time/RTC.h b/Kernel/Time/RTC.h index abdc7033ce..0e211eeb2f 100644 --- a/Kernel/Time/RTC.h +++ b/Kernel/Time/RTC.h @@ -40,8 +40,8 @@ public: virtual bool is_periodic() const override { return true; } virtual bool is_periodic_capable() const override { return true; } - virtual void set_periodic() override {} - virtual void set_non_periodic() override {} + virtual void set_periodic() override { } + virtual void set_non_periodic() override { } virtual void reset_to_default_ticks_per_second() override; virtual bool try_to_set_frequency(size_t frequency) override; diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp index 69b0570c22..ab0ed2bd8c 100644 --- a/Kernel/Time/TimeManagement.cpp +++ b/Kernel/Time/TimeManagement.cpp @@ -73,7 +73,6 @@ void TimeManagement::initialize() { ASSERT(!s_the.is_initialized()); s_the.ensure_instance(); - } time_t TimeManagement::seconds_since_boot() const { diff --git a/Kernel/VM/ContiguousVMObject.h b/Kernel/VM/ContiguousVMObject.h index 0693bf67aa..0df4f9c40d 100644 --- a/Kernel/VM/ContiguousVMObject.h +++ b/Kernel/VM/ContiguousVMObject.h @@ -26,8 +26,8 @@ #pragma once -#include #include +#include namespace Kernel { diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index fc5114f296..8d1e24a7b8 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include #include #include -#include //#define MM_DEBUG //#define PAGE_FAULT_DEBUG @@ -235,6 +235,7 @@ PageTableEntry* MemoryManager::ensure_pte(PageDirectory& page_directory, Virtual // we're writing to the correct underlying physical page pd = quickmap_pd(page_directory, page_directory_table_index); ASSERT(&pde == &pd[page_directory_index]); // Sanity check + ASSERT(!pde.is_present()); // Should have not changed } #ifdef MM_DEBUG diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h index d9823377ab..2bf767a766 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -89,7 +89,7 @@ public: static bool is_initialized(); static void initialize(u32 cpu); - + static inline MemoryManagerData& get_data() { return Processor::current().get_mm_data(); diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h index 92dcd20e24..dddf89ce3b 100644 --- a/Kernel/VM/PhysicalPage.h +++ b/Kernel/VM/PhysicalPage.h @@ -67,7 +67,7 @@ public: private: PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true); - ~PhysicalPage() {} + ~PhysicalPage() { } void return_to_freelist() const; diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp index 84f1e765b0..df28105d65 100644 --- a/Kernel/VM/PhysicalRegion.cpp +++ b/Kernel/VM/PhysicalRegion.cpp @@ -95,19 +95,19 @@ Optional PhysicalRegion::find_one_free_page() // We know we don't have any free pages, no need to check the bitmap // Check if we can draw one from the return queue if (m_recently_returned.size() > 0) { - u8 index = get_fast_random() % m_recently_returned.size(); - ptrdiff_t local_offset = m_recently_returned[index].get() - m_lower.get(); - m_recently_returned.remove(index); - ASSERT(local_offset >= 0); - ASSERT((FlatPtr)local_offset < (FlatPtr)(m_pages * PAGE_SIZE)); - return local_offset / PAGE_SIZE; + u8 index = get_fast_random() % m_recently_returned.size(); + ptrdiff_t local_offset = m_recently_returned[index].get() - m_lower.get(); + m_recently_returned.remove(index); + ASSERT(local_offset >= 0); + ASSERT((FlatPtr)local_offset < (FlatPtr)(m_pages * PAGE_SIZE)); + return local_offset / PAGE_SIZE; } return {}; } auto free_index = m_bitmap.find_one_anywhere_unset(m_free_hint); if (!free_index.has_value()) return {}; - + auto page_index = free_index.value(); m_bitmap.set(page_index, true); m_used++; diff --git a/Kernel/VM/PhysicalRegion.h b/Kernel/VM/PhysicalRegion.h index 9122548c41..4997b30499 100644 --- a/Kernel/VM/PhysicalRegion.h +++ b/Kernel/VM/PhysicalRegion.h @@ -39,7 +39,7 @@ class PhysicalRegion : public RefCounted { public: static NonnullRefPtr create(PhysicalAddress lower, PhysicalAddress upper); - ~PhysicalRegion() {} + ~PhysicalRegion() { } void expand(PhysicalAddress lower, PhysicalAddress upper); unsigned finalize_capacity(); diff --git a/Kernel/VM/PurgeableVMObject.cpp b/Kernel/VM/PurgeableVMObject.cpp index 71eae47e14..8f1af0e1cf 100644 --- a/Kernel/VM/PurgeableVMObject.cpp +++ b/Kernel/VM/PurgeableVMObject.cpp @@ -85,7 +85,7 @@ int PurgeableVMObject::purge_impl() if (purged_page_count > 0) { for_each_region([&](auto& region) { if (®ion.vmobject() == this) - region.remap(); + region.remap(); }); } diff --git a/Kernel/VM/RangeAllocator.h b/Kernel/VM/RangeAllocator.h index 677a150335..a5fe6ad893 100644 --- a/Kernel/VM/RangeAllocator.h +++ b/Kernel/VM/RangeAllocator.h @@ -37,7 +37,7 @@ class Range { friend class RangeAllocator; public: - Range() {} + Range() { } Range(VirtualAddress base, size_t size) : m_base(base) , m_size(size) diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index 68d40e53c3..a81bcd9693 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -118,7 +118,7 @@ public: { return (vaddr - m_range.base()).get() / PAGE_SIZE; } - + VirtualAddress vaddr_from_page_index(size_t page_index) const { return vaddr().offset(page_index * PAGE_SIZE); @@ -238,5 +238,4 @@ inline unsigned prot_to_region_access_flags(int prot) return access; } - } diff --git a/Kernel/VirtualAddress.h b/Kernel/VirtualAddress.h index 2c82cb0d40..7b5da8d5e4 100644 --- a/Kernel/VirtualAddress.h +++ b/Kernel/VirtualAddress.h @@ -31,7 +31,7 @@ class VirtualAddress { public: - VirtualAddress() {} + VirtualAddress() { } explicit VirtualAddress(FlatPtr address) : m_address(address) { diff --git a/Kernel/WaitQueue.cpp b/Kernel/WaitQueue.cpp index f2e95573c6..04c61f0c71 100644 --- a/Kernel/WaitQueue.cpp +++ b/Kernel/WaitQueue.cpp @@ -31,7 +31,6 @@ namespace Kernel { - WaitQueue::WaitQueue() { }