From 5ed7cd6e320ce5bd3882adc8b65ea59131fca01b Mon Sep 17 00:00:00 2001 From: Dan Klishch Date: Thu, 18 Apr 2024 15:32:56 -0400 Subject: [PATCH] Everywhere: Use east const in more places These changes are compatible with clang-format 16 and will be mandatory when we eventually bump clang-format version. So, since there are no real downsides, let's commit them now. --- AK/CheckedFormatString.h | 2 +- AK/CircularQueue.h | 2 +- AK/Complex.h | 6 ++--- AK/DoublyLinkedList.h | 2 +- AK/FloatingPoint.h | 6 ++--- AK/HashTable.h | 4 +-- AK/Hex.cpp | 4 +-- AK/IPv4Address.h | 4 +-- AK/Random.cpp | 4 +-- AK/RedBlackTree.h | 2 +- AK/SinglyLinkedList.h | 2 +- AK/Trie.h | 12 ++++----- AK/Types.h | 4 +-- AK/UFixedBigInt.h | 2 +- AK/kmalloc.cpp | 2 +- Kernel/API/TimePage.h | 4 +-- Kernel/API/kcov.h | 2 +- Kernel/API/ttydefaultschars.h | 2 +- Kernel/Arch/Processor.h | 2 +- Kernel/Arch/SmapDisabler.h | 2 +- Kernel/Arch/aarch64/RPi/Mailbox.cpp | 2 +- Kernel/Arch/aarch64/RPi/MiniUART.cpp | 2 +- Kernel/Arch/x86_64/InterruptManagement.h | 8 +++--- Kernel/Arch/x86_64/Interrupts/IOAPIC.h | 18 ++++++------- Kernel/Arch/x86_64/Time/APICTimer.cpp | 6 ++--- Kernel/Arch/x86_64/Time/HPET.cpp | 16 ++++++------ Kernel/Bus/PCI/Definitions.h | 6 ++--- Kernel/Bus/USB/EHCI/Registers.h | 8 +++--- Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h | 4 +-- Kernel/Bus/VirtIO/Queue.h | 4 +-- Kernel/Devices/Audio/Channel.h | 2 +- Kernel/Devices/BlockDevice.h | 8 +++--- .../Devices/GPU/Intel/DisplayConnectorGroup.h | 6 ++--- .../Devices/GPU/Intel/Plane/G33DisplayPlane.h | 2 +- Kernel/Devices/GPU/VirtIO/GraphicsAdapter.cpp | 2 +- Kernel/Devices/Generic/ConsoleDevice.cpp | 2 +- Kernel/Devices/SerialDevice.cpp | 2 +- Kernel/Devices/Storage/ATA/AHCI/Definitions.h | 2 +- Kernel/Devices/Storage/ATA/ATADevice.h | 4 +-- Kernel/Devices/Storage/ATA/ATAPort.h | 2 +- .../Devices/Storage/SD/SDHostController.cpp | 10 +++---- Kernel/Devices/TTY/SlavePTY.cpp | 2 +- Kernel/Devices/TTY/TTY.cpp | 2 +- Kernel/Devices/TTY/VirtualConsole.cpp | 2 +- Kernel/FileSystem/MountFile.cpp | 2 +- Kernel/FileSystem/Plan9FS/FileSystem.h | 2 +- .../SysFS/Subsystems/Kernel/DiskUsage.cpp | 4 +-- .../SysFS/Subsystems/Kernel/Processes.cpp | 2 +- Kernel/Heap/kmalloc.cpp | 2 +- Kernel/Heap/kmalloc.h | 2 +- Kernel/Library/StdLib.cpp | 2 +- Kernel/Net/IPv4Socket.cpp | 2 +- Kernel/Net/Intel/E1000NetworkAdapter.h | 26 +++++++++---------- Kernel/Net/NetworkTask.cpp | 6 ++--- Kernel/Net/Realtek/RTL8168NetworkAdapter.h | 24 ++++++++--------- Kernel/Net/Routing.h | 8 +++--- Kernel/Net/TCPSocket.cpp | 2 +- Kernel/Net/UDPSocket.cpp | 2 +- Kernel/Prekernel/UBSanitizer.cpp | 4 +-- Kernel/Security/UBSanitizer.cpp | 4 +-- Kernel/Syscalls/SyscallHandler.cpp | 2 +- Kernel/Tasks/Thread.h | 2 +- Userland/Applications/3DFileViewer/Mesh.cpp | 12 ++++----- .../Applications/Calendar/CalendarWidget.cpp | 2 +- Userland/Applications/Debugger/main.cpp | 8 +++--- .../KeyboardMapper/KeyboardMapperWidget.cpp | 6 ++--- .../KeyboardMapper/KeyboardMapperWidget.h | 6 ++--- Userland/Applications/Mail/MailWidget.cpp | 2 +- Userland/Applications/Piano/Music.h | 8 +++--- Userland/Applications/Piano/RollWidget.cpp | 4 +-- .../Applications/PixelPaint/ImageEditor.cpp | 12 ++++----- .../PixelPaint/Tools/GradientTool.cpp | 2 +- .../PixelPaint/Tools/GradientTool.h | 2 +- Userland/Applications/SoundPlayer/Playlist.h | 4 +-- .../SpaceAnalyzer/TreeMapWidget.cpp | 8 +++--- Userland/Applications/SpaceAnalyzer/main.cpp | 2 +- .../Spreadsheet/CellTypeDialog.cpp | 2 +- .../Applications/Spreadsheet/Readers/XSV.h | 4 +-- .../Applications/Spreadsheet/Spreadsheet.cpp | 2 +- .../Spreadsheet/SpreadsheetWidget.cpp | 2 +- Userland/Demos/Gradient/Gradient.cpp | 4 +-- .../DevTools/HackStudio/ClassViewWidget.cpp | 4 +-- .../HackStudio/Debugger/DebugInfoWidget.cpp | 2 +- .../DevTools/HackStudio/Debugger/Debugger.cpp | 2 +- .../DevTools/HackStudio/FindInFilesWidget.cpp | 2 +- .../DevTools/HackStudio/Git/GitWidget.cpp | 4 +-- .../DevTools/HackStudio/HackStudioWidget.cpp | 2 +- .../DevTools/HackStudio/ProjectTemplate.h | 2 +- Userland/Games/Chess/ChessWidget.cpp | 4 +-- Userland/Games/FlappyBug/Game.h | 4 +-- Userland/Libraries/LibAudio/Resampler.h | 4 +-- Userland/Libraries/LibC/net.cpp | 4 +-- Userland/Libraries/LibC/qsort.cpp | 4 +-- Userland/Libraries/LibC/scanf.cpp | 2 +- Userland/Libraries/LibC/stdlib.cpp | 6 ++--- Userland/Libraries/LibCards/Card.h | 2 +- Userland/Libraries/LibChess/Chess.cpp | 4 +-- Userland/Libraries/LibChess/Chess.h | 2 +- .../Cpp/CppComprehensionEngine.cpp | 2 +- .../Cpp/CppComprehensionEngine.h | 2 +- Userland/Libraries/LibCompress/Deflate.cpp | 2 +- .../LibCore/ProcessStatisticsReader.cpp | 2 +- Userland/Libraries/LibCoredump/Reader.cpp | 2 +- Userland/Libraries/LibCoredump/Reader.h | 2 +- .../LibCrypto/Authentication/GHash.cpp | 2 +- .../LibCrypto/Authentication/GHash.h | 2 +- .../LibCrypto/BigInt/UnsignedBigInteger.cpp | 4 +-- Userland/Libraries/LibCrypto/Hash/BLAKE2b.cpp | 2 +- Userland/Libraries/LibCrypto/Hash/BLAKE2b.h | 2 +- Userland/Libraries/LibDiff/Applier.cpp | 2 +- Userland/Libraries/LibELF/DynamicLinker.cpp | 2 +- Userland/Libraries/LibELF/DynamicLoader.cpp | 2 +- Userland/Libraries/LibELF/Hashes.h | 2 +- Userland/Libraries/LibGUI/Breadcrumbbar.h | 2 +- Userland/Libraries/LibGUI/ColorPicker.cpp | 2 +- Userland/Libraries/LibGUI/ComboBox.cpp | 2 +- Userland/Libraries/LibGUI/FilePicker.cpp | 4 +-- Userland/Libraries/LibGUI/FontPicker.cpp | 6 ++--- Userland/Libraries/LibGUI/IconView.cpp | 4 +-- Userland/Libraries/LibGUI/SeparatorWidget.h | 2 +- Userland/Libraries/LibGUI/TextDocument.cpp | 2 +- Userland/Libraries/LibGUI/TextEditor.cpp | 2 +- Userland/Libraries/LibGUI/Toolbar.h | 2 +- Userland/Libraries/LibGUI/TreeView.cpp | 6 ++--- Userland/Libraries/LibGUI/Widget.h | 2 +- Userland/Libraries/LibGUI/Window.cpp | 2 +- Userland/Libraries/LibGfx/ICC/Profile.cpp | 4 +-- .../LibGfx/ImageFormats/BMPWriter.cpp | 2 +- .../ImageFormats/WebPLoaderLossyTables.h | 2 +- Userland/Libraries/LibGfx/Point.cpp | 4 +-- Userland/Libraries/LibIMAP/Objects.cpp | 2 +- Userland/Libraries/LibJS/Lexer.cpp | 2 +- Userland/Libraries/LibJS/Parser.cpp | 2 +- .../LibJS/Runtime/BigIntConstructor.cpp | 2 +- .../LibJS/Runtime/IndexedProperties.cpp | 4 +-- .../LibJS/Runtime/Temporal/Instant.cpp | 2 +- .../Libraries/LibJS/Runtime/ValueTraits.h | 2 +- Userland/Libraries/LibJS/Token.h | 16 ++++++------ Userland/Libraries/LibLine/Editor.h | 4 +-- Userland/Libraries/LibPCIDB/Database.cpp | 12 ++++----- Userland/Libraries/LibPCIDB/Database.h | 12 ++++----- Userland/Libraries/LibPDF/DocumentParser.cpp | 6 ++--- Userland/Libraries/LibPDF/Renderer.cpp | 2 +- .../LibPartition/MBRPartitionTable.h | 2 +- Userland/Libraries/LibRegex/RegexMatcher.h | 4 +-- Userland/Libraries/LibTLS/Extensions.h | 2 +- Userland/Libraries/LibTLS/Record.cpp | 2 +- .../Libraries/LibTest/JavaScriptTestRunner.h | 2 +- Userland/Libraries/LibUSBDB/Database.cpp | 12 ++++----- Userland/Libraries/LibUSBDB/Database.h | 12 ++++----- Userland/Libraries/LibVT/TerminalWidget.h | 2 +- .../LibVideo/Color/ColorPrimaries.cpp | 4 +-- Userland/Libraries/LibVideo/VP9/Decoder.cpp | 10 +++---- .../LibVideo/VP9/SyntaxElementCounter.cpp | 4 +-- Userland/Libraries/LibVideo/VP9/Utilities.h | 2 +- Userland/Libraries/LibVideo/VideoFrame.cpp | 2 +- .../Libraries/LibWeb/Cookie/ParsedCookie.cpp | 2 +- .../LibWeb/Layout/TableFormattingContext.cpp | 4 +-- .../LibWeb/SVG/SVGGraphicsElement.cpp | 2 +- Userland/Services/WindowServer/Compositor.cpp | 16 ++++++------ Userland/Services/WindowServer/Event.h | 2 +- Userland/Services/WindowServer/Screen.h | 2 +- Userland/Shell/main.cpp | 2 +- Userland/Utilities/functrace.cpp | 8 +++--- Userland/Utilities/icc.cpp | 2 +- Userland/Utilities/markdown-check.cpp | 2 +- Userland/Utilities/network-settings.cpp | 2 +- Userland/Utilities/reboot.cpp | 2 +- Userland/Utilities/shutdown.cpp | 2 +- Userland/Utilities/stty.cpp | 2 +- Userland/Utilities/test-imap.cpp | 2 +- Userland/Utilities/w.cpp | 2 +- Userland/Utilities/watch.cpp | 2 +- Userland/Utilities/xargs.cpp | 2 +- Userland/Utilities/xxd.cpp | 2 +- 175 files changed, 353 insertions(+), 353 deletions(-) diff --git a/AK/CheckedFormatString.h b/AK/CheckedFormatString.h index f3b9ca41f04..f459e4426b0 100644 --- a/AK/CheckedFormatString.h +++ b/AK/CheckedFormatString.h @@ -28,7 +28,7 @@ struct Array { constexpr static size_t size() { return Size; } constexpr T const& operator[](size_t index) const { return __data[index]; } constexpr T& operator[](size_t index) { return __data[index]; } - using ConstIterator = SimpleIterator; + using ConstIterator = SimpleIterator; using Iterator = SimpleIterator; constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h index e8ad95456b6..dab46ac3576 100644 --- a/AK/CircularQueue.h +++ b/AK/CircularQueue.h @@ -80,7 +80,7 @@ public: private: friend class CircularQueue; - ConstIterator(CircularQueue const& queue, const size_t index) + ConstIterator(CircularQueue const& queue, size_t const index) : m_queue(queue) , m_index(index) { diff --git a/AK/Complex.h b/AK/Complex.h index d488a175e64..825282c34ae 100644 --- a/AK/Complex.h +++ b/AK/Complex.h @@ -105,7 +105,7 @@ public: template constexpr Complex operator*=(Complex const& x) { - const T real = m_real; + T const real = m_real; m_real = real * x.real() - m_imag * x.imag(); m_imag = real * x.imag() + m_imag * x.real(); return *this; @@ -122,8 +122,8 @@ public: template constexpr Complex operator/=(Complex const& x) { - const T real = m_real; - const T divisor = x.real() * x.real() + x.imag() * x.imag(); + T const real = m_real; + T const divisor = x.real() * x.real() + x.imag() * x.imag(); m_real = (real * x.real() + m_imag * x.imag()) / divisor; m_imag = (m_imag * x.real() - x.real() * x.imag()) / divisor; return *this; diff --git a/AK/DoublyLinkedList.h b/AK/DoublyLinkedList.h index afe53c88b87..c536d40354f 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -158,7 +158,7 @@ public: Iterator begin() { return Iterator(m_head); } Iterator end() { return Iterator::universal_end(); } - using ConstIterator = DoublyLinkedListIterator; + using ConstIterator = DoublyLinkedListIterator; friend ConstIterator; ConstIterator begin() const { return ConstIterator(m_head); } ConstIterator end() const { return ConstIterator::universal_end(); } diff --git a/AK/FloatingPoint.h b/AK/FloatingPoint.h index d615d25d6a9..228e2b67f80 100644 --- a/AK/FloatingPoint.h +++ b/AK/FloatingPoint.h @@ -95,9 +95,9 @@ static_assert(AssertSize, sizeof(f32)>()); template requires(S <= 1 && E >= 1 && M >= 1 && (S + E + M) <= 64) class FloatingPointBits final { public: - static const size_t signbit = S; - static const size_t exponentbits = E; - static const size_t mantissabits = M; + static size_t const signbit = S; + static size_t const exponentbits = E; + static size_t const mantissabits = M; template requires(IsIntegral && IsUnsigned && sizeof(T) <= 8) constexpr FloatingPointBits(T bits) diff --git a/AK/HashTable.h b/AK/HashTable.h index 0b8f679105f..951f544caa7 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -280,8 +280,8 @@ public: } using ConstIterator = Conditional, - HashTableIterator>; + OrderedHashTableIterator, + HashTableIterator>; [[nodiscard]] ConstIterator begin() const { diff --git a/AK/Hex.cpp b/AK/Hex.cpp index 37aeb571396..3bd1902d891 100644 --- a/AK/Hex.cpp +++ b/AK/Hex.cpp @@ -35,7 +35,7 @@ ErrorOr decode_hex(StringView input) } #ifdef KERNEL -ErrorOr> encode_hex(const ReadonlyBytes input) +ErrorOr> encode_hex(ReadonlyBytes const input) { StringBuilder output(input.size() * 2); @@ -45,7 +45,7 @@ ErrorOr> encode_hex(const ReadonlyBytes input) return Kernel::KString::try_create(output.string_view()); } #else -ByteString encode_hex(const ReadonlyBytes input) +ByteString encode_hex(ReadonlyBytes const input) { StringBuilder output(input.size() * 2); diff --git a/AK/IPv4Address.h b/AK/IPv4Address.h index e222442b63b..a32653a2e2b 100644 --- a/AK/IPv4Address.h +++ b/AK/IPv4Address.h @@ -41,7 +41,7 @@ public: m_data = (d << 24) | (c << 16) | (b << 8) | a; } - constexpr IPv4Address(const u8 data[4]) + constexpr IPv4Address(u8 const data[4]) { m_data = (u32(data[3]) << 24) | (u32(data[2]) << 16) | (u32(data[1]) << 8) | u32(data[0]); } @@ -149,7 +149,7 @@ public: } private: - constexpr u32 octet(const SubnetClass subnet) const + constexpr u32 octet(SubnetClass const subnet) const { constexpr auto bits_per_byte = 8; auto const bits_to_shift = bits_per_byte * int(subnet); diff --git a/AK/Random.cpp b/AK/Random.cpp index 229ead9e6e9..5f89c77d496 100644 --- a/AK/Random.cpp +++ b/AK/Random.cpp @@ -17,7 +17,7 @@ u32 get_random_uniform(u32 max_bounds) // `arc4random() % max_bounds` would be insufficient. Here we compute the last number of the // last "full group". Note that if max_bounds is a divisor of UINT32_MAX, // then we end up with UINT32_MAX: - const u32 max_usable = UINT32_MAX - (static_cast(UINT32_MAX) + 1) % max_bounds; + u32 const max_usable = UINT32_MAX - (static_cast(UINT32_MAX) + 1) % max_bounds; auto random_value = get_random(); for (int i = 0; i < 20 && random_value > max_usable; ++i) { // By chance we picked a value from the incomplete group. Note that this group has size at @@ -34,7 +34,7 @@ u64 get_random_uniform_64(u64 max_bounds) { // Uses the same algorithm as `get_random_uniform`, // by replacing u64 with u128 and u32 with u64. - const u64 max_usable = UINT64_MAX - static_cast((static_cast(UINT64_MAX) + 1) % max_bounds); + u64 const max_usable = UINT64_MAX - static_cast((static_cast(UINT64_MAX) + 1) % max_bounds); auto random_value = get_random(); for (int i = 0; i < 20 && random_value > max_usable; ++i) { random_value = get_random(); diff --git a/AK/RedBlackTree.h b/AK/RedBlackTree.h index 11bc1413593..54aea2c74df 100644 --- a/AK/RedBlackTree.h +++ b/AK/RedBlackTree.h @@ -505,7 +505,7 @@ public: Iterator end() { return {}; } Iterator begin_from(K key) { return Iterator(static_cast(BaseTree::find(this->m_root, key))); } - using ConstIterator = RedBlackTreeIterator; + using ConstIterator = RedBlackTreeIterator; friend ConstIterator; ConstIterator begin() const { return ConstIterator(static_cast(this->m_minimum)); } ConstIterator end() const { return {}; } diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h index f78ad50996e..319752cb204 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -205,7 +205,7 @@ public: Iterator begin() { return Iterator(m_head); } Iterator end() { return {}; } - using ConstIterator = SinglyLinkedListIterator; + using ConstIterator = SinglyLinkedListIterator; friend ConstIterator; ConstIterator begin() const { return ConstIterator(m_head); } ConstIterator end() const { return {}; } diff --git a/AK/Trie.h b/AK/Trie.h index ca940f384a4..c8f00577a7f 100644 --- a/AK/Trie.h +++ b/AK/Trie.h @@ -183,13 +183,13 @@ public: TRY(state.try_empend(false, m_children.begin(), m_children.end())); auto invoke = [&](auto& current_node) -> ErrorOr { - if constexpr (VoidFunction) { - callback(static_cast(current_node)); + if constexpr (VoidFunction) { + callback(static_cast(current_node)); return IterationDecision::Continue; - } else if constexpr (IsSpecializationOf())), ErrorOr>) { - return callback(static_cast(current_node)); - } else if constexpr (IteratorFunction) { - return callback(static_cast(current_node)); + } else if constexpr (IsSpecializationOf())), ErrorOr>) { + return callback(static_cast(current_node)); + } else if constexpr (IteratorFunction) { + return callback(static_cast(current_node)); } else { static_assert(DependentFalse, "Invalid iterator function type signature"); } diff --git a/AK/Types.h b/AK/Types.h index 652bbd0c9d8..cb110da0981 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -180,12 +180,12 @@ static_assert(explode_byte(0x80) == static_cast(0x8080808080808080ull)) static_assert(explode_byte(0x7f) == static_cast(0x7f7f7f7f7f7f7f7full)); static_assert(explode_byte(0) == 0); -constexpr size_t align_up_to(const size_t value, const size_t alignment) +constexpr size_t align_up_to(size_t const value, size_t const alignment) { return (value + (alignment - 1)) & ~(alignment - 1); } -constexpr size_t align_down_to(const size_t value, const size_t alignment) +constexpr size_t align_down_to(size_t const value, size_t const alignment) { return value & ~(alignment - 1); } diff --git a/AK/UFixedBigInt.h b/AK/UFixedBigInt.h index cf60001ae3a..09325fefe38 100644 --- a/AK/UFixedBigInt.h +++ b/AK/UFixedBigInt.h @@ -108,7 +108,7 @@ public: } template - requires((assumed_bit_size * n) <= bit_size) constexpr UFixedBigInt(const T (&value)[n]) + requires((assumed_bit_size * n) <= bit_size) constexpr UFixedBigInt(T const (&value)[n]) { size_t offset = 0; diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp index 45bf6e1c380..926a3e88277 100644 --- a/AK/kmalloc.cpp +++ b/AK/kmalloc.cpp @@ -63,7 +63,7 @@ void operator delete[](void* ptr, size_t) noexcept // This is usually provided by libstdc++ in most cases, and the kernel has its own definition in // Kernel/Heap/kmalloc.cpp. If neither of those apply, the following should suffice to not fail during linking. namespace AK_REPLACED_STD_NAMESPACE { -const nothrow_t nothrow; +nothrow_t const nothrow; } #endif diff --git a/Kernel/API/TimePage.h b/Kernel/API/TimePage.h index 76e6b44f8f4..4092b347bfb 100644 --- a/Kernel/API/TimePage.h +++ b/Kernel/API/TimePage.h @@ -22,9 +22,9 @@ inline bool time_page_supports(clockid_t clock_id) } struct TimePage { - volatile u32 update1; + u32 volatile update1; struct timespec clocks[CLOCK_ID_COUNT]; - volatile u32 update2; + u32 volatile update2; }; } diff --git a/Kernel/API/kcov.h b/Kernel/API/kcov.h index 30a4982bc05..2957a44569e 100644 --- a/Kernel/API/kcov.h +++ b/Kernel/API/kcov.h @@ -8,5 +8,5 @@ #include -typedef volatile u64 kcov_pc_t; +typedef u64 volatile kcov_pc_t; #define KCOV_ENTRY_SIZE sizeof(kcov_pc_t) diff --git a/Kernel/API/ttydefaultschars.h b/Kernel/API/ttydefaultschars.h index 0b7dc9b15cf..3b48f9a8a1f 100644 --- a/Kernel/API/ttydefaultschars.h +++ b/Kernel/API/ttydefaultschars.h @@ -18,7 +18,7 @@ extern "C" { #endif -static const cc_t ttydefchars[NCCS] = { +static cc_t const ttydefchars[NCCS] = { [VINTR] = CINTR, [VQUIT] = CQUIT, [VERASE] = CERASE, diff --git a/Kernel/Arch/Processor.h b/Kernel/Arch/Processor.h index 6e6b962eb9f..d96b2ce4a3a 100644 --- a/Kernel/Arch/Processor.h +++ b/Kernel/Arch/Processor.h @@ -192,7 +192,7 @@ private: // FIXME: On aarch64, once there is code in place to differentiate IRQs from synchronous exceptions (syscalls), // this member should be incremented. Also this member shouldn't be a FlatPtr. FlatPtr m_in_irq { 0 }; - volatile u32 m_in_critical; + u32 volatile m_in_critical; // NOTE: Since these variables are accessed with atomic magic on x86 (through GP with a single load instruction), // they need to be FlatPtrs or everything becomes highly unsound and breaks. They are actually just booleans. FlatPtr m_in_scheduler; diff --git a/Kernel/Arch/SmapDisabler.h b/Kernel/Arch/SmapDisabler.h index 319f24b7f87..89973189b1d 100644 --- a/Kernel/Arch/SmapDisabler.h +++ b/Kernel/Arch/SmapDisabler.h @@ -16,7 +16,7 @@ public: ~SmapDisabler(); private: - const FlatPtr m_flags; + FlatPtr const m_flags; }; } diff --git a/Kernel/Arch/aarch64/RPi/Mailbox.cpp b/Kernel/Arch/aarch64/RPi/Mailbox.cpp index 9743ce29859..5379114f3fa 100644 --- a/Kernel/Arch/aarch64/RPi/Mailbox.cpp +++ b/Kernel/Arch/aarch64/RPi/Mailbox.cpp @@ -76,7 +76,7 @@ static void wait_for_reply(MMIO& mmio) bool Mailbox::send_queue(void* queue, u32 queue_size) const { // According to Raspberry Pi specs this is the only channel implemented. - const u32 channel = ARM_TO_VIDEOCORE_CHANNEL; + u32 const channel = ARM_TO_VIDEOCORE_CHANNEL; auto message_header = reinterpret_cast(queue); message_header->set_queue_size(queue_size); diff --git a/Kernel/Arch/aarch64/RPi/MiniUART.cpp b/Kernel/Arch/aarch64/RPi/MiniUART.cpp index 812f7d9470c..98d305ab4a3 100644 --- a/Kernel/Arch/aarch64/RPi/MiniUART.cpp +++ b/Kernel/Arch/aarch64/RPi/MiniUART.cpp @@ -105,7 +105,7 @@ ErrorOr MiniUART::write(Kernel::OpenFileDescription& description, u64, K return EAGAIN; return buffer.read_buffered<128>(size, [&](ReadonlyBytes bytes) { - for (const auto& byte : bytes) + for (auto const& byte : bytes) put_char(byte); return bytes.size(); }); diff --git a/Kernel/Arch/x86_64/InterruptManagement.h b/Kernel/Arch/x86_64/InterruptManagement.h index 129dc454d06..e004d1ece88 100644 --- a/Kernel/Arch/x86_64/InterruptManagement.h +++ b/Kernel/Arch/x86_64/InterruptManagement.h @@ -34,10 +34,10 @@ public: u16 flags() const { return m_flags; } private: - const u8 m_bus; - const u8 m_source; - const u32 m_global_system_interrupt; - const u16 m_flags; + u8 const m_bus; + u8 const m_source; + u32 const m_global_system_interrupt; + u16 const m_flags; }; class InterruptManagement { diff --git a/Kernel/Arch/x86_64/Interrupts/IOAPIC.h b/Kernel/Arch/x86_64/Interrupts/IOAPIC.h index cbd88631653..7079897af2c 100644 --- a/Kernel/Arch/x86_64/Interrupts/IOAPIC.h +++ b/Kernel/Arch/x86_64/Interrupts/IOAPIC.h @@ -11,9 +11,9 @@ namespace Kernel { struct [[gnu::packed]] ioapic_mmio_regs { - volatile u32 select; + u32 volatile select; u32 reserved[3]; - volatile u32 window; + u32 volatile window; }; class PCIInterruptOverrideMetadata { @@ -28,13 +28,13 @@ public: u16 ioapic_interrupt_pin() const { return m_ioapic_interrupt_pin; } private: - const u8 m_bus_id; - const u8 m_polarity; - const u8 m_trigger_mode; - const u8 m_pci_interrupt_pin; - const u8 m_pci_device_number; - const u32 m_ioapic_id; - const u16 m_ioapic_interrupt_pin; + u8 const m_bus_id; + u8 const m_polarity; + u8 const m_trigger_mode; + u8 const m_pci_interrupt_pin; + u8 const m_pci_device_number; + u32 const m_ioapic_id; + u16 const m_ioapic_interrupt_pin; }; class IOAPIC final : public IRQController { diff --git a/Kernel/Arch/x86_64/Time/APICTimer.cpp b/Kernel/Arch/x86_64/Time/APICTimer.cpp index c911c5b59f2..30b72d9bb7d 100644 --- a/Kernel/Arch/x86_64/Time/APICTimer.cpp +++ b/Kernel/Arch/x86_64/Time/APICTimer.cpp @@ -44,10 +44,10 @@ UNMAP_AFTER_INIT bool APICTimer::calibrate(HardwareTimerBase& calibration_source size_t ticks_in_100ms { 0 }; Atomic calibration_ticks { 0 }; #ifdef APIC_TIMER_MEASURE_CPU_CLOCK - volatile u64 start_tsc { 0 }, end_tsc { 0 }; + u64 volatile start_tsc { 0 }, end_tsc { 0 }; #endif - volatile u64 start_reference { 0 }, end_reference { 0 }; - volatile u32 start_apic_count { 0 }, end_apic_count { 0 }; + u64 volatile start_reference { 0 }, end_reference { 0 }; + u32 volatile start_apic_count { 0 }, end_apic_count { 0 }; bool query_reference { false }; } state; diff --git a/Kernel/Arch/x86_64/Time/HPET.cpp b/Kernel/Arch/x86_64/Time/HPET.cpp index 13aaa37d62f..f12dd08a43d 100644 --- a/Kernel/Arch/x86_64/Time/HPET.cpp +++ b/Kernel/Arch/x86_64/Time/HPET.cpp @@ -46,26 +46,26 @@ enum class TimerConfiguration : u32 { struct [[gnu::packed]] HPETRegister { union { - volatile u64 full; + u64 volatile full; struct { - volatile u32 low; - volatile u32 high; + u32 volatile low; + u32 volatile high; }; }; }; struct [[gnu::packed]] TimerStructure { - volatile u32 capabilities; - volatile u32 interrupt_routing; + u32 volatile capabilities; + u32 volatile interrupt_routing; HPETRegister comparator_value; - volatile u64 fsb_interrupt_route; + u64 volatile fsb_interrupt_route; u64 reserved; }; struct [[gnu::packed]] HPETCapabilityRegister { // Note: We must do a 32 bit access to offsets 0x0, or 0x4 only, according to HPET spec. - volatile u32 attributes; - volatile u32 main_counter_tick_period; + u32 volatile attributes; + u32 volatile main_counter_tick_period; u64 reserved; }; diff --git a/Kernel/Bus/PCI/Definitions.h b/Kernel/Bus/PCI/Definitions.h index f604010a574..ede6010fd3c 100644 --- a/Kernel/Bus/PCI/Definitions.h +++ b/Kernel/Bus/PCI/Definitions.h @@ -337,9 +337,9 @@ public: void write32(size_t offset, u32 value) const; private: - const Address m_address; - const CapabilityID m_id; - const u8 m_ptr; + Address const m_address; + CapabilityID const m_id; + u8 const m_ptr; }; AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, ClassCode); diff --git a/Kernel/Bus/USB/EHCI/Registers.h b/Kernel/Bus/USB/EHCI/Registers.h index a515068a174..3a9caa26f0a 100644 --- a/Kernel/Bus/USB/EHCI/Registers.h +++ b/Kernel/Bus/USB/EHCI/Registers.h @@ -202,21 +202,21 @@ struct OperationalRegisters { // 2.3.4 FRINDEX - Frame Index Register // Note: We use `volatile` to ensure 32 bit writes // Note: Only up to 14 bits are actually used, and the last 3 bits must never be `000` or `111` - volatile u32 frame_index; + u32 volatile frame_index; // 2.3.5 CTRLDSSEGMENT - Control Data Structure Segment Register // Note: We use `volatile` to ensure 32 bit writes // Note: Upper 32 bits of periodic-frame- and asynchronous-list pointers - volatile u32 segment_selector; + u32 volatile segment_selector; // 2.3.6 PERIODICLISTBASE - Periodic Frame List Base Address Register // Note: We use `volatile` to ensure 32 bit writes // Note: Page-aligned addresses only - volatile u32 frame_list_base_address; + u32 volatile frame_list_base_address; // 2.3.7 ASYNCLISTADDR - Current Asynchronous List Address Register // Note: We use `volatile` to ensure 32 bit writes // Note: 32 byte (cache-line) aligned addresses only - volatile u32 next_asynchronous_list_address; + u32 volatile next_asynchronous_list_address; u32 _padding[9]; diff --git a/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h b/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h index 8dab52c99c1..4bf18b9c02b 100644 --- a/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h +++ b/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h @@ -241,7 +241,7 @@ struct alignas(16) TransferDescriptor final { private: u32 m_link_ptr; // Points to another Queue Head or Transfer Descriptor - volatile u32 m_control_status; // Control and status field + u32 volatile m_control_status; // Control and status field u32 m_token; // Contains all information required to fill in a USB Start Token u32 m_buffer_ptr; // Points to a data buffer for this transaction (i.e what we want to send or recv) @@ -367,7 +367,7 @@ struct alignas(16) QueueHead { private: u32 m_link_ptr { 0 }; // Pointer to the next horizontal object that the controller will execute after this one - volatile u32 m_element_link_ptr { 0 }; // Pointer to the first data object in the queue (can be modified by hw) + u32 volatile m_element_link_ptr { 0 }; // Pointer to the first data object in the queue (can be modified by hw) // This structure pointer will be ignored by the controller, but we can use it for configuration and bookkeeping QueueHeadBookkeeping* m_bookkeeping { nullptr }; diff --git a/Kernel/Bus/VirtIO/Queue.h b/Kernel/Bus/VirtIO/Queue.h index 40347c9b461..457f9fee445 100644 --- a/Kernel/Bus/VirtIO/Queue.h +++ b/Kernel/Bus/VirtIO/Queue.h @@ -87,8 +87,8 @@ private: QueueDeviceItem rings[]; }; - const u16 m_queue_size; - const u16 m_notify_offset; + u16 const m_queue_size; + u16 const m_notify_offset; u16 m_free_buffers; u16 m_free_head { 0 }; u16 m_used_tail { 0 }; diff --git a/Kernel/Devices/Audio/Channel.h b/Kernel/Devices/Audio/Channel.h index 5af55240122..2991c2e1f5f 100644 --- a/Kernel/Devices/Audio/Channel.h +++ b/Kernel/Devices/Audio/Channel.h @@ -34,6 +34,6 @@ private: virtual StringView class_name() const override { return "AudioChannel"sv; } LockWeakPtr m_controller; - const size_t m_channel_index; + size_t const m_channel_index; }; } diff --git a/Kernel/Devices/BlockDevice.h b/Kernel/Devices/BlockDevice.h index 679e26cf175..f262b4b8683 100644 --- a/Kernel/Devices/BlockDevice.h +++ b/Kernel/Devices/BlockDevice.h @@ -85,11 +85,11 @@ public: private: BlockDevice& m_block_device; - const RequestType m_request_type; - const u64 m_block_index; - const u32 m_block_count; + RequestType const m_request_type; + u64 const m_block_index; + u32 const m_block_count; UserOrKernelBuffer m_buffer; - const size_t m_buffer_size; + size_t const m_buffer_size; }; } diff --git a/Kernel/Devices/GPU/Intel/DisplayConnectorGroup.h b/Kernel/Devices/GPU/Intel/DisplayConnectorGroup.h index 5ef6e4394cd..45a4220afdd 100644 --- a/Kernel/Devices/GPU/Intel/DisplayConnectorGroup.h +++ b/Kernel/Devices/GPU/Intel/DisplayConnectorGroup.h @@ -86,11 +86,11 @@ private: Array, 5> m_transcoders; Array, 3> m_planes; - const MMIORegion m_mmio_first_region; - const MMIORegion m_mmio_second_region; + MMIORegion const m_mmio_first_region; + MMIORegion const m_mmio_second_region; MMIORegion const& m_assigned_mmio_registers_region; - const IntelGraphics::Generation m_generation; + IntelGraphics::Generation const m_generation; NonnullOwnPtr m_registers_region; NonnullOwnPtr m_gmbus_connector; }; diff --git a/Kernel/Devices/GPU/Intel/Plane/G33DisplayPlane.h b/Kernel/Devices/GPU/Intel/Plane/G33DisplayPlane.h index 200b3ee4957..185446dadf1 100644 --- a/Kernel/Devices/GPU/Intel/Plane/G33DisplayPlane.h +++ b/Kernel/Devices/GPU/Intel/Plane/G33DisplayPlane.h @@ -21,6 +21,6 @@ public: virtual ErrorOr enable(Badge) override; private: - explicit IntelG33DisplayPlane(Memory::TypedMapping plane_registers_mapping); + explicit IntelG33DisplayPlane(Memory::TypedMapping plane_registers_mapping); }; } diff --git a/Kernel/Devices/GPU/VirtIO/GraphicsAdapter.cpp b/Kernel/Devices/GPU/VirtIO/GraphicsAdapter.cpp index e9595aac2a7..e2ec60d9598 100644 --- a/Kernel/Devices/GPU/VirtIO/GraphicsAdapter.cpp +++ b/Kernel/Devices/GPU/VirtIO/GraphicsAdapter.cpp @@ -305,7 +305,7 @@ ErrorOr VirtIOGraphicsAdapter::ensure_backing_storage(Graphics::VirtIOGPU: auto writer = create_scratchspace_writer(); auto& request = writer.append_structure(); - const size_t header_block_size = sizeof(request) + num_mem_regions * sizeof(Graphics::VirtIOGPU::Protocol::MemoryEntry); + size_t const header_block_size = sizeof(request) + num_mem_regions * sizeof(Graphics::VirtIOGPU::Protocol::MemoryEntry); populate_virtio_gpu_request_header(request.header, Graphics::VirtIOGPU::Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING, 0); request.resource_id = resource_id.value(); diff --git a/Kernel/Devices/Generic/ConsoleDevice.cpp b/Kernel/Devices/Generic/ConsoleDevice.cpp index 541d2f69569..53e4d4015c8 100644 --- a/Kernel/Devices/Generic/ConsoleDevice.cpp +++ b/Kernel/Devices/Generic/ConsoleDevice.cpp @@ -50,7 +50,7 @@ ErrorOr ConsoleDevice::write(OpenFileDescription&, u64, Kernel::UserOrKe return 0; return data.read_buffered<256>(size, [&](ReadonlyBytes readonly_bytes) { - for (const auto& byte : readonly_bytes) + for (auto const& byte : readonly_bytes) put_char(byte); return readonly_bytes.size(); }); diff --git a/Kernel/Devices/SerialDevice.cpp b/Kernel/Devices/SerialDevice.cpp index fce9fe6e367..91dc54ceca1 100644 --- a/Kernel/Devices/SerialDevice.cpp +++ b/Kernel/Devices/SerialDevice.cpp @@ -57,7 +57,7 @@ ErrorOr SerialDevice::write(OpenFileDescription& description, u64, UserO return EAGAIN; return buffer.read_buffered<128>(size, [&](ReadonlyBytes bytes) { - for (const auto& byte : bytes) + for (auto const& byte : bytes) put_char(byte); return bytes.size(); }); diff --git a/Kernel/Devices/Storage/ATA/AHCI/Definitions.h b/Kernel/Devices/Storage/ATA/AHCI/Definitions.h index 04292cab0b6..17beea52f42 100644 --- a/Kernel/Devices/Storage/ATA/AHCI/Definitions.h +++ b/Kernel/Devices/Storage/ATA/AHCI/Definitions.h @@ -197,7 +197,7 @@ public: private: u32 volatile& m_bitfield; - const u32 m_bit_mask; + u32 const m_bit_mask; }; enum Limits : u16 { diff --git a/Kernel/Devices/Storage/ATA/ATADevice.h b/Kernel/Devices/Storage/ATA/ATADevice.h index 95b33d59dd9..1759e8eb95d 100644 --- a/Kernel/Devices/Storage/ATA/ATADevice.h +++ b/Kernel/Devices/Storage/ATA/ATADevice.h @@ -39,8 +39,8 @@ protected: ATADevice(ATAController const&, Address, u16, u16, u64); LockWeakPtr m_controller; - const Address m_ata_address; - const u16 m_capabilities; + Address const m_ata_address; + u16 const m_capabilities; }; } diff --git a/Kernel/Devices/Storage/ATA/ATAPort.h b/Kernel/Devices/Storage/ATA/ATAPort.h index 3b05ef8cbcc..b0747b33571 100644 --- a/Kernel/Devices/Storage/ATA/ATAPort.h +++ b/Kernel/Devices/Storage/ATA/ATAPort.h @@ -148,7 +148,7 @@ protected: RefPtr m_prdt_page; RefPtr m_dma_buffer_page; - const u8 m_port_index; + u8 const m_port_index; Vector> m_ata_devices; NonnullOwnPtr m_ata_identify_data_buffer; NonnullLockRefPtr m_parent_ata_controller; diff --git a/Kernel/Devices/Storage/SD/SDHostController.cpp b/Kernel/Devices/Storage/SD/SDHostController.cpp index e705559a46c..9494792d98c 100644 --- a/Kernel/Devices/Storage/SD/SDHostController.cpp +++ b/Kernel/Devices/Storage/SD/SDHostController.cpp @@ -157,7 +157,7 @@ ErrorOr> SDHostController::try_initialize_insert // 2. Send CMD8 (SEND_IF_COND) to the card // SD interface condition: 7:0 = check pattern, 11:8 = supply voltage // 0x1aa: check pattern = 10101010, supply voltage = 1 => 2.7-3.6V - const u32 voltage_window = 0x1aa; + u32 const voltage_window = 0x1aa; TRY(issue_command(SD::Commands::send_if_cond, voltage_window)); auto interface_condition_response = wait_for_response(); @@ -456,14 +456,14 @@ ErrorOr SDHostController::sd_clock_supply(u32 frequency) VERIFY((m_registers->host_configuration_1 & sd_clock_enable) == 0); // 1. Find out the divisor to determine the SD Clock Frequency - const u32 sd_clock_frequency = TRY(retrieve_sd_clock_frequency()); + u32 const sd_clock_frequency = TRY(retrieve_sd_clock_frequency()); u32 divisor = TRY(calculate_sd_clock_divisor(sd_clock_frequency, frequency)); // 2. Set Internal Clock Enable and SDCLK Frequency Select in the Clock Control register - const u32 eight_lower_bits_of_sdclk_frequency_select = (divisor & 0xff) << 8; + u32 const eight_lower_bits_of_sdclk_frequency_select = (divisor & 0xff) << 8; u32 sdclk_frequency_select = eight_lower_bits_of_sdclk_frequency_select; if (host_version() == SD::HostVersion::Version3) { - const u32 two_upper_bits_of_sdclk_frequency_select = (divisor >> 8 & 0x3) << 6; + u32 const two_upper_bits_of_sdclk_frequency_select = (divisor >> 8 & 0x3) << 6; sdclk_frequency_select |= two_upper_bits_of_sdclk_frequency_select; } m_registers->host_configuration_1 = (m_registers->host_configuration_1 & ~sd_clock_divisor_mask) | internal_clock_enable | sdclk_frequency_select; @@ -958,7 +958,7 @@ ErrorOr SDHostController::retrieve_sd_clock_frequency() // If these bits are all 0, the Host System has to get information via another method TODO(); } - const i64 one_mhz = 1'000'000; + i64 const one_mhz = 1'000'000; return { m_registers->capabilities.base_clock_frequency * one_mhz }; } diff --git a/Kernel/Devices/TTY/SlavePTY.cpp b/Kernel/Devices/TTY/SlavePTY.cpp index 284fa42c3c4..ad8ba4861f7 100644 --- a/Kernel/Devices/TTY/SlavePTY.cpp +++ b/Kernel/Devices/TTY/SlavePTY.cpp @@ -67,7 +67,7 @@ void SlavePTY::echo(u8 ch) void SlavePTY::on_master_write(UserOrKernelBuffer const& buffer, size_t size) { auto result = buffer.read_buffered<128>(size, [&](ReadonlyBytes data) { - for (const auto& byte : data) + for (auto const& byte : data) emit(byte, false); return data.size(); }); diff --git a/Kernel/Devices/TTY/TTY.cpp b/Kernel/Devices/TTY/TTY.cpp index cc53748148c..f1e7361e20e 100644 --- a/Kernel/Devices/TTY/TTY.cpp +++ b/Kernel/Devices/TTY/TTY.cpp @@ -89,7 +89,7 @@ ErrorOr TTY::write(OpenFileDescription&, u64, UserOrKernelBuffer const& return buffer.read_buffered(size, [&](ReadonlyBytes bytes) -> ErrorOr { u8 modified_data[num_chars * 2]; size_t modified_data_size = 0; - for (const auto& byte : bytes) { + for (auto const& byte : bytes) { process_output(byte, [&modified_data, &modified_data_size](u8 out_ch) { modified_data[modified_data_size++] = out_ch; }); diff --git a/Kernel/Devices/TTY/VirtualConsole.cpp b/Kernel/Devices/TTY/VirtualConsole.cpp index 7441976d9a5..7e746b2bc10 100644 --- a/Kernel/Devices/TTY/VirtualConsole.cpp +++ b/Kernel/Devices/TTY/VirtualConsole.cpp @@ -285,7 +285,7 @@ ErrorOr VirtualConsole::on_tty_write(UserOrKernelBuffer const& data, siz { SpinlockLocker global_lock(ConsoleManagement::the().tty_write_lock()); auto result = data.read_buffered<512>(size, [&](ReadonlyBytes buffer) { - for (const auto& byte : buffer) + for (auto const& byte : buffer) m_console_impl.on_input(byte); return buffer.size(); }); diff --git a/Kernel/FileSystem/MountFile.cpp b/Kernel/FileSystem/MountFile.cpp index 8f1f79d8af5..4d9a1df3f1a 100644 --- a/Kernel/FileSystem/MountFile.cpp +++ b/Kernel/FileSystem/MountFile.cpp @@ -54,7 +54,7 @@ ErrorOr MountFile::ioctl(OpenFileDescription&, unsigned request, Userspace if ((mount_specific_data.value_type == MountSpecificFlag::ValueType::SignedInteger || mount_specific_data.value_type == MountSpecificFlag::ValueType::UnsignedInteger) && mount_specific_data.value_length != 8) return EDOM; - Syscall::StringArgument user_key_string { reinterpret_cast(mount_specific_data.key_string_addr), static_cast(mount_specific_data.key_string_length) }; + Syscall::StringArgument user_key_string { reinterpret_cast(mount_specific_data.key_string_addr), static_cast(mount_specific_data.key_string_length) }; auto key_string = TRY(Process::get_syscall_name_string_fixed_buffer(user_key_string)); if (mount_specific_data.value_type != MountSpecificFlag::ValueType::Boolean && mount_specific_data.value_length == 0) diff --git a/Kernel/FileSystem/Plan9FS/FileSystem.h b/Kernel/FileSystem/Plan9FS/FileSystem.h index 0818a757b36..99b0d40dfc6 100644 --- a/Kernel/FileSystem/Plan9FS/FileSystem.h +++ b/Kernel/FileSystem/Plan9FS/FileSystem.h @@ -69,7 +69,7 @@ private: struct ReceiveCompletion final : public AtomicRefCounted { mutable Spinlock lock {}; bool completed { false }; - const u16 tag; + u16 const tag; OwnPtr message; ErrorOr result; diff --git a/Kernel/FileSystem/SysFS/Subsystems/Kernel/DiskUsage.cpp b/Kernel/FileSystem/SysFS/Subsystems/Kernel/DiskUsage.cpp index 2f8ed31c72d..b2985d89854 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Kernel/DiskUsage.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Kernel/DiskUsage.cpp @@ -45,13 +45,13 @@ ErrorOr SysFSDiskUsage::try_generate(KBufferBuilder& builder) TRY(fs_object.add("source"sv, "unknown")); } else { if (fs.is_file_backed()) { - auto& file = static_cast(fs).file(); + auto& file = static_cast(fs).file(); if (file.is_loop_device()) { auto& device = static_cast(file); auto path = TRY(device.custody().try_serialize_absolute_path()); TRY(fs_object.add("source"sv, path->view())); } else { - auto pseudo_path = TRY(static_cast(fs).file_description().pseudo_path()); + auto pseudo_path = TRY(static_cast(fs).file_description().pseudo_path()); TRY(fs_object.add("source"sv, pseudo_path->view())); } } else { diff --git a/Kernel/FileSystem/SysFS/Subsystems/Kernel/Processes.cpp b/Kernel/FileSystem/SysFS/Subsystems/Kernel/Processes.cpp index 137dfeb7901..a7c0566aa29 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Kernel/Processes.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Kernel/Processes.cpp @@ -114,7 +114,7 @@ ErrorOr SysFSOverallProcesses::try_generate(KBufferBuilder& builder) TRY(process_object.add("dumpable"sv, process.is_dumpable())); TRY(process_object.add("kernel"sv, process.is_kernel_process())); auto thread_array = TRY(process_object.add_array("threads"sv)); - TRY(process.try_for_each_thread([&](const Thread& thread) -> ErrorOr { + TRY(process.try_for_each_thread([&](Thread const& thread) -> ErrorOr { SpinlockLocker locker(thread.get_lock()); auto thread_object = TRY(thread_array.add_object()); #if LOCK_DEBUG diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index 59cf161fd80..89d9a5e3f12 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -33,7 +33,7 @@ static constexpr size_t KMALLOC_DEFAULT_ALIGNMENT = 16; __attribute__((section(".heap"))) static u8 initial_kmalloc_memory[INITIAL_KMALLOC_MEMORY_SIZE]; namespace std { -const nothrow_t nothrow; +nothrow_t const nothrow; } // FIXME: Figure out whether this can be MemoryManager. diff --git a/Kernel/Heap/kmalloc.h b/Kernel/Heap/kmalloc.h index 666cd6bcf7a..bc75b33e8b0 100644 --- a/Kernel/Heap/kmalloc.h +++ b/Kernel/Heap/kmalloc.h @@ -38,7 +38,7 @@ struct nothrow_t { explicit nothrow_t() = default; }; -extern const nothrow_t nothrow; +extern nothrow_t const nothrow; enum class align_val_t : size_t {}; }; diff --git a/Kernel/Library/StdLib.cpp b/Kernel/Library/StdLib.cpp index 8f003672db6..31a8b756864 100644 --- a/Kernel/Library/StdLib.cpp +++ b/Kernel/Library/StdLib.cpp @@ -213,7 +213,7 @@ ErrorOr memset_user(void* dest_ptr, int c, size_t n) // See https://bugs.llvm.org/show_bug.cgi?id=39634 FlatPtr missing_got_workaround() { - extern volatile FlatPtr _GLOBAL_OFFSET_TABLE_; + extern FlatPtr volatile _GLOBAL_OFFSET_TABLE_; return _GLOBAL_OFFSET_TABLE_; } #endif diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 726baf9ae82..ab84fd19ebd 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -624,7 +624,7 @@ ErrorOr IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac rtentry route; TRY(copy_from_user(&route, user_route)); - Userspace user_rt_dev((FlatPtr)route.rt_dev); + Userspace user_rt_dev((FlatPtr)route.rt_dev); auto ifname = TRY(Process::get_syscall_name_string_fixed_buffer(user_rt_dev)); auto adapter = NetworkingManagement::the().lookup_by_name(ifname.representable_view()); if (!adapter) diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.h b/Kernel/Net/Intel/E1000NetworkAdapter.h index 4d133ade7c5..1d6b3b27ff2 100644 --- a/Kernel/Net/Intel/E1000NetworkAdapter.h +++ b/Kernel/Net/Intel/E1000NetworkAdapter.h @@ -51,22 +51,22 @@ protected: virtual StringView class_name() const override { return "E1000NetworkAdapter"sv; } struct [[gnu::packed]] e1000_rx_desc { - volatile uint64_t addr { 0 }; - volatile uint16_t length { 0 }; - volatile uint16_t checksum { 0 }; - volatile uint8_t status { 0 }; - volatile uint8_t errors { 0 }; - volatile uint16_t special { 0 }; + uint64_t volatile addr { 0 }; + uint16_t volatile length { 0 }; + uint16_t volatile checksum { 0 }; + uint8_t volatile status { 0 }; + uint8_t volatile errors { 0 }; + uint16_t volatile special { 0 }; }; struct [[gnu::packed]] e1000_tx_desc { - volatile uint64_t addr { 0 }; - volatile uint16_t length { 0 }; - volatile uint8_t cso { 0 }; - volatile uint8_t cmd { 0 }; - volatile uint8_t status { 0 }; - volatile uint8_t css { 0 }; - volatile uint16_t special { 0 }; + uint64_t volatile addr { 0 }; + uint16_t volatile length { 0 }; + uint8_t volatile cso { 0 }; + uint8_t volatile cmd { 0 }; + uint8_t volatile status { 0 }; + uint8_t volatile css { 0 }; + uint16_t volatile special { 0 }; }; virtual void detect_eeprom(); diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 7c45d10e021..18ab549c1fb 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -340,9 +340,9 @@ void send_tcp_rst(IPv4Packet const& ipv4_packet, TCPPacket const& tcp_packet, Re auto ipv4_payload_offset = routing_decision.adapter->ipv4_payload_offset(); - const size_t options_size = 0; - const size_t tcp_header_size = sizeof(TCPPacket) + options_size; - const size_t buffer_size = ipv4_payload_offset + tcp_header_size; + size_t const options_size = 0; + size_t const tcp_header_size = sizeof(TCPPacket) + options_size; + size_t const buffer_size = ipv4_payload_offset + tcp_header_size; auto packet = routing_decision.adapter->acquire_packet_buffer(buffer_size); if (!packet) diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h index cfb501739aa..da8f1397ced 100644 --- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h +++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h @@ -50,12 +50,12 @@ private: bool determine_supported_version() const; struct [[gnu::packed]] TXDescriptor { - volatile u16 frame_length; // top 2 bits are reserved - volatile u16 flags; - volatile u16 vlan_tag; - volatile u16 vlan_flags; - volatile u32 buffer_address_low; - volatile u32 buffer_address_high; + u16 volatile frame_length; // top 2 bits are reserved + u16 volatile flags; + u16 volatile vlan_tag; + u16 volatile vlan_flags; + u32 volatile buffer_address_low; + u32 volatile buffer_address_high; // flags bit field static constexpr u16 Ownership = 0x8000u; @@ -68,12 +68,12 @@ private: static_assert(AssertSize()); struct [[gnu::packed]] RXDescriptor { - volatile u16 buffer_size; // top 2 bits are reserved - volatile u16 flags; - volatile u16 vlan_tag; - volatile u16 vlan_flags; - volatile u32 buffer_address_low; - volatile u32 buffer_address_high; + u16 volatile buffer_size; // top 2 bits are reserved + u16 volatile flags; + u16 volatile vlan_tag; + u16 volatile vlan_flags; + u32 volatile buffer_address_low; + u32 volatile buffer_address_high; // flags bit field static constexpr u16 Ownership = 0x8000u; diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h index b7fc5ad2579..001f2fc6470 100644 --- a/Kernel/Net/Routing.h +++ b/Kernel/Net/Routing.h @@ -34,10 +34,10 @@ struct Route final : public AtomicRefCounted { return destination == other.destination && (gateway == other.gateway || other.gateway.is_zero()) && netmask == other.netmask && flags == other.flags && adapter.ptr() == other.adapter.ptr(); } - const IPv4Address destination; - const IPv4Address gateway; - const IPv4Address netmask; - const u16 flags; + IPv4Address const destination; + IPv4Address const gateway; + IPv4Address const netmask; + u16 const flags; NonnullRefPtr const adapter; IntrusiveListNode> route_list_node {}; diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 4a44d94063c..15d2893d38f 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -733,7 +733,7 @@ void TCPSocket::retransmit_packets() packet.tx_counter++; if constexpr (TCP_SOCKET_DEBUG) { - auto& tcp_packet = *(const TCPPacket*)(packet.buffer->buffer->data() + packet.ipv4_payload_offset); + auto& tcp_packet = *(TCPPacket const*)(packet.buffer->buffer->data() + packet.ipv4_payload_offset); dbgln("Sending TCP packet from {}:{} to {}:{} with ({}{}{}{}) seq_no={}, ack_no={}, tx_counter={}", local_address(), local_port(), peer_address(), peer_port(), diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 70a8f21f1c0..0a1c5789366 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -91,7 +91,7 @@ ErrorOr UDPSocket::protocol_send(UserOrKernelBuffer const& data, size_t return set_so_error(EHOSTUNREACH); auto ipv4_payload_offset = routing_decision.adapter->ipv4_payload_offset(); data_length = min(data_length, routing_decision.adapter->mtu() - ipv4_payload_offset - sizeof(UDPPacket)); - const size_t udp_buffer_size = sizeof(UDPPacket) + data_length; + size_t const udp_buffer_size = sizeof(UDPPacket) + data_length; auto packet = routing_decision.adapter->acquire_packet_buffer(ipv4_payload_offset + udp_buffer_size); if (!packet) return set_so_error(ENOMEM); diff --git a/Kernel/Prekernel/UBSanitizer.cpp b/Kernel/Prekernel/UBSanitizer.cpp index 9f73d4fde32..fe17ea85786 100644 --- a/Kernel/Prekernel/UBSanitizer.cpp +++ b/Kernel/Prekernel/UBSanitizer.cpp @@ -130,8 +130,8 @@ void __ubsan_handle_implicit_conversion(ImplicitConversionData const& data, Valu print_location(data.location); } -void __ubsan_handle_invalid_builtin(const InvalidBuiltinData) __attribute__((used)); -void __ubsan_handle_invalid_builtin(const InvalidBuiltinData data) +void __ubsan_handle_invalid_builtin(InvalidBuiltinData const) __attribute__((used)); +void __ubsan_handle_invalid_builtin(InvalidBuiltinData const data) { print_location(data.location); } diff --git a/Kernel/Security/UBSanitizer.cpp b/Kernel/Security/UBSanitizer.cpp index 7e92fd9595c..72be1185e0d 100644 --- a/Kernel/Security/UBSanitizer.cpp +++ b/Kernel/Security/UBSanitizer.cpp @@ -188,8 +188,8 @@ void __ubsan_handle_implicit_conversion(ImplicitConversionData const& data, Valu print_location(data.location); } -void __ubsan_handle_invalid_builtin(const InvalidBuiltinData) __attribute__((used)); -void __ubsan_handle_invalid_builtin(const InvalidBuiltinData data) +void __ubsan_handle_invalid_builtin(InvalidBuiltinData const) __attribute__((used)); +void __ubsan_handle_invalid_builtin(InvalidBuiltinData const data) { critical_dmesgln("KUBSAN: passing invalid argument"); print_location(data.location); diff --git a/Kernel/Syscalls/SyscallHandler.cpp b/Kernel/Syscalls/SyscallHandler.cpp index 4e443199c77..408c38ac1d0 100644 --- a/Kernel/Syscalls/SyscallHandler.cpp +++ b/Kernel/Syscalls/SyscallHandler.cpp @@ -31,7 +31,7 @@ struct HandlerMetadata { }; #define __ENUMERATE_SYSCALL(sys_call, needs_lock) { bit_cast(&Process::sys$##sys_call), needs_lock }, -static const HandlerMetadata s_syscall_table[] = { +static HandlerMetadata const s_syscall_table[] = { ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL) }; #undef __ENUMERATE_SYSCALL diff --git a/Kernel/Tasks/Thread.h b/Kernel/Tasks/Thread.h index 8500ea650b8..c73cc8e331a 100644 --- a/Kernel/Tasks/Thread.h +++ b/Kernel/Tasks/Thread.h @@ -526,7 +526,7 @@ public: private: NonnullRefPtr m_blocked_description; - const BlockFlags m_flags; + BlockFlags const m_flags; BlockFlags& m_unblocked_flags; bool m_did_unblock { false }; }; diff --git a/Userland/Applications/3DFileViewer/Mesh.cpp b/Userland/Applications/3DFileViewer/Mesh.cpp index d4fc13c9b5d..c95fffb3ba1 100644 --- a/Userland/Applications/3DFileViewer/Mesh.cpp +++ b/Userland/Applications/3DFileViewer/Mesh.cpp @@ -13,7 +13,7 @@ #include "Mesh.h" -const Color colors[] { +Color const colors[] { Color::Red, Color::Green, Color::Blue, @@ -36,17 +36,17 @@ void Mesh::draw(float uv_scale) for (u32 i = 0; i < m_triangle_list.size(); i++) { auto const& triangle = m_triangle_list[i]; - const FloatVector3 vertex_a( + FloatVector3 const vertex_a( m_vertex_list.at(triangle.a).x, m_vertex_list.at(triangle.a).y, m_vertex_list.at(triangle.a).z); - const FloatVector3 vertex_b( + FloatVector3 const vertex_b( m_vertex_list.at(triangle.b).x, m_vertex_list.at(triangle.b).y, m_vertex_list.at(triangle.b).z); - const FloatVector3 vertex_c( + FloatVector3 const vertex_c( m_vertex_list.at(triangle.c).x, m_vertex_list.at(triangle.c).y, m_vertex_list.at(triangle.c).z); @@ -70,8 +70,8 @@ void Mesh::draw(float uv_scale) } else { // Compute the triangle normal - const FloatVector3 vec_ab = vertex_b - vertex_a; - const FloatVector3 vec_ac = vertex_c - vertex_a; + FloatVector3 const vec_ab = vertex_b - vertex_a; + FloatVector3 const vec_ac = vertex_c - vertex_a; normal_a = vec_ab.cross(vec_ac).normalized(); normal_b = normal_a; normal_c = normal_a; diff --git a/Userland/Applications/Calendar/CalendarWidget.cpp b/Userland/Applications/Calendar/CalendarWidget.cpp index 1a0f522994a..72fe5c4caf4 100644 --- a/Userland/Applications/Calendar/CalendarWidget.cpp +++ b/Userland/Applications/Calendar/CalendarWidget.cpp @@ -299,7 +299,7 @@ ErrorOr> CalendarWidget::create_open_settings_action( void CalendarWidget::create_on_tile_doubleclick() { m_event_calendar->on_tile_doubleclick = [&] { - for (const auto& event : m_event_calendar->event_manager().events()) { + for (auto const& event : m_event_calendar->event_manager().events()) { auto start = event.start; auto selected_date = m_event_calendar->selected_date(); diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp index a2ee0319c14..889e5b39498 100644 --- a/Userland/Applications/Debugger/main.cpp +++ b/Userland/Applications/Debugger/main.cpp @@ -248,14 +248,14 @@ ErrorOr serenity_main(Main::Arguments arguments) } VERIFY(optional_regs.has_value()); - const PtraceRegisters& regs = optional_regs.value(); + PtraceRegisters const& regs = optional_regs.value(); #if ARCH(X86_64) - const FlatPtr ip = regs.rip; + FlatPtr const ip = regs.rip; #elif ARCH(AARCH64) - const FlatPtr ip = 0; // FIXME + FlatPtr const ip = 0; // FIXME TODO_AARCH64(); #elif ARCH(RISCV64) - const FlatPtr ip = 0; // FIXME + FlatPtr const ip = 0; // FIXME TODO_RISCV64(); #else # error Unknown architecture diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 04e0063cdc1..215816ddeba 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -97,7 +97,7 @@ void KeyboardMapperWidget::create_frame() bottom_widget.add_spacer(); } -void KeyboardMapperWidget::add_map_radio_button(const StringView map_name, String button_text) +void KeyboardMapperWidget::add_map_radio_button(StringView const map_name, String button_text) { auto& map_radio_button = m_map_group->add(button_text); map_radio_button.set_name(map_name); @@ -106,7 +106,7 @@ void KeyboardMapperWidget::add_map_radio_button(const StringView map_name, Strin }; } -u32* KeyboardMapperWidget::map_from_name(const StringView map_name) +u32* KeyboardMapperWidget::map_from_name(StringView const map_name) { u32* map; if (map_name == "map"sv) { @@ -234,7 +234,7 @@ void KeyboardMapperWidget::keyup_event(GUI::KeyEvent& event) } } -void KeyboardMapperWidget::set_current_map(const ByteString current_map) +void KeyboardMapperWidget::set_current_map(ByteString const current_map) { m_current_map_name = current_map; u32* map = map_from_name(m_current_map_name); diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h index c46af2a14d7..0ceb22c6361 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h @@ -31,7 +31,7 @@ protected: virtual void keydown_event(GUI::KeyEvent&) override; virtual void keyup_event(GUI::KeyEvent&) override; - void set_current_map(const ByteString); + void set_current_map(ByteString const); void update_window_title(); private: @@ -39,8 +39,8 @@ private: Vector m_keys; RefPtr m_map_group; - void add_map_radio_button(const StringView map_name, String button_text); - u32* map_from_name(const StringView map_name); + void add_map_radio_button(StringView const map_name, String button_text); + u32* map_from_name(StringView const map_name); void update_modifier_radio_buttons(GUI::KeyEvent&); ByteString m_filename; diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp index 43462f4f72f..d1d8d5f3041 100644 --- a/Userland/Applications/Mail/MailWidget.cpp +++ b/Userland/Applications/Mail/MailWidget.cpp @@ -475,7 +475,7 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index) auto& body_data = fetch_response_data.body_data(); auto body_text_part_iterator = body_data.find_if([](Tuple& data) { - const auto data_item = data.get<0>(); + auto const data_item = data.get<0>(); return data_item.section.has_value() && data_item.section->type == IMAP::FetchCommand::DataItem::SectionType::Parts; }); VERIFY(body_text_part_iterator != body_data.end()); diff --git a/Userland/Applications/Piano/Music.h b/Userland/Applications/Piano/Music.h index 70976149e33..30c71b7e791 100644 --- a/Userland/Applications/Piano/Music.h +++ b/Userland/Applications/Piano/Music.h @@ -51,10 +51,10 @@ constexpr KeyColor key_pattern[] = { White, }; -const Color note_pressed_color(64, 64, 255); -const Color column_playing_color(128, 128, 255); +Color const note_pressed_color(64, 64, 255); +Color const column_playing_color(128, 128, 255); -const Color left_wave_colors[] = { +Color const left_wave_colors[] = { // Sine { 255, @@ -96,7 +96,7 @@ const Color left_wave_colors[] = { // HACK: make the display code shut up for now constexpr int RecordedSample = 5; -const Color right_wave_colors[] = { +Color const right_wave_colors[] = { // Sine { 255, diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index 5ba2defb17b..3ec536fa517 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -237,8 +237,8 @@ void RollWidget::mousemove_event(GUI::MouseEvent& event) int const x_start = get_note_for_x(m_mousedown_event.value().x()); int const x_end = get_note_for_x(event.x()); - const u32 on_sample = round(roll_length * (static_cast(min(x_start, x_end)) / m_num_notes)); - const u32 off_sample = round(roll_length * (static_cast(max(x_start, x_end) + 1) / m_num_notes)) - 1; + u32 const on_sample = round(roll_length * (static_cast(min(x_start, x_end)) / m_num_notes)); + u32 const off_sample = round(roll_length * (static_cast(max(x_start, x_end) + 1) / m_num_notes)) - 1; auto const note = RollNote { on_sample, off_sample, get_pitch_for_y(m_mousedown_event.value().y()), 127 }; m_track_manager.current_track()->set_note(note); diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 321172f7a6f..cf80d89394c 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -248,8 +248,8 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) } // Mouse position indicator - const Gfx::IntPoint indicator_x({ m_mouse_position.x(), m_ruler_thickness }); - const Gfx::IntPoint indicator_y({ m_ruler_thickness, m_mouse_position.y() }); + Gfx::IntPoint const indicator_x({ m_mouse_position.x(), m_ruler_thickness }); + Gfx::IntPoint const indicator_y({ m_ruler_thickness, m_mouse_position.y() }); painter.draw_triangle(indicator_x, indicator_x + Gfx::IntPoint(-m_mouse_indicator_triangle_size, -m_mouse_indicator_triangle_size), indicator_x + Gfx::IntPoint(m_mouse_indicator_triangle_size, -m_mouse_indicator_triangle_size), mouse_indicator_color); painter.draw_triangle(indicator_y, indicator_y + Gfx::IntPoint(-m_mouse_indicator_triangle_size, -m_mouse_indicator_triangle_size), indicator_y + Gfx::IntPoint(-m_mouse_indicator_triangle_size, m_mouse_indicator_triangle_size), mouse_indicator_color); @@ -276,15 +276,15 @@ int ImageEditor::calculate_ruler_step_size() const Gfx::IntRect ImageEditor::mouse_indicator_rect_x() const { - const Gfx::IntPoint top_left({ m_ruler_thickness, m_ruler_thickness - m_mouse_indicator_triangle_size }); - const Gfx::IntSize size({ width() + 1, m_mouse_indicator_triangle_size + 1 }); + Gfx::IntPoint const top_left({ m_ruler_thickness, m_ruler_thickness - m_mouse_indicator_triangle_size }); + Gfx::IntSize const size({ width() + 1, m_mouse_indicator_triangle_size + 1 }); return Gfx::IntRect(top_left, size); } Gfx::IntRect ImageEditor::mouse_indicator_rect_y() const { - const Gfx::IntPoint top_left({ m_ruler_thickness - m_mouse_indicator_triangle_size, m_ruler_thickness }); - const Gfx::IntSize size({ m_mouse_indicator_triangle_size + 1, height() + 1 }); + Gfx::IntPoint const top_left({ m_ruler_thickness - m_mouse_indicator_triangle_size, m_ruler_thickness }); + Gfx::IntSize const size({ m_mouse_indicator_triangle_size + 1, height() + 1 }); return Gfx::IntRect(top_left, size); } diff --git a/Userland/Applications/PixelPaint/Tools/GradientTool.cpp b/Userland/Applications/PixelPaint/Tools/GradientTool.cpp index fad240147b5..d91c8a2a9d8 100644 --- a/Userland/Applications/PixelPaint/Tools/GradientTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GradientTool.cpp @@ -343,7 +343,7 @@ void GradientTool::calculate_gradient_lines() m_editor->update(); } -void GradientTool::draw_gradient(GUI::Painter& painter, bool with_guidelines, const Gfx::FloatPoint drawing_offset, float scale, Optional gradient_clip) +void GradientTool::draw_gradient(GUI::Painter& painter, bool with_guidelines, Gfx::FloatPoint const drawing_offset, float scale, Optional gradient_clip) { auto t_gradient_begin_line = m_gradient_begin_line.scaled(scale, scale).translated(drawing_offset); auto t_gradient_center_line = m_gradient_center_line.scaled(scale, scale).translated(drawing_offset); diff --git a/Userland/Applications/PixelPaint/Tools/GradientTool.h b/Userland/Applications/PixelPaint/Tools/GradientTool.h index 1cfd8db9a4e..85a01e3302a 100644 --- a/Userland/Applications/PixelPaint/Tools/GradientTool.h +++ b/Userland/Applications/PixelPaint/Tools/GradientTool.h @@ -72,7 +72,7 @@ private: void calculate_gradient_lines(); void calculate_transversal_points(float scale_fraction); - void draw_gradient(GUI::Painter&, bool with_guidelines = false, const Gfx::FloatPoint drawing_offset = { 0.0f, 0.0f }, float scale = 1, Optional gradient_clip = {}); + void draw_gradient(GUI::Painter&, bool with_guidelines = false, Gfx::FloatPoint const drawing_offset = { 0.0f, 0.0f }, float scale = 1, Optional gradient_clip = {}); bool has_gradient_data() { return m_gradient_center.has_value() && m_gradient_end.has_value() && m_gradient_start.has_value(); } void move_gradient_position(Gfx::IntPoint const movement_delta); void rasterize_gradient(); diff --git a/Userland/Applications/SoundPlayer/Playlist.h b/Userland/Applications/SoundPlayer/Playlist.h index 370fc6b341f..c0c0344a763 100644 --- a/Userland/Applications/SoundPlayer/Playlist.h +++ b/Userland/Applications/SoundPlayer/Playlist.h @@ -41,8 +41,8 @@ private: class BloomFilter { public: void reset() { m_bitmap = 0; } - void add(const StringView key) { m_bitmap |= mask_for_key(key); } - bool maybe_contains(const StringView key) const + void add(StringView const key) { m_bitmap |= mask_for_key(key); } + bool maybe_contains(StringView const key) const { auto mask = mask_for_key(key); return (m_bitmap & mask) == mask; diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp index 3679d2ba6af..f3939084912 100644 --- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp +++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp @@ -122,12 +122,12 @@ void TreeMapWidget::lay_out_children(TreeNode const& node, Gfx::IntRect const& r Gfx::IntRect canvas = rect; bool remaining_nodes_are_too_small = false; for (size_t i = 0; !remaining_nodes_are_too_small && i < node.num_children(); i++) { - const i64 i_node_area = node.child_at(i).area(); + i64 const i_node_area = node.child_at(i).area(); if (i_node_area == 0) break; - const size_t long_side_size = max(canvas.width(), canvas.height()); - const size_t short_side_size = min(canvas.width(), canvas.height()); + size_t const long_side_size = max(canvas.width(), canvas.height()); + size_t const short_side_size = min(canvas.width(), canvas.height()); size_t row_or_column_size = long_side_size * i_node_area / total_area; i64 node_area_sum = i_node_area; @@ -163,7 +163,7 @@ void TreeMapWidget::lay_out_children(TreeNode const& node, Gfx::IntRect const& r // Paint the elements from 'i' up to and including 'k-1'. { - const size_t fixed_side_size = row_or_column_size; + size_t const fixed_side_size = row_or_column_size; i64 placement_area = node_area_sum; size_t main_dim = short_side_size; diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 738a175f586..0b59c13a331 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -163,7 +163,7 @@ ErrorOr serenity_main(Main::Arguments arguments) continue; } - const TreeNode* node = tree_map_widget.path_node(k); + TreeNode const* node = tree_map_widget.path_node(k); builder.append('/'); builder.append(node->name()); diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp index 1ce5344ecd4..83b141858ba 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp @@ -145,7 +145,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector const& po type_list.set_model(*GUI::ItemListModel::create(g_types)); type_list.set_should_hide_unnecessary_scrollbars(true); type_list.on_selection_change = [&] { - const auto& index = type_list.selection().first(); + auto const& index = type_list.selection().first(); if (!index.is_valid()) { m_type = nullptr; return; diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.h b/Userland/Applications/Spreadsheet/Readers/XSV.h index 7dc3c275fd6..65e40c2f859 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.h +++ b/Userland/Applications/Spreadsheet/Readers/XSV.h @@ -107,7 +107,7 @@ public: size_t index() const { return m_index; } size_t size() const { return m_xsv.headers().size(); } - using ConstIterator = AK::SimpleIterator; + using ConstIterator = AK::SimpleIterator; using Iterator = AK::SimpleIterator; constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } @@ -168,7 +168,7 @@ public: size_t m_index { 0 }; }; - const Row operator[](size_t index) const; + Row const operator[](size_t index) const; Row operator[](size_t index); Row at(size_t index) const; diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index c01ad03e8c5..9bde4cd21d2 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -455,7 +455,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) auto conditional_formats = obj.get_array("conditional_formats"sv); auto cformats = cell->conditional_formats(); if (conditional_formats.has_value()) { - conditional_formats->for_each([&](const auto& fmt_val) { + conditional_formats->for_each([&](auto const& fmt_val) { if (!fmt_val.is_object()) return IterationDecision::Continue; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index f5521360e00..8462dd857b6 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -193,7 +193,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector source_positions, target_positions; auto lines = spreadsheet_data.value().split_view('\n'); diff --git a/Userland/Demos/Gradient/Gradient.cpp b/Userland/Demos/Gradient/Gradient.cpp index c4082b191b1..56168c6057b 100644 --- a/Userland/Demos/Gradient/Gradient.cpp +++ b/Userland/Demos/Gradient/Gradient.cpp @@ -56,7 +56,7 @@ void Gradient::timer_event(Core::TimerEvent&) void Gradient::draw() { - const Color colors[] { + Color const colors[] { Color::Blue, Color::Cyan, Color::Green, @@ -65,7 +65,7 @@ void Gradient::draw() Color::Yellow, }; - const Orientation orientations[] { + Orientation const orientations[] { Gfx::Orientation::Horizontal, Gfx::Orientation::Vertical }; diff --git a/Userland/DevTools/HackStudio/ClassViewWidget.cpp b/Userland/DevTools/HackStudio/ClassViewWidget.cpp index d27c5dd3d30..f5e4e9f7b0a 100644 --- a/Userland/DevTools/HackStudio/ClassViewWidget.cpp +++ b/Userland/DevTools/HackStudio/ClassViewWidget.cpp @@ -19,11 +19,11 @@ ClassViewWidget::ClassViewWidget() m_class_tree = add(); m_class_tree->on_selection_change = [this] { - const auto& index = m_class_tree->selection().first(); + auto const& index = m_class_tree->selection().first(); if (!index.is_valid()) return; - auto* node = static_cast(index.internal_data()); + auto* node = static_cast(index.internal_data()); if (!node->declaration) return; diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index 77c64f177fe..5b2c161a867 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -81,7 +81,7 @@ DebugInfoWidget::DebugInfoWidget() variables_tab_widget.add_widget(build_registers_tab()); m_backtrace_view->on_selection_change = [this] { - const auto& index = m_backtrace_view->selection().first(); + auto const& index = m_backtrace_view->selection().first(); if (!index.is_valid()) { return; diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp index 3f22bfcea88..6f6d96a3697 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp @@ -187,7 +187,7 @@ int Debugger::debugger_loop(Debug::DebugSession::DesiredInitialDebugeeState init } remove_temporary_breakpoints(); VERIFY(optional_regs.has_value()); - const PtraceRegisters& regs = optional_regs.value(); + PtraceRegisters const& regs = optional_regs.value(); auto source_position = m_debug_session->get_source_position(regs.ip()); if (!source_position.has_value()) diff --git a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp index c123e6ea040..8c25aef260e 100644 --- a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp @@ -128,7 +128,7 @@ FindInFilesWidget::FindInFilesWidget() m_result_view = add(); m_result_view->on_activation = [](auto& index) { - auto& match = *(const Match*)index.internal_data(); + auto& match = *(Match const*)index.internal_data(); open_file(match.filename); current_editor().set_selection(match.range); current_editor().set_focus(true); diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 02d853f7c50..d63f263828b 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -43,11 +43,11 @@ GitWidget::GitWidget() [this](auto const& file) { stage_file(file); }, Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors()); m_unstaged_files->on_selection_change = [this] { - const auto& index = m_unstaged_files->selection().first(); + auto const& index = m_unstaged_files->selection().first(); if (!index.is_valid()) return; - const auto& selected = index.data().as_string(); + auto const& selected = index.data().as_string(); show_diff(selected); }; diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index b815bb06c60..0b080ad6c7a 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1044,7 +1044,7 @@ void HackStudioWidget::initialize_debugger() m_project->root_path(), [this](PtraceRegisters const& regs) { VERIFY(Debugger::the().session()); - const auto& debug_session = *Debugger::the().session(); + auto const& debug_session = *Debugger::the().session(); auto source_position = debug_session.get_source_position(regs.ip()); if (!source_position.has_value()) { dbgln("Could not find source position for address: {:p}", regs.ip()); diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.h b/Userland/DevTools/HackStudio/ProjectTemplate.h index edee50348b3..9e5f0750ac0 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.h +++ b/Userland/DevTools/HackStudio/ProjectTemplate.h @@ -29,7 +29,7 @@ public: ByteString const& name() const { return m_name; } ByteString const& description() const { return m_description; } const GUI::Icon& icon() const { return m_icon; } - const ByteString content_path() const + ByteString const content_path() const { return LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", templates_path(), m_id)); } diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index faa676f5c95..de8db6ba798 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -121,8 +121,8 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) float hdx = h * cosf(phi); float hdy = h * sinf(phi); - const auto cos_pi_2_phi = cosf(float { M_PI_2 } - phi); - const auto sin_pi_2_phi = sinf(float { M_PI_2 } - phi); + auto const cos_pi_2_phi = cosf(float { M_PI_2 } - phi); + auto const sin_pi_2_phi = sinf(float { M_PI_2 } - phi); Gfx::FloatPoint A1(A.x() - (w1 / 2) * cos_pi_2_phi, A.y() - (w1 / 2) * sin_pi_2_phi); Gfx::FloatPoint B3(A.x() + (w1 / 2) * cos_pi_2_phi, A.y() + (w1 / 2) * sin_pi_2_phi); diff --git a/Userland/Games/FlappyBug/Game.h b/Userland/Games/FlappyBug/Game.h index 88e3ac64b61..d58a0f8ec10 100644 --- a/Userland/Games/FlappyBug/Game.h +++ b/Userland/Games/FlappyBug/Game.h @@ -176,8 +176,8 @@ private: float m_difficulty {}; float m_restart_cooldown {}; NonnullRefPtr m_background_bitmap { Gfx::Bitmap::load_from_file("/res/graphics/flappybug/background.png"sv).release_value_but_fixme_should_propagate_errors() }; - const Gfx::IntRect m_score_rect { 10, 10, 20, 20 }; - const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 }; + Gfx::IntRect const m_score_rect { 10, 10, 20, 20 }; + Gfx::IntRect const m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 }; Game(Bug, Cloud); }; diff --git a/Userland/Libraries/LibAudio/Resampler.h b/Userland/Libraries/LibAudio/Resampler.h index c4c2e11af21..81640420483 100644 --- a/Userland/Libraries/LibAudio/Resampler.h +++ b/Userland/Libraries/LibAudio/Resampler.h @@ -90,8 +90,8 @@ public: u32 target() const { return m_target; } private: - const u32 m_source; - const u32 m_target; + u32 const m_source; + u32 const m_target; u32 m_current_ratio { 0 }; SampleType m_last_sample_l {}; SampleType m_last_sample_r {}; diff --git a/Userland/Libraries/LibC/net.cpp b/Userland/Libraries/LibC/net.cpp index 3b83df8f61c..88ab6fb3db0 100644 --- a/Userland/Libraries/LibC/net.cpp +++ b/Userland/Libraries/LibC/net.cpp @@ -11,8 +11,8 @@ #include #include -const in6_addr in6addr_any = IN6ADDR_ANY_INIT; -const in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; +in6_addr const in6addr_any = IN6ADDR_ANY_INIT; +in6_addr const in6addr_loopback = IN6ADDR_LOOPBACK_INIT; // https://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nametoindex.html unsigned int if_nametoindex([[maybe_unused]] char const* ifname) diff --git a/Userland/Libraries/LibC/qsort.cpp b/Userland/Libraries/LibC/qsort.cpp index f628e0e1890..1bd437a93e9 100644 --- a/Userland/Libraries/LibC/qsort.cpp +++ b/Userland/Libraries/LibC/qsort.cpp @@ -31,7 +31,7 @@ template<> inline void swap(SizedObject const& a, SizedObject const& b) { VERIFY(a.size() == b.size()); - const size_t size = a.size(); + size_t const size = a.size(); auto const a_data = reinterpret_cast(a.data()); auto const b_data = reinterpret_cast(b.data()); for (auto i = 0u; i < size; ++i) { @@ -49,7 +49,7 @@ public: , m_element_size(element_size) { } - const SizedObject operator[](size_t index) + SizedObject const operator[](size_t index) { return { static_cast(m_data) + index * m_element_size, m_element_size }; } diff --git a/Userland/Libraries/LibC/scanf.cpp b/Userland/Libraries/LibC/scanf.cpp index 887cb223b3d..bcd26abb9f6 100644 --- a/Userland/Libraries/LibC/scanf.cpp +++ b/Userland/Libraries/LibC/scanf.cpp @@ -316,7 +316,7 @@ private: return invert ^ scan_set.contains(c); } - const StringView scan_set; + StringView const scan_set; bool invert { false }; }; diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index 76ea655e4ef..7e933ee91a7 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -144,7 +144,7 @@ private: return m_sign != Sign::Negative; } - const T m_base; + T const m_base; T m_num; T m_cutoff; int m_max_digit_after_cutoff; @@ -313,7 +313,7 @@ static T c_str_to_floating_point(char const* str, char** endptr) // - One of INF or INFINITY, ignoring case // - One of NAN or NAN(n-char-sequenceopt), ignoring case in the NAN part - const Sign sign = strtosign(parse_ptr, &parse_ptr); + Sign const sign = strtosign(parse_ptr, &parse_ptr); if (is_infinity_string(parse_ptr, endptr)) { // Don't set errno to ERANGE here: @@ -973,7 +973,7 @@ long long strtoll(char const* str, char** endptr, int base) // Parse spaces and sign char* parse_ptr = const_cast(str); strtons(parse_ptr, &parse_ptr); - const Sign sign = strtosign(parse_ptr, &parse_ptr); + Sign const sign = strtosign(parse_ptr, &parse_ptr); // Parse base if (base == 0) { diff --git a/Userland/Libraries/LibCards/Card.h b/Userland/Libraries/LibCards/Card.h index f0e193322b4..d126c39e23b 100644 --- a/Userland/Libraries/LibCards/Card.h +++ b/Userland/Libraries/LibCards/Card.h @@ -103,7 +103,7 @@ public: bool is_disabled() const { return m_disabled; } Gfx::Color color() const { return (m_suit == Suit::Diamonds || m_suit == Suit::Hearts) ? Color::Red : Color::Black; } - void set_position(const Gfx::IntPoint p) { m_rect.set_location(p); } + void set_position(Gfx::IntPoint const p) { m_rect.set_location(p); } void set_moving(bool moving) { m_moving = moving; } void set_upside_down(bool upside_down) { m_upside_down = upside_down; } void set_inverted(bool inverted) { m_inverted = inverted; } diff --git a/Userland/Libraries/LibChess/Chess.cpp b/Userland/Libraries/LibChess/Chess.cpp index 245606a9282..7993b6ce9e8 100644 --- a/Userland/Libraries/LibChess/Chess.cpp +++ b/Userland/Libraries/LibChess/Chess.cpp @@ -116,7 +116,7 @@ ErrorOr Move::to_long_algebraic() const return builder.to_string(); } -Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& board) +Move Move::from_algebraic(StringView algebraic, Color const turn, Board const& board) { auto move_string = algebraic; Move move({ 50, 50 }, { 50, 50 }); @@ -294,7 +294,7 @@ ErrorOr Board::to_fen() const int empty = 0; for (int rank = 0; rank < 8; rank++) { for (int file = 0; file < 8; file++) { - const Piece p(get_piece({ 7 - rank, file })); + Piece const p(get_piece({ 7 - rank, file })); if (p.type == Type::None) { empty++; continue; diff --git a/Userland/Libraries/LibChess/Chess.h b/Userland/Libraries/LibChess/Chess.h index 6037cb4200c..47d2691bcfa 100644 --- a/Userland/Libraries/LibChess/Chess.h +++ b/Userland/Libraries/LibChess/Chess.h @@ -117,7 +117,7 @@ struct Move { } bool operator==(Move const& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; } - static Move from_algebraic(StringView algebraic, const Color turn, Board const& board); + static Move from_algebraic(StringView algebraic, Color const turn, Board const& board); ErrorOr to_long_algebraic() const; ErrorOr to_algebraic() const; }; diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp index e0b080b59e9..4e5d79e6c65 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp @@ -206,7 +206,7 @@ Vector CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode return scope_parts; } -Vector CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const ByteString partial_text) const +Vector CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, ByteString const partial_text) const { VERIFY(parent.object()); auto type = type_of(document, *parent.object()); diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h index c6580613e96..60d3c3b61f1 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h @@ -95,7 +95,7 @@ private: HashTable m_available_headers; }; - Vector autocomplete_property(DocumentData const&, MemberExpression const&, const ByteString partial_text) const; + Vector autocomplete_property(DocumentData const&, MemberExpression const&, ByteString const partial_text) const; Vector autocomplete_name(DocumentData const&, ASTNode const&, ByteString const& partial_text) const; ByteString type_of(DocumentData const&, Expression const&) const; ByteString type_of_property(DocumentData const&, Identifier const&) const; diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index d5a2ef35b41..d35201af431 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -532,7 +532,7 @@ void DeflateCompressor::close() // Knuth's multiplicative hash on 4 bytes u16 DeflateCompressor::hash_sequence(u8 const* bytes) { - constexpr const u32 knuth_constant = 2654435761; // shares no common factors with 2^32 + constexpr u32 const knuth_constant = 2654435761; // shares no common factors with 2^32 return ((bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24) * knuth_constant) >> (32 - hash_bits); } diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp index de66ac1f006..8a4503f1f28 100644 --- a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp +++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp @@ -25,7 +25,7 @@ ErrorOr ProcessStatisticsReader::get_all(SeekableStream& auto file_contents = TRY(proc_all_file.read_until_eof()); auto json_obj = TRY(JsonValue::from_string(file_contents)).as_object(); json_obj.get_array("processes"sv)->for_each([&](auto& value) { - const JsonObject& process_object = value.as_object(); + JsonObject const& process_object = value.as_object(); Core::ProcessStatistics process; // kernel data first diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp index b774936276a..f823f8de9d8 100644 --- a/Userland/Libraries/LibCoredump/Reader.cpp +++ b/Userland/Libraries/LibCoredump/Reader.cpp @@ -146,7 +146,7 @@ Optional Reader::peek_memory(FlatPtr address) const return value; } -const JsonObject Reader::process_info() const +JsonObject const Reader::process_info() const { const ELF::Core::ProcessInfo* process_info_notes_entry = nullptr; NotesEntryIterator it(bit_cast(m_coredump_image.program_header(m_notes_segment_index).raw_data())); diff --git a/Userland/Libraries/LibCoredump/Reader.h b/Userland/Libraries/LibCoredump/Reader.h index 7c5be3544ad..5a8813f5334 100644 --- a/Userland/Libraries/LibCoredump/Reader.h +++ b/Userland/Libraries/LibCoredump/Reader.h @@ -105,7 +105,7 @@ private: // Private as we don't need anyone poking around in this JsonObject // manually - we know very well what should be included and expose that // as getters with the appropriate (non-JsonValue) types. - const JsonObject process_info() const; + JsonObject const process_info() const; // For uncompressed coredumps, we keep the MappedFile OwnPtr m_mapped_file; diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.cpp b/Userland/Libraries/LibCrypto/Authentication/GHash.cpp index f53097c7715..1ca2013f41e 100644 --- a/Userland/Libraries/LibCrypto/Authentication/GHash.cpp +++ b/Userland/Libraries/LibCrypto/Authentication/GHash.cpp @@ -86,7 +86,7 @@ GHash::TagType GHash::process(ReadonlyBytes aad, ReadonlyBytes cipher) /// Galois Field multiplication using . /// Note that x, y, and z are strictly BE. -void galois_multiply(u32 (&z)[4], const u32 (&_x)[4], const u32 (&_y)[4]) +void galois_multiply(u32 (&z)[4], u32 const (&_x)[4], u32 const (&_y)[4]) { u32 x[4] { _x[0], _x[1], _x[2], _x[3] }; u32 y[4] { _y[0], _y[1], _y[2], _y[3] }; diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.h b/Userland/Libraries/LibCrypto/Authentication/GHash.h index e61a09b76b6..ff4d8552800 100644 --- a/Userland/Libraries/LibCrypto/Authentication/GHash.h +++ b/Userland/Libraries/LibCrypto/Authentication/GHash.h @@ -17,7 +17,7 @@ namespace Crypto::Authentication { -void galois_multiply(u32 (&z)[4], const u32 (&x)[4], const u32 (&y)[4]); +void galois_multiply(u32 (&z)[4], u32 const (&x)[4], u32 const (&y)[4]); struct GHashDigest { constexpr static size_t Size = 16; diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index 6c88dfb2027..1af99881465 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp @@ -545,8 +545,8 @@ u32 UnsignedBigInteger::hash() const void UnsignedBigInteger::set_bit_inplace(size_t bit_index) { - const size_t word_index = bit_index / UnsignedBigInteger::BITS_IN_WORD; - const size_t inner_word_index = bit_index % UnsignedBigInteger::BITS_IN_WORD; + size_t const word_index = bit_index / UnsignedBigInteger::BITS_IN_WORD; + size_t const inner_word_index = bit_index % UnsignedBigInteger::BITS_IN_WORD; m_words.ensure_capacity(word_index + 1); diff --git a/Userland/Libraries/LibCrypto/Hash/BLAKE2b.cpp b/Userland/Libraries/LibCrypto/Hash/BLAKE2b.cpp index d4dc3e47c79..fa9ac331d82 100644 --- a/Userland/Libraries/LibCrypto/Hash/BLAKE2b.cpp +++ b/Userland/Libraries/LibCrypto/Hash/BLAKE2b.cpp @@ -61,7 +61,7 @@ BLAKE2b::DigestType BLAKE2b::digest() return digest; } -void BLAKE2b::increment_counter_by(const u64 amount) +void BLAKE2b::increment_counter_by(u64 const amount) { m_internal_state.message_byte_offset[0] += amount; m_internal_state.message_byte_offset[1] += (m_internal_state.message_byte_offset[0] < amount); diff --git a/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h b/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h index 756616a3bb2..05d3a8d4fb5 100644 --- a/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h +++ b/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h @@ -86,7 +86,7 @@ private: BLAKE2bState m_internal_state {}; void mix(u64* work_vector, u64 a, u64 b, u64 c, u64 d, u64 x, u64 y); - void increment_counter_by(const u64 amount); + void increment_counter_by(u64 const amount); void transform(u8 const*); }; diff --git a/Userland/Libraries/LibDiff/Applier.cpp b/Userland/Libraries/LibDiff/Applier.cpp index c1a7e90860f..e3f7b75a0c4 100644 --- a/Userland/Libraries/LibDiff/Applier.cpp +++ b/Userland/Libraries/LibDiff/Applier.cpp @@ -81,7 +81,7 @@ static Optional locate_hunk(Vector const& content, Hunk co line += prefix_fuzz; // Ensure that all of the lines in the hunk match starting from 'line', ignoring the specified number of context lines. - return all_of(hunk.lines.begin() + prefix_fuzz, hunk.lines.end() - suffix_fuzz, [&](const Line& hunk_line) { + return all_of(hunk.lines.begin() + prefix_fuzz, hunk.lines.end() - suffix_fuzz, [&](Line const& hunk_line) { // Ignore additions in our increment of line and comparison as they are not part of the 'original file' if (hunk_line.operation == Line::Operation::Addition) return true; diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index 191f5565c15..d57aa162f5b 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.cpp +++ b/Userland/Libraries/LibELF/DynamicLinker.cpp @@ -439,7 +439,7 @@ static Optional verify_tls_for_dlopen(DynamicLoader const& loade if (program_header.type() != PT_TLS) return IterationDecision::Continue; - auto* tls_data = (const u8*)loader.image().base_address() + program_header.offset(); + auto* tls_data = (u8 const*)loader.image().base_address() + program_header.offset(); for (size_t i = 0; i < program_header.size_in_image(); ++i) { if (tls_data[i] != 0) { tls_data_is_all_zero = false; diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index 98283f38f55..284d55516ec 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -772,7 +772,7 @@ void DynamicLoader::copy_initial_tls_data_into(ByteBuffer& buffer) const VERIFY(program_header.size_in_image() <= program_header.size_in_memory()); VERIFY(program_header.size_in_memory() <= m_tls_size_of_current_object); VERIFY(tls_start_in_buffer + program_header.size_in_memory() <= buffer.size()); - memcpy(buffer.data() + tls_start_in_buffer, static_cast(m_file_data) + program_header.offset(), program_header.size_in_image()); + memcpy(buffer.data() + tls_start_in_buffer, static_cast(m_file_data) + program_header.offset(), program_header.size_in_image()); return IterationDecision::Break; }); diff --git a/Userland/Libraries/LibELF/Hashes.h b/Userland/Libraries/LibELF/Hashes.h index f941e450ba9..0fbbfea7eda 100644 --- a/Userland/Libraries/LibELF/Hashes.h +++ b/Userland/Libraries/LibELF/Hashes.h @@ -22,7 +22,7 @@ constexpr u32 compute_sysv_hash(StringView name) hash = hash << 4; hash += ch; - const u32 top_nibble_of_hash = hash & 0xf0000000u; + u32 const top_nibble_of_hash = hash & 0xf0000000u; hash ^= top_nibble_of_hash >> 24; hash &= ~top_nibble_of_hash; } diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.h b/Userland/Libraries/LibGUI/Breadcrumbbar.h index c53a3266692..267b8bc3963 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.h +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.h @@ -47,7 +47,7 @@ private: virtual void resize_event(ResizeEvent&) override; struct Segment { - RefPtr icon; + RefPtr icon; ByteString text; ByteString data; int width { 0 }; diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 59531413cf8..5cda98fb1ed 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -29,7 +29,7 @@ public: void set_selected(bool selected); Color color() const { return m_color; } - Function on_click; + Function on_click; protected: virtual void click(unsigned modifiers = 0) override; diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 27d1c7f5e5a..7849e0fc981 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -124,7 +124,7 @@ ComboBox::ComboBox() m_list_view->set_activates_on_selection(true); m_list_view->on_selection_change = [this] { VERIFY(model()); - const auto& index = m_list_view->selection().first(); + auto const& index = m_list_view->selection().first(); if (m_updating_model) selection_updated(index); }; diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index d6b37fab352..ced378258c9 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -260,7 +260,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St auto index = m_view->selection().first(); auto& filter_model = (SortingProxyModel&)*m_view->model(); auto local_index = filter_model.map_to_source(index); - const FileSystemModel::Node& node = m_model->node(local_index); + FileSystemModel::Node const& node = m_model->node(local_index); auto should_open_folder = m_mode == Mode::OpenFolder; if (should_open_folder == node.is_directory()) { @@ -273,7 +273,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St m_view->on_activation = [this](auto& index) { auto& filter_model = (SortingProxyModel&)*m_view->model(); auto local_index = filter_model.map_to_source(index); - const FileSystemModel::Node& node = m_model->node(local_index); + FileSystemModel::Node const& node = m_model->node(local_index); auto path = node.full_path(); if (node.is_directory() || node.is_symlink_to_directory()) { diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index d76f9a81e46..bbbdbfff128 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -56,7 +56,7 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo quick_sort(m_families); m_family_list_view->on_selection_change = [this] { - const auto& index = m_family_list_view->selection().first(); + auto const& index = m_family_list_view->selection().first(); m_family = MUST(String::from_byte_string(index.data().to_byte_string())); m_variants.clear(); Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) { @@ -76,7 +76,7 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo }; m_variant_list_view->on_selection_change = [this] { - const auto& index = m_variant_list_view->selection().first(); + auto const& index = m_variant_list_view->selection().first(); bool font_is_fixed_size = false; m_variant = MUST(String::from_byte_string(index.data().to_byte_string())); m_sizes.clear(); @@ -132,7 +132,7 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo }; m_size_list_view->on_selection_change = [this] { - const auto& index = m_size_list_view->selection().first(); + auto const& index = m_size_list_view->selection().first(); auto size = index.data().to_i32(); Optional index_of_new_size_in_list = m_sizes.find_first_index(size); if (index_of_new_size_in_list.has_value()) { diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 115070602da..852bac1932d 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -537,7 +537,7 @@ void IconView::paint_event(PaintEvent& event) auto font = font_for_index(item_data.index); - const auto& text_rect = item_data.text_rect; + auto const& text_rect = item_data.text_rect; if (m_edit_index != item_data.index) painter.fill_rect(text_rect, background_color); @@ -550,7 +550,7 @@ void IconView::paint_event(PaintEvent& event) if (!item_data.wrapped_text_lines.is_empty()) { // Item text would not fit in the item text rect, let's break it up into lines.. - const auto& lines = item_data.wrapped_text_lines; + auto const& lines = item_data.wrapped_text_lines; size_t number_of_text_lines = min((size_t)text_rect.height() / font->pixel_size_rounded_up(), lines.size()); size_t previous_line_lengths = 0; for (size_t line_index = 0; line_index < number_of_text_lines; ++line_index) { diff --git a/Userland/Libraries/LibGUI/SeparatorWidget.h b/Userland/Libraries/LibGUI/SeparatorWidget.h index d32b78b3efe..0fca567d22c 100644 --- a/Userland/Libraries/LibGUI/SeparatorWidget.h +++ b/Userland/Libraries/LibGUI/SeparatorWidget.h @@ -25,7 +25,7 @@ private: virtual Optional calculated_preferred_size() const override; virtual Optional calculated_min_size() const override; - const Gfx::Orientation m_orientation; + Gfx::Orientation const m_orientation; }; class VerticalSeparator final : public SeparatorWidget { diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index bf67cc09475..ca8de504881 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -732,7 +732,7 @@ bool InsertTextCommand::merge_with(GUI::Command const& other) void InsertTextCommand::perform_formatting(TextDocument::Client const& client) { - const size_t tab_width = client.soft_tab_width(); + size_t const tab_width = client.soft_tab_width(); auto const& dest_line = m_document.line(m_range.start().line()); bool const should_auto_indent = client.is_automatic_indentation_enabled(); diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 4f07411610d..2b282908c50 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1947,7 +1947,7 @@ void TextEditor::did_change(AllowCallback allow_callback) if (on_change && allow_callback == AllowCallback::Yes) on_change(); } -void TextEditor::set_mode(const Mode mode) +void TextEditor::set_mode(Mode const mode) { if (m_mode == mode) return; diff --git a/Userland/Libraries/LibGUI/Toolbar.h b/Userland/Libraries/LibGUI/Toolbar.h index 9defb2b07ea..41f74b82345 100644 --- a/Userland/Libraries/LibGUI/Toolbar.h +++ b/Userland/Libraries/LibGUI/Toolbar.h @@ -53,7 +53,7 @@ private: RefPtr m_overflow_menu; RefPtr m_overflow_action; RefPtr