diff --git a/AK/Atomic.h b/AK/Atomic.h index c28dfbf4e5e..ec0b20f945f 100644 --- a/AK/Atomic.h +++ b/AK/Atomic.h @@ -146,9 +146,9 @@ class Atomic { public: Atomic() noexcept = default; - Atomic& operator=(const Atomic&) volatile = delete; + Atomic& operator=(Atomic const&) volatile = delete; Atomic& operator=(Atomic&&) volatile = delete; - Atomic(const Atomic&) = delete; + Atomic(Atomic const&) = delete; Atomic(Atomic&&) = delete; constexpr Atomic(T val) noexcept @@ -215,9 +215,9 @@ class Atomic { public: Atomic() noexcept = default; - Atomic& operator=(const Atomic&) volatile = delete; + Atomic& operator=(Atomic const&) volatile = delete; Atomic& operator=(Atomic&&) volatile = delete; - Atomic(const Atomic&) = delete; + Atomic(Atomic const&) = delete; Atomic(Atomic&&) = delete; constexpr Atomic(T val) noexcept @@ -346,9 +346,9 @@ class Atomic { public: Atomic() noexcept = default; - Atomic& operator=(const Atomic&) volatile = delete; + Atomic& operator=(Atomic const&) volatile = delete; Atomic& operator=(Atomic&&) volatile = delete; - Atomic(const Atomic&) = delete; + Atomic(Atomic const&) = delete; Atomic(Atomic&&) = delete; constexpr Atomic(T* val) noexcept diff --git a/AK/Badge.h b/AK/Badge.h index 7cdb6df2d44..6b3fdb09dc5 100644 --- a/AK/Badge.h +++ b/AK/Badge.h @@ -17,8 +17,8 @@ private: friend T; constexpr Badge() = default; - Badge(const Badge&) = delete; - Badge& operator=(const Badge&) = delete; + Badge(Badge const&) = delete; + Badge& operator=(Badge const&) = delete; Badge(Badge&&) = delete; Badge& operator=(Badge&&) = delete; diff --git a/AK/Base64.cpp b/AK/Base64.cpp index 028fe5d1ed4..d3b8f674506 100644 --- a/AK/Base64.cpp +++ b/AK/Base64.cpp @@ -126,10 +126,10 @@ String encode_base64(ReadonlyBytes input) const u8 index2 = ((in1 << 2) | (in2 >> 6)) & 0x3f; const u8 index3 = in2 & 0x3f; - const char out0 = alphabet[index0]; - const char out1 = alphabet[index1]; - const char out2 = is_16bit ? '=' : alphabet[index2]; - const char out3 = is_8bit ? '=' : alphabet[index3]; + char const out0 = alphabet[index0]; + char const out1 = alphabet[index1]; + char const out2 = is_16bit ? '=' : alphabet[index2]; + char const out3 = is_8bit ? '=' : alphabet[index3]; output.append(out0); output.append(out1); diff --git a/AK/BitStream.h b/AK/BitStream.h index 54f63f63586..97257c51365 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -74,7 +74,7 @@ public: } if (m_next_byte.has_value()) { - const auto bit = (m_next_byte.value() >> m_bit_offset) & 1; + auto const bit = (m_next_byte.value() >> m_bit_offset) & 1; result |= bit << nread; ++nread; @@ -109,7 +109,7 @@ public: nread += 8; m_next_byte.clear(); } else { - const auto bit = (m_next_byte.value() >> (7 - m_bit_offset)) & 1; + auto const bit = (m_next_byte.value() >> (7 - m_bit_offset)) & 1; result <<= 1; result |= bit; ++nread; diff --git a/AK/BitmapView.h b/AK/BitmapView.h index 813385ac6e9..b5d470b747d 100644 --- a/AK/BitmapView.h +++ b/AK/BitmapView.h @@ -48,8 +48,8 @@ public: return 0; size_t count; - const u8* first = &m_data[start / 8]; - const u8* last = &m_data[(start + len) / 8]; + u8 const* first = &m_data[start / 8]; + u8 const* last = &m_data[(start + len) / 8]; u8 byte = *first; byte &= bitmask_first_byte[start % 8]; if (first == last) { @@ -64,19 +64,19 @@ public: count += popcount(byte); } if (++first < last) { - const size_t* ptr_large = (const size_t*)(((FlatPtr)first + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1)); - if ((const u8*)ptr_large > last) - ptr_large = (const size_t*)last; - while (first < (const u8*)ptr_large) { + size_t const* ptr_large = (size_t const*)(((FlatPtr)first + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1)); + if ((u8 const*)ptr_large > last) + ptr_large = (size_t const*)last; + while (first < (u8 const*)ptr_large) { count += popcount(*first); first++; } - const size_t* last_large = (const size_t*)((FlatPtr)last & ~(sizeof(size_t) - 1)); + size_t const* last_large = (size_t const*)((FlatPtr)last & ~(sizeof(size_t) - 1)); while (ptr_large < last_large) { count += popcount(*ptr_large); ptr_large++; } - for (first = (const u8*)ptr_large; first < last; first++) + for (first = (u8 const*)ptr_large; first < last; first++) count += popcount(*first); } } @@ -88,24 +88,24 @@ public: [[nodiscard]] bool is_null() const { return m_data == nullptr; } - [[nodiscard]] const u8* data() const { return m_data; } + [[nodiscard]] u8 const* data() const { return m_data; } template Optional find_one_anywhere(size_t hint = 0) const { VERIFY(hint < m_size); - const u8* end = &m_data[m_size / 8]; + u8 const* end = &m_data[m_size / 8]; for (;;) { // We will use hint as what it is: a hint. Because we try to // scan over entire 32 bit words, we may start searching before // the hint! - const size_t* ptr_large = (const size_t*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1)); - if ((const u8*)ptr_large < &m_data[0]) { + size_t const* ptr_large = (size_t const*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1)); + if ((u8 const*)ptr_large < &m_data[0]) { ptr_large++; // m_data isn't aligned, check first bytes - size_t start_ptr_large = (const u8*)ptr_large - &m_data[0]; + size_t start_ptr_large = (u8 const*)ptr_large - &m_data[0]; size_t i = 0; u8 byte = VALUE ? 0x00 : 0xff; while (i < start_ptr_large && m_data[i] == byte) @@ -120,14 +120,14 @@ public: } size_t val_large = VALUE ? 0x0 : NumericLimits::max(); - const size_t* end_large = (const size_t*)((FlatPtr)end & ~(sizeof(size_t) - 1)); + size_t const* end_large = (size_t const*)((FlatPtr)end & ~(sizeof(size_t) - 1)); while (ptr_large < end_large && *ptr_large == val_large) ptr_large++; if (ptr_large == end_large) { // We didn't find anything, check the remaining few bytes (if any) u8 byte = VALUE ? 0x00 : 0xff; - size_t i = (const u8*)ptr_large - &m_data[0]; + size_t i = (u8 const*)ptr_large - &m_data[0]; size_t byte_count = m_size / 8; VERIFY(i <= byte_count); while (i < byte_count && m_data[i] == byte) @@ -137,7 +137,7 @@ public: return {}; // We already checked from the beginning // Try scanning before the hint - end = (const u8*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1)); + end = (u8 const*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1)); hint = 0; continue; } @@ -154,7 +154,7 @@ public: if constexpr (!VALUE) val_large = ~val_large; VERIFY(val_large != 0); - return ((const u8*)ptr_large - &m_data[0]) * 8 + bit_scan_forward(val_large) - 1; + return ((u8 const*)ptr_large - &m_data[0]) * 8 + bit_scan_forward(val_large) - 1; } } diff --git a/AK/ByteReader.h b/AK/ByteReader.h index 71d451f76db..d981b69c865 100644 --- a/AK/ByteReader.h +++ b/AK/ByteReader.h @@ -18,34 +18,34 @@ struct ByteReader { __builtin_memcpy(addr, &value, sizeof(T)); } template - requires(IsTriviallyConstructible) static void load(const u8* addr, T& value) + requires(IsTriviallyConstructible) static void load(u8 const* addr, T& value) { __builtin_memcpy(&value, addr, sizeof(T)); } template - static T* load_pointer(const u8* address) + static T* load_pointer(u8 const* address) { FlatPtr value; load(address, value); return reinterpret_cast(value); } - static u16 load16(const u8* address) + static u16 load16(u8 const* address) { u16 value; load(address, value); return value; } - static u32 load32(const u8* address) + static u32 load32(u8 const* address) { u32 value; load(address, value); return value; } - static u64 load64(const u8* address) + static u64 load64(u8 const* address) { u64 value; load(address, value); diff --git a/AK/Checked.h b/AK/Checked.h index feba84b3efc..5cf1d987f23 100644 --- a/AK/Checked.h +++ b/AK/Checked.h @@ -127,7 +127,7 @@ public: m_value = value; } - constexpr Checked(const Checked&) = default; + constexpr Checked(Checked const&) = default; constexpr Checked(Checked&& other) : m_value(exchange(other.m_value, 0)) @@ -142,7 +142,7 @@ public: return *this; } - constexpr Checked& operator=(const Checked& other) = default; + constexpr Checked& operator=(Checked const& other) = default; constexpr Checked& operator=(Checked&& other) { @@ -199,7 +199,7 @@ public: m_value /= other; } - constexpr Checked& operator+=(const Checked& other) + constexpr Checked& operator+=(Checked const& other) { m_overflow |= other.m_overflow; add(other.value()); @@ -212,7 +212,7 @@ public: return *this; } - constexpr Checked& operator-=(const Checked& other) + constexpr Checked& operator-=(Checked const& other) { m_overflow |= other.m_overflow; sub(other.value()); @@ -225,7 +225,7 @@ public: return *this; } - constexpr Checked& operator*=(const Checked& other) + constexpr Checked& operator*=(Checked const& other) { m_overflow |= other.m_overflow; mul(other.value()); @@ -238,7 +238,7 @@ public: return *this; } - constexpr Checked& operator/=(const Checked& other) + constexpr Checked& operator/=(Checked const& other) { m_overflow |= other.m_overflow; div(other.value()); @@ -319,7 +319,7 @@ private: }; template -constexpr Checked operator+(const Checked& a, const Checked& b) +constexpr Checked operator+(Checked const& a, Checked const& b) { Checked c { a }; c.add(b.value()); @@ -327,7 +327,7 @@ constexpr Checked operator+(const Checked& a, const Checked& b) } template -constexpr Checked operator-(const Checked& a, const Checked& b) +constexpr Checked operator-(Checked const& a, Checked const& b) { Checked c { a }; c.sub(b.value()); @@ -335,7 +335,7 @@ constexpr Checked operator-(const Checked& a, const Checked& b) } template -constexpr Checked operator*(const Checked& a, const Checked& b) +constexpr Checked operator*(Checked const& a, Checked const& b) { Checked c { a }; c.mul(b.value()); @@ -343,7 +343,7 @@ constexpr Checked operator*(const Checked& a, const Checked& b) } template -constexpr Checked operator/(const Checked& a, const Checked& b) +constexpr Checked operator/(Checked const& a, Checked const& b) { Checked c { a }; c.div(b.value()); @@ -351,73 +351,73 @@ constexpr Checked operator/(const Checked& a, const Checked& b) } template -constexpr bool operator<(const Checked& a, T b) +constexpr bool operator<(Checked const& a, T b) { return a.value() < b; } template -constexpr bool operator>(const Checked& a, T b) +constexpr bool operator>(Checked const& a, T b) { return a.value() > b; } template -constexpr bool operator>=(const Checked& a, T b) +constexpr bool operator>=(Checked const& a, T b) { return a.value() >= b; } template -constexpr bool operator<=(const Checked& a, T b) +constexpr bool operator<=(Checked const& a, T b) { return a.value() <= b; } template -constexpr bool operator==(const Checked& a, T b) +constexpr bool operator==(Checked const& a, T b) { return a.value() == b; } template -constexpr bool operator!=(const Checked& a, T b) +constexpr bool operator!=(Checked const& a, T b) { return a.value() != b; } template -constexpr bool operator<(T a, const Checked& b) +constexpr bool operator<(T a, Checked const& b) { return a < b.value(); } template -constexpr bool operator>(T a, const Checked& b) +constexpr bool operator>(T a, Checked const& b) { return a > b.value(); } template -constexpr bool operator>=(T a, const Checked& b) +constexpr bool operator>=(T a, Checked const& b) { return a >= b.value(); } template -constexpr bool operator<=(T a, const Checked& b) +constexpr bool operator<=(T a, Checked const& b) { return a <= b.value(); } template -constexpr bool operator==(T a, const Checked& b) +constexpr bool operator==(T a, Checked const& b) { return a == b.value(); } template -constexpr bool operator!=(T a, const Checked& b) +constexpr bool operator!=(T a, Checked const& b) { return a != b.value(); } diff --git a/AK/CheckedFormatString.h b/AK/CheckedFormatString.h index cf83944533f..5113691cff8 100644 --- a/AK/CheckedFormatString.h +++ b/AK/CheckedFormatString.h @@ -45,7 +45,7 @@ template void compiletime_fail(Args...); template -consteval auto extract_used_argument_index(const char (&fmt)[N], size_t specifier_start_index, size_t specifier_end_index, size_t& next_implicit_argument_index) +consteval auto extract_used_argument_index(char const (&fmt)[N], size_t specifier_start_index, size_t specifier_end_index, size_t& next_implicit_argument_index) { struct { size_t index_value { 0 }; @@ -69,7 +69,7 @@ consteval auto extract_used_argument_index(const char (&fmt)[N], size_t specifie // FIXME: We should rather parse these format strings at compile-time if possible. template -consteval auto count_fmt_params(const char (&fmt)[N]) +consteval auto count_fmt_params(char const (&fmt)[N]) { struct { // FIXME: Switch to variable-sized storage whenever we can come up with one :) @@ -118,7 +118,7 @@ consteval auto count_fmt_params(const char (&fmt)[N]) if (result.total_used_last_format_specifier_start_count == 0) compiletime_fail("Format-String Checker internal error: Expected location information"); - const auto specifier_start_index = result.last_format_specifier_start[--result.total_used_last_format_specifier_start_count]; + auto const specifier_start_index = result.last_format_specifier_start[--result.total_used_last_format_specifier_start_count]; if (result.total_used_argument_count >= result.used_arguments.size()) compiletime_fail("Format-String Checker internal error: Too many format arguments in format string"); @@ -146,7 +146,7 @@ namespace AK::Format::Detail { template struct CheckedFormatString { template - consteval CheckedFormatString(const char (&fmt)[N]) + consteval CheckedFormatString(char const (&fmt)[N]) : m_string { fmt } { #ifdef ENABLE_COMPILETIME_FORMAT_CHECK @@ -165,7 +165,7 @@ struct CheckedFormatString { private: #ifdef ENABLE_COMPILETIME_FORMAT_CHECK template - consteval static bool check_format_parameter_consistency(const char (&fmt)[N]) + consteval static bool check_format_parameter_consistency(char const (&fmt)[N]) { auto check = count_fmt_params(fmt); if (check.unclosed_braces != 0) diff --git a/AK/CircularDeque.h b/AK/CircularDeque.h index 5e6732a2f4f..7174ddcaf15 100644 --- a/AK/CircularDeque.h +++ b/AK/CircularDeque.h @@ -17,7 +17,7 @@ public: template void enqueue_begin(U&& value) { - const auto new_head = (this->m_head - 1 + Capacity) % Capacity; + auto const new_head = (this->m_head - 1 + Capacity) % Capacity; auto& slot = this->elements()[new_head]; if (this->m_size == Capacity) slot.~T(); diff --git a/AK/CircularDuplexStream.h b/AK/CircularDuplexStream.h index e6d9b23826d..1819e6254f6 100644 --- a/AK/CircularDuplexStream.h +++ b/AK/CircularDuplexStream.h @@ -18,7 +18,7 @@ class CircularDuplexStream : public AK::DuplexStream { public: size_t write(ReadonlyBytes bytes) override { - const auto nwritten = min(bytes.size(), Capacity - m_queue.size()); + auto const nwritten = min(bytes.size(), Capacity - m_queue.size()); for (size_t idx = 0; idx < nwritten; ++idx) m_queue.enqueue(bytes[idx]); @@ -34,7 +34,7 @@ public: return false; } - const auto nwritten = write(bytes); + auto const nwritten = write(bytes); VERIFY(nwritten == bytes.size()); return true; } @@ -44,7 +44,7 @@ public: if (has_any_error()) return 0; - const auto nread = min(bytes.size(), m_queue.size()); + auto const nread = min(bytes.size(), m_queue.size()); for (size_t idx = 0; idx < nread; ++idx) bytes[idx] = m_queue.dequeue(); @@ -59,10 +59,10 @@ public: return 0; } - const auto nread = min(bytes.size(), seekback); + auto const nread = min(bytes.size(), seekback); for (size_t idx = 0; idx < nread; ++idx) { - const auto index = (m_total_written - seekback + idx) % Capacity; + auto const index = (m_total_written - seekback + idx) % Capacity; bytes[idx] = m_queue.m_storage[index]; } diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h index 8c9a835b615..d4ab79d9b3f 100644 --- a/AK/CircularQueue.h +++ b/AK/CircularQueue.h @@ -70,7 +70,7 @@ public: class ConstIterator { public: - bool operator!=(const ConstIterator& other) { return m_index != other.m_index; } + bool operator!=(ConstIterator const& other) { return m_index != other.m_index; } ConstIterator& operator++() { ++m_index; @@ -81,12 +81,12 @@ public: private: friend class CircularQueue; - ConstIterator(const CircularQueue& queue, const size_t index) + ConstIterator(CircularQueue const& queue, const size_t index) : m_queue(queue) , m_index(index) { } - const CircularQueue& m_queue; + CircularQueue const& m_queue; size_t m_index { 0 }; }; diff --git a/AK/Complex.h b/AK/Complex.h index 728ae33c77a..365c19b3b40 100644 --- a/AK/Complex.h +++ b/AK/Complex.h @@ -61,7 +61,7 @@ public: } template - constexpr Complex& operator=(const Complex& other) + constexpr Complex& operator=(Complex const& other) { m_real = other.real(); m_imag = other.imag(); @@ -77,7 +77,7 @@ public: } template - constexpr Complex operator+=(const Complex& x) + constexpr Complex operator+=(Complex const& x) { m_real += x.real(); m_imag += x.imag(); @@ -92,7 +92,7 @@ public: } template - constexpr Complex operator-=(const Complex& x) + constexpr Complex operator-=(Complex const& x) { m_real -= x.real(); m_imag -= x.imag(); @@ -107,7 +107,7 @@ public: } template - constexpr Complex operator*=(const Complex& x) + constexpr Complex operator*=(Complex const& x) { const T real = m_real; m_real = real * x.real() - m_imag * x.imag(); @@ -124,7 +124,7 @@ public: } template - constexpr Complex operator/=(const Complex& x) + constexpr Complex operator/=(Complex const& x) { const T real = m_real; const T divisor = x.real() * x.real() + x.imag() * x.imag(); @@ -142,7 +142,7 @@ public: } template - constexpr Complex operator+(const Complex& a) + constexpr Complex operator+(Complex const& a) { Complex x = *this; x += a; @@ -158,7 +158,7 @@ public: } template - constexpr Complex operator-(const Complex& a) + constexpr Complex operator-(Complex const& a) { Complex x = *this; x -= a; @@ -174,7 +174,7 @@ public: } template - constexpr Complex operator*(const Complex& a) + constexpr Complex operator*(Complex const& a) { Complex x = *this; x *= a; @@ -190,7 +190,7 @@ public: } template - constexpr Complex operator/(const Complex& a) + constexpr Complex operator/(Complex const& a) { Complex x = *this; x /= a; @@ -206,13 +206,13 @@ public: } template - constexpr bool operator==(const Complex& a) const + constexpr bool operator==(Complex const& a) const { return (this->real() == a.real()) && (this->imag() == a.imag()); } template - constexpr bool operator!=(const Complex& a) const + constexpr bool operator!=(Complex const& a) const { return !(*this == a); } @@ -234,7 +234,7 @@ private: // reverse associativity operators for scalars template -constexpr Complex operator+(const U& b, const Complex& a) +constexpr Complex operator+(const U& b, Complex const& a) { Complex x = a; x += b; @@ -242,7 +242,7 @@ constexpr Complex operator+(const U& b, const Complex& a) } template -constexpr Complex operator-(const U& b, const Complex& a) +constexpr Complex operator-(const U& b, Complex const& a) { Complex x = a; x -= b; @@ -250,7 +250,7 @@ constexpr Complex operator-(const U& b, const Complex& a) } template -constexpr Complex operator*(const U& b, const Complex& a) +constexpr Complex operator*(const U& b, Complex const& a) { Complex x = a; x *= b; @@ -258,7 +258,7 @@ constexpr Complex operator*(const U& b, const Complex& a) } template -constexpr Complex operator/(const U& b, const Complex& a) +constexpr Complex operator/(const U& b, Complex const& a) { Complex x = a; x /= b; @@ -272,15 +272,15 @@ template static constinit Complex complex_imag_unit = Complex((T)0, (T)1); template -static constexpr bool approx_eq(const Complex& a, const Complex& b, const double margin = 0.000001) +static constexpr bool approx_eq(Complex const& a, Complex const& b, double const margin = 0.000001) { - const auto x = const_cast&>(a) - const_cast&>(b); + auto const x = const_cast&>(a) - const_cast&>(b); return x.magnitude() <= margin; } // complex version of exp() template -static constexpr Complex cexp(const Complex& a) +static constexpr Complex cexp(Complex const& a) { // FIXME: this can probably be faster and not use so many "expensive" trigonometric functions return exp(a.real()) * Complex(cos(a.imag()), sin(a.imag())); diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 95ebd53d39e..89ebbad2d3c 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -63,11 +63,11 @@ public: constexpr T& value() { return m_value; } // Always implemented: identity. - constexpr bool operator==(const Self& other) const + constexpr bool operator==(Self const& other) const { return this->m_value == other.m_value; } - constexpr bool operator!=(const Self& other) const + constexpr bool operator!=(Self const& other) const { return this->m_value != other.m_value; } @@ -101,22 +101,22 @@ public: } // Only implemented when `Cmp` is true: - constexpr bool operator>(const Self& other) const + constexpr bool operator>(Self const& other) const { static_assert(Cmp, "'a>b' is only available for DistinctNumeric types with 'Cmp'."); return this->m_value > other.m_value; } - constexpr bool operator<(const Self& other) const + constexpr bool operator<(Self const& other) const { static_assert(Cmp, "'am_value < other.m_value; } - constexpr bool operator>=(const Self& other) const + constexpr bool operator>=(Self const& other) const { static_assert(Cmp, "'a>=b' is only available for DistinctNumeric types with 'Cmp'."); return this->m_value >= other.m_value; } - constexpr bool operator<=(const Self& other) const + constexpr bool operator<=(Self const& other) const { static_assert(Cmp, "'a<=b' is only available for DistinctNumeric types with 'Cmp'."); return this->m_value <= other.m_value; @@ -140,34 +140,34 @@ public: static_assert(Flags, "'~a' is only available for DistinctNumeric types with 'Flags'."); return ~this->m_value; } - constexpr Self operator&(const Self& other) const + constexpr Self operator&(Self const& other) const { static_assert(Flags, "'a&b' is only available for DistinctNumeric types with 'Flags'."); return this->m_value & other.m_value; } - constexpr Self operator|(const Self& other) const + constexpr Self operator|(Self const& other) const { static_assert(Flags, "'a|b' is only available for DistinctNumeric types with 'Flags'."); return this->m_value | other.m_value; } - constexpr Self operator^(const Self& other) const + constexpr Self operator^(Self const& other) const { static_assert(Flags, "'a^b' is only available for DistinctNumeric types with 'Flags'."); return this->m_value ^ other.m_value; } - constexpr Self& operator&=(const Self& other) + constexpr Self& operator&=(Self const& other) { static_assert(Flags, "'a&=b' is only available for DistinctNumeric types with 'Flags'."); this->m_value &= other.m_value; return *this; } - constexpr Self& operator|=(const Self& other) + constexpr Self& operator|=(Self const& other) { static_assert(Flags, "'a|=b' is only available for DistinctNumeric types with 'Flags'."); this->m_value |= other.m_value; return *this; } - constexpr Self& operator^=(const Self& other) + constexpr Self& operator^=(Self const& other) { static_assert(Flags, "'a^=b' is only available for DistinctNumeric types with 'Flags'."); this->m_value ^= other.m_value; @@ -176,23 +176,23 @@ public: // Only implemented when `Shift` is true: // TODO: Should this take `int` instead? - constexpr Self operator<<(const Self& other) const + constexpr Self operator<<(Self const& other) const { static_assert(Shift, "'a<m_value << other.m_value; } - constexpr Self operator>>(const Self& other) const + constexpr Self operator>>(Self const& other) const { static_assert(Shift, "'a>>b' is only available for DistinctNumeric types with 'Shift'."); return this->m_value >> other.m_value; } - constexpr Self& operator<<=(const Self& other) + constexpr Self& operator<<=(Self const& other) { static_assert(Shift, "'a<<=b' is only available for DistinctNumeric types with 'Shift'."); this->m_value <<= other.m_value; return *this; } - constexpr Self& operator>>=(const Self& other) + constexpr Self& operator>>=(Self const& other) { static_assert(Shift, "'a>>=b' is only available for DistinctNumeric types with 'Shift'."); this->m_value >>= other.m_value; @@ -200,12 +200,12 @@ public: } // Only implemented when `Arith` is true: - constexpr Self operator+(const Self& other) const + constexpr Self operator+(Self const& other) const { static_assert(Arith, "'a+b' is only available for DistinctNumeric types with 'Arith'."); return this->m_value + other.m_value; } - constexpr Self operator-(const Self& other) const + constexpr Self operator-(Self const& other) const { static_assert(Arith, "'a-b' is only available for DistinctNumeric types with 'Arith'."); return this->m_value - other.m_value; @@ -220,46 +220,46 @@ public: static_assert(Arith, "'-a' is only available for DistinctNumeric types with 'Arith'."); return -this->m_value; } - constexpr Self operator*(const Self& other) const + constexpr Self operator*(Self const& other) const { static_assert(Arith, "'a*b' is only available for DistinctNumeric types with 'Arith'."); return this->m_value * other.m_value; } - constexpr Self operator/(const Self& other) const + constexpr Self operator/(Self const& other) const { static_assert(Arith, "'a/b' is only available for DistinctNumeric types with 'Arith'."); return this->m_value / other.m_value; } - constexpr Self operator%(const Self& other) const + constexpr Self operator%(Self const& other) const { static_assert(Arith, "'a%b' is only available for DistinctNumeric types with 'Arith'."); return this->m_value % other.m_value; } - constexpr Self& operator+=(const Self& other) + constexpr Self& operator+=(Self const& other) { static_assert(Arith, "'a+=b' is only available for DistinctNumeric types with 'Arith'."); this->m_value += other.m_value; return *this; } - constexpr Self& operator-=(const Self& other) + constexpr Self& operator-=(Self const& other) { static_assert(Arith, "'a+=b' is only available for DistinctNumeric types with 'Arith'."); this->m_value += other.m_value; return *this; } - constexpr Self& operator*=(const Self& other) + constexpr Self& operator*=(Self const& other) { static_assert(Arith, "'a*=b' is only available for DistinctNumeric types with 'Arith'."); this->m_value *= other.m_value; return *this; } - constexpr Self& operator/=(const Self& other) + constexpr Self& operator/=(Self const& other) { static_assert(Arith, "'a/=b' is only available for DistinctNumeric types with 'Arith'."); this->m_value /= other.m_value; return *this; } - constexpr Self& operator%=(const Self& other) + constexpr Self& operator%=(Self const& other) { static_assert(Arith, "'a%=b' is only available for DistinctNumeric types with 'Arith'."); this->m_value %= other.m_value; @@ -292,7 +292,7 @@ struct Formatter> : template struct Traits> : public GenericTraits> { static constexpr bool is_trivial() { return true; } - static constexpr auto hash(const DistinctNumeric& d) { return Traits::hash(d.value()); } + static constexpr auto hash(DistinctNumeric const& d) { return Traits::hash(d.value()); } }; using AK::DistinctNumeric; diff --git a/AK/DoublyLinkedList.h b/AK/DoublyLinkedList.h index f2425fdede6..9d22d31e22f 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -15,8 +15,8 @@ namespace AK { template class DoublyLinkedListIterator { public: - bool operator!=(const DoublyLinkedListIterator& other) const { return m_node != other.m_node; } - bool operator==(const DoublyLinkedListIterator& other) const { return m_node == other.m_node; } + bool operator!=(DoublyLinkedListIterator const& other) const { return m_node != other.m_node; } + bool operator==(DoublyLinkedListIterator const& other) const { return m_node == other.m_node; } DoublyLinkedListIterator& operator++() { m_node = m_node->next; diff --git a/AK/Endian.h b/AK/Endian.h index adf3d822570..dbddd3f713b 100644 --- a/AK/Endian.h +++ b/AK/Endian.h @@ -89,7 +89,7 @@ template class [[gnu::packed]] LittleEndian { public: friend InputStream& operator>>(InputStream&, LittleEndian&); - friend OutputStream& operator<<(OutputStream&, LittleEndian); + friend OutputStream& operator<< (OutputStream&, LittleEndian); constexpr LittleEndian() = default; @@ -117,7 +117,7 @@ template class [[gnu::packed]] BigEndian { public: friend InputStream& operator>>(InputStream&, BigEndian&); - friend OutputStream& operator<<(OutputStream&, BigEndian); + friend OutputStream& operator<< (OutputStream&, BigEndian); constexpr BigEndian() = default; diff --git a/AK/FixedArray.h b/AK/FixedArray.h index 5708a67b698..c7e52a189d8 100644 --- a/AK/FixedArray.h +++ b/AK/FixedArray.h @@ -55,7 +55,7 @@ public: // the compiler will inline this anyway and therefore not generate any duplicate code. template - static ErrorOr> try_create(T(&&array)[N]) + static ErrorOr> try_create(T (&&array)[N]) { if (N == 0) return FixedArray(); diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index 0bb1b63c52c..7e4465876f4 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -15,8 +15,8 @@ namespace AK { struct FlyStringImplTraits : public Traits { - static unsigned hash(const StringImpl* s) { return s ? s->hash() : 0; } - static bool equals(const StringImpl* a, const StringImpl* b) + static unsigned hash(StringImpl const* s) { return s ? s->hash() : 0; } + static bool equals(StringImpl const* a, StringImpl const* b) { VERIFY(a); VERIFY(b); @@ -36,7 +36,7 @@ void FlyString::did_destroy_impl(Badge, StringImpl& impl) fly_impls().remove(&impl); } -FlyString::FlyString(const String& string) +FlyString::FlyString(String const& string) { if (string.is_null()) return; @@ -115,7 +115,7 @@ FlyString FlyString::to_lowercase() const return String(*m_impl).to_lowercase(); } -bool FlyString::operator==(const String& other) const +bool FlyString::operator==(String const& other) const { return m_impl == other.impl() || view() == other.view(); } @@ -125,7 +125,7 @@ bool FlyString::operator==(StringView string) const return view() == string; } -bool FlyString::operator==(const char* string) const +bool FlyString::operator==(char const* string) const { return view() == string; } diff --git a/AK/FlyString.h b/AK/FlyString.h index 8c8d55dad08..c81eb65e48e 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -14,7 +14,7 @@ namespace AK { class FlyString { public: FlyString() = default; - FlyString(const FlyString& other) + FlyString(FlyString const& other) : m_impl(other.impl()) { } @@ -22,9 +22,9 @@ public: : m_impl(move(other.m_impl)) { } - FlyString(const String&); + FlyString(String const&); FlyString(StringView); - FlyString(const char* string) + FlyString(char const* string) : FlyString(static_cast(string)) { } @@ -37,7 +37,7 @@ public: return string; } - FlyString& operator=(const FlyString& other) + FlyString& operator=(FlyString const& other) { m_impl = other.m_impl; return *this; @@ -52,20 +52,20 @@ public: bool is_empty() const { return !m_impl || !m_impl->length(); } bool is_null() const { return !m_impl; } - bool operator==(const FlyString& other) const { return m_impl == other.m_impl; } - bool operator!=(const FlyString& other) const { return m_impl != other.m_impl; } + bool operator==(FlyString const& other) const { return m_impl == other.m_impl; } + bool operator!=(FlyString const& other) const { return m_impl != other.m_impl; } - bool operator==(const String&) const; - bool operator!=(const String& string) const { return !(*this == string); } + bool operator==(String const&) const; + bool operator!=(String const& string) const { return !(*this == string); } bool operator==(StringView) const; bool operator!=(StringView string) const { return !(*this == string); } - bool operator==(const char*) const; - bool operator!=(const char* string) const { return !(*this == string); } + bool operator==(char const*) const; + bool operator!=(char const* string) const { return !(*this == string); } - const StringImpl* impl() const { return m_impl; } - const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } + StringImpl const* impl() const { return m_impl; } + char const* characters() const { return m_impl ? m_impl->characters() : nullptr; } size_t length() const { return m_impl ? m_impl->length() : 0; } ALWAYS_INLINE u32 hash() const { return m_impl ? m_impl->existing_hash() : 0; } @@ -96,7 +96,7 @@ private: template<> struct Traits : public GenericTraits { - static unsigned hash(const FlyString& s) { return s.hash(); } + static unsigned hash(FlyString const& s) { return s.hash(); } }; } diff --git a/AK/Format.cpp b/AK/Format.cpp index ecd0948d311..cad570e6b48 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -51,8 +51,8 @@ static constexpr size_t convert_unsigned_to_string(u64 value, Array& bu { VERIFY(base >= 2 && base <= 16); - constexpr const char* lowercase_lookup = "0123456789abcdef"; - constexpr const char* uppercase_lookup = "0123456789ABCDEF"; + constexpr char const* lowercase_lookup = "0123456789abcdef"; + constexpr char const* uppercase_lookup = "0123456789ABCDEF"; if (value == 0) { buffer[0] = '0'; @@ -77,7 +77,7 @@ static constexpr size_t convert_unsigned_to_string(u64 value, Array& bu ErrorOr vformat_impl(TypeErasedFormatParams& params, FormatBuilder& builder, FormatParser& parser) { - const auto literal = parser.consume_literal(); + auto const literal = parser.consume_literal(); TRY(builder.put_literal(literal)); FormatParser::FormatSpecifier specifier; @@ -105,7 +105,7 @@ FormatParser::FormatParser(StringView input) } StringView FormatParser::consume_literal() { - const auto begin = tell(); + auto const begin = tell(); while (!is_eof()) { if (consume_specific("{{")) @@ -146,7 +146,7 @@ bool FormatParser::consume_specifier(FormatSpecifier& specifier) specifier.index = use_next_index; if (consume_specific(':')) { - const auto begin = tell(); + auto const begin = tell(); size_t level = 1; while (level > 0) { @@ -212,8 +212,8 @@ ErrorOr FormatBuilder::put_string( size_t max_width, char fill) { - const auto used_by_string = min(max_width, value.length()); - const auto used_by_padding = max(min_width, used_by_string) - used_by_string; + auto const used_by_string = min(max_width, value.length()); + auto const used_by_padding = max(min_width, used_by_string) - used_by_string; if (used_by_string < value.length()) value = value.substring_view(0, used_by_string); @@ -222,8 +222,8 @@ ErrorOr FormatBuilder::put_string( TRY(m_builder.try_append(value)); TRY(put_padding(fill, used_by_padding)); } else if (align == Align::Center) { - const auto used_by_left_padding = used_by_padding / 2; - const auto used_by_right_padding = ceil_div(used_by_padding, 2); + auto const used_by_left_padding = used_by_padding / 2; + auto const used_by_right_padding = ceil_div(used_by_padding, 2); TRY(put_padding(fill, used_by_left_padding)); TRY(m_builder.try_append(value)); @@ -252,7 +252,7 @@ ErrorOr FormatBuilder::put_u64( Array buffer; - const auto used_by_digits = convert_unsigned_to_string(value, buffer, base, upper_case); + auto const used_by_digits = convert_unsigned_to_string(value, buffer, base, upper_case); size_t used_by_prefix = 0; if (align == Align::Right && zero_pad) { @@ -273,10 +273,10 @@ ErrorOr FormatBuilder::put_u64( } } - const auto used_by_field = used_by_prefix + used_by_digits; - const auto used_by_padding = max(used_by_field, min_width) - used_by_field; + auto const used_by_field = used_by_prefix + used_by_digits; + auto const used_by_padding = max(used_by_field, min_width) - used_by_field; - const auto put_prefix = [&]() -> ErrorOr { + auto const put_prefix = [&]() -> ErrorOr { if (is_negative) TRY(m_builder.try_append('-')); else if (sign_mode == SignMode::Always) @@ -302,28 +302,28 @@ ErrorOr FormatBuilder::put_u64( return {}; }; - const auto put_digits = [&]() -> ErrorOr { + auto const put_digits = [&]() -> ErrorOr { for (size_t i = 0; i < used_by_digits; ++i) TRY(m_builder.try_append(buffer[i])); return {}; }; if (align == Align::Left) { - const auto used_by_right_padding = used_by_padding; + auto const used_by_right_padding = used_by_padding; TRY(put_prefix()); TRY(put_digits()); TRY(put_padding(fill, used_by_right_padding)); } else if (align == Align::Center) { - const auto used_by_left_padding = used_by_padding / 2; - const auto used_by_right_padding = ceil_div(used_by_padding, 2); + auto const used_by_left_padding = used_by_padding / 2; + auto const used_by_right_padding = ceil_div(used_by_padding, 2); TRY(put_padding(fill, used_by_left_padding)); TRY(put_prefix()); TRY(put_digits()); TRY(put_padding(fill, used_by_right_padding)); } else if (align == Align::Right) { - const auto used_by_left_padding = used_by_padding; + auto const used_by_left_padding = used_by_padding; if (zero_pad) { TRY(put_prefix()); @@ -349,7 +349,7 @@ ErrorOr FormatBuilder::put_i64( char fill, SignMode sign_mode) { - const auto is_negative = value < 0; + auto const is_negative = value < 0; value = is_negative ? -value : value; TRY(put_u64(static_cast(value), base, prefix, upper_case, zero_pad, align, min_width, fill, sign_mode, is_negative)); @@ -702,7 +702,7 @@ ErrorOr Formatter::format(FormatBuilder& builder, T value) m_mode = Mode::String; Formatter formatter { *this }; - return formatter.format(builder, StringView { reinterpret_cast(&value), 1 }); + return formatter.format(builder, StringView { reinterpret_cast(&value), 1 }); } if (m_precision.has_value()) @@ -854,8 +854,8 @@ void vout(FILE* file, StringView fmtstr, TypeErasedFormatParams& params, bool ne if (newline) builder.append('\n'); - const auto string = builder.string_view(); - const auto retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), file); + auto const string = builder.string_view(); + auto const retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), file); if (static_cast(retval) != string.length()) { auto error = ferror(file); dbgln("vout() failed ({} written out of {}), error was {} ({})", retval, string.length(), error, strerror(error)); @@ -912,7 +912,7 @@ void vdbgln(StringView fmtstr, TypeErasedFormatParams& params) MUST(vformat(builder, fmtstr, params)); builder.append('\n'); - const auto string = builder.string_view(); + auto const string = builder.string_view(); #ifdef __serenity__ # ifdef KERNEL @@ -949,7 +949,7 @@ void vdmesgln(StringView fmtstr, TypeErasedFormatParams& params) MUST(vformat(builder, fmtstr, params)); builder.append('\n'); - const auto string = builder.string_view(); + auto const string = builder.string_view(); kernelputstr(string.characters_without_null_termination(), string.length()); } @@ -971,7 +971,7 @@ void v_critical_dmesgln(StringView fmtstr, TypeErasedFormatParams& params) MUST(vformat(builder, fmtstr, params)); builder.append('\n'); - const auto string = builder.string_view(); + auto const string = builder.string_view(); kernelcriticalputstr(string.characters_without_null_termination(), string.length()); } diff --git a/AK/Format.h b/AK/Format.h index 661a37ce248..ddd612968d7 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -94,21 +94,21 @@ struct TypeErasedParameter { { switch (type) { case TypeErasedParameter::Type::UInt8: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::UInt16: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::UInt32: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::UInt64: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::Int8: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::Int16: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::Int32: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); case TypeErasedParameter::Type::Int64: - return visitor(*static_cast(value)); + return visitor(*static_cast(value)); default: TODO(); } @@ -127,7 +127,7 @@ struct TypeErasedParameter { // FIXME: Getters and setters. - const void* value; + void const* value; Type type; ErrorOr (*formatter)(TypeErasedFormatParams&, FormatBuilder&, FormatParser&, void const* value); }; @@ -227,7 +227,7 @@ public: size_t width, char fill = ' '); - const StringBuilder& builder() const + StringBuilder const& builder() const { return m_builder; } @@ -250,7 +250,7 @@ private: }; template -ErrorOr __format_value(TypeErasedFormatParams& params, FormatBuilder& builder, FormatParser& parser, const void* value) +ErrorOr __format_value(TypeErasedFormatParams& params, FormatBuilder& builder, FormatParser& parser, void const* value) { Formatter formatter; @@ -263,7 +263,7 @@ class VariadicFormatParams : public TypeErasedFormatParams { public: static_assert(sizeof...(Parameters) <= max_format_arguments); - explicit VariadicFormatParams(const Parameters&... parameters) + explicit VariadicFormatParams(Parameters const&... parameters) : m_data({ TypeErasedParameter { ¶meters, TypeErasedParameter::get_type(), __format_value }... }) { this->set_parameters(m_data); @@ -396,8 +396,8 @@ struct Formatter : Formatter { }; template<> -struct Formatter : Formatter { - ErrorOr format(FormatBuilder& builder, const char* value) +struct Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, char const* value) { if (m_mode == Mode::Pointer) { Formatter formatter { *this }; @@ -407,14 +407,14 @@ struct Formatter : Formatter { } }; template<> -struct Formatter : Formatter { +struct Formatter : Formatter { }; template -struct Formatter : Formatter { +struct Formatter : Formatter { }; template struct Formatter : Formatter { - ErrorOr format(FormatBuilder& builder, const unsigned char* value) + ErrorOr format(FormatBuilder& builder, unsigned char const* value) { if (m_mode == Mode::Pointer) { Formatter formatter { *this }; @@ -535,14 +535,14 @@ ErrorOr vformat(StringBuilder&, StringView fmtstr, TypeErasedFormatParams& void vout(FILE*, StringView fmtstr, TypeErasedFormatParams&, bool newline = false); template -void out(FILE* file, CheckedFormatString&& fmtstr, const Parameters&... parameters) +void out(FILE* file, CheckedFormatString&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; vout(file, fmtstr.view(), variadic_format_params); } template -void outln(FILE* file, CheckedFormatString&& fmtstr, const Parameters&... parameters) +void outln(FILE* file, CheckedFormatString&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; vout(file, fmtstr.view(), variadic_format_params, true); @@ -551,10 +551,10 @@ void outln(FILE* file, CheckedFormatString&& fmtstr, const Parame inline void outln(FILE* file) { fputc('\n', file); } template -void out(CheckedFormatString&& fmtstr, const Parameters&... parameters) { out(stdout, move(fmtstr), parameters...); } +void out(CheckedFormatString&& fmtstr, Parameters const&... parameters) { out(stdout, move(fmtstr), parameters...); } template -void outln(CheckedFormatString&& fmtstr, const Parameters&... parameters) { outln(stdout, move(fmtstr), parameters...); } +void outln(CheckedFormatString&& fmtstr, Parameters const&... parameters) { outln(stdout, move(fmtstr), parameters...); } inline void outln() { outln(stdout); } @@ -565,13 +565,13 @@ inline void outln() { outln(stdout); } } while (0) template -void warn(CheckedFormatString&& fmtstr, const Parameters&... parameters) +void warn(CheckedFormatString&& fmtstr, Parameters const&... parameters) { out(stderr, move(fmtstr), parameters...); } template -void warnln(CheckedFormatString&& fmtstr, const Parameters&... parameters) { outln(stderr, move(fmtstr), parameters...); } +void warnln(CheckedFormatString&& fmtstr, Parameters const&... parameters) { outln(stderr, move(fmtstr), parameters...); } inline void warnln() { outln(stderr); } @@ -586,7 +586,7 @@ inline void warnln() { outln(stderr); } void vdbgln(StringView fmtstr, TypeErasedFormatParams&); template -void dbgln(CheckedFormatString&& fmtstr, const Parameters&... parameters) +void dbgln(CheckedFormatString&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; vdbgln(fmtstr.view(), variadic_format_params); @@ -600,7 +600,7 @@ void set_debug_enabled(bool); void vdmesgln(StringView fmtstr, TypeErasedFormatParams&); template -void dmesgln(CheckedFormatString&& fmt, const Parameters&... parameters) +void dmesgln(CheckedFormatString&& fmt, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; vdmesgln(fmt.view(), variadic_format_params); @@ -611,7 +611,7 @@ void v_critical_dmesgln(StringView fmtstr, TypeErasedFormatParams&); // be very careful to not cause any allocations here, since we could be in // a very unstable situation template -void critical_dmesgln(CheckedFormatString&& fmt, const Parameters&... parameters) +void critical_dmesgln(CheckedFormatString&& fmt, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; v_critical_dmesgln(fmt.view(), variadic_format_params); @@ -656,7 +656,7 @@ struct FormatString { template<> struct Formatter : Formatter { template - ErrorOr format(FormatBuilder& builder, StringView fmtstr, const Parameters&... parameters) + ErrorOr format(FormatBuilder& builder, StringView fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; return vformat(builder, fmtstr, variadic_format_params); diff --git a/AK/GenericLexer.cpp b/AK/GenericLexer.cpp index d6e977a0074..29049257b41 100644 --- a/AK/GenericLexer.cpp +++ b/AK/GenericLexer.cpp @@ -69,7 +69,7 @@ StringView GenericLexer::consume_until(char stop) } // Consume and return characters until the string `stop` is found -StringView GenericLexer::consume_until(const char* stop) +StringView GenericLexer::consume_until(char const* stop) { size_t start = m_index; while (!is_eof() && !next_is(stop)) diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index 57649f9840a..5db2bdc5eac 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -43,7 +43,7 @@ public: return true; } - constexpr bool next_is(const char* expected) const + constexpr bool next_is(char const* expected) const { for (size_t i = 0; expected[i] != '\0'; ++i) if (peek(i) != expected[i]) @@ -84,13 +84,13 @@ public: } #ifndef KERNEL - bool consume_specific(const String& next) + bool consume_specific(String const& next) { return consume_specific(StringView { next }); } #endif - constexpr bool consume_specific(const char* next) + constexpr bool consume_specific(char const* next) { return consume_specific(StringView { next }); } @@ -114,7 +114,7 @@ public: StringView consume_all(); StringView consume_line(); StringView consume_until(char); - StringView consume_until(const char*); + StringView consume_until(char const*); StringView consume_until(StringView); StringView consume_quoted_string(char escape_char = 0); #ifndef KERNEL @@ -144,7 +144,7 @@ public: ignore(); } - constexpr void ignore_until(const char* stop) + constexpr void ignore_until(char const* stop) { while (!is_eof() && !next_is(stop)) { ++m_index; diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h index e869b448008..f20e4465890 100644 --- a/AK/HashFunctions.h +++ b/AK/HashFunctions.h @@ -21,7 +21,7 @@ constexpr unsigned int_hash(u32 key) constexpr unsigned double_hash(u32 key) { - const unsigned magic = 0xBA5EDB01; + unsigned const magic = 0xBA5EDB01; if (key == magic) return 0u; if (key == 0u) @@ -53,7 +53,7 @@ constexpr unsigned ptr_hash(FlatPtr ptr) return int_hash(ptr); } -inline unsigned ptr_hash(const void* ptr) +inline unsigned ptr_hash(void const* ptr) { return ptr_hash(FlatPtr(ptr)); } diff --git a/AK/HashMap.h b/AK/HashMap.h index 87d66c2523d..4590f932d04 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -22,8 +22,8 @@ private: }; struct EntryTraits { - static unsigned hash(const Entry& entry) { return KeyTraits::hash(entry.key); } - static bool equals(const Entry& a, const Entry& b) { return KeyTraits::equals(a.key, b.key); } + static unsigned hash(Entry const& entry) { return KeyTraits::hash(entry.key); } + static bool equals(Entry const& a, Entry const& b) { return KeyTraits::equals(a.key, b.key); } }; public: @@ -152,7 +152,8 @@ public: } template Key> - requires(IsSame>) Optional::PeekType> get(const Key& key) const requires(!IsPointer::PeekType>) + requires(IsSame>) Optional::PeekType> get(Key const& key) + const requires(!IsPointer::PeekType>) { auto it = find(key); if (it == end()) @@ -161,7 +162,8 @@ public: } template Key> - requires(IsSame>) Optional::ConstPeekType> get(const Key& key) const requires(IsPointer::PeekType>) + requires(IsSame>) Optional::ConstPeekType> get(Key const& key) + const requires(IsPointer::PeekType>) { auto it = find(key); if (it == end()) @@ -170,7 +172,8 @@ public: } template Key> - requires(IsSame>) Optional::PeekType> get(const Key& key) requires(!IsConst::PeekType>) + requires(IsSame>) Optional::PeekType> get(Key const& key) + requires(!IsConst::PeekType>) { auto it = find(key); if (it == end()) diff --git a/AK/HashTable.h b/AK/HashTable.h index d4dc8aa7e4c..14478b47011 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -57,8 +57,8 @@ class HashTableIterator { friend HashTableType; public: - bool operator==(const HashTableIterator& other) const { return m_bucket == other.m_bucket; } - bool operator!=(const HashTableIterator& other) const { return m_bucket != other.m_bucket; } + bool operator==(HashTableIterator const& other) const { return m_bucket == other.m_bucket; } + bool operator!=(HashTableIterator const& other) const { return m_bucket != other.m_bucket; } T& operator*() { return *m_bucket->slot(); } T* operator->() { return m_bucket->slot(); } void operator++() { skip_to_next(); } @@ -90,8 +90,8 @@ class OrderedHashTableIterator { friend OrderedHashTableType; public: - bool operator==(const OrderedHashTableIterator& other) const { return m_bucket == other.m_bucket; } - bool operator!=(const OrderedHashTableIterator& other) const { return m_bucket != other.m_bucket; } + bool operator==(OrderedHashTableIterator const& other) const { return m_bucket == other.m_bucket; } + bool operator!=(OrderedHashTableIterator const& other) const { return m_bucket != other.m_bucket; } T& operator*() { return *m_bucket->slot(); } T* operator->() { return m_bucket->slot(); } void operator++() { m_bucket = m_bucket->next; } @@ -156,14 +156,14 @@ public: kfree_sized(m_buckets, size_in_bytes(m_capacity)); } - HashTable(const HashTable& other) + HashTable(HashTable const& other) { rehash(other.capacity()); for (auto& it : other) set(it); } - HashTable& operator=(const HashTable& other) + HashTable& operator=(HashTable const& other) { HashTable temporary(other); swap(*this, temporary); diff --git a/AK/Hex.cpp b/AK/Hex.cpp index dfd0d410ef6..666dcdf70db 100644 --- a/AK/Hex.cpp +++ b/AK/Hex.cpp @@ -21,11 +21,11 @@ ErrorOr decode_hex(StringView input) auto output = TRY(ByteBuffer::create_zeroed(input.length() / 2)); for (size_t i = 0; i < input.length() / 2; ++i) { - const auto c1 = decode_hex_digit(input[i * 2]); + auto const c1 = decode_hex_digit(input[i * 2]); if (c1 >= 16) return Error::from_string_literal("Hex string contains invalid digit"); - const auto c2 = decode_hex_digit(input[i * 2 + 1]); + auto const c2 = decode_hex_digit(input[i * 2 + 1]); if (c2 >= 16) return Error::from_string_literal("Hex string contains invalid digit"); diff --git a/AK/IPv4Address.h b/AK/IPv4Address.h index 03a6f61cab1..8f72f8d3a08 100644 --- a/AK/IPv4Address.h +++ b/AK/IPv4Address.h @@ -89,7 +89,7 @@ public: if (string.is_null()) return {}; - const auto parts = string.split_view('.'); + auto const parts = string.split_view('.'); u32 a {}; u32 b {}; @@ -122,8 +122,8 @@ public: constexpr in_addr_t to_in_addr_t() const { return m_data; } constexpr u32 to_u32() const { return m_data; } - constexpr bool operator==(const IPv4Address& other) const = default; - constexpr bool operator!=(const IPv4Address& other) const = default; + constexpr bool operator==(IPv4Address const& other) const = default; + constexpr bool operator!=(IPv4Address const& other) const = default; constexpr bool is_zero() const { @@ -135,7 +135,7 @@ private: { NetworkOrdered address(m_data); constexpr auto bits_per_byte = 8; - const auto bits_to_shift = bits_per_byte * int(subnet); + auto const bits_to_shift = bits_per_byte * int(subnet); return (m_data >> bits_to_shift) & 0x0000'00FF; } @@ -146,7 +146,7 @@ static_assert(sizeof(IPv4Address) == 4); template<> struct Traits : public GenericTraits { - static constexpr unsigned hash(const IPv4Address& address) { return int_hash(address.to_u32()); } + static constexpr unsigned hash(IPv4Address const& address) { return int_hash(address.to_u32()); } }; #ifdef KERNEL diff --git a/AK/IntrusiveList.h b/AK/IntrusiveList.h index b485443980f..f946a5f527a 100644 --- a/AK/IntrusiveList.h +++ b/AK/IntrusiveList.h @@ -75,8 +75,8 @@ public: auto operator->() const { return m_value; } T& operator*() { return *m_value; } auto operator->() { return m_value; } - bool operator==(const Iterator& other) const { return other.m_value == m_value; } - bool operator!=(const Iterator& other) const { return !(*this == other); } + bool operator==(Iterator const& other) const { return other.m_value == m_value; } + bool operator!=(Iterator const& other) const { return !(*this == other); } Iterator& operator++() { m_value = IntrusiveList::next(m_value); @@ -103,8 +103,8 @@ public: auto operator->() const { return m_value; } T& operator*() { return *m_value; } auto operator->() { return m_value; } - bool operator==(const ReverseIterator& other) const { return other.m_value == m_value; } - bool operator!=(const ReverseIterator& other) const { return !(*this == other); } + bool operator==(ReverseIterator const& other) const { return other.m_value == m_value; } + bool operator!=(ReverseIterator const& other) const { return !(*this == other); } ReverseIterator& operator++() { m_value = IntrusiveList::prev(m_value); @@ -129,8 +129,8 @@ public: const T& operator*() const { return *m_value; } auto operator->() const { return m_value; } - bool operator==(const ConstIterator& other) const { return other.m_value == m_value; } - bool operator!=(const ConstIterator& other) const { return !(*this == other); } + bool operator==(ConstIterator const& other) const { return other.m_value == m_value; } + bool operator!=(ConstIterator const& other) const { return !(*this == other); } ConstIterator& operator++() { m_value = IntrusiveList::next(m_value); diff --git a/AK/IntrusiveRedBlackTree.h b/AK/IntrusiveRedBlackTree.h index 56424ec8465..5bc0f79ec02 100644 --- a/AK/IntrusiveRedBlackTree.h +++ b/AK/IntrusiveRedBlackTree.h @@ -70,7 +70,7 @@ public: class BaseIterator { public: BaseIterator() = default; - bool operator!=(const BaseIterator& other) const { return m_node != other.m_node; } + bool operator!=(BaseIterator const& other) const { return m_node != other.m_node; } BaseIterator& operator++() { if (!m_node) diff --git a/AK/Iterator.h b/AK/Iterator.h index 953c0919670..76b078386ad 100644 --- a/AK/Iterator.h +++ b/AK/Iterator.h @@ -58,12 +58,12 @@ public: ALWAYS_INLINE constexpr ValueType const* operator->() const { return &m_container[m_index]; } ALWAYS_INLINE constexpr ValueType* operator->() { return &m_container[m_index]; } - SimpleIterator& operator=(const SimpleIterator& other) + SimpleIterator& operator=(SimpleIterator const& other) { m_index = other.m_index; return *this; } - SimpleIterator(const SimpleIterator& obj) = default; + SimpleIterator(SimpleIterator const& obj) = default; private: static constexpr SimpleIterator begin(Container& container) { return { container, 0 }; } diff --git a/AK/JsonArraySerializer.h b/AK/JsonArraySerializer.h index 3a757765a14..7c24a4149b1 100644 --- a/AK/JsonArraySerializer.h +++ b/AK/JsonArraySerializer.h @@ -41,7 +41,7 @@ public: { } - JsonArraySerializer(const JsonArraySerializer&) = delete; + JsonArraySerializer(JsonArraySerializer const&) = delete; ~JsonArraySerializer() { @@ -49,7 +49,7 @@ public: } #ifndef KERNEL - ErrorOr add(const JsonValue& value) + ErrorOr add(JsonValue const& value) { TRY(begin_item()); value.serialize(m_builder); @@ -73,7 +73,7 @@ public: } #ifndef KERNEL - ErrorOr add(const String& value) + ErrorOr add(String const& value) { TRY(begin_item()); if constexpr (IsLegacyBuilder) { @@ -89,7 +89,7 @@ public: } #endif - ErrorOr add(const char* value) + ErrorOr add(char const* value) { TRY(begin_item()); if constexpr (IsLegacyBuilder) { diff --git a/AK/JsonObjectSerializer.h b/AK/JsonObjectSerializer.h index 05d9e12c9c2..0869205517d 100644 --- a/AK/JsonObjectSerializer.h +++ b/AK/JsonObjectSerializer.h @@ -36,7 +36,7 @@ public: { } - JsonObjectSerializer(const JsonObjectSerializer&) = delete; + JsonObjectSerializer(JsonObjectSerializer const&) = delete; ~JsonObjectSerializer() { @@ -44,7 +44,7 @@ public: } #ifndef KERNEL - ErrorOr add(StringView key, const JsonValue& value) + ErrorOr add(StringView key, JsonValue const& value) { TRY(begin_item(key)); value.serialize(m_builder); @@ -68,7 +68,7 @@ public: } #ifndef KERNEL - ErrorOr add(StringView key, const String& value) + ErrorOr add(StringView key, String const& value) { TRY(begin_item(key)); if constexpr (IsLegacyBuilder) { @@ -84,7 +84,7 @@ public: } #endif - ErrorOr add(StringView key, const char* value) + ErrorOr add(StringView key, char const* value) { TRY(begin_item(key)); if constexpr (IsLegacyBuilder) { diff --git a/AK/JsonPath.cpp b/AK/JsonPath.cpp index 5ad87517b50..9ad66184744 100644 --- a/AK/JsonPath.cpp +++ b/AK/JsonPath.cpp @@ -13,7 +13,7 @@ namespace AK { JsonPathElement JsonPathElement::any_array_element { Kind::AnyIndex }; JsonPathElement JsonPathElement::any_object_element { Kind::AnyKey }; -JsonValue JsonPath::resolve(const JsonValue& top_root) const +JsonValue JsonPath::resolve(JsonValue const& top_root) const { auto root = top_root; for (auto const& element : *this) { diff --git a/AK/JsonPath.h b/AK/JsonPath.h index ab93c2d8ca5..dbb52f0ac80 100644 --- a/AK/JsonPath.h +++ b/AK/JsonPath.h @@ -34,7 +34,7 @@ public: } Kind kind() const { return m_kind; } - const String& key() const + String const& key() const { VERIFY(m_kind == Kind::Key); return m_key; @@ -61,7 +61,7 @@ public: static JsonPathElement any_array_element; static JsonPathElement any_object_element; - bool operator==(const JsonPathElement& other) const + bool operator==(JsonPathElement const& other) const { switch (other.kind()) { case Kind::Key: @@ -75,7 +75,7 @@ public: } return false; } - bool operator!=(const JsonPathElement& other) const + bool operator!=(JsonPathElement const& other) const { return !(*this == other); } @@ -93,7 +93,7 @@ private: class JsonPath : public Vector { public: - JsonValue resolve(const JsonValue&) const; + JsonValue resolve(JsonValue const&) const; String to_string() const; }; diff --git a/AK/JsonValue.cpp b/AK/JsonValue.cpp index b29cf1a9b08..9a6536b6196 100644 --- a/AK/JsonValue.cpp +++ b/AK/JsonValue.cpp @@ -20,12 +20,12 @@ JsonValue::JsonValue(Type type) { } -JsonValue::JsonValue(const JsonValue& other) +JsonValue::JsonValue(JsonValue const& other) { copy_from(other); } -JsonValue& JsonValue::operator=(const JsonValue& other) +JsonValue& JsonValue::operator=(JsonValue const& other) { if (this != &other) { clear(); @@ -34,7 +34,7 @@ JsonValue& JsonValue::operator=(const JsonValue& other) return *this; } -void JsonValue::copy_from(const JsonValue& other) +void JsonValue::copy_from(JsonValue const& other) { m_type = other.m_type; switch (m_type) { @@ -71,7 +71,7 @@ JsonValue& JsonValue::operator=(JsonValue&& other) return *this; } -bool JsonValue::equals(const JsonValue& other) const +bool JsonValue::equals(JsonValue const& other) const { if (is_null() && other.is_null()) return true; @@ -155,7 +155,7 @@ JsonValue::JsonValue(long long unsigned value) m_value.as_u64 = value; } -JsonValue::JsonValue(const char* cstring) +JsonValue::JsonValue(char const* cstring) : JsonValue(String(cstring)) { } @@ -174,7 +174,7 @@ JsonValue::JsonValue(bool value) m_value.as_bool = value; } -JsonValue::JsonValue(const String& value) +JsonValue::JsonValue(String const& value) { if (value.is_null()) { m_type = Type::Null; @@ -190,13 +190,13 @@ JsonValue::JsonValue(StringView value) { } -JsonValue::JsonValue(const JsonObject& value) +JsonValue::JsonValue(JsonObject const& value) : m_type(Type::Object) { m_value.as_object = new JsonObject(value); } -JsonValue::JsonValue(const JsonArray& value) +JsonValue::JsonValue(JsonArray const& value) : m_type(Type::Array) { m_value.as_array = new JsonArray(value); diff --git a/AK/JsonValue.h b/AK/JsonValue.h index 328d7ee0d92..c52d0bb471d 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -38,10 +38,10 @@ public: explicit JsonValue(Type = Type::Null); ~JsonValue() { clear(); } - JsonValue(const JsonValue&); + JsonValue(JsonValue const&); JsonValue(JsonValue&&); - JsonValue& operator=(const JsonValue&); + JsonValue& operator=(JsonValue const&); JsonValue& operator=(JsonValue&&); JsonValue(int); @@ -55,13 +55,13 @@ public: JsonValue(double); #endif JsonValue(bool); - JsonValue(const char*); + JsonValue(char const*); #ifndef KERNEL - JsonValue(const String&); + JsonValue(String const&); #endif JsonValue(StringView); - JsonValue(const JsonArray&); - JsonValue(const JsonObject&); + JsonValue(JsonArray const&); + JsonValue(JsonObject const&); JsonValue(JsonArray&&); JsonValue(JsonObject&&); @@ -163,13 +163,13 @@ public: } #endif - const JsonObject& as_object() const + JsonObject const& as_object() const { VERIFY(is_object()); return *m_value.as_object; } - const JsonArray& as_array() const + JsonArray const& as_array() const { VERIFY(is_array()); return *m_value.as_array; @@ -240,11 +240,11 @@ public: return default_value; } - bool equals(const JsonValue& other) const; + bool equals(JsonValue const& other) const; private: void clear(); - void copy_from(const JsonValue&); + void copy_from(JsonValue const&); Type m_type { Type::Null }; diff --git a/AK/LEB128.h b/AK/LEB128.h index 5bff2523289..69b48576bc0 100644 --- a/AK/LEB128.h +++ b/AK/LEB128.h @@ -36,11 +36,11 @@ struct LEB128 { return false; ValueType masked_byte = byte & ~(1 << 7); - const bool shift_too_large_for_result = (num_bytes * 7 > sizeof(ValueType) * 8) && (masked_byte != 0); + bool const shift_too_large_for_result = (num_bytes * 7 > sizeof(ValueType) * 8) && (masked_byte != 0); if (shift_too_large_for_result) return false; - const bool shift_too_large_for_byte = ((masked_byte << (num_bytes * 7)) >> (num_bytes * 7)) != masked_byte; + bool const shift_too_large_for_byte = ((masked_byte << (num_bytes * 7)) >> (num_bytes * 7)) != masked_byte; if (shift_too_large_for_byte) return false; @@ -83,11 +83,11 @@ struct LEB128 { // note: 64 bit assumptions! u64 masked_byte = byte & ~(1 << 7); - const bool shift_too_large_for_result = (num_bytes * 7 >= 64) && (masked_byte != ((temp < 0) ? 0x7Fu : 0u)); + bool const shift_too_large_for_result = (num_bytes * 7 >= 64) && (masked_byte != ((temp < 0) ? 0x7Fu : 0u)); if (shift_too_large_for_result) return false; - const bool shift_too_large_for_byte = (num_bytes * 7) == 63 && masked_byte != 0x00 && masked_byte != 0x7Fu; + bool const shift_too_large_for_byte = (num_bytes * 7) == 63 && masked_byte != 0x00 && masked_byte != 0x7Fu; if (shift_too_large_for_byte) return false; diff --git a/AK/MACAddress.h b/AK/MACAddress.h index d91cc5b24af..6caeeac73c0 100644 --- a/AK/MACAddress.h +++ b/AK/MACAddress.h @@ -36,7 +36,7 @@ public: constexpr ~MACAddress() = default; - constexpr const u8& operator[](unsigned i) const + constexpr u8 const& operator[](unsigned i) const { VERIFY(i < s_mac_address_length); return m_data[i]; @@ -48,7 +48,7 @@ public: return m_data[i]; } - constexpr bool operator==(const MACAddress& other) const + constexpr bool operator==(MACAddress const& other) const { for (auto i = 0u; i < m_data.size(); ++i) { if (m_data[i] != other.m_data[i]) { @@ -75,7 +75,7 @@ public: if (string.is_null()) return {}; - const auto parts = string.split_view(":"); + auto const parts = string.split_view(":"); if (parts.size() != 6) return {}; @@ -94,7 +94,7 @@ public: constexpr bool is_zero() const { - return all_of(m_data, [](const auto octet) { return octet == 0; }); + return all_of(m_data, [](auto const octet) { return octet == 0; }); } void copy_to(Bytes destination) const @@ -112,7 +112,7 @@ namespace AK { template<> struct Traits : public GenericTraits { - static unsigned hash(const MACAddress& address) { return string_hash((const char*)&address, sizeof(address)); } + static unsigned hash(MACAddress const& address) { return string_hash((char const*)&address, sizeof(address)); } }; } diff --git a/AK/MemMem.h b/AK/MemMem.h index ee49e116e71..d97b7c0d1aa 100644 --- a/AK/MemMem.h +++ b/AK/MemMem.h @@ -15,7 +15,7 @@ namespace AK { namespace Detail { -constexpr const void* bitap_bitwise(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) +constexpr void const* bitap_bitwise(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) { VERIFY(needle_length < 32); @@ -28,14 +28,14 @@ constexpr const void* bitap_bitwise(const void* haystack, size_t haystack_length needle_mask[i] = 0xffffffff; for (size_t i = 0; i < needle_length; ++i) - needle_mask[((const u8*)needle)[i]] &= ~(0x00000001 << i); + needle_mask[((u8 const*)needle)[i]] &= ~(0x00000001 << i); for (size_t i = 0; i < haystack_length; ++i) { - lookup |= needle_mask[((const u8*)haystack)[i]]; + lookup |= needle_mask[((u8 const*)haystack)[i]]; lookup <<= 1; if (0 == (lookup & (0x00000001 << needle_length))) - return ((const u8*)haystack) + i - needle_length + 1; + return ((u8 const*)haystack) + i - needle_length + 1; } return nullptr; @@ -43,7 +43,7 @@ constexpr const void* bitap_bitwise(const void* haystack, size_t haystack_length } template -inline Optional memmem(const HaystackIterT& haystack_begin, const HaystackIterT& haystack_end, Span needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) +inline Optional memmem(HaystackIterT const& haystack_begin, HaystackIterT const& haystack_end, Span needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) { auto prepare_kmp_partial_table = [&] { Vector table; @@ -100,7 +100,7 @@ inline Optional memmem(const HaystackIterT& haystack_begin, const Haysta return {}; } -inline Optional memmem_optional(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) +inline Optional memmem_optional(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) { if (needle_length == 0) return 0; @@ -122,15 +122,15 @@ inline Optional memmem_optional(const void* haystack, size_t haystack_le } // Fallback to KMP. - Array, 1> spans { Span { (const u8*)haystack, haystack_length } }; - return memmem(spans.begin(), spans.end(), { (const u8*)needle, needle_length }); + Array, 1> spans { Span { (u8 const*)haystack, haystack_length } }; + return memmem(spans.begin(), spans.end(), { (u8 const*)needle, needle_length }); } -inline const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) +inline void const* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) { auto offset = memmem_optional(haystack, haystack_length, needle, needle_length); if (offset.has_value()) - return ((const u8*)haystack) + offset.value(); + return ((u8 const*)haystack) + offset.value(); return nullptr; } diff --git a/AK/Memory.h b/AK/Memory.h index 6cee4fe8466..83cad053086 100644 --- a/AK/Memory.h +++ b/AK/Memory.h @@ -16,7 +16,7 @@ # include #endif -ALWAYS_INLINE void fast_u32_copy(u32* dest, const u32* src, size_t count) +ALWAYS_INLINE void fast_u32_copy(u32* dest, u32 const* src, size_t count) { #if ARCH(I386) || ARCH(X86_64) asm volatile( @@ -58,10 +58,10 @@ inline void secure_zero(void* ptr, size_t size) // guarded against potential timing attacks. // // See OpenBSD's timingsafe_memcmp for more advanced implementations. -inline bool timing_safe_compare(const void* b1, const void* b2, size_t len) +inline bool timing_safe_compare(void const* b1, void const* b2, size_t len) { - auto* c1 = static_cast(b1); - auto* c2 = static_cast(b2); + auto* c1 = static_cast(b1); + auto* c2 = static_cast(b2); u8 res = 0; for (size_t i = 0; i < len; i++) { diff --git a/AK/MemoryStream.h b/AK/MemoryStream.h index 2b58ce14620..c4fd384f0c4 100644 --- a/AK/MemoryStream.h +++ b/AK/MemoryStream.h @@ -29,7 +29,7 @@ public: if (has_any_error()) return 0; - const auto count = min(bytes.size(), remaining()); + auto const count = min(bytes.size(), remaining()); __builtin_memcpy(bytes.data(), m_bytes.data() + m_offset, count); m_offset += count; return count; @@ -98,7 +98,7 @@ public: size_t write(ReadonlyBytes bytes) override { - const auto nwritten = bytes.copy_trimmed_to(m_bytes.slice(m_offset)); + auto const nwritten = bytes.copy_trimmed_to(m_bytes.slice(m_offset)); m_offset += nwritten; return nwritten; } @@ -116,7 +116,7 @@ public: size_t fill_to_end(u8 value) { - const auto nwritten = m_bytes.slice(m_offset).fill(value); + auto const nwritten = m_bytes.slice(m_offset).fill(value); m_offset += nwritten; return nwritten; } @@ -126,7 +126,7 @@ public: ReadonlyBytes bytes() const { return { data(), size() }; } Bytes bytes() { return { data(), size() }; } - const u8* data() const { return m_bytes.data(); } + u8 const* data() const { return m_bytes.data(); } u8* data() { return m_bytes.data(); } size_t size() const { return m_offset; } @@ -186,8 +186,8 @@ public: { size_t nread = 0; while (bytes.size() - nread > 0 && m_write_offset - m_read_offset - nread > 0) { - const auto chunk_index = (m_read_offset - m_base_offset + nread) / chunk_size; - const auto chunk_bytes = m_chunks[chunk_index].bytes().slice((m_read_offset + nread) % chunk_size).trim(m_write_offset - m_read_offset - nread); + auto const chunk_index = (m_read_offset - m_base_offset + nread) / chunk_size; + auto const chunk_bytes = m_chunks[chunk_index].bytes().slice((m_read_offset + nread) % chunk_size).trim(m_write_offset - m_read_offset - nread); nread += chunk_bytes.copy_trimmed_to(bytes.slice(nread)); } @@ -199,7 +199,7 @@ public: if (has_any_error()) return 0; - const auto nread = read_without_consuming(bytes); + auto const nread = read_without_consuming(bytes); m_read_offset += nread; try_discard_chunks(); @@ -244,7 +244,7 @@ public: // FIXME: Handle possible OOM situation. auto buffer = ByteBuffer::create_uninitialized(size()).release_value_but_fixme_should_propagate_errors(); - const auto nread = read_without_consuming(buffer); + auto const nread = read_without_consuming(buffer); VERIFY(nread == buffer.size()); return buffer; diff --git a/AK/Noncopyable.h b/AK/Noncopyable.h index b3bbbda6d96..646386576b8 100644 --- a/AK/Noncopyable.h +++ b/AK/Noncopyable.h @@ -8,8 +8,8 @@ #define AK_MAKE_NONCOPYABLE(c) \ private: \ - c(const c&) = delete; \ - c& operator=(const c&) = delete + c(c const&) = delete; \ + c& operator=(c const&) = delete #define AK_MAKE_NONMOVABLE(c) \ private: \ diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index 87be16e2614..ad374dcad58 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -57,25 +57,25 @@ public: #endif } - NonnullOwnPtr(const NonnullOwnPtr&) = delete; + NonnullOwnPtr(NonnullOwnPtr const&) = delete; template - NonnullOwnPtr(const NonnullOwnPtr&) = delete; - NonnullOwnPtr& operator=(const NonnullOwnPtr&) = delete; + NonnullOwnPtr(NonnullOwnPtr const&) = delete; + NonnullOwnPtr& operator=(NonnullOwnPtr const&) = delete; template - NonnullOwnPtr& operator=(const NonnullOwnPtr&) = delete; + NonnullOwnPtr& operator=(NonnullOwnPtr const&) = delete; template> - NonnullOwnPtr(const RefPtr&) = delete; + NonnullOwnPtr(RefPtr const&) = delete; template - NonnullOwnPtr(const NonnullRefPtr&) = delete; + NonnullOwnPtr(NonnullRefPtr const&) = delete; template - NonnullOwnPtr(const WeakPtr&) = delete; + NonnullOwnPtr(WeakPtr const&) = delete; template> - NonnullOwnPtr& operator=(const RefPtr&) = delete; + NonnullOwnPtr& operator=(RefPtr const&) = delete; template - NonnullOwnPtr& operator=(const NonnullRefPtr&) = delete; + NonnullOwnPtr& operator=(NonnullRefPtr const&) = delete; template - NonnullOwnPtr& operator=(const WeakPtr&) = delete; + NonnullOwnPtr& operator=(WeakPtr const&) = delete; NonnullOwnPtr& operator=(NonnullOwnPtr&& other) { @@ -178,8 +178,8 @@ template struct Traits> : public GenericTraits> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const NonnullOwnPtr& p) { return ptr_hash((FlatPtr)p.ptr()); } - static bool equals(const NonnullOwnPtr& a, const NonnullOwnPtr& b) { return a.ptr() == b.ptr(); } + static unsigned hash(NonnullOwnPtr const& p) { return ptr_hash((FlatPtr)p.ptr()); } + static bool equals(NonnullOwnPtr const& a, NonnullOwnPtr const& b) { return a.ptr() == b.ptr(); } }; template diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 6db27644d39..b71f85c0028 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -22,8 +22,8 @@ public: : Base(static_cast(other)) { } - NonnullPtrVector(const Vector& other) - : Base(static_cast(other)) + NonnullPtrVector(Vector const& other) + : Base(static_cast(other)) { } @@ -48,7 +48,7 @@ public: ALWAYS_INLINE constexpr auto in_reverse() const { return ReverseWrapper::in_reverse(*this); } ALWAYS_INLINE PtrType& ptr_at(size_t index) { return Base::at(index); } - ALWAYS_INLINE const PtrType& ptr_at(size_t index) const { return Base::at(index); } + ALWAYS_INLINE PtrType const& ptr_at(size_t index) const { return Base::at(index); } ALWAYS_INLINE T& at(size_t index) { return *Base::at(index); } ALWAYS_INLINE const T& at(size_t index) const { return *Base::at(index); } diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 4640518c2a9..2aab1d65ead 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -104,16 +104,16 @@ public: } template - NonnullRefPtr(const OwnPtr&) = delete; + NonnullRefPtr(OwnPtr const&) = delete; template - NonnullRefPtr& operator=(const OwnPtr&) = delete; + NonnullRefPtr& operator=(OwnPtr const&) = delete; template - NonnullRefPtr(const RefPtr&) = delete; + NonnullRefPtr(RefPtr const&) = delete; template - NonnullRefPtr& operator=(const RefPtr&) = delete; - NonnullRefPtr(const RefPtr&) = delete; - NonnullRefPtr& operator=(const RefPtr&) = delete; + NonnullRefPtr& operator=(RefPtr const&) = delete; + NonnullRefPtr(RefPtr const&) = delete; + NonnullRefPtr& operator=(RefPtr const&) = delete; NonnullRefPtr& operator=(NonnullRefPtr const& other) { @@ -270,8 +270,8 @@ template struct Traits> : public GenericTraits> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const NonnullRefPtr& p) { return ptr_hash(p.ptr()); } - static bool equals(const NonnullRefPtr& a, const NonnullRefPtr& b) { return a.ptr() == b.ptr(); } + static unsigned hash(NonnullRefPtr const& p) { return ptr_hash(p.ptr()); } + static bool equals(NonnullRefPtr const& a, NonnullRefPtr const& b) { return a.ptr() == b.ptr(); } }; using AK::adopt_ref; diff --git a/AK/NumberFormat.h b/AK/NumberFormat.h index d63d424277f..ce778eccc73 100644 --- a/AK/NumberFormat.h +++ b/AK/NumberFormat.h @@ -11,7 +11,7 @@ namespace AK { // FIXME: Remove this hackery once printf() supports floats. -static String number_string_with_one_decimal(u64 number, u64 unit, const char* suffix) +static String number_string_with_one_decimal(u64 number, u64 unit, char const* suffix) { int decimal = (number % unit) * 10 / unit; return String::formatted("{}.{} {}", number / unit, decimal, suffix); diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index 1eb888583cf..4f6b1fbc64a 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -47,29 +47,29 @@ public: #endif } - OwnPtr(const OwnPtr&) = delete; + OwnPtr(OwnPtr const&) = delete; template - OwnPtr(const OwnPtr&) = delete; - OwnPtr& operator=(const OwnPtr&) = delete; + OwnPtr(OwnPtr const&) = delete; + OwnPtr& operator=(OwnPtr const&) = delete; template - OwnPtr& operator=(const OwnPtr&) = delete; + OwnPtr& operator=(OwnPtr const&) = delete; template - OwnPtr(const NonnullOwnPtr&) = delete; + OwnPtr(NonnullOwnPtr const&) = delete; template - OwnPtr& operator=(const NonnullOwnPtr&) = delete; + OwnPtr& operator=(NonnullOwnPtr const&) = delete; template - OwnPtr(const RefPtr&) = delete; + OwnPtr(RefPtr const&) = delete; template - OwnPtr(const NonnullRefPtr&) = delete; + OwnPtr(NonnullRefPtr const&) = delete; template - OwnPtr(const WeakPtr&) = delete; + OwnPtr(WeakPtr const&) = delete; template - OwnPtr& operator=(const RefPtr&) = delete; + OwnPtr& operator=(RefPtr const&) = delete; template - OwnPtr& operator=(const NonnullRefPtr&) = delete; + OwnPtr& operator=(NonnullRefPtr const&) = delete; template - OwnPtr& operator=(const WeakPtr&) = delete; + OwnPtr& operator=(WeakPtr const&) = delete; OwnPtr& operator=(OwnPtr&& other) { @@ -232,8 +232,8 @@ template struct Traits> : public GenericTraits> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const OwnPtr& p) { return ptr_hash(p.ptr()); } - static bool equals(const OwnPtr& a, const OwnPtr& b) { return a.ptr() == b.ptr(); } + static unsigned hash(OwnPtr const& p) { return ptr_hash(p.ptr()); } + static bool equals(OwnPtr const& a, OwnPtr const& b) { return a.ptr() == b.ptr(); } }; } diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 51b46b4b470..eb344c5eb8d 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -14,7 +14,7 @@ #include #ifdef __serenity__ -extern "C" size_t strlen(const char*); +extern "C" size_t strlen(char const*); #else # include #endif @@ -24,8 +24,8 @@ namespace PrintfImplementation { template ALWAYS_INLINE int print_hex(PutChFunc putch, CharType*& bufptr, T number, bool upper_case, bool alternate_form, bool left_pad, bool zero_pad, u32 field_width, bool has_precision, u32 precision) { - constexpr const char* printf_hex_digits_lower = "0123456789abcdef"; - constexpr const char* printf_hex_digits_upper = "0123456789ABCDEF"; + constexpr char const* printf_hex_digits_lower = "0123456789abcdef"; + constexpr char const* printf_hex_digits_upper = "0123456789ABCDEF"; u32 digits = 0; for (T n = number; n > 0; n >>= 4) @@ -331,104 +331,104 @@ struct ModifierState { template typename NextArgument, typename CharType = char> struct PrintfImpl { - ALWAYS_INLINE PrintfImpl(PutChFunc& putch, CharType*& bufptr, const int& nwritten) + ALWAYS_INLINE PrintfImpl(PutChFunc& putch, CharType*& bufptr, int const& nwritten) : m_bufptr(bufptr) , m_nwritten(nwritten) , m_putch(putch) { } - ALWAYS_INLINE int format_s(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_s(ModifierState const& state, ArgumentListRefT ap) const { // FIXME: Narrow characters should be converted to wide characters on the fly and vice versa. // https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wprintf.html #ifndef KERNEL if (state.long_qualifiers) { - const wchar_t* sp = NextArgument()(ap); + wchar_t const* sp = NextArgument()(ap); if (!sp) sp = L"(null)"; return print_string(m_putch, m_bufptr, sp, wcslen(sp), state.left_pad, state.field_width, state.dot, state.precision, state.has_precision); } #endif - const char* sp = NextArgument()(ap); + char const* sp = NextArgument()(ap); if (!sp) sp = "(null)"; return print_string(m_putch, m_bufptr, sp, strlen(sp), state.left_pad, state.field_width, state.dot, state.precision, state.has_precision); } - ALWAYS_INLINE int format_d(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_d(ModifierState const& state, ArgumentListRefT ap) const { if (state.long_qualifiers >= 2) return print_i64(m_putch, m_bufptr, NextArgument()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); return print_signed_number(m_putch, m_bufptr, NextArgument()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); } - ALWAYS_INLINE int format_i(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_i(ModifierState const& state, ArgumentListRefT ap) const { return format_d(state, ap); } - ALWAYS_INLINE int format_u(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_u(ModifierState const& state, ArgumentListRefT ap) const { if (state.long_qualifiers >= 2) return print_decimal(m_putch, m_bufptr, NextArgument()(ap), false, false, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); return print_decimal(m_putch, m_bufptr, NextArgument()(ap), false, false, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); } - ALWAYS_INLINE int format_Q(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_Q(ModifierState const& state, ArgumentListRefT ap) const { return print_decimal(m_putch, m_bufptr, NextArgument()(ap), false, false, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); } - ALWAYS_INLINE int format_q(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_q(ModifierState const& state, ArgumentListRefT ap) const { return print_hex(m_putch, m_bufptr, NextArgument()(ap), false, false, state.left_pad, state.zero_pad, 16, false, 1); } - ALWAYS_INLINE int format_g(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_g(ModifierState const& state, ArgumentListRefT ap) const { return format_f(state, ap); } - ALWAYS_INLINE int format_f(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_f(ModifierState const& state, ArgumentListRefT ap) const { return print_double(m_putch, m_bufptr, NextArgument()(ap), state.always_sign, state.left_pad, state.zero_pad, state.field_width, state.precision); } - ALWAYS_INLINE int format_o(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_o(ModifierState const& state, ArgumentListRefT ap) const { return print_octal_number(m_putch, m_bufptr, NextArgument()(ap), state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); } - ALWAYS_INLINE int format_x(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_x(ModifierState const& state, ArgumentListRefT ap) const { if (state.long_qualifiers >= 2) return print_hex(m_putch, m_bufptr, NextArgument()(ap), false, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); return print_hex(m_putch, m_bufptr, NextArgument()(ap), false, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); } - ALWAYS_INLINE int format_X(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_X(ModifierState const& state, ArgumentListRefT ap) const { if (state.long_qualifiers >= 2) return print_hex(m_putch, m_bufptr, NextArgument()(ap), true, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); return print_hex(m_putch, m_bufptr, NextArgument()(ap), true, state.alternate_form, state.left_pad, state.zero_pad, state.field_width, state.has_precision, state.precision); } - ALWAYS_INLINE int format_n(const ModifierState&, ArgumentListRefT ap) const + ALWAYS_INLINE int format_n(ModifierState const&, ArgumentListRefT ap) const { *NextArgument()(ap) = m_nwritten; return 0; } - ALWAYS_INLINE int format_p(const ModifierState&, ArgumentListRefT ap) const + ALWAYS_INLINE int format_p(ModifierState const&, ArgumentListRefT ap) const { return print_hex(m_putch, m_bufptr, NextArgument()(ap), false, true, false, true, 8, false, 1); } - ALWAYS_INLINE int format_P(const ModifierState&, ArgumentListRefT ap) const + ALWAYS_INLINE int format_P(ModifierState const&, ArgumentListRefT ap) const { return print_hex(m_putch, m_bufptr, NextArgument()(ap), true, true, false, true, 8, false, 1); } - ALWAYS_INLINE int format_percent(const ModifierState&, ArgumentListRefT) const + ALWAYS_INLINE int format_percent(ModifierState const&, ArgumentListRefT) const { m_putch(m_bufptr, '%'); return 1; } - ALWAYS_INLINE int format_c(const ModifierState& state, ArgumentListRefT ap) const + ALWAYS_INLINE int format_c(ModifierState const& state, ArgumentListRefT ap) const { char c = NextArgument()(ap); return print_string(m_putch, m_bufptr, &c, 1, state.left_pad, state.field_width, state.dot, state.precision, state.has_precision); } - ALWAYS_INLINE int format_unrecognized(CharType format_op, const CharType* fmt, const ModifierState&, ArgumentListRefT) const + ALWAYS_INLINE int format_unrecognized(CharType format_op, CharType const* fmt, ModifierState const&, ArgumentListRefT) const { dbgln("printf_internal: Unimplemented format specifier {} (fmt: {})", format_op, fmt); return 0; @@ -436,7 +436,7 @@ struct PrintfImpl { protected: CharType*& m_bufptr; - const int& m_nwritten; + int const& m_nwritten; PutChFunc& m_putch; }; @@ -454,14 +454,14 @@ struct VaArgNextArgument { break; template typename V, typename C = char> typename Impl = PrintfImpl, typename ArgumentListT = va_list, template())> typename NextArgument = VaArgNextArgument, typename CharType = char> -ALWAYS_INLINE int printf_internal(PutChFunc putch, IdentityType* buffer, const CharType*& fmt, ArgumentListT ap) +ALWAYS_INLINE int printf_internal(PutChFunc putch, IdentityType* buffer, CharType const*& fmt, ArgumentListT ap) { int ret = 0; CharType* bufptr = buffer; Impl impl { putch, bufptr, ret }; - for (const CharType* p = fmt; *p; ++p) { + for (CharType const* p = fmt; *p; ++p) { ModifierState state; if (*p == '%' && *(p + 1)) { one_more: diff --git a/AK/Ptr32.h b/AK/Ptr32.h index c1544b402ee..9c7880123cc 100644 --- a/AK/Ptr32.h +++ b/AK/Ptr32.h @@ -28,7 +28,7 @@ public: T const* operator->() const { return *this; } operator T*() { return reinterpret_cast(static_cast(m_ptr)); } - operator T const *() const { return reinterpret_cast(static_cast(m_ptr)); } + operator T const*() const { return reinterpret_cast(static_cast(m_ptr)); } T& operator[](size_t index) { return static_cast(*this)[index]; } T const& operator[](size_t index) const { return static_cast(*this)[index]; } diff --git a/AK/RedBlackTree.h b/AK/RedBlackTree.h index 27401134209..11994bd4b47 100644 --- a/AK/RedBlackTree.h +++ b/AK/RedBlackTree.h @@ -404,7 +404,7 @@ template class RedBlackTreeIterator { public: RedBlackTreeIterator() = default; - bool operator!=(const RedBlackTreeIterator& other) const { return m_node != other.m_node; } + bool operator!=(RedBlackTreeIterator const& other) const { return m_node != other.m_node; } RedBlackTreeIterator& operator++() { if (!m_node) diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 3696082e14b..53a2fc2a8f7 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -264,8 +264,8 @@ public: bool operator==(std::nullptr_t) const { return is_null(); } bool operator!=(std::nullptr_t) const { return !is_null(); } - bool operator==(const RefPtr& other) const { return as_ptr() == other.as_ptr(); } - bool operator!=(const RefPtr& other) const { return as_ptr() != other.as_ptr(); } + bool operator==(RefPtr const& other) const { return as_ptr() == other.as_ptr(); } + bool operator!=(RefPtr const& other) const { return as_ptr() != other.as_ptr(); } bool operator==(RefPtr& other) { return as_ptr() == other.as_ptr(); } bool operator!=(RefPtr& other) { return as_ptr() != other.as_ptr(); } @@ -305,18 +305,18 @@ template struct Traits> : public GenericTraits> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const RefPtr& p) { return ptr_hash(p.ptr()); } - static bool equals(const RefPtr& a, const RefPtr& b) { return a.ptr() == b.ptr(); } + static unsigned hash(RefPtr const& p) { return ptr_hash(p.ptr()); } + static bool equals(RefPtr const& a, RefPtr const& b) { return a.ptr() == b.ptr(); } }; template -inline NonnullRefPtr static_ptr_cast(const NonnullRefPtr& ptr) +inline NonnullRefPtr static_ptr_cast(NonnullRefPtr const& ptr) { return NonnullRefPtr(static_cast(*ptr)); } template> -inline RefPtr static_ptr_cast(const RefPtr& ptr) +inline RefPtr static_ptr_cast(RefPtr const& ptr) { return RefPtr(static_cast(ptr.ptr())); } diff --git a/AK/Result.h b/AK/Result.h index 85c4f90722f..c4ff023759f 100644 --- a/AK/Result.h +++ b/AK/Result.h @@ -17,7 +17,7 @@ public: using ValueType = ValueT; using ErrorType = ErrorT; - Result(const ValueType& res) + Result(ValueType const& res) : m_result(res) { } @@ -27,7 +27,7 @@ public: { } - Result(const ErrorType& error) + Result(ErrorType const& error) : m_error(error) { } @@ -38,7 +38,7 @@ public: } Result(Result&& other) = default; - Result(const Result& other) = default; + Result(Result const& other) = default; ~Result() = default; ValueType& value() @@ -78,7 +78,7 @@ public: using ValueType = void; using ErrorType = ErrorT; - Result(const ErrorType& error) + Result(ErrorType const& error) : m_error(error) { } @@ -90,7 +90,7 @@ public: Result() = default; Result(Result&& other) = default; - Result(const Result& other) = default; + Result(Result const& other) = default; ~Result() = default; // For compatibility with TRY(). diff --git a/AK/ReverseIterator.h b/AK/ReverseIterator.h index 566a098df16..04e0fc3defa 100644 --- a/AK/ReverseIterator.h +++ b/AK/ReverseIterator.h @@ -55,7 +55,7 @@ public: ALWAYS_INLINE constexpr ValueType const* operator->() const { return &m_container[m_index]; } ALWAYS_INLINE constexpr ValueType* operator->() { return &m_container[m_index]; } - SimpleReverseIterator& operator=(const SimpleReverseIterator& other) + SimpleReverseIterator& operator=(SimpleReverseIterator const& other) { m_index = other.m_index; return *this; diff --git a/AK/ScopeLogger.h b/AK/ScopeLogger.h index 418027862c5..7fabbd348a3 100644 --- a/AK/ScopeLogger.h +++ b/AK/ScopeLogger.h @@ -15,7 +15,7 @@ namespace AK { template class ScopeLogger { public: - ScopeLogger(StringView extra, const SourceLocation& location = SourceLocation::current()) + ScopeLogger(StringView extra, SourceLocation const& location = SourceLocation::current()) : m_location(location) , m_extra(extra) { diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h index 513215e3745..284aa3c3d48 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -18,7 +18,7 @@ template class SinglyLinkedListIterator { public: SinglyLinkedListIterator() = default; - bool operator!=(const SinglyLinkedListIterator& other) const { return m_node != other.m_node; } + bool operator!=(SinglyLinkedListIterator const& other) const { return m_node != other.m_node; } SinglyLinkedListIterator& operator++() { if (m_removed) @@ -80,7 +80,7 @@ private: public: SinglyLinkedList() = default; - SinglyLinkedList(const SinglyLinkedList& other) = delete; + SinglyLinkedList(SinglyLinkedList const& other) = delete; SinglyLinkedList(SinglyLinkedList&& other) : m_head(other.m_head) , m_tail(other.m_tail) @@ -88,7 +88,7 @@ public: other.m_head = nullptr; other.m_tail = nullptr; } - SinglyLinkedList& operator=(const SinglyLinkedList& other) = delete; + SinglyLinkedList& operator=(SinglyLinkedList const& other) = delete; SinglyLinkedList& operator=(SinglyLinkedList&&) = delete; ~SinglyLinkedList() { clear(); } @@ -239,10 +239,10 @@ public: private: Node* head() { return m_head; } - const Node* head() const { return m_head; } + Node const* head() const { return m_head; } Node* tail() { return m_tail; } - const Node* tail() const { return m_tail; } + Node const* tail() const { return m_tail; } Node* m_head { nullptr }; Node* m_tail { nullptr }; diff --git a/AK/SourceGenerator.h b/AK/SourceGenerator.h index 00dfc3ca1f0..3e875a29730 100644 --- a/AK/SourceGenerator.h +++ b/AK/SourceGenerator.h @@ -25,7 +25,7 @@ public: , m_closing(closing) { } - explicit SourceGenerator(StringBuilder& builder, const MappingType& mapping, char opening = '@', char closing = '@') + explicit SourceGenerator(StringBuilder& builder, MappingType const& mapping, char opening = '@', char closing = '@') : m_builder(builder) , m_mapping(mapping) , m_opening(opening) @@ -58,14 +58,14 @@ public: while (!lexer.is_eof()) { // FIXME: It is a bit inconvenient, that 'consume_until' also consumes the 'stop' character, this makes // the method less generic because there is no way to check if the 'stop' character ever appeared. - const auto consume_until_without_consuming_stop_character = [&](char stop) { + auto const consume_until_without_consuming_stop_character = [&](char stop) { return lexer.consume_while([&](char ch) { return ch != stop; }); }; m_builder.append(consume_until_without_consuming_stop_character(m_opening)); if (lexer.consume_specific(m_opening)) { - const auto placeholder = consume_until_without_consuming_stop_character(m_closing); + auto const placeholder = consume_until_without_consuming_stop_character(m_closing); if (!lexer.consume_specific(m_closing)) VERIFY_NOT_REACHED(); diff --git a/AK/SourceLocation.h b/AK/SourceLocation.h index 1a90897b650..c70d7131442 100644 --- a/AK/SourceLocation.h +++ b/AK/SourceLocation.h @@ -19,7 +19,7 @@ public: [[nodiscard]] constexpr StringView filename() const { return StringView(m_file); } [[nodiscard]] constexpr u32 line_number() const { return m_line; } - [[nodiscard]] static constexpr SourceLocation current(const char* const file = __builtin_FILE(), u32 line = __builtin_LINE(), const char* const function = __builtin_FUNCTION()) + [[nodiscard]] static constexpr SourceLocation current(char const* const file = __builtin_FILE(), u32 line = __builtin_LINE(), char const* const function = __builtin_FUNCTION()) { return SourceLocation(file, line, function); } @@ -27,15 +27,15 @@ public: constexpr SourceLocation() = default; private: - constexpr SourceLocation(const char* const file, u32 line, const char* const function) + constexpr SourceLocation(char const* const file, u32 line, char const* const function) : m_function(function) , m_file(file) , m_line(line) { } - const char* const m_function { nullptr }; - const char* const m_file { nullptr }; + char const* const m_function { nullptr }; + char const* const m_file { nullptr }; const u32 m_line { 0 }; }; diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 1a255ede408..c9b64f0b267 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -75,19 +75,19 @@ constexpr SizeType array_size(T (&)[N]) } template -constexpr T min(const T& a, const IdentityType& b) +constexpr T min(const T& a, IdentityType const& b) { return b < a ? b : a; } template -constexpr T max(const T& a, const IdentityType& b) +constexpr T max(const T& a, IdentityType const& b) { return a < b ? b : a; } template -constexpr T clamp(const T& value, const IdentityType& min, const IdentityType& max) +constexpr T clamp(const T& value, IdentityType const& min, IdentityType const& max) { VERIFY(max >= min); if (value > max) diff --git a/AK/String.cpp b/AK/String.cpp index 1e18bca9a25..66c01a21499 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -16,12 +16,12 @@ namespace AK { -bool String::operator==(const FlyString& fly_string) const +bool String::operator==(FlyString const& fly_string) const { return m_impl == fly_string.impl() || view() == fly_string.view(); } -bool String::operator==(const String& other) const +bool String::operator==(String const& other) const { return m_impl == other.impl() || view() == other.view(); } @@ -31,12 +31,12 @@ bool String::operator==(StringView other) const return view() == other; } -bool String::operator<(const String& other) const +bool String::operator<(String const& other) const { return view() < other.view(); } -bool String::operator>(const String& other) const +bool String::operator>(String const& other) const { return view() > other.view(); } @@ -146,7 +146,7 @@ Vector String::split_view(Function separator, bool keep_ return v; } -Vector String::split_view(const char separator, bool keep_empty) const +Vector String::split_view(char const separator, bool keep_empty) const { return split_view([separator](char ch) { return ch == separator; }, keep_empty); } @@ -358,7 +358,7 @@ String escape_html_entities(StringView html) return builder.to_string(); } -String::String(const FlyString& string) +String::String(FlyString const& string) : m_impl(string.impl()) { } @@ -387,27 +387,27 @@ String String::to_titlecase() const return StringUtils::to_titlecase(*this); } -bool operator<(const char* characters, const String& string) +bool operator<(char const* characters, String const& string) { return string.view() > characters; } -bool operator>=(const char* characters, const String& string) +bool operator>=(char const* characters, String const& string) { return string.view() <= characters; } -bool operator>(const char* characters, const String& string) +bool operator>(char const* characters, String const& string) { return string.view() < characters; } -bool operator<=(const char* characters, const String& string) +bool operator<=(char const* characters, String const& string) { return string.view() >= characters; } -bool String::operator==(const char* cstring) const +bool String::operator==(char const* cstring) const { return view() == cstring; } diff --git a/AK/String.h b/AK/String.h index e4221f037f2..9160105a937 100644 --- a/AK/String.h +++ b/AK/String.h @@ -48,7 +48,7 @@ public: { } - String(const String& other) + String(String const& other) : m_impl(const_cast(other).m_impl) { } @@ -58,12 +58,12 @@ public: { } - String(const char* cstring, ShouldChomp shouldChomp = NoChomp) + String(char const* cstring, ShouldChomp shouldChomp = NoChomp) : m_impl(StringImpl::create(cstring, shouldChomp)) { } - String(const char* cstring, size_t length, ShouldChomp shouldChomp = NoChomp) + String(char const* cstring, size_t length, ShouldChomp shouldChomp = NoChomp) : m_impl(StringImpl::create(cstring, length, shouldChomp)) { } @@ -73,12 +73,12 @@ public: { } - String(const StringImpl& impl) + String(StringImpl const& impl) : m_impl(const_cast(impl)) { } - String(const StringImpl* impl) + String(StringImpl const* impl) : m_impl(const_cast(impl)) { } @@ -93,7 +93,7 @@ public: { } - String(const FlyString&); + String(FlyString const&); [[nodiscard]] static String repeated(char, size_t count); [[nodiscard]] static String repeated(StringView, size_t count); @@ -102,7 +102,7 @@ public: [[nodiscard]] static String roman_number_from(size_t value); template - [[nodiscard]] static String join(const SeparatorType& separator, const CollectionType& collection, StringView fmtstr = "{}"sv) + [[nodiscard]] static String join(SeparatorType const& separator, CollectionType const& collection, StringView fmtstr = "{}"sv) { StringBuilder builder; builder.join(separator, collection, fmtstr); @@ -169,7 +169,7 @@ public: [[nodiscard]] ALWAYS_INLINE bool is_empty() const { return length() == 0; } [[nodiscard]] ALWAYS_INLINE size_t length() const { return m_impl ? m_impl->length() : 0; } // Includes NUL-terminator, if non-nullptr. - [[nodiscard]] ALWAYS_INLINE const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } + [[nodiscard]] ALWAYS_INLINE char const* characters() const { return m_impl ? m_impl->characters() : nullptr; } [[nodiscard]] bool copy_characters_to_buffer(char* buffer, size_t buffer_size) const; @@ -181,13 +181,13 @@ public: return {}; } - [[nodiscard]] ALWAYS_INLINE const char& operator[](size_t i) const + [[nodiscard]] ALWAYS_INLINE char const& operator[](size_t i) const { VERIFY(!is_null()); return (*m_impl)[i]; } - using ConstIterator = SimpleIterator; + using ConstIterator = SimpleIterator; [[nodiscard]] constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } [[nodiscard]] constexpr ConstIterator end() const { return ConstIterator::end(*this); } @@ -197,27 +197,27 @@ public: [[nodiscard]] bool starts_with(char) const; [[nodiscard]] bool ends_with(char) const; - bool operator==(const String&) const; - bool operator!=(const String& other) const { return !(*this == other); } + bool operator==(String const&) const; + bool operator!=(String const& other) const { return !(*this == other); } bool operator==(StringView) const; bool operator!=(StringView other) const { return !(*this == other); } - bool operator==(const FlyString&) const; - bool operator!=(const FlyString& other) const { return !(*this == other); } + bool operator==(FlyString const&) const; + bool operator!=(FlyString const& other) const { return !(*this == other); } - bool operator<(const String&) const; - bool operator<(const char*) const; - bool operator>=(const String& other) const { return !(*this < other); } - bool operator>=(const char* other) const { return !(*this < other); } + bool operator<(String const&) const; + bool operator<(char const*) const; + bool operator>=(String const& other) const { return !(*this < other); } + bool operator>=(char const* other) const { return !(*this < other); } - bool operator>(const String&) const; - bool operator>(const char*) const; - bool operator<=(const String& other) const { return !(*this > other); } - bool operator<=(const char* other) const { return !(*this > other); } + bool operator>(String const&) const; + bool operator>(char const*) const; + bool operator<=(String const& other) const { return !(*this > other); } + bool operator<=(char const* other) const { return !(*this > other); } - bool operator==(const char* cstring) const; - bool operator!=(const char* cstring) const { return !(*this == cstring); } + bool operator==(char const* cstring) const; + bool operator!=(char const* cstring) const { return !(*this == cstring); } [[nodiscard]] String isolated_copy() const; @@ -227,7 +227,7 @@ public: } [[nodiscard]] StringImpl* impl() { return m_impl.ptr(); } - [[nodiscard]] const StringImpl* impl() const { return m_impl.ptr(); } + [[nodiscard]] StringImpl const* impl() const { return m_impl.ptr(); } String& operator=(String&& other) { @@ -236,7 +236,7 @@ public: return *this; } - String& operator=(const String& other) + String& operator=(String const& other) { if (this != &other) m_impl = const_cast(other).m_impl; @@ -265,17 +265,17 @@ public: [[nodiscard]] ByteBuffer to_byte_buffer() const; template - [[nodiscard]] static String copy(const BufferType& buffer, ShouldChomp should_chomp = NoChomp) + [[nodiscard]] static String copy(BufferType const& buffer, ShouldChomp should_chomp = NoChomp) { if (buffer.is_empty()) return empty(); - return String((const char*)buffer.data(), buffer.size(), should_chomp); + return String((char const*)buffer.data(), buffer.size(), should_chomp); } [[nodiscard]] static String vformatted(StringView fmtstr, TypeErasedFormatParams&); template - [[nodiscard]] static String formatted(CheckedFormatString&& fmtstr, const Parameters&... parameters) + [[nodiscard]] static String formatted(CheckedFormatString&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_parameters { parameters... }; return vformatted(fmtstr.view(), variadic_format_parameters); @@ -320,7 +320,7 @@ private: template<> struct Traits : public GenericTraits { - static unsigned hash(const String& s) { return s.impl() ? s.impl()->hash() : 0; } + static unsigned hash(String const& s) { return s.impl() ? s.impl()->hash() : 0; } }; struct CaseInsensitiveStringTraits : public Traits { @@ -328,10 +328,10 @@ struct CaseInsensitiveStringTraits : public Traits { static bool equals(String const& a, String const& b) { return a.equals_ignoring_case(b); } }; -bool operator<(const char*, const String&); -bool operator>=(const char*, const String&); -bool operator>(const char*, const String&); -bool operator<=(const char*, const String&); +bool operator<(char const*, String const&); +bool operator>=(char const*, String const&); +bool operator>(char const*, String const&); +bool operator<=(char const*, String const&); String escape_html_entities(StringView html); diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index 9ea6362d597..c31d709ca9d 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -48,7 +48,7 @@ NonnullRefPtr StringImpl::create_uninitialized(size_t length, char*& return new_stringimpl; } -RefPtr StringImpl::create(const char* cstring, size_t length, ShouldChomp should_chomp) +RefPtr StringImpl::create(char const* cstring, size_t length, ShouldChomp should_chomp) { if (!cstring) return nullptr; @@ -73,7 +73,7 @@ RefPtr StringImpl::create(const char* cstring, size_t length, Should return new_stringimpl; } -RefPtr StringImpl::create(const char* cstring, ShouldChomp shouldChomp) +RefPtr StringImpl::create(char const* cstring, ShouldChomp shouldChomp) { if (!cstring) return nullptr; @@ -86,7 +86,7 @@ RefPtr StringImpl::create(const char* cstring, ShouldChomp shouldCho RefPtr StringImpl::create(ReadonlyBytes bytes, ShouldChomp shouldChomp) { - return StringImpl::create(reinterpret_cast(bytes.data()), bytes.size(), shouldChomp); + return StringImpl::create(reinterpret_cast(bytes.data()), bytes.size(), shouldChomp); } RefPtr StringImpl::create_lowercased(char const* cstring, size_t length) diff --git a/AK/StringImpl.h b/AK/StringImpl.h index a06f976ab0d..c89f0e1202d 100644 --- a/AK/StringImpl.h +++ b/AK/StringImpl.h @@ -25,8 +25,8 @@ size_t allocation_size_for_stringimpl(size_t length); class StringImpl : public RefCounted { public: static NonnullRefPtr create_uninitialized(size_t length, char*& buffer); - static RefPtr create(const char* cstring, ShouldChomp = NoChomp); - static RefPtr create(const char* cstring, size_t length, ShouldChomp = NoChomp); + static RefPtr create(char const* cstring, ShouldChomp = NoChomp); + static RefPtr create(char const* cstring, size_t length, ShouldChomp = NoChomp); static RefPtr create(ReadonlyBytes, ShouldChomp = NoChomp); static RefPtr create_lowercased(char const* cstring, size_t length); static RefPtr create_uppercased(char const* cstring, size_t length); @@ -45,18 +45,18 @@ public: size_t length() const { return m_length; } // Includes NUL-terminator. - const char* characters() const { return &m_inline_buffer[0]; } + char const* characters() const { return &m_inline_buffer[0]; } ALWAYS_INLINE ReadonlyBytes bytes() const { return { characters(), length() }; } ALWAYS_INLINE StringView view() const { return { characters(), length() }; } - const char& operator[](size_t i) const + char const& operator[](size_t i) const { VERIFY(i < m_length); return characters()[i]; } - bool operator==(const StringImpl& other) const + bool operator==(StringImpl const& other) const { if (length() != other.length()) return false; diff --git a/AK/StringUtils.cpp b/AK/StringUtils.cpp index 927b3b6ee16..2c66ec68d5c 100644 --- a/AK/StringUtils.cpp +++ b/AK/StringUtils.cpp @@ -37,11 +37,11 @@ bool matches(StringView str, StringView mask, CaseSensitivity case_sensitivity, return true; } - const char* string_ptr = str.characters_without_null_termination(); - const char* string_start = str.characters_without_null_termination(); - const char* string_end = string_ptr + str.length(); - const char* mask_ptr = mask.characters_without_null_termination(); - const char* mask_end = mask_ptr + mask.length(); + char const* string_ptr = str.characters_without_null_termination(); + char const* string_start = str.characters_without_null_termination(); + char const* string_end = string_ptr + str.length(); + char const* mask_ptr = mask.characters_without_null_termination(); + char const* mask_end = mask_ptr + mask.length(); while (string_ptr < string_end && mask_ptr < mask_end) { auto string_start_ptr = string_ptr; @@ -92,7 +92,7 @@ Optional convert_to_int(StringView str, TrimWhitespace trim_whitespace) T sign = 1; size_t i = 0; - const auto characters = string.characters_without_null_termination(); + auto const characters = string.characters_without_null_termination(); if (characters[0] == '-' || characters[0] == '+') { if (string.length() == 1) @@ -132,7 +132,7 @@ Optional convert_to_uint(StringView str, TrimWhitespace trim_whitespace) return {}; T value = 0; - const auto characters = string.characters_without_null_termination(); + auto const characters = string.characters_without_null_termination(); for (size_t i = 0; i < string.length(); i++) { if (characters[i] < '0' || characters[i] > '9') @@ -165,7 +165,7 @@ Optional convert_to_uint_from_hex(StringView str, TrimWhitespace trim_whitesp return {}; T value = 0; - const auto count = string.length(); + auto const count = string.length(); const T upper_bound = NumericLimits::max(); for (size_t i = 0; i < count; i++) { @@ -204,7 +204,7 @@ Optional convert_to_uint_from_octal(StringView str, TrimWhitespace trim_white return {}; T value = 0; - const auto count = string.length(); + auto const count = string.length(); const T upper_bound = NumericLimits::max(); for (size_t i = 0; i < count; i++) { diff --git a/AK/StringUtils.h b/AK/StringUtils.h index 775e28ac6c6..9ba0012041a 100644 --- a/AK/StringUtils.h +++ b/AK/StringUtils.h @@ -37,11 +37,11 @@ struct MaskSpan { size_t start; size_t length; - bool operator==(const MaskSpan& other) const + bool operator==(MaskSpan const& other) const { return start == other.start && length == other.length; } - bool operator!=(const MaskSpan& other) const + bool operator!=(MaskSpan const& other) const { return !(*this == other); } diff --git a/AK/StringView.cpp b/AK/StringView.cpp index 64aea8f2270..fdcb6f4b8ff 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -20,26 +20,26 @@ namespace AK { #ifndef KERNEL -StringView::StringView(const String& string) +StringView::StringView(String const& string) : m_characters(string.characters()) , m_length(string.length()) { } -StringView::StringView(const FlyString& string) +StringView::StringView(FlyString const& string) : m_characters(string.characters()) , m_length(string.length()) { } #endif -StringView::StringView(const ByteBuffer& buffer) - : m_characters((const char*)buffer.data()) +StringView::StringView(ByteBuffer const& buffer) + : m_characters((char const*)buffer.data()) , m_length(buffer.size()) { } -Vector StringView::split_view(const char separator, bool keep_empty) const +Vector StringView::split_view(char const separator, bool keep_empty) const { StringView seperator_view { &separator, 1 }; return split_view(seperator_view, keep_empty); @@ -166,7 +166,7 @@ String StringView::to_titlecase_string() const StringView StringView::substring_view_starting_from_substring(StringView substring) const { - const char* remaining_characters = substring.characters_without_null_termination(); + char const* remaining_characters = substring.characters_without_null_termination(); VERIFY(remaining_characters >= m_characters); VERIFY(remaining_characters <= m_characters + m_length); size_t remaining_length = m_length - (remaining_characters - m_characters); @@ -175,7 +175,7 @@ StringView StringView::substring_view_starting_from_substring(StringView substri StringView StringView::substring_view_starting_after_substring(StringView substring) const { - const char* remaining_characters = substring.characters_without_null_termination() + substring.length(); + char const* remaining_characters = substring.characters_without_null_termination() + substring.length(); VERIFY(remaining_characters >= m_characters); VERIFY(remaining_characters <= m_characters + m_length); size_t remaining_length = m_length - (remaining_characters - m_characters); @@ -209,7 +209,7 @@ template Optional StringView::to_uint() const; template Optional StringView::to_uint() const; #ifndef KERNEL -bool StringView::operator==(const String& string) const +bool StringView::operator==(String const& string) const { return *this == string.view(); } diff --git a/AK/StringView.h b/AK/StringView.h index d37ee4d8c94..05331e05804 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -20,34 +20,34 @@ namespace AK { class StringView { public: ALWAYS_INLINE constexpr StringView() = default; - ALWAYS_INLINE constexpr StringView(const char* characters, size_t length) + ALWAYS_INLINE constexpr StringView(char const* characters, size_t length) : m_characters(characters) , m_length(length) { if (!is_constant_evaluated()) VERIFY(!Checked::addition_would_overflow((uintptr_t)characters, length)); } - ALWAYS_INLINE StringView(const unsigned char* characters, size_t length) - : m_characters((const char*)characters) + ALWAYS_INLINE StringView(unsigned char const* characters, size_t length) + : m_characters((char const*)characters) , m_length(length) { VERIFY(!Checked::addition_would_overflow((uintptr_t)characters, length)); } - ALWAYS_INLINE constexpr StringView(const char* cstring) + ALWAYS_INLINE constexpr StringView(char const* cstring) : m_characters(cstring) , m_length(cstring ? __builtin_strlen(cstring) : 0) { } ALWAYS_INLINE StringView(ReadonlyBytes bytes) - : m_characters(reinterpret_cast(bytes.data())) + : m_characters(reinterpret_cast(bytes.data())) , m_length(bytes.size()) { } - StringView(const ByteBuffer&); + StringView(ByteBuffer const&); #ifndef KERNEL - StringView(const String&); - StringView(const FlyString&); + StringView(String const&); + StringView(FlyString const&); #endif explicit StringView(ByteBuffer&&) = delete; @@ -67,9 +67,9 @@ public: [[nodiscard]] ReadonlyBytes bytes() const { return { m_characters, m_length }; } - constexpr const char& operator[](size_t index) const { return m_characters[index]; } + constexpr char const& operator[](size_t index) const { return m_characters[index]; } - using ConstIterator = SimpleIterator; + using ConstIterator = SimpleIterator; [[nodiscard]] constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } [[nodiscard]] constexpr ConstIterator end() const { return ConstIterator::end(*this); } @@ -192,14 +192,14 @@ public: [[nodiscard]] StringView substring_view_starting_from_substring(StringView substring) const; [[nodiscard]] StringView substring_view_starting_after_substring(StringView substring) const; - constexpr bool operator==(const char* cstring) const + constexpr bool operator==(char const* cstring) const { if (is_null()) return cstring == nullptr; if (!cstring) return false; // NOTE: `m_characters` is not guaranteed to be null-terminated, but `cstring` is. - const char* cp = cstring; + char const* cp = cstring; for (size_t i = 0; i < m_length; ++i) { if (*cp == '\0') return false; @@ -209,13 +209,13 @@ public: return *cp == '\0'; } - constexpr bool operator!=(const char* cstring) const + constexpr bool operator!=(char const* cstring) const { return !(*this == cstring); } #ifndef KERNEL - bool operator==(const String&) const; + bool operator==(String const&) const; #endif [[nodiscard]] constexpr int compare(StringView other) const @@ -293,7 +293,7 @@ public: private: friend class String; - const char* m_characters { nullptr }; + char const* m_characters { nullptr }; size_t m_length { 0 }; }; @@ -321,7 +321,7 @@ struct CaseInsensitiveStringViewTraits : public Traits { # define AK_STRING_VIEW_LITERAL_CONSTEVAL consteval #endif -[[nodiscard]] ALWAYS_INLINE AK_STRING_VIEW_LITERAL_CONSTEVAL AK::StringView operator"" sv(const char* cstring, size_t length) +[[nodiscard]] ALWAYS_INLINE AK_STRING_VIEW_LITERAL_CONSTEVAL AK::StringView operator"" sv(char const* cstring, size_t length) { return AK::StringView(cstring, length); } diff --git a/AK/Time.cpp b/AK/Time.cpp index 825002ed30b..bb01b1e9070 100644 --- a/AK/Time.cpp +++ b/AK/Time.cpp @@ -182,7 +182,7 @@ timeval Time::to_timeval() const return { static_cast(m_seconds), static_cast(m_nanoseconds) / 1000 }; } -Time Time::operator+(const Time& other) const +Time Time::operator+(Time const& other) const { VERIFY(m_nanoseconds < 1'000'000'000); VERIFY(other.m_nanoseconds < 1'000'000'000); @@ -222,13 +222,13 @@ Time Time::operator+(const Time& other) const return Time { new_secs.value(), new_nsecs }; } -Time& Time::operator+=(const Time& other) +Time& Time::operator+=(Time const& other) { *this = *this + other; return *this; } -Time Time::operator-(const Time& other) const +Time Time::operator-(Time const& other) const { VERIFY(m_nanoseconds < 1'000'000'000); VERIFY(other.m_nanoseconds < 1'000'000'000); @@ -247,28 +247,28 @@ Time Time::operator-(const Time& other) const return Time { (m_seconds + 0x4000'0000'0000'0000) + 0x4000'0000'0000'0000, m_nanoseconds }; } -Time& Time::operator-=(const Time& other) +Time& Time::operator-=(Time const& other) { *this = *this - other; return *this; } -bool Time::operator<(const Time& other) const +bool Time::operator<(Time const& other) const { return m_seconds < other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds < other.m_nanoseconds); } -bool Time::operator<=(const Time& other) const +bool Time::operator<=(Time const& other) const { return m_seconds < other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds <= other.m_nanoseconds); } -bool Time::operator>(const Time& other) const +bool Time::operator>(Time const& other) const { return m_seconds > other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds > other.m_nanoseconds); } -bool Time::operator>=(const Time& other) const +bool Time::operator>=(Time const& other) const { return m_seconds > other.m_seconds || (m_seconds == other.m_seconds && m_nanoseconds >= other.m_nanoseconds); } diff --git a/AK/Time.h b/AK/Time.h index 869a0c21a4d..d64e1b9ac5a 100644 --- a/AK/Time.h +++ b/AK/Time.h @@ -106,8 +106,8 @@ constexpr i64 seconds_since_epoch_to_year(i64 seconds) class Time { public: Time() = default; - Time(const Time&) = default; - Time& operator=(const Time&) = default; + Time(Time const&) = default; + Time& operator=(Time const&) = default; Time(Time&& other) : m_seconds(exchange(other.m_seconds, 0)) @@ -218,16 +218,16 @@ public: [[nodiscard]] bool is_zero() const { return (m_seconds == 0) && (m_nanoseconds == 0); } [[nodiscard]] bool is_negative() const { return m_seconds < 0; } - bool operator==(const Time& other) const { return this->m_seconds == other.m_seconds && this->m_nanoseconds == other.m_nanoseconds; } - bool operator!=(const Time& other) const { return !(*this == other); } - Time operator+(const Time& other) const; - Time& operator+=(const Time& other); - Time operator-(const Time& other) const; - Time& operator-=(const Time& other); - bool operator<(const Time& other) const; - bool operator<=(const Time& other) const; - bool operator>(const Time& other) const; - bool operator>=(const Time& other) const; + bool operator==(Time const& other) const { return this->m_seconds == other.m_seconds && this->m_nanoseconds == other.m_nanoseconds; } + bool operator!=(Time const& other) const { return !(*this == other); } + Time operator+(Time const& other) const; + Time& operator+=(Time const& other); + Time operator-(Time const& other) const; + Time& operator-=(Time const& other); + bool operator<(Time const& other) const; + bool operator<=(Time const& other) const; + bool operator>(Time const& other) const; + bool operator>=(Time const& other) const; private: constexpr explicit Time(i64 seconds, u32 nanoseconds) @@ -243,7 +243,7 @@ private: }; template -inline void timeval_sub(const TimevalType& a, const TimevalType& b, TimevalType& result) +inline void timeval_sub(TimevalType const& a, TimevalType const& b, TimevalType& result) { result.tv_sec = a.tv_sec - b.tv_sec; result.tv_usec = a.tv_usec - b.tv_usec; @@ -254,7 +254,7 @@ inline void timeval_sub(const TimevalType& a, const TimevalType& b, TimevalType& } template -inline void timeval_add(const TimevalType& a, const TimevalType& b, TimevalType& result) +inline void timeval_add(TimevalType const& a, TimevalType const& b, TimevalType& result) { result.tv_sec = a.tv_sec + b.tv_sec; result.tv_usec = a.tv_usec + b.tv_usec; @@ -265,7 +265,7 @@ inline void timeval_add(const TimevalType& a, const TimevalType& b, TimevalType& } template -inline void timespec_sub(const TimespecType& a, const TimespecType& b, TimespecType& result) +inline void timespec_sub(TimespecType const& a, TimespecType const& b, TimespecType& result) { result.tv_sec = a.tv_sec - b.tv_sec; result.tv_nsec = a.tv_nsec - b.tv_nsec; @@ -276,7 +276,7 @@ inline void timespec_sub(const TimespecType& a, const TimespecType& b, TimespecT } template -inline void timespec_add(const TimespecType& a, const TimespecType& b, TimespecType& result) +inline void timespec_add(TimespecType const& a, TimespecType const& b, TimespecType& result) { result.tv_sec = a.tv_sec + b.tv_sec; result.tv_nsec = a.tv_nsec + b.tv_nsec; @@ -287,7 +287,7 @@ inline void timespec_add(const TimespecType& a, const TimespecType& b, TimespecT } template -inline void timespec_add_timeval(const TimespecType& a, const TimevalType& b, TimespecType& result) +inline void timespec_add_timeval(TimespecType const& a, TimevalType const& b, TimespecType& result) { result.tv_sec = a.tv_sec + b.tv_sec; result.tv_nsec = a.tv_nsec + b.tv_usec * 1000; @@ -298,14 +298,14 @@ inline void timespec_add_timeval(const TimespecType& a, const TimevalType& b, Ti } template -inline void timeval_to_timespec(const TimevalType& tv, TimespecType& ts) +inline void timeval_to_timespec(TimevalType const& tv, TimespecType& ts) { ts.tv_sec = tv.tv_sec; ts.tv_nsec = tv.tv_usec * 1000; } template -inline void timespec_to_timeval(const TimespecType& ts, TimevalType& tv) +inline void timespec_to_timeval(TimespecType const& ts, TimevalType& tv) { tv.tv_sec = ts.tv_sec; tv.tv_usec = ts.tv_nsec / 1000; diff --git a/AK/Trie.h b/AK/Trie.h index 0160ed18837..50c2d556b03 100644 --- a/AK/Trie.h +++ b/AK/Trie.h @@ -40,7 +40,7 @@ public: } template - BaseType& traverse_until_last_accessible_node(It& it, const It& end) + BaseType& traverse_until_last_accessible_node(It& it, It const& end) { Trie* node = this; for (; it < end; ++it) { @@ -53,17 +53,17 @@ public: } template - const BaseType& traverse_until_last_accessible_node(It& it, const It& end) const { return const_cast(this)->traverse_until_last_accessible_node(it, end); } + BaseType const& traverse_until_last_accessible_node(It& it, It const& end) const { return const_cast(this)->traverse_until_last_accessible_node(it, end); } template - BaseType& traverse_until_last_accessible_node(const It& begin, const It& end) + BaseType& traverse_until_last_accessible_node(It const& begin, It const& end) { auto it = begin; return const_cast(this)->traverse_until_last_accessible_node(it, end); } template - const BaseType& traverse_until_last_accessible_node(const It& begin, const It& end) const + BaseType const& traverse_until_last_accessible_node(It const& begin, It const& end) const { auto it = begin; return const_cast(this)->traverse_until_last_accessible_node(it, end); @@ -71,10 +71,10 @@ public: Optional metadata() const requires(!IsNullPointer) { return m_metadata; } void set_metadata(MetadataType metadata) requires(!IsNullPointer) { m_metadata = move(metadata); } - const MetadataType& metadata_value() const requires(!IsNullPointer) { return m_metadata.value(); } + MetadataType const& metadata_value() const requires(!IsNullPointer) { return m_metadata.value(); } MetadataType& metadata_value() requires(!IsNullPointer) { return m_metadata.value(); } - const ValueType& value() const { return m_value; } + ValueType const& value() const { return m_value; } ValueType& value() { return m_value; } ErrorOr ensure_child(ValueType value, Optional metadata = {}) @@ -99,11 +99,10 @@ public: template ErrorOr insert( - It& it, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer) + It& it, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer) { Trie* last_root_node = &traverse_until_last_accessible_node(it, end); - auto invoke_provide_missing_metadata = [&](Ts && ... args)->ErrorOr> - { + auto invoke_provide_missing_metadata = [&](Ts&&... args) -> ErrorOr> { if constexpr (SameAs(args)...))>) return Optional(provide_missing_metadata(forward(args)...)); else @@ -120,7 +119,7 @@ public: } template - ErrorOr insert(It& it, const It& end) requires(IsNullPointer) + ErrorOr insert(It& it, It const& end) requires(IsNullPointer) { Trie* last_root_node = &traverse_until_last_accessible_node(it, end); for (; it != end; ++it) { @@ -134,14 +133,14 @@ public: template ErrorOr insert( - const It& begin, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer) + It const& begin, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer) { auto it = begin; return insert(it, end, move(metadata), move(provide_missing_metadata)); } template - ErrorOr insert(const It& begin, const It& end) requires(IsNullPointer) + ErrorOr insert(It const& begin, It const& end) requires(IsNullPointer) { auto it = begin; return insert(it, end); diff --git a/AK/Tuple.h b/AK/Tuple.h index 9bdec66f158..ff628facff3 100644 --- a/AK/Tuple.h +++ b/AK/Tuple.h @@ -122,7 +122,7 @@ struct Tuple : Detail::Tuple { { } - Tuple(const Tuple& other) + Tuple(Tuple const& other) : Tuple(other, Indices()) { } @@ -133,7 +133,7 @@ struct Tuple : Detail::Tuple { return *this; } - Tuple& operator=(const Tuple& other) + Tuple& operator=(Tuple const& other) { set(other, Indices()); return *this; @@ -185,7 +185,7 @@ private: } template - Tuple(const Tuple& other, IndexSequence) + Tuple(Tuple const& other, IndexSequence) : Detail::Tuple(other.get()...) { } @@ -197,7 +197,7 @@ private: } template - void set(const Tuple& other, IndexSequence) + void set(Tuple const& other, IndexSequence) { ((get() = other.get()), ...); } diff --git a/AK/Types.h b/AK/Types.h index 8610a69e0da..bf223afca9d 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -61,7 +61,7 @@ constexpr u64 TiB = KiB * KiB * KiB * KiB; constexpr u64 PiB = KiB * KiB * KiB * KiB * KiB; constexpr u64 EiB = KiB * KiB * KiB * KiB * KiB * KiB; -namespace std { //NOLINT(cert-dcl58-cpp) nullptr_t must be in ::std:: for some analysis tools +namespace std { // NOLINT(cert-dcl58-cpp) nullptr_t must be in ::std:: for some analysis tools using nullptr_t = decltype(nullptr); } diff --git a/AK/UBSanitizer.h b/AK/UBSanitizer.h index 70724e42d9f..2dedbacfb4a 100644 --- a/AK/UBSanitizer.h +++ b/AK/UBSanitizer.h @@ -21,7 +21,7 @@ class SourceLocation { AK_MAKE_NONCOPYABLE(SourceLocation); public: - const char* filename() const { return m_filename; } + char const* filename() const { return m_filename; } u32 line() const { return m_line; } u32 column() const { return m_column; } @@ -52,7 +52,7 @@ public: } private: - const char* m_filename { nullptr }; + char const* m_filename { nullptr }; u32 m_line { 0 }; u32 m_column { 0 }; }; @@ -65,7 +65,7 @@ enum TypeKind : u16 { class TypeDescriptor { public: - const char* name() const { return m_name; } + char const* name() const { return m_name; } TypeKind kind() const { return (TypeKind)m_kind; } bool is_integer() const { return kind() == TypeKind::Integer; } bool is_signed() const { return m_info & 1; } @@ -80,7 +80,7 @@ private: struct InvalidValueData { SourceLocation location; - const TypeDescriptor& type; + TypeDescriptor const& type; }; struct NonnullArgData { @@ -95,29 +95,29 @@ struct NonnullReturnData { struct OverflowData { SourceLocation location; - const TypeDescriptor& type; + TypeDescriptor const& type; }; struct VLABoundData { SourceLocation location; - const TypeDescriptor& type; + TypeDescriptor const& type; }; struct ShiftOutOfBoundsData { SourceLocation location; - const TypeDescriptor& lhs_type; - const TypeDescriptor& rhs_type; + TypeDescriptor const& lhs_type; + TypeDescriptor const& rhs_type; }; struct OutOfBoundsData { SourceLocation location; - const TypeDescriptor& array_type; - const TypeDescriptor& index_type; + TypeDescriptor const& array_type; + TypeDescriptor const& index_type; }; struct TypeMismatchData { SourceLocation location; - const TypeDescriptor& type; + TypeDescriptor const& type; u8 log_alignment; u8 type_check_kind; }; @@ -125,7 +125,7 @@ struct TypeMismatchData { struct AlignmentAssumptionData { SourceLocation location; SourceLocation assumption_location; - const TypeDescriptor& type; + TypeDescriptor const& type; }; struct UnreachableData { @@ -134,8 +134,8 @@ struct UnreachableData { struct ImplicitConversionData { SourceLocation location; - const TypeDescriptor& from_type; - const TypeDescriptor& to_type; + TypeDescriptor const& from_type; + TypeDescriptor const& to_type; /* ImplicitConversionCheckKind */ unsigned char kind; }; diff --git a/AK/UFixedBigInt.h b/AK/UFixedBigInt.h index 0d2f4cc257b..9880dc75d79 100644 --- a/AK/UFixedBigInt.h +++ b/AK/UFixedBigInt.h @@ -83,7 +83,7 @@ public: } Span bytes() const { - return Span(reinterpret_cast(this), sizeof(R)); + return Span(reinterpret_cast(this), sizeof(R)); } template @@ -417,7 +417,7 @@ public: return { lower, higher }; } - constexpr R operator+(const bool& other) const + constexpr R operator+(bool const& other) const { bool carry = false; // unused return addc((u8)other, carry); @@ -429,7 +429,7 @@ public: return addc(other, carry); } - constexpr R operator-(const bool& other) const + constexpr R operator-(bool const& other) const { bool carry = false; // unused return subc((u8)other, carry); @@ -491,9 +491,9 @@ public: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdiv-by-zero" if (!divisor) { - volatile int x = 1; - volatile int y = 0; - [[maybe_unused]] volatile int z = x / y; + int volatile x = 1; + int volatile y = 0; + [[maybe_unused]] int volatile z = x / y; } #pragma GCC diagnostic pop @@ -796,13 +796,13 @@ private: // reverse operators template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<(const U a, const UFixedBigInt& b) { return b >= a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<(const U a, UFixedBigInt const& b) { return b >= a; } template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>(const U a, const UFixedBigInt& b) { return b <= a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>(const U a, UFixedBigInt const& b) { return b <= a; } template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<=(const U a, const UFixedBigInt& b) { return b > a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<=(const U a, UFixedBigInt const& b) { return b > a; } template -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>=(const U a, const UFixedBigInt& b) { return b < a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>=(const U a, UFixedBigInt const& b) { return b < a; } template struct Formatter> : StandardFormatter { diff --git a/AK/UUID.cpp b/AK/UUID.cpp index c04f10cd888..3c08fc7c526 100644 --- a/AK/UUID.cpp +++ b/AK/UUID.cpp @@ -124,7 +124,7 @@ bool UUID::operator==(const UUID& other) const bool UUID::is_zero() const { - return all_of(m_uuid_buffer, [](const auto octet) { return octet == 0; }); + return all_of(m_uuid_buffer, [](auto const octet) { return octet == 0; }); } } diff --git a/AK/Userspace.h b/AK/Userspace.h index 267862424e0..f741df9b9c8 100644 --- a/AK/Userspace.h +++ b/AK/Userspace.h @@ -25,11 +25,11 @@ public: Userspace() = default; // Disable default implementations that would use surprising integer promotion. - bool operator==(const Userspace&) const = delete; - bool operator<=(const Userspace&) const = delete; - bool operator>=(const Userspace&) const = delete; - bool operator<(const Userspace&) const = delete; - bool operator>(const Userspace&) const = delete; + bool operator==(Userspace const&) const = delete; + bool operator<=(Userspace const&) const = delete; + bool operator>=(Userspace const&) const = delete; + bool operator<(Userspace const&) const = delete; + bool operator>(Userspace const&) const = delete; #ifdef KERNEL Userspace(FlatPtr ptr) @@ -62,7 +62,7 @@ private: }; template -inline Userspace static_ptr_cast(const Userspace& ptr) +inline Userspace static_ptr_cast(Userspace const& ptr) { #ifdef KERNEL auto casted_ptr = static_cast(ptr.unsafe_userspace_ptr()); diff --git a/AK/Utf32View.h b/AK/Utf32View.h index 75c7d2c0d98..249407f8c5f 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -21,11 +21,11 @@ public: Utf32CodePointIterator() = default; ~Utf32CodePointIterator() = default; - bool operator==(const Utf32CodePointIterator& other) const + bool operator==(Utf32CodePointIterator const& other) const { return m_ptr == other.m_ptr && m_length == other.m_length; } - bool operator!=(const Utf32CodePointIterator& other) const + bool operator!=(Utf32CodePointIterator const& other) const { return !(*this == other); } @@ -36,7 +36,7 @@ public: m_length--; return *this; } - ssize_t operator-(const Utf32CodePointIterator& other) const + ssize_t operator-(Utf32CodePointIterator const& other) const { return m_ptr - other.m_ptr; } @@ -50,12 +50,12 @@ public: bool done() const { return !m_length; } private: - Utf32CodePointIterator(const u32* ptr, size_t length) + Utf32CodePointIterator(u32 const* ptr, size_t length) : m_ptr(ptr) , m_length((ssize_t)length) { } - const u32* m_ptr { nullptr }; + u32 const* m_ptr { nullptr }; ssize_t m_length { -1 }; }; @@ -64,7 +64,7 @@ public: using Iterator = Utf32CodePointIterator; Utf32View() = default; - Utf32View(const u32* code_points, size_t length) + Utf32View(u32 const* code_points, size_t length) : m_code_points(code_points) , m_length(length) { @@ -89,12 +89,12 @@ public: u32 operator[](size_t index) const { return at(index); } - const u32* code_points() const { return m_code_points; } + u32 const* code_points() const { return m_code_points; } bool is_empty() const { return m_length == 0; } bool is_null() const { return !m_code_points; } size_t length() const { return m_length; } - size_t iterator_offset(const Utf32CodePointIterator& it) const + size_t iterator_offset(Utf32CodePointIterator const& it) const { VERIFY(it.m_ptr >= m_code_points); VERIFY(it.m_ptr < m_code_points + m_length); @@ -110,16 +110,16 @@ public: } private: - const u32* begin_ptr() const + u32 const* begin_ptr() const { return m_code_points; } - const u32* end_ptr() const + u32 const* end_ptr() const { return m_code_points + m_length; } - const u32* m_code_points { nullptr }; + u32 const* m_code_points { nullptr }; size_t m_length { 0 }; }; diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index 4c559a886dd..7d93d73b78a 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -22,7 +22,7 @@ Utf8CodePointIterator Utf8View::iterator_at_byte_offset(size_t byte_offset) cons return end(); } -size_t Utf8View::byte_offset_of(const Utf8CodePointIterator& it) const +size_t Utf8View::byte_offset_of(Utf8CodePointIterator const& it) const { VERIFY(it.m_ptr >= begin_ptr()); VERIFY(it.m_ptr <= end_ptr()); @@ -129,7 +129,7 @@ size_t Utf8View::calculate_length() const return length; } -bool Utf8View::starts_with(const Utf8View& start) const +bool Utf8View::starts_with(Utf8View const& start) const { if (start.is_empty()) return true; @@ -156,7 +156,7 @@ bool Utf8View::contains(u32 needle) const return false; } -Utf8View Utf8View::trim(const Utf8View& characters, TrimMode mode) const +Utf8View Utf8View::trim(Utf8View const& characters, TrimMode mode) const { size_t substring_start = 0; size_t substring_length = byte_length(); diff --git a/AK/Utf8View.h b/AK/Utf8View.h index f63ac2c178d..19dd62ff1d2 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -29,7 +29,7 @@ public: // NOTE: This returns {} if the peek is at or past EOF. Optional peek(size_t offset = 0) const; - ssize_t operator-(const Utf8CodePointIterator& other) const + ssize_t operator-(Utf8CodePointIterator const& other) const { return m_ptr - other.m_ptr; } @@ -80,9 +80,9 @@ public: Utf8CodePointIterator end() const { return { end_ptr(), 0 }; } Utf8CodePointIterator iterator_at_byte_offset(size_t) const; - const unsigned char* bytes() const { return begin_ptr(); } + unsigned char const* bytes() const { return begin_ptr(); } size_t byte_length() const { return m_string.length(); } - size_t byte_offset_of(const Utf8CodePointIterator&) const; + size_t byte_offset_of(Utf8CodePointIterator const&) const; size_t byte_offset_of(size_t code_point_offset) const; Utf8View substring_view(size_t byte_offset, size_t byte_length) const { return Utf8View { m_string.substring_view(byte_offset, byte_length) }; } @@ -92,12 +92,12 @@ public: bool is_empty() const { return m_string.is_empty(); } bool is_null() const { return m_string.is_null(); } - bool starts_with(const Utf8View&) const; + bool starts_with(Utf8View const&) const; bool contains(u32) const; - Utf8View trim(const Utf8View& characters, TrimMode mode = TrimMode::Both) const; + Utf8View trim(Utf8View const& characters, TrimMode mode = TrimMode::Both) const; - size_t iterator_offset(const Utf8CodePointIterator& it) const + size_t iterator_offset(Utf8CodePointIterator const& it) const { return byte_offset_of(it); } diff --git a/AK/Variant.h b/AK/Variant.h index 8425f79f7ce..c0919ab01ed 100644 --- a/AK/Variant.h +++ b/AK/Variant.h @@ -62,7 +62,7 @@ struct Variant { Variant::move_(old_id, old_data, new_data); } - ALWAYS_INLINE static void copy_(IndexType old_id, const void* old_data, void* new_data) + ALWAYS_INLINE static void copy_(IndexType old_id, void const* old_data, void* new_data) { if (old_id == current_index) new (new_data) F(*bit_cast(old_data)); @@ -75,7 +75,7 @@ template struct Variant { ALWAYS_INLINE static void delete_(IndexType, void*) { } ALWAYS_INLINE static void move_(IndexType, void*, void*) { } - ALWAYS_INLINE static void copy_(IndexType, const void*, void*) { } + ALWAYS_INLINE static void copy_(IndexType, void const*, void*) { } }; template @@ -97,7 +97,7 @@ struct VisitImpl { } template - ALWAYS_INLINE static constexpr decltype(auto) visit(Self& self, IndexType id, const void* data, Visitor&& visitor) requires(CurrentIndex < sizeof...(Ts)) + ALWAYS_INLINE static constexpr decltype(auto) visit(Self& self, IndexType id, void const* data, Visitor&& visitor) requires(CurrentIndex < sizeof...(Ts)) { using T = typename TypeList::template Type; @@ -239,7 +239,7 @@ public: } template - Variant(const Variant& old) requires((can_contain() && ...)) + Variant(Variant const& old) requires((can_contain() && ...)) : Variant(old.template downcast()) { } @@ -254,8 +254,8 @@ public: } #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - Variant(const Variant&) requires(!(IsCopyConstructible && ...)) = delete; - Variant(const Variant&) = default; + Variant(Variant const&) requires(!(IsCopyConstructible && ...)) = delete; + Variant(Variant const&) = default; Variant(Variant&&) requires(!(IsMoveConstructible && ...)) = delete; Variant(Variant&&) = default; @@ -263,14 +263,14 @@ public: ~Variant() requires(!(IsDestructible && ...)) = delete; ~Variant() = default; - Variant& operator=(const Variant&) requires(!(IsCopyConstructible && ...) || !(IsDestructible && ...)) = delete; - Variant& operator=(const Variant&) = default; + Variant& operator=(Variant const&) requires(!(IsCopyConstructible && ...) || !(IsDestructible && ...)) = delete; + Variant& operator=(Variant const&) = default; Variant& operator=(Variant&&) requires(!(IsMoveConstructible && ...) || !(IsDestructible && ...)) = delete; Variant& operator=(Variant&&) = default; #endif - ALWAYS_INLINE Variant(const Variant& old) + ALWAYS_INLINE Variant(Variant const& old) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL requires(!(IsTriviallyCopyConstructible && ...)) #endif @@ -303,7 +303,7 @@ public: Helper::delete_(m_index, m_data); } - ALWAYS_INLINE Variant& operator=(const Variant& other) + ALWAYS_INLINE Variant& operator=(Variant const& other) #ifdef AK_HAS_CONDITIONALLY_TRIVIAL requires(!(IsTriviallyCopyConstructible && ...) || !(IsTriviallyDestructible && ...)) #endif @@ -418,7 +418,7 @@ public: Variant downcast() const& { Variant instance { Variant::invalid_index, Detail::VariantConstructTag {} }; - visit([&](const auto& value) { + visit([&](auto const& value) { if constexpr (Variant::template can_contain>()) instance.set(value, Detail::VariantNoClearTag {}); }); diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index a7e3346abe8..a6efeb81038 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -23,7 +23,7 @@ public: WeakPtr() = default; template - WeakPtr(const WeakPtr& other) requires(IsBaseOf) + WeakPtr(WeakPtr const& other) requires(IsBaseOf) : m_link(other.m_link) { } @@ -42,9 +42,9 @@ public: } template - WeakPtr& operator=(const WeakPtr& other) requires(IsBaseOf) + WeakPtr& operator=(WeakPtr const& other) requires(IsBaseOf) { - if ((const void*)this != (const void*)&other) + if ((void const*)this != (void const*)&other) m_link = other.m_link; return *this; } @@ -99,7 +99,7 @@ public: } template - WeakPtr& operator=(const RefPtr& object) requires(IsBaseOf) + WeakPtr& operator=(RefPtr const& object) requires(IsBaseOf) { if (object) m_link = object->template make_weak_ptr().take_link(); @@ -109,7 +109,7 @@ public: } template - WeakPtr& operator=(const NonnullRefPtr& object) requires(IsBaseOf) + WeakPtr& operator=(NonnullRefPtr const& object) requires(IsBaseOf) { m_link = object->template make_weak_ptr().take_link(); return *this; @@ -141,7 +141,7 @@ public: [[nodiscard]] RefPtr take_link() { return move(m_link); } private: - WeakPtr(const RefPtr& link) + WeakPtr(RefPtr const& link) : m_link(link) { } diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp index d6635f9ee22..cba00d36078 100644 --- a/AK/kmalloc.cpp +++ b/AK/kmalloc.cpp @@ -22,7 +22,7 @@ void* operator new(size_t size) return ptr; } -void* operator new(size_t size, const std::nothrow_t&) noexcept +void* operator new(size_t size, std::nothrow_t const&) noexcept { return malloc(size); } @@ -44,7 +44,7 @@ void* operator new[](size_t size) return ptr; } -void* operator new[](size_t size, const std::nothrow_t&) noexcept +void* operator new[](size_t size, std::nothrow_t const&) noexcept { return malloc(size); } diff --git a/AK/kstdio.h b/AK/kstdio.h index 79b81aef219..2ef6b341aa0 100644 --- a/AK/kstdio.h +++ b/AK/kstdio.h @@ -13,20 +13,20 @@ # include # include extern "C" { -void dbgputstr(const char*, size_t); -int sprintf(char* buf, const char* fmt, ...) __attribute__((format(printf, 2, 3))); -int snprintf(char* buffer, size_t, const char* fmt, ...) __attribute__((format(printf, 3, 4))); +void dbgputstr(char const*, size_t); +int sprintf(char* buf, char const* fmt, ...) __attribute__((format(printf, 2, 3))); +int snprintf(char* buffer, size_t, char const* fmt, ...) __attribute__((format(printf, 3, 4))); } # endif #else # include -inline void dbgputstr(const char* characters, size_t length) +inline void dbgputstr(char const* characters, size_t length) { fwrite(characters, 1, length, stderr); } #endif template -inline void dbgputstr(const char (&array)[N]) +inline void dbgputstr(char const (&array)[N]) { return ::dbgputstr(array, N); } diff --git a/Kernel/API/InodeWatcherEvent.h b/Kernel/API/InodeWatcherEvent.h index 9a2ce68152b..0c2cf8f9b4f 100644 --- a/Kernel/API/InodeWatcherEvent.h +++ b/Kernel/API/InodeWatcherEvent.h @@ -29,7 +29,7 @@ struct [[gnu::packed]] InodeWatcherEvent { Type type { Type::Invalid }; size_t name_length { 0 }; // This is a VLA which is written during the read() from the descriptor. - const char name[]; + char const name[]; }; AK_ENUM_BITWISE_OPERATORS(InodeWatcherEvent::Type); diff --git a/Kernel/API/KeyCode.h b/Kernel/API/KeyCode.h index a212bdd65ff..ba04a9843af 100644 --- a/Kernel/API/KeyCode.h +++ b/Kernel/API/KeyCode.h @@ -125,7 +125,7 @@ enum KeyCode : u8 { Key_Shift = Key_LeftShift, }; -const int key_code_count = Key_Menu; +int const key_code_count = Key_Menu; enum KeyModifier { Mod_None = 0x00, @@ -155,7 +155,7 @@ struct KeyEvent { bool is_press() const { return flags & Is_Press; } }; -inline const char* key_code_to_string(KeyCode key) +inline char const* key_code_to_string(KeyCode key) { switch (key) { #define __ENUMERATE_KEY_CODE(name, ui_name) \ diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 921eb4ee8ac..de41ae6f732 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -218,7 +218,7 @@ constexpr StringView to_string(Function function) #ifdef __serenity__ struct StringArgument { - const char* characters; + char const* characters; size_t length { 0 }; }; @@ -262,7 +262,7 @@ struct SC_poll_params { struct pollfd* fds; unsigned nfds; const struct timespec* timeout; - const u32* sigmask; + u32 const* sigmask; }; struct SC_clock_nanosleep_params { @@ -288,7 +288,7 @@ struct SC_getsockopt_params { }; struct SC_setsockopt_params { - const void* value; + void const* value; int sockfd; int level; int option; @@ -319,7 +319,7 @@ struct SC_futex_params { int futex_op; u32 val; union { - const timespec* timeout; + timespec const* timeout; uintptr_t val2; }; u32* userspace_address2; @@ -327,11 +327,11 @@ struct SC_futex_params { }; struct SC_setkeymap_params { - const u32* map; - const u32* shift_map; - const u32* alt_map; - const u32* altgr_map; - const u32* shift_altgr_map; + u32 const* map; + u32 const* shift_map; + u32 const* alt_map; + u32 const* altgr_map; + u32 const* shift_altgr_map; StringArgument map_name; }; diff --git a/Kernel/API/VirGL.h b/Kernel/API/VirGL.h index de6e1c6a432..2d7a848459d 100644 --- a/Kernel/API/VirGL.h +++ b/Kernel/API/VirGL.h @@ -23,7 +23,7 @@ struct VirGL3DResourceSpec { }; struct VirGLCommandBuffer { - const u32* data; + u32 const* data; u32 num_elems; }; diff --git a/Kernel/AddressSanitizer.cpp b/Kernel/AddressSanitizer.cpp index b23f134f95d..f1bc6f0d90e 100644 --- a/Kernel/AddressSanitizer.cpp +++ b/Kernel/AddressSanitizer.cpp @@ -92,8 +92,8 @@ void __asan_handle_no_return(void) { } -void __asan_before_dynamic_init(const char*); -void __asan_before_dynamic_init(const char* /* module_name */) +void __asan_before_dynamic_init(char const*); +void __asan_before_dynamic_init(char const* /* module_name */) { } diff --git a/Kernel/Arch/Processor.h b/Kernel/Arch/Processor.h index 83a322bc47f..2b4794e8513 100644 --- a/Kernel/Arch/Processor.h +++ b/Kernel/Arch/Processor.h @@ -44,7 +44,7 @@ struct ProcessorMessage { } flush_tlb; }; - volatile bool async; + bool volatile async; ProcessorMessageEntry* per_proc_entries; diff --git a/Kernel/Arch/aarch64/Prekernel.h b/Kernel/Arch/aarch64/Prekernel.h index 4bb284f7cd7..1012ad4e3b9 100644 --- a/Kernel/Arch/aarch64/Prekernel.h +++ b/Kernel/Arch/aarch64/Prekernel.h @@ -11,7 +11,7 @@ namespace Prekernel { void drop_to_exception_level_1(); void init_prekernel_page_tables(); -[[noreturn]] void panic(const char* msg); +[[noreturn]] void panic(char const* msg); [[noreturn]] void halt(); diff --git a/Kernel/Arch/aarch64/PrekernelCommon.cpp b/Kernel/Arch/aarch64/PrekernelCommon.cpp index 5035ae5ab87..5f7310daa37 100644 --- a/Kernel/Arch/aarch64/PrekernelCommon.cpp +++ b/Kernel/Arch/aarch64/PrekernelCommon.cpp @@ -11,7 +11,7 @@ namespace Prekernel { -[[noreturn]] void panic(const char* msg) +[[noreturn]] void panic(char const* msg) { auto& uart = Prekernel::UART::the(); diff --git a/Kernel/Arch/aarch64/PrekernelMMU.cpp b/Kernel/Arch/aarch64/PrekernelMMU.cpp index 38c953b600e..31ec5732994 100644 --- a/Kernel/Arch/aarch64/PrekernelMMU.cpp +++ b/Kernel/Arch/aarch64/PrekernelMMU.cpp @@ -91,8 +91,8 @@ private: } } - const u64* m_start; - const u64* m_end; + u64 const* m_start; + u64 const* m_end; u64* m_current; }; } @@ -181,7 +181,7 @@ static void activate_mmu() // Enable MMU in the system control register Aarch64::SCTLR_EL1 sctlr_el1 = Aarch64::SCTLR_EL1::read(); - sctlr_el1.M = 1; //Enable MMU + sctlr_el1.M = 1; // Enable MMU Aarch64::SCTLR_EL1::write(sctlr_el1); Aarch64::Asm::flush(); diff --git a/Kernel/Arch/aarch64/Processor.h b/Kernel/Arch/aarch64/Processor.h index f7a5a1e50c5..c26963ef536 100644 --- a/Kernel/Arch/aarch64/Processor.h +++ b/Kernel/Arch/aarch64/Processor.h @@ -17,8 +17,8 @@ namespace Kernel { class Thread; -//FIXME This needs to go behind some sort of platform abstraction -// it is used between Thread and Processor. +// FIXME This needs to go behind some sort of platform abstraction +// it is used between Thread and Processor. struct [[gnu::aligned(16)]] FPUState { u8 buffer[512]; diff --git a/Kernel/Arch/aarch64/UART.h b/Kernel/Arch/aarch64/UART.h index 79cef0a1664..7b77cda167c 100644 --- a/Kernel/Arch/aarch64/UART.h +++ b/Kernel/Arch/aarch64/UART.h @@ -22,7 +22,7 @@ public: void send(u32 c); u32 receive(); - void print_str(const char* s) + void print_str(char const* s) { while (*s) send(*s++); @@ -42,7 +42,7 @@ public: void print_hex(u64 n) { char buf[17]; - static const char* digits = "0123456789ABCDEF"; + static char const* digits = "0123456789ABCDEF"; int i = 0; do { buf[i++] = digits[n % 16]; diff --git a/Kernel/Arch/aarch64/Utils.cpp b/Kernel/Arch/aarch64/Utils.cpp index 92d2f3a7d88..9c9fe88ae9f 100644 --- a/Kernel/Arch/aarch64/Utils.cpp +++ b/Kernel/Arch/aarch64/Utils.cpp @@ -7,14 +7,14 @@ #include #include -void Prekernel::dbgln(const char* text) +void Prekernel::dbgln(char const* text) { auto& uart = Prekernel::UART::the(); uart.print_str(text); uart.print_str("\r\n"); } -void Prekernel::warnln(const char* text) +void Prekernel::warnln(char const* text) { dbgln(text); } diff --git a/Kernel/Arch/aarch64/Utils.h b/Kernel/Arch/aarch64/Utils.h index 0c25610654b..da5eea7ad72 100644 --- a/Kernel/Arch/aarch64/Utils.h +++ b/Kernel/Arch/aarch64/Utils.h @@ -9,7 +9,7 @@ namespace Prekernel { // FIXME: to be replaced by real implementation from AK/Format.h -void dbgln(const char* text); -void warnln(const char* text); +void dbgln(char const* text); +void warnln(char const* text); } diff --git a/Kernel/Arch/aarch64/dummy.cpp b/Kernel/Arch/aarch64/dummy.cpp index 74264c2fa1c..0d2fb587cdf 100644 --- a/Kernel/Arch/aarch64/dummy.cpp +++ b/Kernel/Arch/aarch64/dummy.cpp @@ -19,9 +19,9 @@ void dummy(); void dummy() { } // Assertions.h -[[noreturn]] void __assertion_failed(const char*, const char*, unsigned, const char*); +[[noreturn]] void __assertion_failed(char const*, char const*, unsigned, char const*); -[[noreturn]] void __assertion_failed(const char*, const char*, unsigned, const char*) +[[noreturn]] void __assertion_failed(char const*, char const*, unsigned, char const*) { for (;;) { } } @@ -58,20 +58,20 @@ ssize_t safe_strnlen(char const*, unsigned long, void*&) { return 0; } bool safe_memcpy(void*, void const*, unsigned long, void*&); bool safe_memcpy(void*, void const*, unsigned long, void*&) { return false; } -Optional safe_atomic_compare_exchange_relaxed(volatile u32*, u32&, u32); -Optional safe_atomic_compare_exchange_relaxed(volatile u32*, u32&, u32) { return {}; } +Optional safe_atomic_compare_exchange_relaxed(u32 volatile*, u32&, u32); +Optional safe_atomic_compare_exchange_relaxed(u32 volatile*, u32&, u32) { return {}; } -Optional safe_atomic_load_relaxed(volatile u32*); -Optional safe_atomic_load_relaxed(volatile u32*) { return {}; } +Optional safe_atomic_load_relaxed(u32 volatile*); +Optional safe_atomic_load_relaxed(u32 volatile*) { return {}; } -Optional safe_atomic_fetch_add_relaxed(volatile u32*, u32); -Optional safe_atomic_fetch_add_relaxed(volatile u32*, u32) { return {}; } +Optional safe_atomic_fetch_add_relaxed(u32 volatile*, u32); +Optional safe_atomic_fetch_add_relaxed(u32 volatile*, u32) { return {}; } -Optional safe_atomic_exchange_relaxed(volatile u32*, u32); -Optional safe_atomic_exchange_relaxed(volatile u32*, u32) { return {}; } +Optional safe_atomic_exchange_relaxed(u32 volatile*, u32); +Optional safe_atomic_exchange_relaxed(u32 volatile*, u32) { return {}; } -bool safe_atomic_store_relaxed(volatile u32*, u32); -bool safe_atomic_store_relaxed(volatile u32*, u32) { return {}; } +bool safe_atomic_store_relaxed(u32 volatile*, u32); +bool safe_atomic_store_relaxed(u32 volatile*, u32) { return {}; } } @@ -79,12 +79,12 @@ extern "C" { FlatPtr kernel_mapping_base; -void kernelputstr(const char*, size_t); -void kernelputstr(const char*, size_t) { } +void kernelputstr(char const*, size_t); +void kernelputstr(char const*, size_t) { } -void kernelcriticalputstr(const char*, size_t); -void kernelcriticalputstr(const char*, size_t) { } +void kernelcriticalputstr(char const*, size_t); +void kernelcriticalputstr(char const*, size_t) { } -void kernelearlyputstr(const char*, size_t); -void kernelearlyputstr(const char*, size_t) { } +void kernelearlyputstr(char const*, size_t); +void kernelearlyputstr(char const*, size_t) { } } diff --git a/Kernel/Arch/aarch64/init.cpp b/Kernel/Arch/aarch64/init.cpp index bce753da49c..a5fc1e16f8f 100644 --- a/Kernel/Arch/aarch64/init.cpp +++ b/Kernel/Arch/aarch64/init.cpp @@ -164,7 +164,7 @@ extern "C" const u32 serenity_boot_logo_size; static void draw_logo() { - Prekernel::BootPPMParser logo_parser(reinterpret_cast(&serenity_boot_logo_start), serenity_boot_logo_size); + Prekernel::BootPPMParser logo_parser(reinterpret_cast(&serenity_boot_logo_start), serenity_boot_logo_size); if (!logo_parser.parse()) { Prekernel::warnln("Invalid boot logo."); return; diff --git a/Kernel/Arch/x86/CPU.h b/Kernel/Arch/x86/CPU.h index 99d579c287f..caa946fd28b 100644 --- a/Kernel/Arch/x86/CPU.h +++ b/Kernel/Arch/x86/CPU.h @@ -33,8 +33,8 @@ inline u32 get_iopl_from_eflags(u32 eflags) return (eflags & iopl_mask) >> 12; } -const DescriptorTablePointer& get_gdtr(); -const DescriptorTablePointer& get_idtr(); +DescriptorTablePointer const& get_gdtr(); +DescriptorTablePointer const& get_idtr(); void handle_crash(RegisterState const&, char const* description, int signal, bool out_of_memory = false); @@ -48,7 +48,7 @@ constexpr FlatPtr page_base_of(FlatPtr address) return address & PAGE_MASK; } -inline FlatPtr page_base_of(const void* address) +inline FlatPtr page_base_of(void const* address) { return page_base_of((FlatPtr)address); } @@ -58,7 +58,7 @@ constexpr FlatPtr offset_in_page(FlatPtr address) return address & (~PAGE_MASK); } -inline FlatPtr offset_in_page(const void* address) +inline FlatPtr offset_in_page(void const* address) { return offset_in_page((FlatPtr)address); } diff --git a/Kernel/Arch/x86/IO.h b/Kernel/Arch/x86/IO.h index 5dd0c8ac223..f38dfc89bd2 100644 --- a/Kernel/Arch/x86/IO.h +++ b/Kernel/Arch/x86/IO.h @@ -133,12 +133,12 @@ public: bool is_null() const { return m_address == 0; } - bool operator==(const IOAddress& other) const { return m_address == other.m_address; } - bool operator!=(const IOAddress& other) const { return m_address != other.m_address; } - bool operator>(const IOAddress& other) const { return m_address > other.m_address; } - bool operator>=(const IOAddress& other) const { return m_address >= other.m_address; } - bool operator<(const IOAddress& other) const { return m_address < other.m_address; } - bool operator<=(const IOAddress& other) const { return m_address <= other.m_address; } + bool operator==(IOAddress const& other) const { return m_address == other.m_address; } + bool operator!=(IOAddress const& other) const { return m_address != other.m_address; } + bool operator>(IOAddress const& other) const { return m_address > other.m_address; } + bool operator>=(IOAddress const& other) const { return m_address >= other.m_address; } + bool operator<(IOAddress const& other) const { return m_address < other.m_address; } + bool operator<=(IOAddress const& other) const { return m_address <= other.m_address; } private: u16 m_address { 0 }; diff --git a/Kernel/Arch/x86/PageDirectory.h b/Kernel/Arch/x86/PageDirectory.h index d0e241e987c..7c8e7e2cf90 100644 --- a/Kernel/Arch/x86/PageDirectory.h +++ b/Kernel/Arch/x86/PageDirectory.h @@ -29,7 +29,7 @@ public: void clear() { m_raw = 0; } u64 raw() const { return m_raw; } - void copy_from(Badge, const PageDirectoryEntry& other) { m_raw = other.m_raw; } + void copy_from(Badge, PageDirectoryEntry const& other) { m_raw = other.m_raw; } enum Flags { Present = 1 << 0, diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h index 39418ae8dd0..60740dc9dd2 100644 --- a/Kernel/Arch/x86/Processor.h +++ b/Kernel/Arch/x86/Processor.h @@ -182,7 +182,7 @@ public: Descriptor& get_gdt_entry(u16 selector); void flush_gdt(); - const DescriptorTablePointer& get_gdtr(); + DescriptorTablePointer const& get_gdtr(); template Callback> static inline IterationDecision for_each(Callback callback) diff --git a/Kernel/Arch/x86/RegisterState.h b/Kernel/Arch/x86/RegisterState.h index bc48812bac9..42af83a5a12 100644 --- a/Kernel/Arch/x86/RegisterState.h +++ b/Kernel/Arch/x86/RegisterState.h @@ -128,7 +128,7 @@ static_assert(AssertSize()); static_assert(AssertSize()); #endif -inline void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_regs, const RegisterState& kernel_regs) +inline void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_regs, RegisterState const& kernel_regs) { #if ARCH(I386) ptrace_regs.eax = kernel_regs.eax; @@ -169,7 +169,7 @@ inline void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_ ptrace_regs.gs = 0; } -inline void copy_ptrace_registers_into_kernel_registers(RegisterState& kernel_regs, const PtraceRegisters& ptrace_regs) +inline void copy_ptrace_registers_into_kernel_registers(RegisterState& kernel_regs, PtraceRegisters const& ptrace_regs) { #if ARCH(I386) kernel_regs.eax = ptrace_regs.eax; @@ -224,7 +224,7 @@ inline void read_debug_registers_into(DebugRegisterState& state) state.dr7 = read_dr7(); } -inline void write_debug_registers_from(const DebugRegisterState& state) +inline void write_debug_registers_from(DebugRegisterState const& state) { write_dr0(state.dr0); write_dr1(state.dr1); diff --git a/Kernel/Arch/x86/SafeMem.h b/Kernel/Arch/x86/SafeMem.h index df90e847b3d..df5be2d7706 100644 --- a/Kernel/Arch/x86/SafeMem.h +++ b/Kernel/Arch/x86/SafeMem.h @@ -14,16 +14,16 @@ namespace Kernel { struct RegisterState; -[[nodiscard]] bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, void*& fault_at) __attribute__((used)); -[[nodiscard]] ssize_t safe_strnlen(const char* str, size_t max_n, void*& fault_at) __attribute__((used)); +[[nodiscard]] bool safe_memcpy(void* dest_ptr, void const* src_ptr, size_t n, void*& fault_at) __attribute__((used)); +[[nodiscard]] ssize_t safe_strnlen(char const* str, size_t max_n, void*& fault_at) __attribute__((used)); [[nodiscard]] bool safe_memset(void* dest_ptr, int c, size_t n, void*& fault_at) __attribute__((used)); -[[nodiscard]] Optional safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val) __attribute__((used)); -[[nodiscard]] Optional safe_atomic_exchange_relaxed(volatile u32* var, u32 val) __attribute__((used)); -[[nodiscard]] Optional safe_atomic_load_relaxed(volatile u32* var) __attribute__((used)); -[[nodiscard]] bool safe_atomic_store_relaxed(volatile u32* var, u32 val) __attribute__((used)); -[[nodiscard]] Optional safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_fetch_add_relaxed(u32 volatile* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_exchange_relaxed(u32 volatile* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_load_relaxed(u32 volatile* var) __attribute__((used)); +[[nodiscard]] bool safe_atomic_store_relaxed(u32 volatile* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val) __attribute__((used)); -[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_and_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_and_relaxed(u32 volatile* var, u32 val) { auto expected_value = safe_atomic_load_relaxed(var); if (!expected_value.has_value()) @@ -41,7 +41,7 @@ struct RegisterState; } } -[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_and_not_relaxed(u32 volatile* var, u32 val) { auto expected_value = safe_atomic_load_relaxed(var); if (!expected_value.has_value()) @@ -59,7 +59,7 @@ struct RegisterState; } } -[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_or_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_or_relaxed(u32 volatile* var, u32 val) { auto expected_value = safe_atomic_load_relaxed(var); if (!expected_value.has_value()) @@ -77,7 +77,7 @@ struct RegisterState; } } -[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_xor_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_xor_relaxed(u32 volatile* var, u32 val) { auto expected_value = safe_atomic_load_relaxed(var); if (!expected_value.has_value()) diff --git a/Kernel/Arch/x86/TSS.h b/Kernel/Arch/x86/TSS.h index ef735ad1f34..03e2a943b92 100644 --- a/Kernel/Arch/x86/TSS.h +++ b/Kernel/Arch/x86/TSS.h @@ -42,7 +42,7 @@ struct [[gnu::packed]] TSS64 { u32 rsp1h; u32 rsp2l; u32 rsp2h; - u64 __2; //probably CR3 and EIP? + u64 __2; // probably CR3 and EIP? u32 ist1l; u32 ist1h; u32 ist2l; diff --git a/Kernel/Arch/x86/TrapFrame.h b/Kernel/Arch/x86/TrapFrame.h index 48e99953d2f..33ddaf69170 100644 --- a/Kernel/Arch/x86/TrapFrame.h +++ b/Kernel/Arch/x86/TrapFrame.h @@ -21,9 +21,9 @@ struct TrapFrame { RegisterState* regs; // must be last TrapFrame() = delete; - TrapFrame(const TrapFrame&) = delete; + TrapFrame(TrapFrame const&) = delete; TrapFrame(TrapFrame&&) = delete; - TrapFrame& operator=(const TrapFrame&) = delete; + TrapFrame& operator=(TrapFrame const&) = delete; TrapFrame& operator=(TrapFrame&&) = delete; }; diff --git a/Kernel/Arch/x86/common/CPU.cpp b/Kernel/Arch/x86/common/CPU.cpp index 53afe555d2e..c334ffc584c 100644 --- a/Kernel/Arch/x86/common/CPU.cpp +++ b/Kernel/Arch/x86/common/CPU.cpp @@ -11,7 +11,7 @@ using namespace Kernel; -void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func) +void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func) { asm volatile("cli"); critical_dmesgln("ASSERTION FAILED: {}", msg); diff --git a/Kernel/Arch/x86/common/Interrupts.cpp b/Kernel/Arch/x86/common/Interrupts.cpp index 7a0cf0e4045..e87601130d6 100644 --- a/Kernel/Arch/x86/common/Interrupts.cpp +++ b/Kernel/Arch/x86/common/Interrupts.cpp @@ -174,7 +174,7 @@ static EntropySource s_entropy_source_interrupts { EntropySource::Static::Interr // clang-format on -static void dump(const RegisterState& regs) +static void dump(RegisterState const& regs) { #if ARCH(I386) u16 ss; @@ -522,7 +522,7 @@ void handle_interrupt(TrapFrame* trap) handler->eoi(); } -const DescriptorTablePointer& get_idtr() +DescriptorTablePointer const& get_idtr() { return s_idtr; } diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp index a0e3908eb9c..1cf3a1e6bee 100644 --- a/Kernel/Arch/x86/common/Processor.cpp +++ b/Kernel/Arch/x86/common/Processor.cpp @@ -38,7 +38,7 @@ READONLY_AFTER_INIT FPUState Processor::s_clean_fpu_state; READONLY_AFTER_INIT static ProcessorContainer s_processors {}; READONLY_AFTER_INIT Atomic Processor::g_total_processors; -READONLY_AFTER_INIT static volatile bool s_smp_enabled; +READONLY_AFTER_INIT static bool volatile s_smp_enabled; static Atomic s_message_pool; Atomic Processor::s_idle_cpu_mask { 0 }; @@ -775,7 +775,7 @@ void Processor::flush_gdt() : "memory"); } -const DescriptorTablePointer& Processor::get_gdtr() +DescriptorTablePointer const& Processor::get_gdtr() { return m_gdtr; } diff --git a/Kernel/Arch/x86/common/SafeMem.cpp b/Kernel/Arch/x86/common/SafeMem.cpp index 6a93fef67d4..b7acc471e62 100644 --- a/Kernel/Arch/x86/common/SafeMem.cpp +++ b/Kernel/Arch/x86/common/SafeMem.cpp @@ -53,7 +53,7 @@ ALWAYS_INLINE bool validate_canonical_address(size_t address) } CODE_SECTION(".text.safemem") -NEVER_INLINE bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, void*& fault_at) +NEVER_INLINE bool safe_memcpy(void* dest_ptr, void const* src_ptr, size_t n, void*& fault_at) { fault_at = nullptr; size_t dest = (size_t)dest_ptr; @@ -115,7 +115,7 @@ NEVER_INLINE bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, voi } CODE_SECTION(".text.safemem") -NEVER_INLINE ssize_t safe_strnlen(const char* str, size_t max_n, void*& fault_at) +NEVER_INLINE ssize_t safe_strnlen(char const* str, size_t max_n, void*& fault_at) { if (!validate_canonical_address((size_t)str)) { fault_at = const_cast(str); @@ -210,7 +210,7 @@ NEVER_INLINE bool safe_memset(void* dest_ptr, int c, size_t n, void*& fault_at) } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE Optional safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val) +NEVER_INLINE Optional safe_atomic_fetch_add_relaxed(u32 volatile* var, u32 val) { u32 result; bool error; @@ -230,7 +230,7 @@ NEVER_INLINE Optional safe_atomic_fetch_add_relaxed(volatile u32* var, u32 } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE Optional safe_atomic_exchange_relaxed(volatile u32* var, u32 val) +NEVER_INLINE Optional safe_atomic_exchange_relaxed(u32 volatile* var, u32 val) { u32 result; bool error; @@ -250,7 +250,7 @@ NEVER_INLINE Optional safe_atomic_exchange_relaxed(volatile u32* var, u32 v } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE Optional safe_atomic_load_relaxed(volatile u32* var) +NEVER_INLINE Optional safe_atomic_load_relaxed(u32 volatile* var) { u32 result; bool error; @@ -270,7 +270,7 @@ NEVER_INLINE Optional safe_atomic_load_relaxed(volatile u32* var) } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE bool safe_atomic_store_relaxed(volatile u32* var, u32 val) +NEVER_INLINE bool safe_atomic_store_relaxed(u32 volatile* var, u32 val) { bool error; asm volatile( @@ -287,7 +287,7 @@ NEVER_INLINE bool safe_atomic_store_relaxed(volatile u32* var, u32 val) } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE Optional safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) +NEVER_INLINE Optional safe_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val) { // NOTE: accessing expected is NOT protected as it should always point // to a valid location in kernel memory! diff --git a/Kernel/Assertions.h b/Kernel/Assertions.h index c292984c960..9c74d12c4ec 100644 --- a/Kernel/Assertions.h +++ b/Kernel/Assertions.h @@ -11,7 +11,7 @@ #define __STRINGIFY_HELPER(x) #x #define __STRINGIFY(x) __STRINGIFY_HELPER(x) -[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func); +[[noreturn]] void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func); #define VERIFY(expr) \ do { \ if (!static_cast(expr)) [[unlikely]] \ diff --git a/Kernel/BootInfo.h b/Kernel/BootInfo.h index 48330cce7d9..d19faec40f7 100644 --- a/Kernel/BootInfo.h +++ b/Kernel/BootInfo.h @@ -28,7 +28,7 @@ extern "C" PhysicalAddress boot_pdpt; extern "C" PhysicalAddress boot_pd0; extern "C" PhysicalAddress boot_pd_kernel; extern "C" Kernel::PageTableEntry* boot_pd_kernel_pt1023; -extern "C" const char* kernel_cmdline; +extern "C" char const* kernel_cmdline; extern "C" u32 multiboot_flags; extern "C" multiboot_memory_map_t* multiboot_memory_map; extern "C" size_t multiboot_memory_map_count; diff --git a/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp b/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp index febee0a0682..4cfb1663819 100644 --- a/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp +++ b/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp @@ -26,7 +26,7 @@ u8 MemoryBackedHostBridge::read8_field(BusNumber bus, DeviceNumber device, Funct { VERIFY(Access::the().access_lock().is_locked()); VERIFY(field <= 0xfff); - return *((volatile u8*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff))); + return *((u8 volatile*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff))); } u16 MemoryBackedHostBridge::read16_field(BusNumber bus, DeviceNumber device, FunctionNumber function, u32 field) { @@ -48,7 +48,7 @@ void MemoryBackedHostBridge::write8_field(BusNumber bus, DeviceNumber device, Fu { VERIFY(Access::the().access_lock().is_locked()); VERIFY(field <= 0xfff); - *((volatile u8*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff))) = value; + *((u8 volatile*)(get_device_configuration_memory_mapped_space(bus, device, function).get() + (field & 0xfff))) = value; } void MemoryBackedHostBridge::write16_field(BusNumber bus, DeviceNumber device, FunctionNumber function, u32 field, u16 value) { diff --git a/Kernel/Bus/PCI/Definitions.h b/Kernel/Bus/PCI/Definitions.h index c4a9d6e79be..16a11ed8e11 100644 --- a/Kernel/Bus/PCI/Definitions.h +++ b/Kernel/Bus/PCI/Definitions.h @@ -115,11 +115,11 @@ struct HardwareID { bool is_null() const { return !vendor_id && !device_id; } - bool operator==(const HardwareID& other) const + bool operator==(HardwareID const& other) const { return vendor_id == other.vendor_id && device_id == other.device_id; } - bool operator!=(const HardwareID& other) const + bool operator!=(HardwareID const& other) const { return vendor_id != other.vendor_id || device_id != other.device_id; } @@ -162,24 +162,24 @@ public: { } - Address(const Address& address) = default; + Address(Address const& address) = default; bool is_null() const { return !m_bus && !m_device && !m_function; } operator bool() const { return !is_null(); } // Disable default implementations that would use surprising integer promotion. - bool operator<=(const Address&) const = delete; - bool operator>=(const Address&) const = delete; - bool operator<(const Address&) const = delete; - bool operator>(const Address&) const = delete; + bool operator<=(Address const&) const = delete; + bool operator>=(Address const&) const = delete; + bool operator<(Address const&) const = delete; + bool operator>(Address const&) const = delete; - bool operator==(const Address& other) const + bool operator==(Address const& other) const { if (this == &other) return true; return m_domain == other.m_domain && m_bus == other.m_bus && m_device == other.m_device && m_function == other.m_function; } - bool operator!=(const Address& other) const + bool operator!=(Address const& other) const { return !(*this == other); } @@ -198,7 +198,7 @@ private: class Capability { public: - Capability(const Address& address, u8 id, u8 ptr) + Capability(Address const& address, u8 id, u8 ptr) : m_address(address) , m_id(id) , m_ptr(ptr) @@ -246,7 +246,7 @@ public: , m_capabilities(capabilities) { if constexpr (PCI_DEBUG) { - for (const auto& capability : capabilities) + for (auto const& capability : capabilities) dbgln("{} has capability {}", address, capability.id()); } } diff --git a/Kernel/Bus/PCI/SysFSPCI.cpp b/Kernel/Bus/PCI/SysFSPCI.cpp index 7fe347ef0ba..069ae33804e 100644 --- a/Kernel/Bus/PCI/SysFSPCI.cpp +++ b/Kernel/Bus/PCI/SysFSPCI.cpp @@ -12,14 +12,14 @@ namespace Kernel::PCI { -UNMAP_AFTER_INIT NonnullRefPtr PCIDeviceSysFSDirectory::create(const SysFSDirectory& parent_directory, Address address) +UNMAP_AFTER_INIT NonnullRefPtr PCIDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, Address address) { // FIXME: Handle allocation failure gracefully auto device_name = MUST(KString::formatted("{:04x}:{:02x}:{:02x}.{}", address.domain(), address.bus(), address.device(), address.function())); return adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(move(device_name), parent_directory, address)); } -UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(NonnullOwnPtr device_directory_name, const SysFSDirectory& parent_directory, Address address) +UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(NonnullOwnPtr device_directory_name, SysFSDirectory const& parent_directory, Address address) : SysFSDirectory(parent_directory) , m_address(address) , m_device_directory_name(move(device_directory_name)) @@ -92,12 +92,12 @@ StringView PCIDeviceAttributeSysFSComponent::name() const } } -NonnullRefPtr PCIDeviceAttributeSysFSComponent::create(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width) +NonnullRefPtr PCIDeviceAttributeSysFSComponent::create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width) { return adopt_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(device, offset, field_bytes_width)); } -PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width) +PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width) : SysFSComponent() , m_device(device) , m_offset(offset) diff --git a/Kernel/Bus/PCI/SysFSPCI.h b/Kernel/Bus/PCI/SysFSPCI.h index 4f549c45c3c..80c09e46e5a 100644 --- a/Kernel/Bus/PCI/SysFSPCI.h +++ b/Kernel/Bus/PCI/SysFSPCI.h @@ -23,13 +23,13 @@ private: class PCIDeviceSysFSDirectory final : public SysFSDirectory { public: - static NonnullRefPtr create(const SysFSDirectory&, Address); - const Address& address() const { return m_address; } + static NonnullRefPtr create(SysFSDirectory const&, Address); + Address const& address() const { return m_address; } virtual StringView name() const override { return m_device_directory_name->view(); } private: - PCIDeviceSysFSDirectory(NonnullOwnPtr device_directory_name, const SysFSDirectory&, Address); + PCIDeviceSysFSDirectory(NonnullOwnPtr device_directory_name, SysFSDirectory const&, Address); Address m_address; @@ -38,7 +38,7 @@ private: class PCIDeviceAttributeSysFSComponent : public SysFSComponent { public: - static NonnullRefPtr create(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width); + static NonnullRefPtr create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width); virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override; virtual ~PCIDeviceAttributeSysFSComponent() {}; @@ -47,7 +47,7 @@ public: protected: ErrorOr> try_to_generate_buffer() const; - PCIDeviceAttributeSysFSComponent(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width); + PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width); NonnullRefPtr m_device; PCI::RegisterOffset m_offset; size_t m_field_bytes_width; diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp index f478cd66227..488e3b59c44 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.cpp +++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp @@ -476,7 +476,7 @@ ErrorOr UHCIController::spawn_port_process() return {}; } -bool UHCIController::handle_irq(const RegisterState&) +bool UHCIController::handle_irq(RegisterState const&) { u32 status = read_usbsts(); diff --git a/Kernel/Bus/USB/UHCI/UHCIController.h b/Kernel/Bus/USB/UHCI/UHCIController.h index 0cd243cc92a..66279b510e4 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.h +++ b/Kernel/Bus/USB/UHCI/UHCIController.h @@ -71,7 +71,7 @@ private: void write_portsc1(u16 value) { m_io_base.offset(0x10).out(value); } void write_portsc2(u16 value) { m_io_base.offset(0x12).out(value); } - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; ErrorOr create_structures(); void setup_schedule(); diff --git a/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h b/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h index 3f95302b112..8cae746922d 100644 --- a/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h +++ b/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h @@ -185,11 +185,11 @@ struct alignas(16) TransferDescriptor final { // FIXME: For the love of God, use AK SMART POINTERS PLEASE!! TransferDescriptor* next_td() { return m_next_td; } - const TransferDescriptor* next_td() const { return m_next_td; } + TransferDescriptor const* next_td() const { return m_next_td; } void set_next_td(TransferDescriptor* td) { m_next_td = td; } TransferDescriptor* prev_td() { return m_prev_td; } - const TransferDescriptor* prev_td() const { return m_prev_td; } + TransferDescriptor const* prev_td() const { return m_prev_td; } void set_previous_td(TransferDescriptor* td) { m_prev_td = td; } void insert_next_transfer_descriptor(TransferDescriptor* td) @@ -274,11 +274,11 @@ struct alignas(16) QueueHead { // FIXME: For the love of God, use AK SMART POINTERS PLEASE!! QueueHead* next_qh() { return m_next_qh; } - const QueueHead* next_qh() const { return m_next_qh; } + QueueHead const* next_qh() const { return m_next_qh; } void set_next_qh(QueueHead* qh) { m_next_qh = qh; } QueueHead* prev_qh() { return m_prev_qh; } - const QueueHead* prev_qh() const { return m_prev_qh; } + QueueHead const* prev_qh() const { return m_prev_qh; } void set_previous_qh(QueueHead* qh) { m_prev_qh = qh; diff --git a/Kernel/Bus/USB/USBDevice.h b/Kernel/Bus/USB/USBDevice.h index 37336461a87..2ac68482baa 100644 --- a/Kernel/Bus/USB/USBDevice.h +++ b/Kernel/Bus/USB/USBDevice.h @@ -39,7 +39,7 @@ public: u8 address() const { return m_address; } - const USBDeviceDescriptor& device_descriptor() const { return m_device_descriptor; } + USBDeviceDescriptor const& device_descriptor() const { return m_device_descriptor; } USBController& controller() { return *m_controller; } USBController const& controller() const { return *m_controller; } diff --git a/Kernel/Bus/USB/USBEndpoint.h b/Kernel/Bus/USB/USBEndpoint.h index a8e7eba7623..15329fc391e 100644 --- a/Kernel/Bus/USB/USBEndpoint.h +++ b/Kernel/Bus/USB/USBEndpoint.h @@ -42,7 +42,7 @@ public: static constexpr u8 ENDPOINT_ATTRIBUTES_ISO_MODE_SYNC_TYPE = 0x0c; static constexpr u8 ENDPOINT_ATTRIBUTES_ISO_MODE_USAGE_TYPE = 0x30; - const USBEndpointDescriptor& descriptor() const { return m_descriptor; } + USBEndpointDescriptor const& descriptor() const { return m_descriptor; } bool is_control() const { return (m_descriptor.endpoint_attributes_bitmap & ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_MASK) == ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_CONTROL; } bool is_isochronous() const { return (m_descriptor.endpoint_attributes_bitmap & ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_MASK) == ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_ISOCHRONOUS; } diff --git a/Kernel/Bus/USB/USBTransfer.cpp b/Kernel/Bus/USB/USBTransfer.cpp index c01b3904e7e..62dc28e1164 100644 --- a/Kernel/Bus/USB/USBTransfer.cpp +++ b/Kernel/Bus/USB/USBTransfer.cpp @@ -26,7 +26,7 @@ Transfer::Transfer(Pipe& pipe, u16 len, NonnullOwnPtr data_buffe Transfer::~Transfer() = default; -void Transfer::set_setup_packet(const USBRequestData& request) +void Transfer::set_setup_packet(USBRequestData const& request) { // Kind of a nasty hack... Because the kernel isn't in the business // of handing out physical pointers that we can directly write to, diff --git a/Kernel/Bus/USB/USBTransfer.h b/Kernel/Bus/USB/USBTransfer.h index f4c6570a85b..78487da9fc9 100644 --- a/Kernel/Bus/USB/USBTransfer.h +++ b/Kernel/Bus/USB/USBTransfer.h @@ -24,13 +24,13 @@ public: Transfer() = delete; ~Transfer(); - void set_setup_packet(const USBRequestData& request); + void set_setup_packet(USBRequestData const& request); void set_complete() { m_complete = true; } void set_error_occurred() { m_error_occurred = true; } // `const` here makes sure we don't blow up by writing to a physical address - const USBRequestData& request() const { return m_request; } - const Pipe& pipe() const { return m_pipe; } + USBRequestData const& request() const { return m_request; } + Pipe const& pipe() const { return m_pipe; } Pipe& pipe() { return m_pipe; } VirtualAddress buffer() const { return m_data_buffer->vaddr(); } PhysicalAddress buffer_physical() const { return m_data_buffer->physical_page(0)->paddr(); } diff --git a/Kernel/Bus/VirtIO/ConsolePort.cpp b/Kernel/Bus/VirtIO/ConsolePort.cpp index b13729d8ec3..1908f117af3 100644 --- a/Kernel/Bus/VirtIO/ConsolePort.cpp +++ b/Kernel/Bus/VirtIO/ConsolePort.cpp @@ -92,7 +92,7 @@ void ConsolePort::handle_queue_update(Badge, u16 queue_index) } } -bool ConsolePort::can_read(const OpenFileDescription&, u64) const +bool ConsolePort::can_read(OpenFileDescription const&, u64) const { return m_receive_buffer->used_bytes() > 0; } @@ -122,12 +122,12 @@ ErrorOr ConsolePort::read(OpenFileDescription& desc, u64, UserOrKernelBu return bytes_copied; } -bool ConsolePort::can_write(const OpenFileDescription&, u64) const +bool ConsolePort::can_write(OpenFileDescription const&, u64) const { return m_console.get_queue(m_transmit_queue).has_free_slots() && m_transmit_buffer->has_space(); } -ErrorOr ConsolePort::write(OpenFileDescription& desc, u64, const UserOrKernelBuffer& data, size_t size) +ErrorOr ConsolePort::write(OpenFileDescription& desc, u64, UserOrKernelBuffer const& data, size_t size) { if (!size) return 0; diff --git a/Kernel/Bus/VirtIO/ConsolePort.h b/Kernel/Bus/VirtIO/ConsolePort.h index beed06e1a25..f5c9088ceda 100644 --- a/Kernel/Bus/VirtIO/ConsolePort.h +++ b/Kernel/Bus/VirtIO/ConsolePort.h @@ -40,10 +40,10 @@ private: virtual StringView class_name() const override { return "VirtIOConsolePort"sv; } - virtual bool can_read(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; virtual ErrorOr> open(int options) override; static unsigned next_device_id; diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp index 06f5850bcdb..9296dc42133 100644 --- a/Kernel/Bus/VirtIO/Device.cpp +++ b/Kernel/Bus/VirtIO/Device.cpp @@ -179,37 +179,37 @@ void Device::notify_queue(u16 queue_index) config_write16(*m_notify_cfg, get_queue(queue_index).notify_offset() * m_notify_multiplier, queue_index); } -u8 Device::config_read8(const Configuration& config, u32 offset) +u8 Device::config_read8(Configuration const& config, u32 offset) { return mapping_for_bar(config.bar).read(config.offset + offset); } -u16 Device::config_read16(const Configuration& config, u32 offset) +u16 Device::config_read16(Configuration const& config, u32 offset) { return mapping_for_bar(config.bar).read(config.offset + offset); } -u32 Device::config_read32(const Configuration& config, u32 offset) +u32 Device::config_read32(Configuration const& config, u32 offset) { return mapping_for_bar(config.bar).read(config.offset + offset); } -void Device::config_write8(const Configuration& config, u32 offset, u8 value) +void Device::config_write8(Configuration const& config, u32 offset, u8 value) { mapping_for_bar(config.bar).write(config.offset + offset, value); } -void Device::config_write16(const Configuration& config, u32 offset, u16 value) +void Device::config_write16(Configuration const& config, u32 offset, u16 value) { mapping_for_bar(config.bar).write(config.offset + offset, value); } -void Device::config_write32(const Configuration& config, u32 offset, u32 value) +void Device::config_write32(Configuration const& config, u32 offset, u32 value) { mapping_for_bar(config.bar).write(config.offset + offset, value); } -void Device::config_write64(const Configuration& config, u32 offset, u64 value) +void Device::config_write64(Configuration const& config, u32 offset, u64 value) { mapping_for_bar(config.bar).write(config.offset + offset, value); } @@ -403,7 +403,7 @@ u8 Device::isr_status() return config_read8(*m_isr_cfg, 0); } -bool Device::handle_irq(const RegisterState&) +bool Device::handle_irq(RegisterState const&) { u8 isr_type = isr_status(); if ((isr_type & (QUEUE_INTERRUPT | DEVICE_CONFIG_INTERRUPT)) == 0) { diff --git a/Kernel/Bus/VirtIO/Device.h b/Kernel/Bus/VirtIO/Device.h index e42be0bb97a..3c8fe360bc9 100644 --- a/Kernel/Bus/VirtIO/Device.h +++ b/Kernel/Bus/VirtIO/Device.h @@ -119,7 +119,7 @@ protected: } }; - const Configuration* get_config(ConfigurationType cfg_type, u32 index = 0) const + Configuration const* get_config(ConfigurationType cfg_type, u32 index = 0) const { for (auto const& cfg : m_configs) { if (cfg.cfg_type != cfg_type) @@ -148,13 +148,13 @@ protected: } } - u8 config_read8(const Configuration&, u32); - u16 config_read16(const Configuration&, u32); - u32 config_read32(const Configuration&, u32); - void config_write8(const Configuration&, u32, u8); - void config_write16(const Configuration&, u32, u16); - void config_write32(const Configuration&, u32, u32); - void config_write64(const Configuration&, u32, u64); + u8 config_read8(Configuration const&, u32); + u16 config_read16(Configuration const&, u32); + u32 config_read32(Configuration const&, u32); + void config_write8(Configuration const&, u32, u8); + void config_write16(Configuration const&, u32, u16); + void config_write32(Configuration const&, u32, u32); + void config_write64(Configuration const&, u32, u64); auto mapping_for_bar(u8) -> MappedMMIO&; @@ -171,7 +171,7 @@ protected: return m_queues[queue_index]; } - const Queue& get_queue(u16 queue_index) const + Queue const& get_queue(u16 queue_index) const { VERIFY(queue_index < m_queue_count); return m_queues[queue_index]; @@ -224,13 +224,13 @@ private: void reset_device(); u8 isr_status(); - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; NonnullOwnPtrVector m_queues; Vector m_configs; - const Configuration* m_common_cfg { nullptr }; // Cached due to high usage - const Configuration* m_notify_cfg { nullptr }; // Cached due to high usage - const Configuration* m_isr_cfg { nullptr }; // Cached due to high usage + Configuration const* m_common_cfg { nullptr }; // Cached due to high usage + Configuration const* m_notify_cfg { nullptr }; // Cached due to high usage + Configuration const* m_isr_cfg { nullptr }; // Cached due to high usage IOAddress m_io_base; MappedMMIO m_mmio[6]; diff --git a/Kernel/Bus/VirtIO/Queue.cpp b/Kernel/Bus/VirtIO/Queue.cpp index cb31571e4a1..9f18278906b 100644 --- a/Kernel/Bus/VirtIO/Queue.cpp +++ b/Kernel/Bus/VirtIO/Queue.cpp @@ -60,8 +60,8 @@ void Queue::disable_interrupts() bool Queue::new_data_available() const { - const auto index = AK::atomic_load(&m_device->index, AK::MemoryOrder::memory_order_relaxed); - const auto used_tail = AK::atomic_load(&m_used_tail, AK::MemoryOrder::memory_order_relaxed); + auto const index = AK::atomic_load(&m_device->index, AK::MemoryOrder::memory_order_relaxed); + auto const used_tail = AK::atomic_load(&m_used_tail, AK::MemoryOrder::memory_order_relaxed); return index != used_tail; } @@ -112,7 +112,7 @@ void Queue::reclaim_buffer_chain(u16 chain_start_index, u16 chain_end_index, siz bool Queue::has_free_slots() const { - const auto free_buffers = AK::atomic_load(&m_free_buffers, AK::MemoryOrder::memory_order_relaxed); + auto const free_buffers = AK::atomic_load(&m_free_buffers, AK::MemoryOrder::memory_order_relaxed); return free_buffers > 0; } diff --git a/Kernel/Bus/VirtIO/Queue.h b/Kernel/Bus/VirtIO/Queue.h index fab091b700f..12a5940e15d 100644 --- a/Kernel/Bus/VirtIO/Queue.h +++ b/Kernel/Bus/VirtIO/Queue.h @@ -56,7 +56,7 @@ private: void reclaim_buffer_chain(u16 chain_start_index, u16 chain_end_index, size_t length_of_chain); - PhysicalAddress to_physical(const void* ptr) const + PhysicalAddress to_physical(void const* ptr) const { auto offset = FlatPtr(ptr) - m_queue_region->vaddr().get(); return m_queue_region->physical_page(0)->paddr().offset(offset); diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 8f9d24bdd41..1369b02b8f2 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -16,7 +16,7 @@ static char s_cmd_line[1024]; static constexpr StringView s_embedded_cmd_line = ""; static CommandLine* s_the; -UNMAP_AFTER_INIT void CommandLine::early_initialize(const char* cmd_line) +UNMAP_AFTER_INIT void CommandLine::early_initialize(char const* cmd_line) { if (!cmd_line) return; @@ -32,7 +32,7 @@ bool CommandLine::was_initialized() return s_the != nullptr; } -const CommandLine& kernel_command_line() +CommandLine const& kernel_command_line() { VERIFY(s_the); return *s_the; @@ -64,7 +64,7 @@ UNMAP_AFTER_INIT NonnullOwnPtr CommandLine::build_commandline(StringVie return KString::must_create(builder.string_view()); } -UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector& args) +UNMAP_AFTER_INIT void CommandLine::add_arguments(Vector const& args) { for (auto&& str : args) { if (str == ""sv) { @@ -86,7 +86,7 @@ UNMAP_AFTER_INIT CommandLine::CommandLine(StringView cmdline_from_bootloader) : m_string(build_commandline(cmdline_from_bootloader)) { s_the = this; - const auto& args = m_string->view().split_view(' '); + auto const& args = m_string->view().split_view(' '); m_params.ensure_capacity(args.size()); add_arguments(args); } @@ -251,7 +251,7 @@ UNMAP_AFTER_INIT bool CommandLine::disable_virtio() const UNMAP_AFTER_INIT AHCIResetMode CommandLine::ahci_reset_mode() const { - const auto ahci_reset_mode = lookup("ahci_reset_mode"sv).value_or("controllers"sv); + auto const ahci_reset_mode = lookup("ahci_reset_mode"sv).value_or("controllers"sv); if (ahci_reset_mode == "controllers"sv) { return AHCIResetMode::ControllerOnly; } @@ -268,7 +268,7 @@ StringView CommandLine::system_mode() const PanicMode CommandLine::panic_mode(Validate should_validate) const { - const auto panic_mode = lookup("panic"sv).value_or("halt"sv); + auto const panic_mode = lookup("panic"sv).value_or("halt"sv); if (panic_mode == "halt"sv) { return PanicMode::Halt; } @@ -284,7 +284,7 @@ PanicMode CommandLine::panic_mode(Validate should_validate) const UNMAP_AFTER_INIT auto CommandLine::are_framebuffer_devices_enabled() const -> FrameBufferDevices { - const auto fbdev_value = lookup("fbdev"sv).value_or("on"sv); + auto const fbdev_value = lookup("fbdev"sv).value_or("on"sv); if (fbdev_value == "on"sv) return FrameBufferDevices::Enabled; if (fbdev_value == "bootloader"sv) @@ -311,7 +311,7 @@ NonnullOwnPtrVector CommandLine::userspace_init_args() const UNMAP_AFTER_INIT size_t CommandLine::switch_to_tty() const { - const auto default_tty = lookup("switch_to_tty"sv).value_or("1"sv); + auto const default_tty = lookup("switch_to_tty"sv).value_or("1"sv); auto switch_tty_number = default_tty.to_uint(); if (switch_tty_number.has_value() && switch_tty_number.value() >= 1) { return switch_tty_number.value() - 1; diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 0fe2ef11690..a52e2daa35e 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -44,7 +44,7 @@ enum class AHCIResetMode { class CommandLine { public: - static void early_initialize(const char* cmd_line); + static void early_initialize(char const* cmd_line); static void initialize(); static bool was_initialized(); @@ -96,13 +96,13 @@ public: private: CommandLine(StringView); - void add_arguments(const Vector& args); + void add_arguments(Vector const& args); static NonnullOwnPtr build_commandline(StringView cmdline_from_bootloader); NonnullOwnPtr m_string; HashMap m_params; }; -const CommandLine& kernel_command_line(); +CommandLine const& kernel_command_line(); } diff --git a/Kernel/Devices/AsyncDeviceRequest.h b/Kernel/Devices/AsyncDeviceRequest.h index ed690703a53..4aa7c2ff89d 100644 --- a/Kernel/Devices/AsyncDeviceRequest.h +++ b/Kernel/Devices/AsyncDeviceRequest.h @@ -99,7 +99,7 @@ public: } template - ErrorOr read_from_buffer(const UserOrKernelBuffer& buffer, Args... args) + ErrorOr read_from_buffer(UserOrKernelBuffer const& buffer, Args... args) { if (in_target_context(buffer)) return buffer.read(forward(args)...); @@ -108,7 +108,7 @@ public: } template - ErrorOr read_from_buffer_buffered(const UserOrKernelBuffer& buffer, Args... args) + ErrorOr read_from_buffer_buffered(UserOrKernelBuffer const& buffer, Args... args) { if (in_target_context(buffer)) return buffer.read_buffered(forward(args)...); @@ -125,7 +125,7 @@ private: void sub_request_finished(AsyncDeviceRequest&); void request_finished(); - [[nodiscard]] bool in_target_context(const UserOrKernelBuffer& buffer) const + [[nodiscard]] bool in_target_context(UserOrKernelBuffer const& buffer) const { if (buffer.is_kernel_buffer()) return true; diff --git a/Kernel/Devices/Audio/AC97.h b/Kernel/Devices/Audio/AC97.h index cd38567a3a4..1b144931132 100644 --- a/Kernel/Devices/Audio/AC97.h +++ b/Kernel/Devices/Audio/AC97.h @@ -147,7 +147,7 @@ private: explicit AC97(PCI::DeviceIdentifier const&); // ^IRQHandler - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; AC97Channel channel(StringView name, NativeAudioBusChannel channel) { return AC97Channel(*this, name, m_io_bus_base.offset(channel)); } ErrorOr initialize(); diff --git a/Kernel/Devices/Audio/Channel.cpp b/Kernel/Devices/Audio/Channel.cpp index ac390d7aed5..a0585b47594 100644 --- a/Kernel/Devices/Audio/Channel.cpp +++ b/Kernel/Devices/Audio/Channel.cpp @@ -50,7 +50,7 @@ ErrorOr AudioChannel::ioctl(OpenFileDescription&, unsigned request, Usersp } } -bool AudioChannel::can_read(const OpenFileDescription&, u64) const +bool AudioChannel::can_read(OpenFileDescription const&, u64) const { // FIXME: Implement input from device return false; diff --git a/Kernel/Devices/Audio/Channel.h b/Kernel/Devices/Audio/Channel.h index affd85a8ffa..6ef85eee72f 100644 --- a/Kernel/Devices/Audio/Channel.h +++ b/Kernel/Devices/Audio/Channel.h @@ -24,10 +24,10 @@ public: virtual ~AudioChannel() override = default; // ^CharacterDevice - virtual bool can_read(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr ioctl(OpenFileDescription&, unsigned, Userspace) override; diff --git a/Kernel/Devices/BlockDevice.cpp b/Kernel/Devices/BlockDevice.cpp index a9e8f2d8026..894e4a94627 100644 --- a/Kernel/Devices/BlockDevice.cpp +++ b/Kernel/Devices/BlockDevice.cpp @@ -8,7 +8,7 @@ namespace Kernel { -AsyncBlockDeviceRequest::AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size) +AsyncBlockDeviceRequest::AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, u64 block_index, u32 block_count, UserOrKernelBuffer const& buffer, size_t buffer_size) : AsyncDeviceRequest(block_device) , m_block_device(static_cast(block_device)) , m_request_type(request_type) @@ -52,7 +52,7 @@ bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer) return false; } -bool BlockDevice::write_block(u64 index, const UserOrKernelBuffer& buffer) +bool BlockDevice::write_block(u64 index, UserOrKernelBuffer const& buffer) { auto write_request_or_error = try_make_request(AsyncBlockDeviceRequest::Write, index, 1, buffer, m_block_size); if (write_request_or_error.is_error()) { diff --git a/Kernel/Devices/BlockDevice.h b/Kernel/Devices/BlockDevice.h index 018a19551a5..2af743f03fa 100644 --- a/Kernel/Devices/BlockDevice.h +++ b/Kernel/Devices/BlockDevice.h @@ -23,7 +23,7 @@ public: virtual bool is_seekable() const override { return true; } bool read_block(u64 index, UserOrKernelBuffer&); - bool write_block(u64 index, const UserOrKernelBuffer&); + bool write_block(u64 index, UserOrKernelBuffer const&); virtual void start_request(AsyncBlockDeviceRequest&) = 0; @@ -52,14 +52,14 @@ public: Write }; AsyncBlockDeviceRequest(Device& block_device, RequestType request_type, - u64 block_index, u32 block_count, const UserOrKernelBuffer& buffer, size_t buffer_size); + u64 block_index, u32 block_count, UserOrKernelBuffer const& buffer, size_t buffer_size); RequestType request_type() const { return m_request_type; } u64 block_index() const { return m_block_index; } u32 block_count() const { return m_block_count; } size_t block_size() const { return m_block_device.block_size(); } UserOrKernelBuffer& buffer() { return m_buffer; } - const UserOrKernelBuffer& buffer() const { return m_buffer; } + UserOrKernelBuffer const& buffer() const { return m_buffer; } size_t buffer_size() const { return m_buffer_size; } virtual void start() override; diff --git a/Kernel/Devices/ConsoleDevice.cpp b/Kernel/Devices/ConsoleDevice.cpp index 5de75013aff..2d68440992e 100644 --- a/Kernel/Devices/ConsoleDevice.cpp +++ b/Kernel/Devices/ConsoleDevice.cpp @@ -30,7 +30,7 @@ UNMAP_AFTER_INIT ConsoleDevice::ConsoleDevice() UNMAP_AFTER_INIT ConsoleDevice::~ConsoleDevice() = default; -bool ConsoleDevice::can_read(const Kernel::OpenFileDescription&, u64) const +bool ConsoleDevice::can_read(Kernel::OpenFileDescription const&, u64) const { return false; } @@ -42,7 +42,7 @@ ErrorOr ConsoleDevice::read(OpenFileDescription&, u64, Kernel::UserOrKer return 0; } -ErrorOr ConsoleDevice::write(OpenFileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size) +ErrorOr ConsoleDevice::write(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer const& data, size_t size) { if (!size) return 0; diff --git a/Kernel/Devices/ConsoleDevice.h b/Kernel/Devices/ConsoleDevice.h index 7af4d41bb86..e0df08ca320 100644 --- a/Kernel/Devices/ConsoleDevice.h +++ b/Kernel/Devices/ConsoleDevice.h @@ -21,15 +21,15 @@ public: virtual ~ConsoleDevice() override; // ^CharacterDevice - virtual bool can_read(const Kernel::OpenFileDescription&, u64) const override; - virtual bool can_write(const Kernel::OpenFileDescription&, u64) const override { return true; } + virtual bool can_read(Kernel::OpenFileDescription const&, u64) const override; + virtual bool can_write(Kernel::OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr read(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const Kernel::UserOrKernelBuffer&, size_t) override; + virtual ErrorOr write(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer const&, size_t) override; virtual StringView class_name() const override { return "Console"sv; } void put_char(char); - const CircularQueue& logbuffer() const { return m_logbuffer; } + CircularQueue const& logbuffer() const { return m_logbuffer; } private: ConsoleDevice(); diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index 65454e1d9b1..5c7ee8ab079 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -146,12 +146,12 @@ Device::~Device() VERIFY(m_state == State::BeingRemoved); } -ErrorOr> Device::pseudo_path(const OpenFileDescription&) const +ErrorOr> Device::pseudo_path(OpenFileDescription const&) const { return KString::formatted("device:{},{}", major(), minor()); } -void Device::process_next_queued_request(Badge, const AsyncDeviceRequest& completed_request) +void Device::process_next_queued_request(Badge, AsyncDeviceRequest const& completed_request) { SpinlockLocker lock(m_requests_lock); VERIFY(!m_requests.is_empty()); diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 9546c0927cd..8002d069ecf 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -40,7 +40,7 @@ public: MajorNumber major() const { return m_major; } MinorNumber minor() const { return m_minor; } - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const override; UserID uid() const { return m_uid; } GroupID gid() const { return m_gid; } @@ -48,7 +48,7 @@ public: virtual bool is_device() const override { return true; } virtual void will_be_destroyed() override; virtual void after_inserting(); - void process_next_queued_request(Badge, const AsyncDeviceRequest&); + void process_next_queued_request(Badge, AsyncDeviceRequest const&); template ErrorOr> try_make_request(Args&&... args) diff --git a/Kernel/Devices/DeviceControlDevice.cpp b/Kernel/Devices/DeviceControlDevice.cpp index a78d03f40b3..0e5f4c5cf75 100644 --- a/Kernel/Devices/DeviceControlDevice.cpp +++ b/Kernel/Devices/DeviceControlDevice.cpp @@ -17,7 +17,7 @@ UNMAP_AFTER_INIT NonnullRefPtr DeviceControlDevice::must_cr return device_control_device_or_error.release_value(); } -bool DeviceControlDevice::can_read(const OpenFileDescription&, u64) const +bool DeviceControlDevice::can_read(OpenFileDescription const&, u64) const { return true; } diff --git a/Kernel/Devices/DeviceControlDevice.h b/Kernel/Devices/DeviceControlDevice.h index 8eeb0670f84..5e86a736504 100644 --- a/Kernel/Devices/DeviceControlDevice.h +++ b/Kernel/Devices/DeviceControlDevice.h @@ -23,9 +23,9 @@ private: // ^CharacterDevice virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return Error::from_errno(ENOTSUP); } - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return false; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return Error::from_errno(ENOTSUP); } + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return false; } virtual StringView class_name() const override { return "DeviceControlDevice"sv; } }; diff --git a/Kernel/Devices/FullDevice.cpp b/Kernel/Devices/FullDevice.cpp index 14cbaa817b7..1073c588005 100644 --- a/Kernel/Devices/FullDevice.cpp +++ b/Kernel/Devices/FullDevice.cpp @@ -27,7 +27,7 @@ UNMAP_AFTER_INIT FullDevice::FullDevice() UNMAP_AFTER_INIT FullDevice::~FullDevice() = default; -bool FullDevice::can_read(const OpenFileDescription&, u64) const +bool FullDevice::can_read(OpenFileDescription const&, u64) const { return true; } @@ -38,7 +38,7 @@ ErrorOr FullDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer& return size; } -ErrorOr FullDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size) +ErrorOr FullDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size) { if (size == 0) return 0; diff --git a/Kernel/Devices/FullDevice.h b/Kernel/Devices/FullDevice.h index 2206f789d25..8329d4f9fcc 100644 --- a/Kernel/Devices/FullDevice.h +++ b/Kernel/Devices/FullDevice.h @@ -22,9 +22,9 @@ private: // ^CharacterDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual StringView class_name() const override { return "FullDevice"sv; } }; diff --git a/Kernel/Devices/HID/I8042Controller.h b/Kernel/Devices/HID/I8042Controller.h index 923ab83dd3f..5bbedce7983 100644 --- a/Kernel/Devices/HID/I8042Controller.h +++ b/Kernel/Devices/HID/I8042Controller.h @@ -71,7 +71,7 @@ public: virtual void irq_handle_byte_read(u8 byte) = 0; protected: - explicit I8042Device(const I8042Controller& ps2_controller) + explicit I8042Device(I8042Controller const& ps2_controller) : m_i8042_controller(ps2_controller) { } diff --git a/Kernel/Devices/HID/KeyboardDevice.cpp b/Kernel/Devices/HID/KeyboardDevice.cpp index db88181837e..ee1179cb54a 100644 --- a/Kernel/Devices/HID/KeyboardDevice.cpp +++ b/Kernel/Devices/HID/KeyboardDevice.cpp @@ -278,7 +278,7 @@ UNMAP_AFTER_INIT KeyboardDevice::KeyboardDevice() // like USB keyboards, we need to remove this UNMAP_AFTER_INIT KeyboardDevice::~KeyboardDevice() = default; -bool KeyboardDevice::can_read(const OpenFileDescription&, u64) const +bool KeyboardDevice::can_read(OpenFileDescription const&, u64) const { return !m_queue.is_empty(); } diff --git a/Kernel/Devices/HID/KeyboardDevice.h b/Kernel/Devices/HID/KeyboardDevice.h index 238a60894b0..273fde66619 100644 --- a/Kernel/Devices/HID/KeyboardDevice.h +++ b/Kernel/Devices/HID/KeyboardDevice.h @@ -26,9 +26,9 @@ public: // ^CharacterDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } // ^HIDDevice virtual Type instrument_type() const override { return Type::Keyboard; } diff --git a/Kernel/Devices/HID/MouseDevice.cpp b/Kernel/Devices/HID/MouseDevice.cpp index 1aff69396f7..0adaee5034c 100644 --- a/Kernel/Devices/HID/MouseDevice.cpp +++ b/Kernel/Devices/HID/MouseDevice.cpp @@ -16,7 +16,7 @@ MouseDevice::MouseDevice() MouseDevice::~MouseDevice() = default; -bool MouseDevice::can_read(const OpenFileDescription&, u64) const +bool MouseDevice::can_read(OpenFileDescription const&, u64) const { SpinlockLocker lock(m_queue_lock); return !m_queue.is_empty(); diff --git a/Kernel/Devices/HID/MouseDevice.h b/Kernel/Devices/HID/MouseDevice.h index d80d4fcce37..d7317a6799a 100644 --- a/Kernel/Devices/HID/MouseDevice.h +++ b/Kernel/Devices/HID/MouseDevice.h @@ -24,9 +24,9 @@ public: // ^CharacterDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } // ^HIDDevice virtual Type instrument_type() const override { return Type::Mouse; } diff --git a/Kernel/Devices/HID/PS2KeyboardDevice.cpp b/Kernel/Devices/HID/PS2KeyboardDevice.cpp index 23f696fa307..8dcd080e216 100644 --- a/Kernel/Devices/HID/PS2KeyboardDevice.cpp +++ b/Kernel/Devices/HID/PS2KeyboardDevice.cpp @@ -79,14 +79,14 @@ void PS2KeyboardDevice::irq_handle_byte_read(u8 byte) } } -bool PS2KeyboardDevice::handle_irq(const RegisterState&) +bool PS2KeyboardDevice::handle_irq(RegisterState const&) { // The controller will read the data and call irq_handle_byte_read // for the appropriate device return m_i8042_controller->irq_process_input_buffer(HIDDevice::Type::Keyboard); } -UNMAP_AFTER_INIT ErrorOr> PS2KeyboardDevice::try_to_initialize(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT ErrorOr> PS2KeyboardDevice::try_to_initialize(I8042Controller const& ps2_controller) { auto keyboard_device = TRY(DeviceManagement::try_create_device(ps2_controller)); @@ -102,7 +102,7 @@ UNMAP_AFTER_INIT ErrorOr PS2KeyboardDevice::initialize() // FIXME: UNMAP_AFTER_INIT might not be correct, because in practice PS/2 devices // are hot pluggable. -UNMAP_AFTER_INIT PS2KeyboardDevice::PS2KeyboardDevice(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT PS2KeyboardDevice::PS2KeyboardDevice(I8042Controller const& ps2_controller) : IRQHandler(IRQ_KEYBOARD) , KeyboardDevice() , I8042Device(ps2_controller) diff --git a/Kernel/Devices/HID/PS2KeyboardDevice.h b/Kernel/Devices/HID/PS2KeyboardDevice.h index 737b870bcd8..0bb1da70a60 100644 --- a/Kernel/Devices/HID/PS2KeyboardDevice.h +++ b/Kernel/Devices/HID/PS2KeyboardDevice.h @@ -23,7 +23,7 @@ class PS2KeyboardDevice final : public IRQHandler friend class DeviceManagement; public: - static ErrorOr> try_to_initialize(const I8042Controller&); + static ErrorOr> try_to_initialize(I8042Controller const&); virtual ~PS2KeyboardDevice() override; ErrorOr initialize(); @@ -37,10 +37,10 @@ public: } private: - explicit PS2KeyboardDevice(const I8042Controller&); + explicit PS2KeyboardDevice(I8042Controller const&); // ^IRQHandler - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; // ^CharacterDevice virtual StringView class_name() const override { return "KeyboardDevice"sv; } diff --git a/Kernel/Devices/HID/PS2MouseDevice.cpp b/Kernel/Devices/HID/PS2MouseDevice.cpp index 13fc67035f0..da703432957 100644 --- a/Kernel/Devices/HID/PS2MouseDevice.cpp +++ b/Kernel/Devices/HID/PS2MouseDevice.cpp @@ -19,7 +19,7 @@ namespace Kernel { #define PS2MOUSE_INTELLIMOUSE_ID 0x03 #define PS2MOUSE_INTELLIMOUSE_EXPLORER_ID 0x04 -UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(I8042Controller const& ps2_controller) : IRQHandler(IRQ_MOUSE) , MouseDevice() , I8042Device(ps2_controller) @@ -28,7 +28,7 @@ UNMAP_AFTER_INIT PS2MouseDevice::PS2MouseDevice(const I8042Controller& ps2_contr UNMAP_AFTER_INIT PS2MouseDevice::~PS2MouseDevice() = default; -bool PS2MouseDevice::handle_irq(const RegisterState&) +bool PS2MouseDevice::handle_irq(RegisterState const&) { // The controller will read the data and call irq_handle_byte_read // for the appropriate device @@ -82,7 +82,7 @@ void PS2MouseDevice::irq_handle_byte_read(u8 byte) } } -MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet) +MousePacket PS2MouseDevice::parse_data_packet(RawPacket const& raw_packet) { int x = raw_packet.bytes[1]; int y = raw_packet.bytes[2]; @@ -175,7 +175,7 @@ ErrorOr PS2MouseDevice::set_sample_rate(u8 rate) return {}; } -UNMAP_AFTER_INIT ErrorOr> PS2MouseDevice::try_to_initialize(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT ErrorOr> PS2MouseDevice::try_to_initialize(I8042Controller const& ps2_controller) { auto mouse_device = TRY(DeviceManagement::try_create_device(ps2_controller)); TRY(mouse_device->initialize()); diff --git a/Kernel/Devices/HID/PS2MouseDevice.h b/Kernel/Devices/HID/PS2MouseDevice.h index 6822b7ef9d9..bac8c127b61 100644 --- a/Kernel/Devices/HID/PS2MouseDevice.h +++ b/Kernel/Devices/HID/PS2MouseDevice.h @@ -20,7 +20,7 @@ class PS2MouseDevice : public IRQHandler friend class DeviceManagement; public: - static ErrorOr> try_to_initialize(const I8042Controller&); + static ErrorOr> try_to_initialize(I8042Controller const&); ErrorOr initialize(); virtual ~PS2MouseDevice() override; @@ -35,10 +35,10 @@ public: } protected: - explicit PS2MouseDevice(const I8042Controller&); + explicit PS2MouseDevice(I8042Controller const&); // ^IRQHandler - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; struct RawPacket { union { @@ -50,7 +50,7 @@ protected: ErrorOr read_from_device(); ErrorOr send_command(u8 command); ErrorOr send_command(u8 command, u8 data); - MousePacket parse_data_packet(const RawPacket&); + MousePacket parse_data_packet(RawPacket const&); ErrorOr set_sample_rate(u8); ErrorOr get_device_id(); diff --git a/Kernel/Devices/HID/VMWareMouseDevice.cpp b/Kernel/Devices/HID/VMWareMouseDevice.cpp index aaeeb4f9c60..ccc66d684d0 100644 --- a/Kernel/Devices/HID/VMWareMouseDevice.cpp +++ b/Kernel/Devices/HID/VMWareMouseDevice.cpp @@ -11,7 +11,7 @@ namespace Kernel { -UNMAP_AFTER_INIT ErrorOr> VMWareMouseDevice::try_to_initialize(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT ErrorOr> VMWareMouseDevice::try_to_initialize(I8042Controller const& ps2_controller) { // FIXME: return the correct error if (!VMWareBackdoor::the()) @@ -51,7 +51,7 @@ void VMWareMouseDevice::irq_handle_byte_read(u8) evaluate_block_conditions(); } -VMWareMouseDevice::VMWareMouseDevice(const I8042Controller& ps2_controller) +VMWareMouseDevice::VMWareMouseDevice(I8042Controller const& ps2_controller) : PS2MouseDevice(ps2_controller) { } diff --git a/Kernel/Devices/HID/VMWareMouseDevice.h b/Kernel/Devices/HID/VMWareMouseDevice.h index 64680d54ff6..f004682aa36 100644 --- a/Kernel/Devices/HID/VMWareMouseDevice.h +++ b/Kernel/Devices/HID/VMWareMouseDevice.h @@ -18,14 +18,14 @@ namespace Kernel { class VMWareMouseDevice final : public PS2MouseDevice { public: friend class DeviceManagement; - static ErrorOr> try_to_initialize(const I8042Controller&); + static ErrorOr> try_to_initialize(I8042Controller const&); virtual ~VMWareMouseDevice() override; // ^I8042Device virtual void irq_handle_byte_read(u8 byte) override; private: - explicit VMWareMouseDevice(const I8042Controller&); + explicit VMWareMouseDevice(I8042Controller const&); }; } diff --git a/Kernel/Devices/KCOVDevice.h b/Kernel/Devices/KCOVDevice.h index 8d2af84c92b..5c1ae79c0ff 100644 --- a/Kernel/Devices/KCOVDevice.h +++ b/Kernel/Devices/KCOVDevice.h @@ -30,11 +30,11 @@ protected: virtual StringView class_name() const override { return "KCOVDevice"sv; } - virtual bool can_read(const OpenFileDescription&, u64) const override final { return true; } - virtual bool can_write(const OpenFileDescription&, u64) const override final { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override final { return true; } + virtual bool can_write(OpenFileDescription const&, u64) const override final { return true; } virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; }; diff --git a/Kernel/Devices/KCOVInstance.h b/Kernel/Devices/KCOVInstance.h index 097e7b64681..3cfc9c7ab20 100644 --- a/Kernel/Devices/KCOVInstance.h +++ b/Kernel/Devices/KCOVInstance.h @@ -21,7 +21,7 @@ typedef volatile u64 kcov_pc_t; * for the first time. At this point it is in state OPENED. When a thread in * the same process then uses the KCOV_ENABLE ioctl on the block device, the * instance enters state TRACING. - * + * * A KCOVInstance in state TRACING can return to state OPENED by either the * KCOV_DISABLE ioctl or by killing the thread. A KCOVInstance in state OPENED * can return to state UNUSED only when the process dies. At this point diff --git a/Kernel/Devices/MemoryDevice.h b/Kernel/Devices/MemoryDevice.h index 2efa9614a0a..2755149e4e8 100644 --- a/Kernel/Devices/MemoryDevice.h +++ b/Kernel/Devices/MemoryDevice.h @@ -25,11 +25,11 @@ private: MemoryDevice(); virtual StringView class_name() const override { return "MemoryDevice"sv; } - virtual bool can_read(const OpenFileDescription&, u64) const override { return true; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return false; } + virtual bool can_read(OpenFileDescription const&, u64) const override { return true; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return false; } virtual bool is_seekable() const override { return true; } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } bool is_allowed_range(PhysicalAddress, Memory::VirtualRange const&) const; }; diff --git a/Kernel/Devices/NullDevice.cpp b/Kernel/Devices/NullDevice.cpp index 4a30e9a09ee..d8eeba1f36e 100644 --- a/Kernel/Devices/NullDevice.cpp +++ b/Kernel/Devices/NullDevice.cpp @@ -26,7 +26,7 @@ UNMAP_AFTER_INIT NullDevice::NullDevice() UNMAP_AFTER_INIT NullDevice::~NullDevice() = default; -bool NullDevice::can_read(const OpenFileDescription&, u64) const +bool NullDevice::can_read(OpenFileDescription const&, u64) const { return true; } @@ -36,7 +36,7 @@ ErrorOr NullDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&, return 0; } -ErrorOr NullDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t buffer_size) +ErrorOr NullDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t buffer_size) { return buffer_size; } diff --git a/Kernel/Devices/NullDevice.h b/Kernel/Devices/NullDevice.h index a906fba13d9..23b647cfe57 100644 --- a/Kernel/Devices/NullDevice.h +++ b/Kernel/Devices/NullDevice.h @@ -22,9 +22,9 @@ private: NullDevice(); // ^CharacterDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } - virtual bool can_read(const OpenFileDescription&, u64) const override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override; virtual StringView class_name() const override { return "NullDevice"sv; } virtual bool is_seekable() const override { return true; } }; diff --git a/Kernel/Devices/RandomDevice.cpp b/Kernel/Devices/RandomDevice.cpp index 9734349d276..7e7c988cdd4 100644 --- a/Kernel/Devices/RandomDevice.cpp +++ b/Kernel/Devices/RandomDevice.cpp @@ -26,7 +26,7 @@ UNMAP_AFTER_INIT RandomDevice::RandomDevice() UNMAP_AFTER_INIT RandomDevice::~RandomDevice() = default; -bool RandomDevice::can_read(const OpenFileDescription&, u64) const +bool RandomDevice::can_read(OpenFileDescription const&, u64) const { return true; } @@ -39,7 +39,7 @@ ErrorOr RandomDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer }); } -ErrorOr RandomDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size) +ErrorOr RandomDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size) { // FIXME: Use input for entropy? I guess that could be a neat feature? return size; diff --git a/Kernel/Devices/RandomDevice.h b/Kernel/Devices/RandomDevice.h index 93f523a3eac..a86ba9f8542 100644 --- a/Kernel/Devices/RandomDevice.h +++ b/Kernel/Devices/RandomDevice.h @@ -22,9 +22,9 @@ private: // ^CharacterDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual StringView class_name() const override { return "RandomDevice"sv; } }; diff --git a/Kernel/Devices/SerialDevice.cpp b/Kernel/Devices/SerialDevice.cpp index 50d603e118b..96db5b6904d 100644 --- a/Kernel/Devices/SerialDevice.cpp +++ b/Kernel/Devices/SerialDevice.cpp @@ -54,7 +54,7 @@ UNMAP_AFTER_INIT SerialDevice::SerialDevice(IOAddress base_addr, unsigned minor) UNMAP_AFTER_INIT SerialDevice::~SerialDevice() = default; -bool SerialDevice::can_read(const OpenFileDescription&, u64) const +bool SerialDevice::can_read(OpenFileDescription const&, u64) const { return (get_line_status() & DataReady) != 0; } @@ -75,12 +75,12 @@ ErrorOr SerialDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer }); } -bool SerialDevice::can_write(const OpenFileDescription&, u64) const +bool SerialDevice::can_write(OpenFileDescription const&, u64) const { return (get_line_status() & EmptyTransmitterHoldingRegister) != 0; } -ErrorOr SerialDevice::write(OpenFileDescription& description, u64, const UserOrKernelBuffer& buffer, size_t size) +ErrorOr SerialDevice::write(OpenFileDescription& description, u64, UserOrKernelBuffer const& buffer, size_t size) { if (!size) return 0; diff --git a/Kernel/Devices/SerialDevice.h b/Kernel/Devices/SerialDevice.h index 4da3c7439dd..5827e17e852 100644 --- a/Kernel/Devices/SerialDevice.h +++ b/Kernel/Devices/SerialDevice.h @@ -20,10 +20,10 @@ public: virtual ~SerialDevice() override; // ^CharacterDevice - virtual bool can_read(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; void put_char(char); diff --git a/Kernel/Devices/ZeroDevice.cpp b/Kernel/Devices/ZeroDevice.cpp index 1d001630cfa..f4d59a8677a 100644 --- a/Kernel/Devices/ZeroDevice.cpp +++ b/Kernel/Devices/ZeroDevice.cpp @@ -26,7 +26,7 @@ UNMAP_AFTER_INIT ZeroDevice::ZeroDevice() UNMAP_AFTER_INIT ZeroDevice::~ZeroDevice() = default; -bool ZeroDevice::can_read(const OpenFileDescription&, u64) const +bool ZeroDevice::can_read(OpenFileDescription const&, u64) const { return true; } @@ -37,7 +37,7 @@ ErrorOr ZeroDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer& return size; } -ErrorOr ZeroDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size) +ErrorOr ZeroDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size) { return size; } diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h index aab5633abf5..d10be8387fc 100644 --- a/Kernel/Devices/ZeroDevice.h +++ b/Kernel/Devices/ZeroDevice.h @@ -22,9 +22,9 @@ private: // ^CharacterDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual StringView class_name() const override { return "ZeroDevice"sv; } }; diff --git a/Kernel/DoubleBuffer.cpp b/Kernel/DoubleBuffer.cpp index 864568b593f..498bf0f538e 100644 --- a/Kernel/DoubleBuffer.cpp +++ b/Kernel/DoubleBuffer.cpp @@ -45,7 +45,7 @@ void DoubleBuffer::flip() compute_lockfree_metadata(); } -ErrorOr DoubleBuffer::write(const UserOrKernelBuffer& data, size_t size) +ErrorOr DoubleBuffer::write(UserOrKernelBuffer const& data, size_t size) { if (!size) return 0; diff --git a/Kernel/DoubleBuffer.h b/Kernel/DoubleBuffer.h index 2d735b34dcd..32d92933d50 100644 --- a/Kernel/DoubleBuffer.h +++ b/Kernel/DoubleBuffer.h @@ -17,8 +17,8 @@ namespace Kernel { class DoubleBuffer { public: static ErrorOr> try_create(size_t capacity = 65536); - ErrorOr write(const UserOrKernelBuffer&, size_t); - ErrorOr write(const u8* data, size_t size) + ErrorOr write(UserOrKernelBuffer const&, size_t); + ErrorOr write(u8 const* data, size_t size) { return write(UserOrKernelBuffer::for_kernel_buffer(const_cast(data)), size); } diff --git a/Kernel/FileSystem/AnonymousFile.cpp b/Kernel/FileSystem/AnonymousFile.cpp index 3e7955e9720..5d46a5e6fbb 100644 --- a/Kernel/FileSystem/AnonymousFile.cpp +++ b/Kernel/FileSystem/AnonymousFile.cpp @@ -28,7 +28,7 @@ ErrorOr AnonymousFile::mmap(Process& process, OpenFileDescripti return process.address_space().allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared); } -ErrorOr> AnonymousFile::pseudo_path(const OpenFileDescription&) const +ErrorOr> AnonymousFile::pseudo_path(OpenFileDescription const&) const { return KString::try_create(":anonymous-file:"sv); } diff --git a/Kernel/FileSystem/AnonymousFile.h b/Kernel/FileSystem/AnonymousFile.h index 4703a87831d..d03342ec7d8 100644 --- a/Kernel/FileSystem/AnonymousFile.h +++ b/Kernel/FileSystem/AnonymousFile.h @@ -24,11 +24,11 @@ public: private: virtual StringView class_name() const override { return "AnonymousFile"sv; } - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override; - virtual bool can_read(const OpenFileDescription&, u64) const override { return false; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return false; } + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override { return false; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return false; } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; } - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; } explicit AnonymousFile(NonnullRefPtr); diff --git a/Kernel/FileSystem/BlockBasedFileSystem.cpp b/Kernel/FileSystem/BlockBasedFileSystem.cpp index 1325c12d485..1ae40139ddd 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.cpp +++ b/Kernel/FileSystem/BlockBasedFileSystem.cpp @@ -89,7 +89,7 @@ public: return &new_entry; } - const CacheEntry* entries() const { return (const CacheEntry*)m_entries->data(); } + CacheEntry const* entries() const { return (CacheEntry const*)m_entries->data(); } CacheEntry* entries() { return (CacheEntry*)m_entries->data(); } template @@ -129,7 +129,7 @@ ErrorOr BlockBasedFileSystem::initialize() return {}; } -ErrorOr BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, u64 offset, bool allow_cache) +ErrorOr BlockBasedFileSystem::write_block(BlockIndex index, UserOrKernelBuffer const& data, size_t count, u64 offset, bool allow_cache) { VERIFY(m_logical_block_size); VERIFY(offset + count <= block_size()); @@ -172,7 +172,7 @@ ErrorOr BlockBasedFileSystem::raw_read(BlockIndex index, UserOrKernelBuffe return {}; } -ErrorOr BlockBasedFileSystem::raw_write(BlockIndex index, const UserOrKernelBuffer& buffer) +ErrorOr BlockBasedFileSystem::raw_write(BlockIndex index, UserOrKernelBuffer const& buffer) { auto base_offset = index.value() * m_logical_block_size; auto nwritten = TRY(file_description().write(base_offset, buffer, m_logical_block_size)); @@ -190,7 +190,7 @@ ErrorOr BlockBasedFileSystem::raw_read_blocks(BlockIndex index, size_t cou return {}; } -ErrorOr BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer& buffer) +ErrorOr BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t count, UserOrKernelBuffer const& buffer) { auto current = buffer; for (auto block = index.value(); block < (index.value() + count); block++) { @@ -200,7 +200,7 @@ ErrorOr BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t co return {}; } -ErrorOr BlockBasedFileSystem::write_blocks(BlockIndex index, unsigned count, const UserOrKernelBuffer& data, bool allow_cache) +ErrorOr BlockBasedFileSystem::write_blocks(BlockIndex index, unsigned count, UserOrKernelBuffer const& data, bool allow_cache) { VERIFY(m_logical_block_size); dbgln_if(BBFS_DEBUG, "BlockBasedFileSystem::write_blocks {}, count={}", index, count); diff --git a/Kernel/FileSystem/BlockBasedFileSystem.h b/Kernel/FileSystem/BlockBasedFileSystem.h index 235ab2935cd..5a11fbc8cb4 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.h +++ b/Kernel/FileSystem/BlockBasedFileSystem.h @@ -30,13 +30,13 @@ protected: ErrorOr read_blocks(BlockIndex, unsigned count, UserOrKernelBuffer&, bool allow_cache = true) const; ErrorOr raw_read(BlockIndex, UserOrKernelBuffer&); - ErrorOr raw_write(BlockIndex, const UserOrKernelBuffer&); + ErrorOr raw_write(BlockIndex, UserOrKernelBuffer const&); ErrorOr raw_read_blocks(BlockIndex index, size_t count, UserOrKernelBuffer&); - ErrorOr raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer&); + ErrorOr raw_write_blocks(BlockIndex index, size_t count, UserOrKernelBuffer const&); - ErrorOr write_block(BlockIndex, const UserOrKernelBuffer&, size_t count, u64 offset = 0, bool allow_cache = true); - ErrorOr write_blocks(BlockIndex, unsigned count, const UserOrKernelBuffer&, bool allow_cache = true); + ErrorOr write_block(BlockIndex, UserOrKernelBuffer const&, size_t count, u64 offset = 0, bool allow_cache = true); + ErrorOr write_blocks(BlockIndex, unsigned count, UserOrKernelBuffer const&, bool allow_cache = true); u64 m_logical_block_size { 512 }; diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index d09a58862f1..edd2f205cc1 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -83,7 +83,7 @@ ErrorOr DevPtsFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, Op VERIFY_NOT_REACHED(); } -ErrorOr DevPtsFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr DevPtsFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { VERIFY_NOT_REACHED(); } diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS.h index 94b94e1b4f4..fc030dc121e 100644 --- a/Kernel/FileSystem/DevPtsFS.h +++ b/Kernel/FileSystem/DevPtsFS.h @@ -52,7 +52,7 @@ private: virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr flush_metadata() override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr remove_child(StringView name) override; diff --git a/Kernel/FileSystem/DevTmpFS.cpp b/Kernel/FileSystem/DevTmpFS.cpp index 151bd6d12b5..1f881154bff 100644 --- a/Kernel/FileSystem/DevTmpFS.cpp +++ b/Kernel/FileSystem/DevTmpFS.cpp @@ -71,7 +71,7 @@ ErrorOr DevTmpFSInode::flush_metadata() return {}; } -ErrorOr DevTmpFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr DevTmpFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { VERIFY_NOT_REACHED(); } @@ -318,7 +318,7 @@ ErrorOr DevTmpFSDeviceInode::read_bytes(off_t offset, size_t count, User return result.value(); } -ErrorOr DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* description) +ErrorOr DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription* description) { MutexLocker locker(m_inode_lock); VERIFY(!!description); diff --git a/Kernel/FileSystem/DevTmpFS.h b/Kernel/FileSystem/DevTmpFS.h index c3d872fc4ae..91ca9cdd549 100644 --- a/Kernel/FileSystem/DevTmpFS.h +++ b/Kernel/FileSystem/DevTmpFS.h @@ -53,7 +53,7 @@ protected: virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr flush_metadata() override; virtual InodeMetadata metadata() const override final; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr remove_child(StringView name) override; @@ -96,10 +96,10 @@ private: // ^Inode virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; NonnullOwnPtr m_name; - const bool m_block_device; + bool const m_block_device; }; class DevTmpFSLinkInode final : public DevTmpFSInode { @@ -117,7 +117,7 @@ protected: // ^Inode virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; NonnullOwnPtr m_name; OwnPtr m_link; diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 27eb4766f03..b016a2403c4 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -69,7 +69,7 @@ ErrorOr Ext2FS::flush_super_block() return raw_write_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer); } -const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const +ext2_group_desc const& Ext2FS::group_descriptor(GroupIndex group_index) const { // FIXME: Should this fail gracefully somehow? VERIFY(group_index <= m_block_group_count); @@ -164,7 +164,7 @@ bool Ext2FS::find_block_containing_inode(InodeIndex inode, BlockIndex& block_ind Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const { BlockListShape shape; - const unsigned entries_per_block = EXT2_ADDR_PER_BLOCK(&super_block()); + unsigned const entries_per_block = EXT2_ADDR_PER_BLOCK(&super_block()); unsigned blocks_remaining = blocks; shape.direct_blocks = min((unsigned)EXT2_NDIR_BLOCKS, blocks_remaining); @@ -196,7 +196,7 @@ Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const ErrorOr Ext2FSInode::write_indirect_block(BlockBasedFileSystem::BlockIndex block, Span blocks_indices) { - const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); + auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); VERIFY(blocks_indices.size() <= entries_per_block); auto block_contents = TRY(ByteBuffer::create_uninitialized(fs().block_size())); @@ -213,10 +213,10 @@ ErrorOr Ext2FSInode::write_indirect_block(BlockBasedFileSystem::BlockIndex ErrorOr Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, Span blocks_indices, Vector& new_meta_blocks, unsigned& meta_blocks) { - const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); - const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block; - const auto old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block); - const auto new_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_block); + auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); + auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block; + auto const old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block); + auto const new_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_block); VERIFY(blocks_indices.size() > 0); VERIFY(blocks_indices.size() > old_blocks_length); VERIFY(blocks_indices.size() <= entries_per_doubly_indirect_block); @@ -243,7 +243,7 @@ ErrorOr Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::Bloc // Write out the indirect blocks. for (unsigned i = old_blocks_length / entries_per_block; i < new_indirect_blocks_length; i++) { - const auto offset_block = i * entries_per_block; + auto const offset_block = i * entries_per_block; TRY(write_indirect_block(block_as_pointers[i], blocks_indices.slice(offset_block, min(blocks_indices.size() - offset_block, entries_per_block)))); } @@ -253,10 +253,10 @@ ErrorOr Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::Bloc ErrorOr Ext2FSInode::shrink_doubly_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, size_t new_blocks_length, unsigned& meta_blocks) { - const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); - const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block; - const auto old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block); - const auto new_indirect_blocks_length = ceil_div(new_blocks_length, entries_per_block); + auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); + auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block; + auto const old_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_block); + auto const new_indirect_blocks_length = ceil_div(new_blocks_length, entries_per_block); VERIFY(old_blocks_length > 0); VERIFY(old_blocks_length >= new_blocks_length); VERIFY(new_blocks_length <= entries_per_doubly_indirect_block); @@ -285,11 +285,11 @@ ErrorOr Ext2FSInode::shrink_doubly_indirect_block(BlockBasedFileSystem::Bl ErrorOr Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, Span blocks_indices, Vector& new_meta_blocks, unsigned& meta_blocks) { - const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); - const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block; - const auto entries_per_triply_indirect_block = entries_per_block * entries_per_block; - const auto old_doubly_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block); - const auto new_doubly_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_doubly_indirect_block); + auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); + auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block; + auto const entries_per_triply_indirect_block = entries_per_block * entries_per_block; + auto const old_doubly_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block); + auto const new_doubly_indirect_blocks_length = ceil_div(blocks_indices.size(), entries_per_doubly_indirect_block); VERIFY(blocks_indices.size() > 0); VERIFY(blocks_indices.size() > old_blocks_length); VERIFY(blocks_indices.size() <= entries_per_triply_indirect_block); @@ -316,9 +316,9 @@ ErrorOr Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::Bloc // Write out the doubly indirect blocks. for (unsigned i = old_blocks_length / entries_per_doubly_indirect_block; i < new_doubly_indirect_blocks_length; i++) { - const auto processed_blocks = i * entries_per_doubly_indirect_block; - const auto old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block); - const auto new_doubly_indirect_blocks_length = min(blocks_indices.size() > processed_blocks ? blocks_indices.size() - processed_blocks : 0, entries_per_doubly_indirect_block); + auto const processed_blocks = i * entries_per_doubly_indirect_block; + auto const old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block); + auto const new_doubly_indirect_blocks_length = min(blocks_indices.size() > processed_blocks ? blocks_indices.size() - processed_blocks : 0, entries_per_doubly_indirect_block); TRY(grow_doubly_indirect_block(block_as_pointers[i], old_doubly_indirect_blocks_length, blocks_indices.slice(processed_blocks, new_doubly_indirect_blocks_length), new_meta_blocks, meta_blocks)); } @@ -328,11 +328,11 @@ ErrorOr Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::Bloc ErrorOr Ext2FSInode::shrink_triply_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, size_t new_blocks_length, unsigned& meta_blocks) { - const auto entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); - const auto entries_per_doubly_indirect_block = entries_per_block * entries_per_block; - const auto entries_per_triply_indirect_block = entries_per_doubly_indirect_block * entries_per_block; - const auto old_triply_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block); - const auto new_triply_indirect_blocks_length = new_blocks_length / entries_per_doubly_indirect_block; + auto const entries_per_block = EXT2_ADDR_PER_BLOCK(&fs().super_block()); + auto const entries_per_doubly_indirect_block = entries_per_block * entries_per_block; + auto const entries_per_triply_indirect_block = entries_per_doubly_indirect_block * entries_per_block; + auto const old_triply_indirect_blocks_length = ceil_div(old_blocks_length, entries_per_doubly_indirect_block); + auto const new_triply_indirect_blocks_length = new_blocks_length / entries_per_doubly_indirect_block; VERIFY(old_blocks_length > 0); VERIFY(old_blocks_length >= new_blocks_length); VERIFY(new_blocks_length <= entries_per_triply_indirect_block); @@ -344,9 +344,9 @@ ErrorOr Ext2FSInode::shrink_triply_indirect_block(BlockBasedFileSystem::Bl // Shrink the doubly indirect blocks. for (unsigned i = new_triply_indirect_blocks_length; i < old_triply_indirect_blocks_length; i++) { - const auto processed_blocks = i * entries_per_doubly_indirect_block; - const auto old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block); - const auto new_doubly_indirect_blocks_length = min(new_blocks_length > processed_blocks ? new_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block); + auto const processed_blocks = i * entries_per_doubly_indirect_block; + auto const old_doubly_indirect_blocks_length = min(old_blocks_length > processed_blocks ? old_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block); + auto const new_doubly_indirect_blocks_length = min(new_blocks_length > processed_blocks ? new_blocks_length - processed_blocks : 0, entries_per_doubly_indirect_block); dbgln_if(EXT2_BLOCKLIST_DEBUG, "Ext2FSInode[{}]::shrink_triply_indirect_block(): Shrinking doubly indirect block {} at index {}", identifier(), block_as_pointers[i], i); TRY(shrink_doubly_indirect_block(block_as_pointers[i], old_doubly_indirect_blocks_length, new_doubly_indirect_blocks_length, meta_blocks)); } @@ -373,10 +373,10 @@ ErrorOr Ext2FSInode::flush_block_list() } // NOTE: There is a mismatch between i_blocks and blocks.size() since i_blocks includes meta blocks and blocks.size() does not. - const auto old_block_count = ceil_div(size(), static_cast(fs().block_size())); + auto const old_block_count = ceil_div(size(), static_cast(fs().block_size())); auto old_shape = fs().compute_block_list_shape(old_block_count); - const auto new_shape = fs().compute_block_list_shape(m_block_list.size()); + auto const new_shape = fs().compute_block_list_shape(m_block_list.size()); Vector new_meta_blocks; if (new_shape.meta_blocks > old_shape.meta_blocks) { @@ -813,7 +813,7 @@ ErrorOr Ext2FSInode::read_bytes(off_t offset, size_t count, UserOrKernel if (is_symlink() && size() < max_inline_symlink_length) { VERIFY(offset == 0); size_t nread = min((off_t)size() - offset, static_cast(count)); - TRY(buffer.write(((const u8*)m_raw_inode.i_block) + offset, nread)); + TRY(buffer.write(((u8 const*)m_raw_inode.i_block) + offset, nread)); return nread; } @@ -827,7 +827,7 @@ ErrorOr Ext2FSInode::read_bytes(off_t offset, size_t count, UserOrKernel bool allow_cache = !description || !description->is_direct(); - const int block_size = fs().block_size(); + int const block_size = fs().block_size(); BlockBasedFileSystem::BlockIndex first_block_logical_index = offset / block_size; BlockBasedFileSystem::BlockIndex last_block_logical_index = (offset + count) / block_size; @@ -935,7 +935,7 @@ ErrorOr Ext2FSInode::resize(u64 new_size) return {}; } -ErrorOr Ext2FSInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& data, OpenFileDescription* description) +ErrorOr Ext2FSInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& data, OpenFileDescription* description) { VERIFY(offset >= 0); @@ -960,7 +960,7 @@ ErrorOr Ext2FSInode::write_bytes(off_t offset, size_t count, const UserO bool allow_cache = !description || !description->is_direct(); - const auto block_size = fs().block_size(); + auto const block_size = fs().block_size(); auto new_size = max(static_cast(offset) + count, size()); TRY(resize(new_size)); @@ -1003,7 +1003,7 @@ ErrorOr Ext2FSInode::write_bytes(off_t offset, size_t count, const UserO return nwritten; } -u8 Ext2FS::internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const +u8 Ext2FS::internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const { switch (entry.file_type) { case EXT2_FT_REG_FILE: @@ -1219,7 +1219,7 @@ ErrorOr Ext2FS::write_ext2_inode(InodeIndex inode, ext2_inode const& e2ino unsigned offset; if (!find_block_containing_inode(inode, block_index, offset)) return EINVAL; - auto buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast((const u8*)&e2inode)); + auto buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast((u8 const*)&e2inode)); return write_block(block_index, buffer, inode_size(), offset); } diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 4dd6ad904b7..90563b95480 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -40,7 +40,7 @@ private: virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr flush_metadata() override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr add_child(Inode& child, StringView name, mode_t) override; virtual ErrorOr remove_child(StringView name) override; @@ -69,7 +69,7 @@ private: ErrorOr> compute_block_list_impl_internal(ext2_inode const&, bool include_block_list_blocks) const; Ext2FS& fs(); - const Ext2FS& fs() const; + Ext2FS const& fs() const; Ext2FSInode(Ext2FS&, InodeIndex); mutable Vector m_block_list; @@ -100,7 +100,7 @@ public: virtual bool supports_watchers() const override { return true; } - virtual u8 internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const override; + virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override; FeaturesReadOnly get_features_readonly() const; @@ -109,10 +109,10 @@ private: explicit Ext2FS(OpenFileDescription&); - const ext2_super_block& super_block() const { return m_super_block; } - const ext2_group_desc& group_descriptor(GroupIndex) const; + ext2_super_block const& super_block() const { return m_super_block; } + ext2_group_desc const& group_descriptor(GroupIndex) const; ext2_group_desc* block_group_descriptors() { return (ext2_group_desc*)m_cached_group_descriptor_table->data(); } - const ext2_group_desc* block_group_descriptors() const { return (const ext2_group_desc*)m_cached_group_descriptor_table->data(); } + ext2_group_desc const* block_group_descriptors() const { return (ext2_group_desc const*)m_cached_group_descriptor_table->data(); } void flush_block_group_descriptor_table(); u64 inodes_per_block() const; u64 inodes_per_group() const; @@ -188,9 +188,9 @@ inline Ext2FS& Ext2FSInode::fs() return static_cast(Inode::fs()); } -inline const Ext2FS& Ext2FSInode::fs() const +inline Ext2FS const& Ext2FSInode::fs() const { - return static_cast(Inode::fs()); + return static_cast(Inode::fs()); } } diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 0d0e63df2ca..c4f573a418c 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -97,12 +97,12 @@ void FIFO::detach(Direction direction) evaluate_block_conditions(); } -bool FIFO::can_read(const OpenFileDescription&, u64) const +bool FIFO::can_read(OpenFileDescription const&, u64) const { return !m_buffer->is_empty() || !m_writers; } -bool FIFO::can_write(const OpenFileDescription&, u64) const +bool FIFO::can_write(OpenFileDescription const&, u64) const { return m_buffer->space_for_writing() || !m_readers; } @@ -118,7 +118,7 @@ ErrorOr FIFO::read(OpenFileDescription& fd, u64, UserOrKernelBuffer& buf return m_buffer->read(buffer, size); } -ErrorOr FIFO::write(OpenFileDescription& fd, u64, const UserOrKernelBuffer& buffer, size_t size) +ErrorOr FIFO::write(OpenFileDescription& fd, u64, UserOrKernelBuffer const& buffer, size_t size) { if (!m_readers) { Thread::current()->send_signal(SIGPIPE, &Process::current()); @@ -130,7 +130,7 @@ ErrorOr FIFO::write(OpenFileDescription& fd, u64, const UserOrKernelBuff return m_buffer->write(buffer, size); } -ErrorOr> FIFO::pseudo_path(const OpenFileDescription&) const +ErrorOr> FIFO::pseudo_path(OpenFileDescription const&) const { return KString::formatted("fifo:{}", m_fifo_id); } diff --git a/Kernel/FileSystem/FIFO.h b/Kernel/FileSystem/FIFO.h index 106cf51080e..bce07e57936 100644 --- a/Kernel/FileSystem/FIFO.h +++ b/Kernel/FileSystem/FIFO.h @@ -40,12 +40,12 @@ public: private: // ^File - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; virtual ErrorOr stat() const override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const override; virtual StringView class_name() const override { return "FIFO"sv; } virtual bool is_fifo() const override { return true; } diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h index 05dedd9d908..bb9065a8a77 100644 --- a/Kernel/FileSystem/File.h +++ b/Kernel/FileSystem/File.h @@ -81,20 +81,20 @@ public: virtual ErrorOr> open(int options); virtual ErrorOr close(); - virtual bool can_read(const OpenFileDescription&, u64) const = 0; - virtual bool can_write(const OpenFileDescription&, u64) const = 0; + virtual bool can_read(OpenFileDescription const&, u64) const = 0; + virtual bool can_write(OpenFileDescription const&, u64) const = 0; virtual ErrorOr attach(OpenFileDescription&); virtual void detach(OpenFileDescription&); virtual void did_seek(OpenFileDescription&, off_t) { } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) = 0; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) = 0; virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg); virtual ErrorOr mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared); virtual ErrorOr stat() const { return EBADF; } // Although this might be better described "name" or "description", these terms already have other meanings. - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const = 0; + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const = 0; virtual ErrorOr truncate(u64) { return EINVAL; } virtual ErrorOr sync() { return EINVAL; } diff --git a/Kernel/FileSystem/FileBackedFileSystem.h b/Kernel/FileSystem/FileBackedFileSystem.h index 95cfc42337b..47bd36ea606 100644 --- a/Kernel/FileSystem/FileBackedFileSystem.h +++ b/Kernel/FileSystem/FileBackedFileSystem.h @@ -17,7 +17,7 @@ public: File& file() { return m_file_description->file(); } OpenFileDescription& file_description() { return *m_file_description; } - const File& file() const { return m_file_description->file(); } + File const& file() const { return m_file_description->file(); } OpenFileDescription& file_description() const { return *m_file_description; } protected: diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 96bf7385a33..f7f5e1a1885 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -61,7 +61,7 @@ public: virtual bool is_file_backed() const { return false; } // Converts file types that are used internally by the filesystem to DT_* types - virtual u8 internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const { return entry.file_type; } + virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const { return entry.file_type; } protected: FileSystem(); @@ -83,7 +83,7 @@ inline FileSystem* InodeIdentifier::fs() // NOLINT(readability-make-member-funct return FileSystem::from_fsid(m_fsid); } -inline const FileSystem* InodeIdentifier::fs() const +inline FileSystem const* InodeIdentifier::fs() const { return FileSystem::from_fsid(m_fsid); } @@ -94,7 +94,7 @@ namespace AK { template<> struct Traits : public GenericTraits { - static unsigned hash(const Kernel::InodeIdentifier& inode) { return pair_int_hash(inode.fsid().value(), inode.index().value()); } + static unsigned hash(Kernel::InodeIdentifier const& inode) { return pair_int_hash(inode.fsid().value(), inode.index().value()); } }; } diff --git a/Kernel/FileSystem/ISO9660FileSystem.cpp b/Kernel/FileSystem/ISO9660FileSystem.cpp index ed688363ac9..4c08f6fbee6 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.cpp +++ b/Kernel/FileSystem/ISO9660FileSystem.cpp @@ -214,7 +214,7 @@ unsigned ISO9660FS::total_inode_count() const return m_cached_inode_count; } -u8 ISO9660FS::internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const +u8 ISO9660FS::internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const { if (has_flag(static_cast(entry.file_type), ISO::FileFlags::Directory)) { return DT_DIR; @@ -493,7 +493,7 @@ ErrorOr ISO9660Inode::flush_metadata() return {}; } -ErrorOr ISO9660Inode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr ISO9660Inode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; } diff --git a/Kernel/FileSystem/ISO9660FileSystem.h b/Kernel/FileSystem/ISO9660FileSystem.h index 94f20274840..48e4c6941fc 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.h +++ b/Kernel/FileSystem/ISO9660FileSystem.h @@ -352,7 +352,7 @@ public: virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr flush_metadata() override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr remove_child(StringView name) override; diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index bfe2e4210db..04857e8a048 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -63,7 +63,7 @@ ErrorOr> Inode::read_entire(OpenFileDescription* descript VERIFY(nread <= sizeof(buffer)); if (nread == 0) break; - TRY(builder.append((const char*)buffer, nread)); + TRY(builder.append((char const*)buffer, nread)); offset += nread; if (nread < sizeof(buffer)) break; diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index d5d06b8a024..84c8eca1b7d 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -54,7 +54,7 @@ public: virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const = 0; virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const = 0; virtual ErrorOr> lookup(StringView name) = 0; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) = 0; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) = 0; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) = 0; virtual ErrorOr add_child(Inode&, StringView name, mode_t) = 0; virtual ErrorOr remove_child(StringView name) = 0; diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index eeccf5fcae9..bbc030908e7 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -37,7 +37,7 @@ ErrorOr InodeFile::read(OpenFileDescription& description, u64 offset, Us return nread; } -ErrorOr InodeFile::write(OpenFileDescription& description, u64 offset, const UserOrKernelBuffer& data, size_t count) +ErrorOr InodeFile::write(OpenFileDescription& description, u64 offset, UserOrKernelBuffer const& data, size_t count) { if (Checked::addition_would_overflow(offset, count)) return EOVERFLOW; @@ -91,7 +91,7 @@ ErrorOr InodeFile::mmap(Process& process, OpenFileDescription& return process.address_space().allocate_region_with_vmobject(range, vmobject.release_nonnull(), offset, path->view(), prot, shared); } -ErrorOr> InodeFile::pseudo_path(const OpenFileDescription&) const +ErrorOr> InodeFile::pseudo_path(OpenFileDescription const&) const { // If it has an inode, then it has a path, and therefore the caller should have been able to get a custody at some point. VERIFY_NOT_REACHED(); diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h index 478fe9347de..5f9dce10ded 100644 --- a/Kernel/FileSystem/InodeFile.h +++ b/Kernel/FileSystem/InodeFile.h @@ -24,19 +24,19 @@ public: virtual ~InodeFile() override; - const Inode& inode() const { return *m_inode; } + Inode const& inode() const { return *m_inode; } Inode& inode() { return *m_inode; } - virtual bool can_read(const OpenFileDescription&, u64) const override { return true; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override { return true; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; virtual ErrorOr mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override; virtual ErrorOr stat() const override { return inode().metadata().stat(); } - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const override; virtual ErrorOr truncate(u64) override; virtual ErrorOr sync() override; diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index 2af6d5f6c3a..585bbe6905b 100644 --- a/Kernel/FileSystem/InodeIdentifier.h +++ b/Kernel/FileSystem/InodeIdentifier.h @@ -33,14 +33,14 @@ public: InodeIndex index() const { return m_index; } FileSystem* fs(); - const FileSystem* fs() const; + FileSystem const* fs() const; - bool operator==(const InodeIdentifier& other) const + bool operator==(InodeIdentifier const& other) const { return m_fsid == other.m_fsid && m_index == other.m_index; } - bool operator!=(const InodeIdentifier& other) const + bool operator!=(InodeIdentifier const& other) const { return m_fsid != other.m_fsid || m_index != other.m_index; } diff --git a/Kernel/FileSystem/InodeMetadata.h b/Kernel/FileSystem/InodeMetadata.h index 1dc23b6d72d..93e5ed27421 100644 --- a/Kernel/FileSystem/InodeMetadata.h +++ b/Kernel/FileSystem/InodeMetadata.h @@ -38,9 +38,9 @@ inline bool is_setgid(mode_t mode) { return (mode & S_ISGID) == S_ISGID; } struct InodeMetadata { bool is_valid() const { return inode.is_valid(); } - bool may_read(const Process&) const; - bool may_write(const Process&) const; - bool may_execute(const Process&) const; + bool may_read(Process const&) const; + bool may_write(Process const&) const; + bool may_execute(Process const&) const; bool may_read(UserID u, GroupID g, Span eg) const { diff --git a/Kernel/FileSystem/InodeWatcher.cpp b/Kernel/FileSystem/InodeWatcher.cpp index e3563f599bc..e2a033ec14d 100644 --- a/Kernel/FileSystem/InodeWatcher.cpp +++ b/Kernel/FileSystem/InodeWatcher.cpp @@ -22,7 +22,7 @@ InodeWatcher::~InodeWatcher() (void)close(); } -bool InodeWatcher::can_read(const OpenFileDescription&, u64) const +bool InodeWatcher::can_read(OpenFileDescription const&, u64) const { MutexLocker locker(m_lock); return !m_queue.is_empty(); @@ -81,7 +81,7 @@ ErrorOr InodeWatcher::close() return {}; } -ErrorOr> InodeWatcher::pseudo_path(const OpenFileDescription&) const +ErrorOr> InodeWatcher::pseudo_path(OpenFileDescription const&) const { return KString::formatted("InodeWatcher:({})", m_wd_to_watches.size()); } diff --git a/Kernel/FileSystem/InodeWatcher.h b/Kernel/FileSystem/InodeWatcher.h index a003d58b908..fb01da67e4a 100644 --- a/Kernel/FileSystem/InodeWatcher.h +++ b/Kernel/FileSystem/InodeWatcher.h @@ -43,14 +43,14 @@ public: static ErrorOr> try_create(); virtual ~InodeWatcher() override; - virtual bool can_read(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; // Can't write to an inode watcher. - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EIO; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EIO; } virtual ErrorOr close() override; - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const override; virtual StringView class_name() const override { return "InodeWatcher"sv; }; virtual bool is_inode_watcher() const override { return true; } diff --git a/Kernel/FileSystem/OpenFileDescription.cpp b/Kernel/FileSystem/OpenFileDescription.cpp index 37e1a6eb0cf..f4381c7dce0 100644 --- a/Kernel/FileSystem/OpenFileDescription.cpp +++ b/Kernel/FileSystem/OpenFileDescription.cpp @@ -175,7 +175,7 @@ ErrorOr OpenFileDescription::read(UserOrKernelBuffer& buffer, size_t cou return nread; } -ErrorOr OpenFileDescription::write(const UserOrKernelBuffer& data, size_t size) +ErrorOr OpenFileDescription::write(UserOrKernelBuffer const& data, size_t size) { auto offset = TRY(m_state.with([&](auto& state) -> ErrorOr { if (Checked::addition_would_overflow(state.current_offset, size)) @@ -275,11 +275,11 @@ bool OpenFileDescription::is_device() const return m_file->is_device(); } -const Device* OpenFileDescription::device() const +Device const* OpenFileDescription::device() const { if (!is_device()) return nullptr; - return static_cast(m_file.ptr()); + return static_cast(m_file.ptr()); } Device* OpenFileDescription::device() @@ -313,11 +313,11 @@ bool OpenFileDescription::is_inode_watcher() const return m_file->is_inode_watcher(); } -const InodeWatcher* OpenFileDescription::inode_watcher() const +InodeWatcher const* OpenFileDescription::inode_watcher() const { if (!is_inode_watcher()) return nullptr; - return static_cast(m_file.ptr()); + return static_cast(m_file.ptr()); } InodeWatcher* OpenFileDescription::inode_watcher() @@ -332,11 +332,11 @@ bool OpenFileDescription::is_master_pty() const return m_file->is_master_pty(); } -const MasterPTY* OpenFileDescription::master_pty() const +MasterPTY const* OpenFileDescription::master_pty() const { if (!is_master_pty()) return nullptr; - return static_cast(m_file.ptr()); + return static_cast(m_file.ptr()); } MasterPTY* OpenFileDescription::master_pty() @@ -413,11 +413,11 @@ Socket* OpenFileDescription::socket() return static_cast(m_file.ptr()); } -const Socket* OpenFileDescription::socket() const +Socket const* OpenFileDescription::socket() const { if (!is_socket()) return nullptr; - return static_cast(m_file.ptr()); + return static_cast(m_file.ptr()); } void OpenFileDescription::set_file_flags(u32 flags) diff --git a/Kernel/FileSystem/OpenFileDescription.h b/Kernel/FileSystem/OpenFileDescription.h index acc6df00fe4..3d0c7b2c94e 100644 --- a/Kernel/FileSystem/OpenFileDescription.h +++ b/Kernel/FileSystem/OpenFileDescription.h @@ -42,7 +42,7 @@ public: ErrorOr seek(off_t, int whence); ErrorOr read(UserOrKernelBuffer&, size_t); - ErrorOr write(const UserOrKernelBuffer& data, size_t); + ErrorOr write(UserOrKernelBuffer const& data, size_t); ErrorOr stat(); // NOTE: These ignore the current offset of this file description. @@ -66,10 +66,10 @@ public: bool is_directory() const; File& file() { return *m_file; } - const File& file() const { return *m_file; } + File const& file() const { return *m_file; } bool is_device() const; - const Device* device() const; + Device const* device() const; Device* device(); bool is_tty() const; @@ -77,19 +77,19 @@ public: TTY* tty(); bool is_inode_watcher() const; - const InodeWatcher* inode_watcher() const; + InodeWatcher const* inode_watcher() const; InodeWatcher* inode_watcher(); bool is_master_pty() const; - const MasterPTY* master_pty() const; + MasterPTY const* master_pty() const; MasterPTY* master_pty(); InodeMetadata metadata() const; Inode* inode() { return m_inode.ptr(); } - const Inode* inode() const { return m_inode.ptr(); } + Inode const* inode() const { return m_inode.ptr(); } Custody* custody() { return m_custody.ptr(); } - const Custody* custody() const { return m_custody.ptr(); } + Custody const* custody() const { return m_custody.ptr(); } ErrorOr mmap(Process&, Memory::VirtualRange const&, u64 offset, int prot, bool shared); @@ -103,7 +103,7 @@ public: bool is_socket() const; Socket* socket(); - const Socket* socket() const; + Socket const* socket() const; bool is_fifo() const; FIFO* fifo(); diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp index a4f34c3437e..3d079183be9 100644 --- a/Kernel/FileSystem/Plan9FileSystem.cpp +++ b/Kernel/FileSystem/Plan9FileSystem.cpp @@ -169,7 +169,7 @@ public: ~Message(); Message& operator=(Message&&); - const KBuffer& build(); + KBuffer const& build(); static constexpr size_t max_header_size = 24; @@ -179,7 +179,7 @@ private: { VERIFY(!m_have_been_built); // FIXME: Handle append failure. - (void)m_builder.append(reinterpret_cast(&number), sizeof(number)); + (void)m_builder.append(reinterpret_cast(&number), sizeof(number)); return *this; } @@ -375,7 +375,7 @@ Plan9FS::Message& Plan9FS::Message::operator=(Message&& message) return *this; } -const KBuffer& Plan9FS::Message::build() +KBuffer const& Plan9FS::Message::build() { VERIFY(!m_have_been_built); @@ -472,7 +472,7 @@ void Plan9FS::Plan9FSBlockerSet::try_unblock(Plan9FS::Blocker& blocker) } } -bool Plan9FS::is_complete(const ReceiveCompletion& completion) +bool Plan9FS::is_complete(ReceiveCompletion const& completion) { MutexLocker locker(m_lock); if (m_completions.contains(completion.tag)) { @@ -490,7 +490,7 @@ bool Plan9FS::is_complete(const ReceiveCompletion& completion) ErrorOr Plan9FS::post_message(Message& message, RefPtr completion) { auto const& buffer = message.build(); - const u8* data = buffer.data(); + u8 const* data = buffer.data(); size_t size = buffer.size(); auto& description = file_description(); @@ -750,7 +750,7 @@ ErrorOr Plan9FSInode::read_bytes(off_t offset, size_t size, UserOrKernel return nread; } -ErrorOr Plan9FSInode::write_bytes(off_t offset, size_t size, const UserOrKernelBuffer& data, OpenFileDescription*) +ErrorOr Plan9FSInode::write_bytes(off_t offset, size_t size, UserOrKernelBuffer const& data, OpenFileDescription*) { TRY(ensure_open_for_mode(O_WRONLY)); size = fs().adjust_buffer_size(size); diff --git a/Kernel/FileSystem/Plan9FileSystem.h b/Kernel/FileSystem/Plan9FileSystem.h index df0cf3d9ca5..f992c3a0fb9 100644 --- a/Kernel/FileSystem/Plan9FileSystem.h +++ b/Kernel/FileSystem/Plan9FileSystem.h @@ -93,7 +93,7 @@ private: virtual Type blocker_type() const override { return Type::Plan9FS; } virtual void will_unblock_immediately_without_blocking(UnblockImmediatelyReason) override; - const NonnullRefPtr& completion() const { return m_completion; } + NonnullRefPtr const& completion() const { return m_completion; } u16 tag() const { return m_completion->tag; } bool is_completed() const; @@ -115,7 +115,7 @@ private: virtual StringView class_name() const override { return "Plan9FS"sv; } - bool is_complete(const ReceiveCompletion&); + bool is_complete(ReceiveCompletion const&); ErrorOr post_message(Message&, RefPtr); ErrorOr do_read(u8* buffer, size_t); ErrorOr read_and_dispatch_one_message(); @@ -157,7 +157,7 @@ public: virtual InodeMetadata metadata() const override; virtual ErrorOr flush_metadata() override; virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override; virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; @@ -211,7 +211,7 @@ private: Plan9FS& fs() { return reinterpret_cast(Inode::fs()); } Plan9FS& fs() const { - return const_cast(reinterpret_cast(Inode::fs())); + return const_cast(reinterpret_cast(Inode::fs())); } }; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 5d8a0075299..a6f3b98027c 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -56,7 +56,7 @@ Inode& ProcFS::root_inode() return *m_root_inode; } -ProcFSInode::ProcFSInode(const ProcFS& fs, InodeIndex index) +ProcFSInode::ProcFSInode(ProcFS const& fs, InodeIndex index) : Inode(const_cast(fs), index) { } @@ -93,12 +93,12 @@ ErrorOr ProcFSInode::chown(UserID, GroupID) return EPERM; } -ErrorOr> ProcFSGlobalInode::try_create(const ProcFS& fs, const ProcFSExposedComponent& component) +ErrorOr> ProcFSGlobalInode::try_create(ProcFS const& fs, ProcFSExposedComponent const& component) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSGlobalInode(fs, component)); } -ProcFSGlobalInode::ProcFSGlobalInode(const ProcFS& fs, const ProcFSExposedComponent& component) +ProcFSGlobalInode::ProcFSGlobalInode(ProcFS const& fs, ProcFSExposedComponent const& component) : ProcFSInode(fs, component.component_index()) , m_associated_component(component) { @@ -163,17 +163,17 @@ InodeMetadata ProcFSGlobalInode::metadata() const return metadata; } -ErrorOr ProcFSGlobalInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* fd) +ErrorOr ProcFSGlobalInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription* fd) { return m_associated_component->write_bytes(offset, count, buffer, fd); } -ErrorOr> ProcFSDirectoryInode::try_create(const ProcFS& procfs, const ProcFSExposedComponent& component) +ErrorOr> ProcFSDirectoryInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSDirectoryInode(procfs, component)); } -ProcFSDirectoryInode::ProcFSDirectoryInode(const ProcFS& fs, const ProcFSExposedComponent& component) +ProcFSDirectoryInode::ProcFSDirectoryInode(ProcFS const& fs, ProcFSExposedComponent const& component) : ProcFSGlobalInode(fs, component) { } @@ -204,12 +204,12 @@ ErrorOr> ProcFSDirectoryInode::lookup(StringView name) return component->to_inode(procfs()); } -ErrorOr> ProcFSLinkInode::try_create(const ProcFS& procfs, const ProcFSExposedComponent& component) +ErrorOr> ProcFSLinkInode::try_create(ProcFS const& procfs, ProcFSExposedComponent const& component) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSLinkInode(procfs, component)); } -ProcFSLinkInode::ProcFSLinkInode(const ProcFS& fs, const ProcFSExposedComponent& component) +ProcFSLinkInode::ProcFSLinkInode(ProcFS const& fs, ProcFSExposedComponent const& component) : ProcFSGlobalInode(fs, component) { } @@ -227,23 +227,23 @@ InodeMetadata ProcFSLinkInode::metadata() const return metadata; } -ProcFSProcessAssociatedInode::ProcFSProcessAssociatedInode(const ProcFS& fs, ProcessID associated_pid, InodeIndex determined_index) +ProcFSProcessAssociatedInode::ProcFSProcessAssociatedInode(ProcFS const& fs, ProcessID associated_pid, InodeIndex determined_index) : ProcFSInode(fs, determined_index) , m_pid(associated_pid) { } -ErrorOr ProcFSProcessAssociatedInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr ProcFSProcessAssociatedInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return ENOTSUP; } -ErrorOr> ProcFSProcessDirectoryInode::try_create(const ProcFS& procfs, ProcessID pid) +ErrorOr> ProcFSProcessDirectoryInode::try_create(ProcFS const& procfs, ProcessID pid) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessDirectoryInode(procfs, pid)); } -ProcFSProcessDirectoryInode::ProcFSProcessDirectoryInode(const ProcFS& procfs, ProcessID pid) +ProcFSProcessDirectoryInode::ProcFSProcessDirectoryInode(ProcFS const& procfs, ProcessID pid) : ProcFSProcessAssociatedInode(procfs, pid, SegmentedProcFSIndex::build_segmented_index_for_pid_directory(pid)) { } @@ -312,12 +312,12 @@ ErrorOr> ProcFSProcessDirectoryInode::lookup(StringView nam return ENOENT; } -ErrorOr> ProcFSProcessSubDirectoryInode::try_create(const ProcFS& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid) +ErrorOr> ProcFSProcessSubDirectoryInode::try_create(ProcFS const& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessSubDirectoryInode(procfs, sub_directory_type, pid)); } -ProcFSProcessSubDirectoryInode::ProcFSProcessSubDirectoryInode(const ProcFS& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid) +ProcFSProcessSubDirectoryInode::ProcFSProcessSubDirectoryInode(ProcFS const& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid) : ProcFSProcessAssociatedInode(procfs, pid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(pid, sub_directory_type)) , m_sub_directory_type(sub_directory_type) { @@ -389,34 +389,34 @@ ErrorOr> ProcFSProcessSubDirectoryInode::lookup(StringView } } -ErrorOr> ProcFSProcessPropertyInode::try_create_for_file_description_link(const ProcFS& procfs, unsigned file_description_index, ProcessID pid) +ErrorOr> ProcFSProcessPropertyInode::try_create_for_file_description_link(ProcFS const& procfs, unsigned file_description_index, ProcessID pid) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, file_description_index, pid)); } -ErrorOr> ProcFSProcessPropertyInode::try_create_for_thread_stack(const ProcFS& procfs, ThreadID stack_thread_index, ProcessID pid) +ErrorOr> ProcFSProcessPropertyInode::try_create_for_thread_stack(ProcFS const& procfs, ThreadID stack_thread_index, ProcessID pid) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, stack_thread_index, pid)); } -ErrorOr> ProcFSProcessPropertyInode::try_create_for_pid_property(const ProcFS& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid) +ErrorOr> ProcFSProcessPropertyInode::try_create_for_pid_property(ProcFS const& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid) { return adopt_nonnull_ref_or_enomem(new (nothrow) ProcFSProcessPropertyInode(procfs, main_property_type, pid)); } -ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(const ProcFS& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid) +ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(ProcFS const& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid) : ProcFSProcessAssociatedInode(procfs, pid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(pid, main_property_type)) , m_parent_sub_directory_type(SegmentedProcFSIndex::ProcessSubDirectory::Reserved) { m_possible_data.property_type = main_property_type; } -ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(const ProcFS& procfs, unsigned file_description_index, ProcessID pid) +ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(ProcFS const& procfs, unsigned file_description_index, ProcessID pid) : ProcFSProcessAssociatedInode(procfs, pid, SegmentedProcFSIndex::build_segmented_index_for_file_description(pid, file_description_index)) , m_parent_sub_directory_type(SegmentedProcFSIndex::ProcessSubDirectory::OpenFileDescriptions) { m_possible_data.property_index = file_description_index; } -ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(const ProcFS& procfs, ThreadID thread_stack_index, ProcessID pid) +ProcFSProcessPropertyInode::ProcFSProcessPropertyInode(ProcFS const& procfs, ThreadID thread_stack_index, ProcessID pid) : ProcFSProcessAssociatedInode(procfs, pid, SegmentedProcFSIndex::build_segmented_index_for_thread_stack(pid, thread_stack_index)) , m_parent_sub_directory_type(SegmentedProcFSIndex::ProcessSubDirectory::Stacks) { diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index cc83c98cf0f..96c8e462372 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -48,7 +48,7 @@ public: virtual ~ProcFSInode() override; protected: - ProcFSInode(const ProcFS&, InodeIndex); + ProcFSInode(ProcFS const&, InodeIndex); ProcFS& procfs() { return static_cast(Inode::fs()); } ProcFS const& procfs() const { return static_cast(Inode::fs()); } @@ -68,17 +68,17 @@ class ProcFSGlobalInode : public ProcFSInode { friend class ProcFS; public: - static ErrorOr> try_create(const ProcFS&, const ProcFSExposedComponent&); + static ErrorOr> try_create(ProcFS const&, ProcFSExposedComponent const&); virtual ~ProcFSGlobalInode() override {}; StringView name() const; protected: - ProcFSGlobalInode(const ProcFS&, const ProcFSExposedComponent&); + ProcFSGlobalInode(ProcFS const&, ProcFSExposedComponent const&); // ^Inode virtual ErrorOr attach(OpenFileDescription& description) override final; virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override final; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override final; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override final; virtual void did_seek(OpenFileDescription&, off_t) override final; virtual InodeMetadata metadata() const override; virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; @@ -93,10 +93,10 @@ class ProcFSLinkInode : public ProcFSGlobalInode { friend class ProcFS; public: - static ErrorOr> try_create(const ProcFS&, const ProcFSExposedComponent&); + static ErrorOr> try_create(ProcFS const&, ProcFSExposedComponent const&); protected: - ProcFSLinkInode(const ProcFS&, const ProcFSExposedComponent&); + ProcFSLinkInode(ProcFS const&, ProcFSExposedComponent const&); virtual InodeMetadata metadata() const override; }; @@ -104,11 +104,11 @@ class ProcFSDirectoryInode final : public ProcFSGlobalInode { friend class ProcFS; public: - static ErrorOr> try_create(const ProcFS&, const ProcFSExposedComponent&); + static ErrorOr> try_create(ProcFS const&, ProcFSExposedComponent const&); virtual ~ProcFSDirectoryInode() override; protected: - ProcFSDirectoryInode(const ProcFS&, const ProcFSExposedComponent&); + ProcFSDirectoryInode(ProcFS const&, ProcFSExposedComponent const&); // ^Inode virtual InodeMetadata metadata() const override; virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; @@ -119,11 +119,11 @@ class ProcFSProcessAssociatedInode : public ProcFSInode { friend class ProcFS; protected: - ProcFSProcessAssociatedInode(const ProcFS&, ProcessID, InodeIndex); + ProcFSProcessAssociatedInode(ProcFS const&, ProcessID, InodeIndex); ProcessID associated_pid() const { return m_pid; } // ^Inode - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override final; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override final; private: const ProcessID m_pid; @@ -133,10 +133,10 @@ class ProcFSProcessDirectoryInode final : public ProcFSProcessAssociatedInode { friend class ProcFS; public: - static ErrorOr> try_create(const ProcFS&, ProcessID); + static ErrorOr> try_create(ProcFS const&, ProcessID); private: - ProcFSProcessDirectoryInode(const ProcFS&, ProcessID); + ProcFSProcessDirectoryInode(ProcFS const&, ProcessID); // ^Inode virtual ErrorOr attach(OpenFileDescription& description) override; virtual void did_seek(OpenFileDescription&, off_t) override { } @@ -150,10 +150,10 @@ class ProcFSProcessSubDirectoryInode final : public ProcFSProcessAssociatedInode friend class ProcFS; public: - static ErrorOr> try_create(const ProcFS&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); + static ErrorOr> try_create(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); private: - ProcFSProcessSubDirectoryInode(const ProcFS&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); + ProcFSProcessSubDirectoryInode(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); // ^Inode virtual ErrorOr attach(OpenFileDescription& description) override; virtual void did_seek(OpenFileDescription&, off_t) override; @@ -169,14 +169,14 @@ class ProcFSProcessPropertyInode final : public ProcFSProcessAssociatedInode { friend class ProcFS; public: - static ErrorOr> try_create_for_file_description_link(const ProcFS&, unsigned, ProcessID); - static ErrorOr> try_create_for_thread_stack(const ProcFS&, ThreadID, ProcessID); - static ErrorOr> try_create_for_pid_property(const ProcFS&, SegmentedProcFSIndex::MainProcessProperty, ProcessID); + static ErrorOr> try_create_for_file_description_link(ProcFS const&, unsigned, ProcessID); + static ErrorOr> try_create_for_thread_stack(ProcFS const&, ThreadID, ProcessID); + static ErrorOr> try_create_for_pid_property(ProcFS const&, SegmentedProcFSIndex::MainProcessProperty, ProcessID); private: - ProcFSProcessPropertyInode(const ProcFS&, SegmentedProcFSIndex::MainProcessProperty, ProcessID); - ProcFSProcessPropertyInode(const ProcFS&, ThreadID, ProcessID); - ProcFSProcessPropertyInode(const ProcFS&, unsigned, ProcessID); + ProcFSProcessPropertyInode(ProcFS const&, SegmentedProcFSIndex::MainProcessProperty, ProcessID); + ProcFSProcessPropertyInode(ProcFS const&, ThreadID, ProcessID); + ProcFSProcessPropertyInode(ProcFS const&, unsigned, ProcessID); // ^Inode virtual ErrorOr attach(OpenFileDescription& description) override; virtual void did_seek(OpenFileDescription&, off_t) override; diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index 0b44c20d687..e4b54416ea8 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -37,7 +37,7 @@ unsigned TmpFS::next_inode_index() return m_next_inode_index++; } -TmpFSInode::TmpFSInode(TmpFS& fs, const InodeMetadata& metadata, WeakPtr parent) +TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr parent) : Inode(fs, fs.next_inode_index()) , m_metadata(metadata) , m_parent(move(parent)) @@ -106,7 +106,7 @@ ErrorOr TmpFSInode::read_bytes(off_t offset, size_t size, UserOrKernelBu return size; } -ErrorOr TmpFSInode::write_bytes(off_t offset, size_t size, const UserOrKernelBuffer& buffer, OpenFileDescription*) +ErrorOr TmpFSInode::write_bytes(off_t offset, size_t size, UserOrKernelBuffer const& buffer, OpenFileDescription*) { MutexLocker locker(m_inode_lock); VERIFY(!is_directory()); diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS.h index 1166eac6e95..1ca57547433 100644 --- a/Kernel/FileSystem/TmpFS.h +++ b/Kernel/FileSystem/TmpFS.h @@ -44,7 +44,7 @@ public: virtual ~TmpFSInode() override; TmpFS& fs() { return static_cast(Inode::fs()); } - const TmpFS& fs() const { return static_cast(Inode::fs()); } + TmpFS const& fs() const { return static_cast(Inode::fs()); } // ^Inode virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; @@ -52,7 +52,7 @@ public: virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr flush_metadata() override; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr remove_child(StringView name) override; @@ -64,7 +64,7 @@ public: virtual ErrorOr set_mtime(time_t) override; private: - TmpFSInode(TmpFS& fs, const InodeMetadata& metadata, WeakPtr parent); + TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr parent); static ErrorOr> try_create(TmpFS&, InodeMetadata const& metadata, WeakPtr parent); static ErrorOr> try_create_root(TmpFS&); diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index e2c464a86df..3b20e78859a 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -571,7 +571,7 @@ ErrorOr VirtualFileSystem::chown(StringView path, UserID a_uid, GroupID a_ return chown(custody, a_uid, a_gid); } -static bool hard_link_allowed(const Inode& inode) +static bool hard_link_allowed(Inode const& inode) { auto metadata = inode.metadata(); @@ -673,7 +673,7 @@ ErrorOr VirtualFileSystem::symlink(StringView target, StringView linkpath, auto inode = TRY(parent_inode.create_child(basename, S_IFLNK | 0644, 0, current_process.euid(), current_process.egid())); - auto target_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast((const u8*)target.characters_without_null_termination())); + auto target_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast((u8 const*)target.characters_without_null_termination())); TRY(inode->write_bytes(0, target.length(), target_buffer, nullptr)); return {}; } @@ -838,7 +838,7 @@ ErrorOr> VirtualFileSystem::resolve_path(StringView path, return custody; } -static bool safe_to_follow_symlink(const Inode& inode, const InodeMetadata& parent_metadata) +static bool safe_to_follow_symlink(Inode const& inode, InodeMetadata const& parent_metadata) { auto metadata = inode.metadata(); if (Process::current().euid() == metadata.uid) diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index 61ebc2ce12b..169439e4c9a 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -68,7 +68,7 @@ public: ErrorOr mknod(StringView path, mode_t, dev_t, Custody& base); ErrorOr> open_directory(StringView path, Custody& base); - ErrorOr for_each_mount(Function(const Mount&)>) const; + ErrorOr for_each_mount(Function(Mount const&)>) const; InodeIdentifier root_inode_id() const; diff --git a/Kernel/Firmware/ACPI/Parser.cpp b/Kernel/Firmware/ACPI/Parser.cpp index 26811aa91fd..41ebbecd12a 100644 --- a/Kernel/Firmware/ACPI/Parser.cpp +++ b/Kernel/Firmware/ACPI/Parser.cpp @@ -117,7 +117,7 @@ void Parser::enumerate_static_tables(Function search_table_in_xsdt(PhysicalAddress xsdt, StringView signature); static Optional search_table_in_rsdt(PhysicalAddress rsdt, StringView signature); -static bool validate_table(const Structures::SDTHeader&, size_t length); +static bool validate_table(Structures::SDTHeader const&, size_t length); UNMAP_AFTER_INIT void Parser::locate_static_data() { @@ -144,7 +144,7 @@ UNMAP_AFTER_INIT Optional Parser::find_table(StringView signatu return {}; } -bool Parser::handle_irq(const RegisterState&) +bool Parser::handle_irq(RegisterState const&) { TODO(); } @@ -209,7 +209,7 @@ bool Parser::can_reboot() return m_hardware_flags.reset_register_supported; } -void Parser::access_generic_address(const Structures::GenericAddressStructure& structure, u32 value) +void Parser::access_generic_address(Structures::GenericAddressStructure const& structure, u32 value) { switch ((GenericAddressStructure::AddressSpace)structure.address_space) { case GenericAddressStructure::AddressSpace::SystemIO: { @@ -334,7 +334,7 @@ UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table() dmesgln("ACPI: Main Description Table valid? {}", validate_table(*sdt, length)); if (m_xsdt_supported) { - auto& xsdt = (const Structures::XSDT&)*sdt; + auto& xsdt = (Structures::XSDT const&)*sdt; dmesgln("ACPI: Using XSDT, enumerating tables @ {}", m_main_system_description_table); dmesgln("ACPI: XSDT revision {}, total length: {}", revision, length); dbgln_if(ACPI_DEBUG, "ACPI: XSDT pointer @ {}", VirtualAddress { &xsdt }); @@ -343,7 +343,7 @@ UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table() m_sdt_pointers.append(PhysicalAddress(xsdt.table_ptrs[i])); } } else { - auto& rsdt = (const Structures::RSDT&)*sdt; + auto& rsdt = (Structures::RSDT const&)*sdt; dmesgln("ACPI: Using RSDT, enumerating tables @ {}", m_main_system_description_table); dmesgln("ACPI: RSDT revision {}, total length: {}", revision, length); dbgln_if(ACPI_DEBUG, "ACPI: RSDT pointer @ V{}", &rsdt); @@ -382,10 +382,10 @@ UNMAP_AFTER_INIT Parser::Parser(PhysicalAddress rsdp, PhysicalAddress fadt, u8 i locate_static_data(); } -static bool validate_table(const Structures::SDTHeader& v_header, size_t length) +static bool validate_table(Structures::SDTHeader const& v_header, size_t length) { u8 checksum = 0; - auto* sdt = (const u8*)&v_header; + auto* sdt = (u8 const*)&v_header; for (size_t i = 0; i < length; i++) checksum += sdt[i]; if (checksum == 0) diff --git a/Kernel/Firmware/ACPI/Parser.h b/Kernel/Firmware/ACPI/Parser.h index 77ba39b5904..05356fd73ef 100644 --- a/Kernel/Firmware/ACPI/Parser.h +++ b/Kernel/Firmware/ACPI/Parser.h @@ -53,7 +53,7 @@ public: static void must_initialize(PhysicalAddress rsdp, PhysicalAddress fadt, u8 irq_number); virtual StringView purpose() const override { return "ACPI Parser"sv; } - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; Optional find_table(StringView signature); @@ -75,8 +75,8 @@ public: return m_x86_specific_flags.keyboard_8042; } - const FADTFlags::HardwareFeatures& hardware_features() const { return m_hardware_flags; } - const FADTFlags::x86_Specific_Flags& x86_specific_flags() const { return m_x86_specific_flags; } + FADTFlags::HardwareFeatures const& hardware_features() const { return m_hardware_flags; } + FADTFlags::x86_Specific_Flags const& x86_specific_flags() const { return m_x86_specific_flags; } ~Parser() = default; @@ -91,7 +91,7 @@ private: void process_fadt_data(); bool validate_reset_register(Memory::TypedMapping const&); - void access_generic_address(const Structures::GenericAddressStructure&, u32 value); + void access_generic_address(Structures::GenericAddressStructure const&, u32 value); PhysicalAddress m_rsdp; PhysicalAddress m_main_system_description_table; diff --git a/Kernel/Firmware/MultiProcessor/Parser.cpp b/Kernel/Firmware/MultiProcessor/Parser.cpp index 933c35b5b31..1883afc7753 100644 --- a/Kernel/Firmware/MultiProcessor/Parser.cpp +++ b/Kernel/Firmware/MultiProcessor/Parser.cpp @@ -56,14 +56,14 @@ UNMAP_AFTER_INIT void MultiProcessorParser::parse_configuration_table() entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::ProcessorEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::Bus): - MUST(m_bus_entries.try_append(*(const MultiProcessor::BusEntry*)entry)); + MUST(m_bus_entries.try_append(*(MultiProcessor::BusEntry const*)entry)); entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::BusEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::IOAPIC): entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::IOAPICEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::IO_Interrupt_Assignment): - MUST(m_io_interrupt_assignment_entries.try_append(*(const MultiProcessor::IOInterruptAssignmentEntry*)entry)); + MUST(m_io_interrupt_assignment_entries.try_append(*(MultiProcessor::IOInterruptAssignmentEntry const*)entry)); entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::IOInterruptAssignmentEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::Local_Interrupt_Assignment): diff --git a/Kernel/FutexQueue.cpp b/Kernel/FutexQueue.cpp index 6445c93a323..c7b6222e3eb 100644 --- a/Kernel/FutexQueue.cpp +++ b/Kernel/FutexQueue.cpp @@ -30,7 +30,7 @@ bool FutexQueue::should_add_blocker(Thread::Blocker& b, void*) return true; } -u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function& get_target_queue, u32 requeue_count, bool& is_empty, bool& is_empty_target) +u32 FutexQueue::wake_n_requeue(u32 wake_count, Function const& get_target_queue, u32 requeue_count, bool& is_empty, bool& is_empty_target) { is_empty_target = false; SpinlockLocker lock(m_lock); @@ -87,7 +87,7 @@ u32 FutexQueue::wake_n_requeue(u32 wake_count, const Function& ge return did_wake + did_requeue; } -u32 FutexQueue::wake_n(u32 wake_count, const Optional& bitset, bool& is_empty) +u32 FutexQueue::wake_n(u32 wake_count, Optional const& bitset, bool& is_empty) { if (wake_count == 0) { is_empty = false; diff --git a/Kernel/FutexQueue.h b/Kernel/FutexQueue.h index 28a3a600c90..ded3a93c385 100644 --- a/Kernel/FutexQueue.h +++ b/Kernel/FutexQueue.h @@ -21,12 +21,12 @@ public: FutexQueue(); virtual ~FutexQueue(); - u32 wake_n_requeue(u32, const Function&, u32, bool&, bool&); - u32 wake_n(u32, const Optional&, bool&); + u32 wake_n_requeue(u32, Function const&, u32, bool&, bool&); + u32 wake_n(u32, Optional const&, bool&); u32 wake_all(bool&); template - Thread::BlockResult wait_on(const Thread::BlockTimeout& timeout, Args&&... args) + Thread::BlockResult wait_on(Thread::BlockTimeout const& timeout, Args&&... args) { return Thread::current()->block(timeout, *this, forward(args)...); } diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index 08be0a82ec5..ea0c3331783 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -84,7 +84,7 @@ private: virtual ErrorOr try_generate(KBufferBuilder& builder) override { auto array = TRY(JsonArraySerializer<>::try_create(builder)); - TRY(arp_table().with([&](const auto& table) -> ErrorOr { + TRY(arp_table().with([&](auto const& table) -> ErrorOr { for (auto& it : table) { auto obj = TRY(array.add_object()); auto mac_address = it.value.to_string().release_value_but_fixme_should_propagate_errors(); @@ -195,18 +195,18 @@ private: class ProcFSNetworkDirectory : public ProcFSExposedDirectory { public: - static NonnullRefPtr must_create(const ProcFSRootDirectory& parent_directory); + static NonnullRefPtr must_create(ProcFSRootDirectory const& parent_directory); private: - ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_directory); + ProcFSNetworkDirectory(ProcFSRootDirectory const& parent_directory); }; class ProcFSSystemDirectory : public ProcFSExposedDirectory { public: - static NonnullRefPtr must_create(const ProcFSRootDirectory& parent_directory); + static NonnullRefPtr must_create(ProcFSRootDirectory const& parent_directory); private: - ProcFSSystemDirectory(const ProcFSRootDirectory& parent_directory); + ProcFSSystemDirectory(ProcFSRootDirectory const& parent_directory); }; UNMAP_AFTER_INIT NonnullRefPtr ProcFSAdapters::must_create() @@ -230,7 +230,7 @@ UNMAP_AFTER_INIT NonnullRefPtr ProcFSUDP::must_create() return adopt_ref_if_nonnull(new (nothrow) ProcFSUDP).release_nonnull(); } -UNMAP_AFTER_INIT NonnullRefPtr ProcFSNetworkDirectory::must_create(const ProcFSRootDirectory& parent_directory) +UNMAP_AFTER_INIT NonnullRefPtr ProcFSNetworkDirectory::must_create(ProcFSRootDirectory const& parent_directory) { auto directory = adopt_ref(*new (nothrow) ProcFSNetworkDirectory(parent_directory)); directory->m_components.append(ProcFSAdapters::must_create()); @@ -261,14 +261,14 @@ UNMAP_AFTER_INIT ProcFSUDP::ProcFSUDP() : ProcFSGlobalInformation("udp"sv) { } -UNMAP_AFTER_INIT ProcFSNetworkDirectory::ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_directory) +UNMAP_AFTER_INIT ProcFSNetworkDirectory::ProcFSNetworkDirectory(ProcFSRootDirectory const& parent_directory) : ProcFSExposedDirectory("net"sv, parent_directory) { } class ProcFSDumpKmallocStacks : public ProcFSSystemBoolean { public: - static NonnullRefPtr must_create(const ProcFSSystemDirectory&); + static NonnullRefPtr must_create(ProcFSSystemDirectory const&); virtual bool value() const override { MutexLocker locker(m_lock); @@ -287,7 +287,7 @@ private: class ProcFSUBSanDeadly : public ProcFSSystemBoolean { public: - static NonnullRefPtr must_create(const ProcFSSystemDirectory&); + static NonnullRefPtr must_create(ProcFSSystemDirectory const&); virtual bool value() const override { return AK::UBSanitizer::g_ubsan_is_deadly; } virtual void set_value(bool new_value) override { AK::UBSanitizer::g_ubsan_is_deadly = new_value; } @@ -298,7 +298,7 @@ private: class ProcFSCapsLockRemap : public ProcFSSystemBoolean { public: - static NonnullRefPtr must_create(const ProcFSSystemDirectory&); + static NonnullRefPtr must_create(ProcFSSystemDirectory const&); virtual bool value() const override { MutexLocker locker(m_lock); @@ -315,15 +315,15 @@ private: mutable Mutex m_lock; }; -UNMAP_AFTER_INIT NonnullRefPtr ProcFSDumpKmallocStacks::must_create(const ProcFSSystemDirectory&) +UNMAP_AFTER_INIT NonnullRefPtr ProcFSDumpKmallocStacks::must_create(ProcFSSystemDirectory const&) { return adopt_ref_if_nonnull(new (nothrow) ProcFSDumpKmallocStacks).release_nonnull(); } -UNMAP_AFTER_INIT NonnullRefPtr ProcFSUBSanDeadly::must_create(const ProcFSSystemDirectory&) +UNMAP_AFTER_INIT NonnullRefPtr ProcFSUBSanDeadly::must_create(ProcFSSystemDirectory const&) { return adopt_ref_if_nonnull(new (nothrow) ProcFSUBSanDeadly).release_nonnull(); } -UNMAP_AFTER_INIT NonnullRefPtr ProcFSCapsLockRemap::must_create(const ProcFSSystemDirectory&) +UNMAP_AFTER_INIT NonnullRefPtr ProcFSCapsLockRemap::must_create(ProcFSSystemDirectory const&) { return adopt_ref_if_nonnull(new (nothrow) ProcFSCapsLockRemap).release_nonnull(); } @@ -458,7 +458,7 @@ private: auto json = TRY(JsonObjectSerializer<>::try_create(builder)); // Keep this in sync with CProcessStatistics. - auto build_process = [&](JsonArraySerializer& array, const Process& process) -> ErrorOr { + auto build_process = [&](JsonArraySerializer& array, Process const& process) -> ErrorOr { auto process_object = TRY(array.add_object()); if (process.is_user_process()) { @@ -944,7 +944,7 @@ UNMAP_AFTER_INIT ProcFSKernelBase::ProcFSKernelBase() { } -UNMAP_AFTER_INIT NonnullRefPtr ProcFSSystemDirectory::must_create(const ProcFSRootDirectory& parent_directory) +UNMAP_AFTER_INIT NonnullRefPtr ProcFSSystemDirectory::must_create(ProcFSRootDirectory const& parent_directory) { auto directory = adopt_ref(*new (nothrow) ProcFSSystemDirectory(parent_directory)); directory->m_components.append(ProcFSDumpKmallocStacks::must_create(directory)); @@ -953,7 +953,7 @@ UNMAP_AFTER_INIT NonnullRefPtr ProcFSSystemDirectory::mus return directory; } -UNMAP_AFTER_INIT ProcFSSystemDirectory::ProcFSSystemDirectory(const ProcFSRootDirectory& parent_directory) +UNMAP_AFTER_INIT ProcFSSystemDirectory::ProcFSSystemDirectory(ProcFSRootDirectory const& parent_directory) : ProcFSExposedDirectory("sys"sv, parent_directory) { } diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp index c9b16957a09..853abe0c761 100644 --- a/Kernel/Graphics/FramebufferDevice.cpp +++ b/Kernel/Graphics/FramebufferDevice.cpp @@ -19,7 +19,7 @@ namespace Kernel { -NonnullRefPtr FramebufferDevice::create(const GenericGraphicsAdapter& adapter, PhysicalAddress paddr, size_t width, size_t height, size_t pitch) +NonnullRefPtr FramebufferDevice::create(GenericGraphicsAdapter const& adapter, PhysicalAddress paddr, size_t width, size_t height, size_t pitch) { auto framebuffer_device_or_error = DeviceManagement::try_create_device(adapter, paddr, width, height, pitch); // FIXME: Find a way to propagate errors @@ -112,7 +112,7 @@ UNMAP_AFTER_INIT ErrorOr FramebufferDevice::try_to_initialize() return {}; } -UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(const GenericGraphicsAdapter& adapter, PhysicalAddress addr, size_t width, size_t height, size_t pitch) +UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(GenericGraphicsAdapter const& adapter, PhysicalAddress addr, size_t width, size_t height, size_t pitch) : GenericFramebufferDevice(adapter) , m_framebuffer_address(addr) , m_framebuffer_pitch(pitch) diff --git a/Kernel/Graphics/FramebufferDevice.h b/Kernel/Graphics/FramebufferDevice.h index 207155db760..acdc4e3ec8e 100644 --- a/Kernel/Graphics/FramebufferDevice.h +++ b/Kernel/Graphics/FramebufferDevice.h @@ -20,7 +20,7 @@ class FramebufferDevice final : public GenericFramebufferDevice { friend class DeviceManagement; public: - static NonnullRefPtr create(const GenericGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t); + static NonnullRefPtr create(GenericGraphicsAdapter const&, PhysicalAddress, size_t, size_t, size_t); virtual ErrorOr mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override; @@ -50,7 +50,7 @@ private: virtual ErrorOr flush_head_buffer(size_t head) override; virtual ErrorOr flush_rectangle(size_t head, FBRect const&) override; - FramebufferDevice(const GenericGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t); + FramebufferDevice(GenericGraphicsAdapter const&, PhysicalAddress, size_t, size_t, size_t); PhysicalAddress m_framebuffer_address; size_t m_framebuffer_pitch { 0 }; diff --git a/Kernel/Graphics/GenericFramebufferDevice.cpp b/Kernel/Graphics/GenericFramebufferDevice.cpp index 6d622542ef3..9d57383965e 100644 --- a/Kernel/Graphics/GenericFramebufferDevice.cpp +++ b/Kernel/Graphics/GenericFramebufferDevice.cpp @@ -149,7 +149,7 @@ ErrorOr GenericFramebufferDevice::ioctl(OpenFileDescription&, unsigned req }; } -GenericFramebufferDevice::GenericFramebufferDevice(const GenericGraphicsAdapter& adapter) +GenericFramebufferDevice::GenericFramebufferDevice(GenericGraphicsAdapter const& adapter) : BlockDevice(29, GraphicsManagement::the().allocate_minor_device_number()) , m_graphics_adapter(adapter) { diff --git a/Kernel/Graphics/GenericFramebufferDevice.h b/Kernel/Graphics/GenericFramebufferDevice.h index 0c26985b759..1d230d44511 100644 --- a/Kernel/Graphics/GenericFramebufferDevice.h +++ b/Kernel/Graphics/GenericFramebufferDevice.h @@ -33,11 +33,11 @@ public: private: // ^File - virtual bool can_read(const OpenFileDescription&, u64) const override final { return true; } - virtual bool can_write(const OpenFileDescription&, u64) const override final { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override final { return true; } + virtual bool can_write(OpenFileDescription const&, u64) const override final { return true; } virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } protected: virtual bool multihead_support() const = 0; @@ -61,7 +61,7 @@ protected: ErrorOr verify_head_index(int head_index) const; - GenericFramebufferDevice(const GenericGraphicsAdapter&); + GenericFramebufferDevice(GenericGraphicsAdapter const&); mutable WeakPtr m_graphics_adapter; mutable Spinlock m_flushing_lock; mutable Spinlock m_resolution_lock; diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp index 3c3fae30ba4..a158d2f79b0 100644 --- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp +++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp @@ -88,7 +88,7 @@ static Graphics::Modesetting calculate_modesetting_from_edid(EDID::Parser& edid, return mode; } -static bool check_pll_settings(const IntelNativeGraphicsAdapter::PLLSettings& settings, size_t reference_clock, const IntelNativeGraphicsAdapter::PLLMaxSettings& limits) +static bool check_pll_settings(IntelNativeGraphicsAdapter::PLLSettings const& settings, size_t reference_clock, IntelNativeGraphicsAdapter::PLLMaxSettings const& limits) { if (settings.n < limits.n.min || settings.n > limits.n.max) { dbgln_if(INTEL_GRAPHICS_DEBUG, "N is invalid {}", settings.n); @@ -145,7 +145,7 @@ static size_t find_absolute_difference(u64 target_frequency, u64 checked_frequen return checked_frequency - target_frequency; } -Optional IntelNativeGraphicsAdapter::create_pll_settings(u64 target_frequency, u64 reference_clock, const PLLMaxSettings& limits) +Optional IntelNativeGraphicsAdapter::create_pll_settings(u64 target_frequency, u64 reference_clock, PLLMaxSettings const& limits) { IntelNativeGraphicsAdapter::PLLSettings settings; IntelNativeGraphicsAdapter::PLLSettings best_settings; @@ -280,7 +280,7 @@ void IntelNativeGraphicsAdapter::write_to_register(IntelGraphics::RegisterIndex VERIFY(m_registers_region); SpinlockLocker lock(m_registers_lock); dbgln_if(INTEL_GRAPHICS_DEBUG, "Intel Graphics {}: Write to {} value of {:x}", pci_address(), convert_register_index_to_string(index), value); - auto* reg = (volatile u32*)m_registers_region->vaddr().offset(index).as_ptr(); + auto* reg = (u32 volatile*)m_registers_region->vaddr().offset(index).as_ptr(); *reg = value; } u32 IntelNativeGraphicsAdapter::read_from_register(IntelGraphics::RegisterIndex index) const @@ -288,7 +288,7 @@ u32 IntelNativeGraphicsAdapter::read_from_register(IntelGraphics::RegisterIndex VERIFY(m_control_lock.is_locked()); VERIFY(m_registers_region); SpinlockLocker lock(m_registers_lock); - auto* reg = (volatile u32*)m_registers_region->vaddr().offset(index).as_ptr(); + auto* reg = (u32 volatile*)m_registers_region->vaddr().offset(index).as_ptr(); u32 value = *reg; dbgln_if(INTEL_GRAPHICS_DEBUG, "Intel Graphics {}: Read from {} value of {:x}", pci_address(), convert_register_index_to_string(index), value); return value; @@ -460,7 +460,7 @@ bool IntelNativeGraphicsAdapter::set_crt_resolution(size_t width, size_t height) return true; } -void IntelNativeGraphicsAdapter::set_display_timings(const Graphics::Modesetting& modesetting) +void IntelNativeGraphicsAdapter::set_display_timings(Graphics::Modesetting const& modesetting) { VERIFY(m_control_lock.is_locked()); VERIFY(m_modeset_lock.is_locked()); @@ -589,7 +589,7 @@ void IntelNativeGraphicsAdapter::enable_primary_plane(PhysicalAddress fb_address write_to_register(IntelGraphics::RegisterIndex::DisplayPlaneAControl, (read_from_register(IntelGraphics::RegisterIndex::DisplayPlaneAControl) & (~(0b1111 << 26))) | (0b0110 << 26) | (1 << 31)); } -void IntelNativeGraphicsAdapter::set_dpll_registers(const PLLSettings& settings) +void IntelNativeGraphicsAdapter::set_dpll_registers(PLLSettings const& settings) { VERIFY(m_control_lock.is_locked()); VERIFY(m_modeset_lock.is_locked()); @@ -599,7 +599,7 @@ void IntelNativeGraphicsAdapter::set_dpll_registers(const PLLSettings& settings) write_to_register(IntelGraphics::RegisterIndex::DPLLControlA, read_from_register(IntelGraphics::RegisterIndex::DPLLControlA) & ~0x80000000); } -void IntelNativeGraphicsAdapter::enable_dpll_without_vga(const PLLSettings& settings, size_t dac_multiplier) +void IntelNativeGraphicsAdapter::enable_dpll_without_vga(PLLSettings const& settings, size_t dac_multiplier) { VERIFY(m_control_lock.is_locked()); VERIFY(m_modeset_lock.is_locked()); diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h index bf886a6ffbf..825f443b976 100644 --- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h +++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h @@ -137,10 +137,10 @@ private: void disable_pipe_b(); void disable_dpll(); - void set_dpll_registers(const PLLSettings&); + void set_dpll_registers(PLLSettings const&); - void enable_dpll_without_vga(const PLLSettings&, size_t dac_multiplier); - void set_display_timings(const Graphics::Modesetting&); + void enable_dpll_without_vga(PLLSettings const&, size_t dac_multiplier); + void set_display_timings(Graphics::Modesetting const&); void enable_pipe_a(); void set_framebuffer_parameters(size_t, size_t); void enable_primary_plane(PhysicalAddress fb_address, size_t stride); @@ -158,7 +158,7 @@ private: void gmbus_read(unsigned address, u8* buf, size_t length); bool gmbus_wait_for(GMBusStatus desired_status, Optional milliseconds_timeout); - Optional create_pll_settings(u64 target_frequency, u64 reference_clock, const PLLMaxSettings&); + Optional create_pll_settings(u64 target_frequency, u64 reference_clock, PLLMaxSettings const&); Spinlock m_control_lock; Spinlock m_modeset_lock; diff --git a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h index 038d83e741c..de72726084b 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h +++ b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h @@ -112,10 +112,10 @@ public: OwnPtr m_transfer_buffer_region; }; - virtual bool can_read(const OpenFileDescription&, u64) const override { return true; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual bool can_read(OpenFileDescription const&, u64) const override { return true; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; } - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; } + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; } virtual StringView class_name() const override { return "virgl3d"; } virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; diff --git a/Kernel/Heap/Heap.h b/Kernel/Heap/Heap.h index 147e37ac4ff..ef50d23636b 100644 --- a/Kernel/Heap/Heap.h +++ b/Kernel/Heap/Heap.h @@ -33,9 +33,9 @@ class Heap { { return (AllocationHeader*)((((u8*)ptr) - sizeof(AllocationHeader))); } - ALWAYS_INLINE const AllocationHeader* allocation_header(const void* ptr) const + ALWAYS_INLINE AllocationHeader const* allocation_header(void const* ptr) const { - return (const AllocationHeader*)((((const u8*)ptr) - sizeof(AllocationHeader))); + return (AllocationHeader const*)((((u8 const*)ptr) - sizeof(AllocationHeader))); } static size_t calculate_chunks(size_t memory_size) @@ -120,12 +120,12 @@ public: } } - bool contains(const void* ptr) const + bool contains(void const* ptr) const { - const auto* a = allocation_header(ptr); - if ((const u8*)a < m_chunks) + auto const* a = allocation_header(ptr); + if ((u8 const*)a < m_chunks) return false; - if ((const u8*)ptr >= m_chunks + m_total_chunks * CHUNK_SIZE) + if ((u8 const*)ptr >= m_chunks + m_total_chunks * CHUNK_SIZE) return false; return true; } diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index be0e9ab66af..d0f5fdf63b1 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -520,7 +520,7 @@ void* operator new(size_t size) return ptr; } -void* operator new(size_t size, const std::nothrow_t&) noexcept +void* operator new(size_t size, std::nothrow_t const&) noexcept { return kmalloc(size); } @@ -532,7 +532,7 @@ void* operator new(size_t size, std::align_val_t al) return ptr; } -void* operator new(size_t size, std::align_val_t al, const std::nothrow_t&) noexcept +void* operator new(size_t size, std::align_val_t al, std::nothrow_t const&) noexcept { return kmalloc_aligned(size, (size_t)al); } @@ -544,7 +544,7 @@ void* operator new[](size_t size) return ptr; } -void* operator new[](size_t size, const std::nothrow_t&) noexcept +void* operator new[](size_t size, std::nothrow_t const&) noexcept { return kmalloc(size); } diff --git a/Kernel/Heap/kmalloc.h b/Kernel/Heap/kmalloc.h index f7c62fc046f..adb698fb185 100644 --- a/Kernel/Heap/kmalloc.h +++ b/Kernel/Heap/kmalloc.h @@ -21,7 +21,7 @@ public: VERIFY(ptr); \ return ptr; \ } \ - [[nodiscard]] void* operator new(size_t, const std::nothrow_t&) noexcept { return kmalloc_aligned(sizeof(type), alignment); } \ + [[nodiscard]] void* operator new(size_t, std::nothrow_t const&) noexcept { return kmalloc_aligned(sizeof(type), alignment); } \ void operator delete(void* ptr) noexcept { kfree_aligned(ptr); } \ \ private: @@ -56,9 +56,9 @@ inline void* operator new(size_t, void* p) { return p; } inline void* operator new[](size_t, void* p) { return p; } [[nodiscard]] void* operator new(size_t size); -[[nodiscard]] void* operator new(size_t size, const std::nothrow_t&) noexcept; +[[nodiscard]] void* operator new(size_t size, std::nothrow_t const&) noexcept; [[nodiscard]] void* operator new(size_t size, std::align_val_t); -[[nodiscard]] void* operator new(size_t size, std::align_val_t, const std::nothrow_t&) noexcept; +[[nodiscard]] void* operator new(size_t size, std::align_val_t, std::nothrow_t const&) noexcept; void operator delete(void* ptr) noexcept DISALLOW("All deletes in the kernel should have a known size."); void operator delete(void* ptr, size_t) noexcept; @@ -66,7 +66,7 @@ void operator delete(void* ptr, std::align_val_t) noexcept DISALLOW("All deletes void operator delete(void* ptr, size_t, std::align_val_t) noexcept; [[nodiscard]] void* operator new[](size_t size); -[[nodiscard]] void* operator new[](size_t size, const std::nothrow_t&) noexcept; +[[nodiscard]] void* operator new[](size_t size, std::nothrow_t const&) noexcept; void operator delete[](void* ptrs) noexcept DISALLOW("All deletes in the kernel should have a known size."); void operator delete[](void* ptr, size_t) noexcept; diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp index b1244e2ab8e..e54437c1fd9 100644 --- a/Kernel/Interrupts/APIC.cpp +++ b/Kernel/Interrupts/APIC.cpp @@ -75,7 +75,7 @@ public: handler->register_interrupt_handler(); } - virtual bool handle_interrupt(const RegisterState&) override; + virtual bool handle_interrupt(RegisterState const&) override; virtual bool eoi() override; @@ -106,7 +106,7 @@ public: handler->register_interrupt_handler(); } - virtual bool handle_interrupt(const RegisterState&) override; + virtual bool handle_interrupt(RegisterState const&) override; virtual bool eoi() override; @@ -145,7 +145,7 @@ PhysicalAddress APIC::get_base() return PhysicalAddress(base & 0xfffff000); } -void APIC::set_base(const PhysicalAddress& base) +void APIC::set_base(PhysicalAddress const& base) { MSR msr(APIC_BASE_MSR); u64 flags = 1 << 11; @@ -160,7 +160,7 @@ void APIC::write_register(u32 offset, u32 value) MSR msr(APIC_REGS_MSR_BASE + (offset >> 4)); msr.set(value); } else { - *reinterpret_cast(m_apic_base->vaddr().offset(offset).as_ptr()) = value; + *reinterpret_cast(m_apic_base->vaddr().offset(offset).as_ptr()) = value; } } @@ -170,7 +170,7 @@ u32 APIC::read_register(u32 offset) MSR msr(APIC_REGS_MSR_BASE + (offset >> 4)); return (u32)msr.get(); } - return *reinterpret_cast(m_apic_base->vaddr().offset(offset).as_ptr()); + return *reinterpret_cast(m_apic_base->vaddr().offset(offset).as_ptr()); } void APIC::set_lvt(u32 offset, u8 interrupt) @@ -190,7 +190,7 @@ void APIC::wait_for_pending_icr() } } -void APIC::write_icr(const ICRReg& icr) +void APIC::write_icr(ICRReg const& icr) { if (m_is_x2) { MSR msr(APIC_REGS_MSR_BASE + (APIC_REG_ICR_LOW >> 4)); @@ -236,7 +236,7 @@ u8 APIC::spurious_interrupt_vector() } #define APIC_INIT_VAR_PTR(tpe, vaddr, varname) \ - reinterpret_cast(reinterpret_cast(vaddr) \ + reinterpret_cast(reinterpret_cast(vaddr) \ + reinterpret_cast(&varname) \ - reinterpret_cast(&apic_ap_start)) @@ -349,7 +349,7 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment() VERIFY(apic_startup_region_size < USER_RANGE_BASE); auto apic_startup_region = create_identity_mapped_region(PhysicalAddress(apic_startup_region_base), apic_startup_region_size); u8* apic_startup_region_ptr = apic_startup_region->vaddr().as_ptr(); - memcpy(apic_startup_region_ptr, reinterpret_cast(apic_ap_start), apic_ap_start_size); + memcpy(apic_startup_region_ptr, reinterpret_cast(apic_ap_start), apic_ap_start_size); // Allocate enough stacks for all APs m_ap_temporary_boot_stacks.ensure_capacity(aps_to_enable); @@ -387,9 +387,9 @@ UNMAP_AFTER_INIT void APIC::setup_ap_boot_environment() *APIC_INIT_VAR_PTR(FlatPtr, apic_startup_region_ptr, ap_cpu_init_cr3) = MM.kernel_page_directory().cr3(); // Store the BSP's GDT and IDT for the APs to use - const auto& gdtr = Processor::current().get_gdtr(); + auto const& gdtr = Processor::current().get_gdtr(); *APIC_INIT_VAR_PTR(FlatPtr, apic_startup_region_ptr, ap_cpu_gdtr) = FlatPtr(&gdtr); - const auto& idtr = get_idtr(); + auto const& idtr = get_idtr(); *APIC_INIT_VAR_PTR(FlatPtr, apic_startup_region_ptr, ap_cpu_idtr) = FlatPtr(&idtr); #if ARCH(X86_64) @@ -656,7 +656,7 @@ u32 APIC::get_timer_divisor() return 16; } -bool APICIPIInterruptHandler::handle_interrupt(const RegisterState&) +bool APICIPIInterruptHandler::handle_interrupt(RegisterState const&) { dbgln_if(APIC_SMP_DEBUG, "APIC IPI on CPU #{}", Processor::current_id()); return true; @@ -669,7 +669,7 @@ bool APICIPIInterruptHandler::eoi() return true; } -bool APICErrInterruptHandler::handle_interrupt(const RegisterState&) +bool APICErrInterruptHandler::handle_interrupt(RegisterState const&) { dbgln("APIC: SMP error on CPU #{}", Processor::current_id()); return true; diff --git a/Kernel/Interrupts/APIC.h b/Kernel/Interrupts/APIC.h index adcc64f6b88..f64bca7844e 100644 --- a/Kernel/Interrupts/APIC.h +++ b/Kernel/Interrupts/APIC.h @@ -102,13 +102,13 @@ private: bool m_is_x2 { false }; static PhysicalAddress get_base(); - void set_base(const PhysicalAddress& base); + void set_base(PhysicalAddress const& base); void write_register(u32 offset, u32 value); u32 read_register(u32 offset); void set_lvt(u32 offset, u8 interrupt); void set_siv(u32 offset, u8 interrupt); void wait_for_pending_icr(); - void write_icr(const ICRReg& icr); + void write_icr(ICRReg const& icr); void do_boot_aps(); }; diff --git a/Kernel/Interrupts/GenericInterruptHandler.h b/Kernel/Interrupts/GenericInterruptHandler.h index 109c378feef..e2c37162943 100644 --- a/Kernel/Interrupts/GenericInterruptHandler.h +++ b/Kernel/Interrupts/GenericInterruptHandler.h @@ -28,7 +28,7 @@ public: } // Note: this method returns boolean value, to indicate if the handler handled // the interrupt or not. This is useful for shared handlers mostly. - virtual bool handle_interrupt(const RegisterState& regs) = 0; + virtual bool handle_interrupt(RegisterState const& regs) = 0; void will_be_destroyed(); bool is_registered() const { return m_registered; } diff --git a/Kernel/Interrupts/IOAPIC.cpp b/Kernel/Interrupts/IOAPIC.cpp index abc052ccd07..f17be743826 100644 --- a/Kernel/Interrupts/IOAPIC.cpp +++ b/Kernel/Interrupts/IOAPIC.cpp @@ -102,7 +102,7 @@ bool IOAPIC::is_enabled() const return !is_hard_disabled(); } -void IOAPIC::spurious_eoi(const GenericInterruptHandler& handler) const +void IOAPIC::spurious_eoi(GenericInterruptHandler const& handler) const { InterruptDisabler disabler; VERIFY(handler.type() == HandlerType::SpuriousInterruptHandler); @@ -241,7 +241,7 @@ Optional IOAPIC::find_redirection_entry_by_vector(u8 vector) const return {}; } -void IOAPIC::disable(const GenericInterruptHandler& handler) +void IOAPIC::disable(GenericInterruptHandler const& handler) { InterruptDisabler disabler; VERIFY(!is_hard_disabled()); @@ -256,7 +256,7 @@ void IOAPIC::disable(const GenericInterruptHandler& handler) mask_redirection_entry(found_index.value()); } -void IOAPIC::enable(const GenericInterruptHandler& handler) +void IOAPIC::enable(GenericInterruptHandler const& handler) { InterruptDisabler disabler; VERIFY(!is_hard_disabled()); @@ -271,7 +271,7 @@ void IOAPIC::enable(const GenericInterruptHandler& handler) unmask_redirection_entry(found_index.value()); } -void IOAPIC::eoi(const GenericInterruptHandler& handler) const +void IOAPIC::eoi(GenericInterruptHandler const& handler) const { InterruptDisabler disabler; VERIFY(!is_hard_disabled()); diff --git a/Kernel/Interrupts/IOAPIC.h b/Kernel/Interrupts/IOAPIC.h index 4977668664f..2c119879050 100644 --- a/Kernel/Interrupts/IOAPIC.h +++ b/Kernel/Interrupts/IOAPIC.h @@ -40,11 +40,11 @@ private: class IOAPIC final : public IRQController { public: IOAPIC(PhysicalAddress, u32 gsi_base); - virtual void enable(const GenericInterruptHandler&) override; - virtual void disable(const GenericInterruptHandler&) override; + virtual void enable(GenericInterruptHandler const&) override; + virtual void disable(GenericInterruptHandler const&) override; virtual void hard_disable() override; - virtual void eoi(const GenericInterruptHandler&) const override; - virtual void spurious_eoi(const GenericInterruptHandler&) const override; + virtual void eoi(GenericInterruptHandler const&) const override; + virtual void spurious_eoi(GenericInterruptHandler const&) const override; virtual bool is_vector_enabled(u8 number) const override; virtual bool is_enabled() const override; virtual u16 get_isr() const override; diff --git a/Kernel/Interrupts/IRQController.h b/Kernel/Interrupts/IRQController.h index 89af65922ac..016fc80d239 100644 --- a/Kernel/Interrupts/IRQController.h +++ b/Kernel/Interrupts/IRQController.h @@ -20,14 +20,14 @@ class IRQController : public RefCounted { public: virtual ~IRQController() = default; - virtual void enable(const GenericInterruptHandler&) = 0; - virtual void disable(const GenericInterruptHandler&) = 0; + virtual void enable(GenericInterruptHandler const&) = 0; + virtual void disable(GenericInterruptHandler const&) = 0; virtual void hard_disable() { m_hard_disabled = true; } virtual bool is_vector_enabled(u8 number) const = 0; virtual bool is_enabled() const = 0; bool is_hard_disabled() const { return m_hard_disabled; } - virtual void eoi(const GenericInterruptHandler&) const = 0; - virtual void spurious_eoi(const GenericInterruptHandler&) const = 0; + virtual void eoi(GenericInterruptHandler const&) const = 0; + virtual void spurious_eoi(GenericInterruptHandler const&) const = 0; virtual size_t interrupt_vectors_count() const = 0; virtual u32 gsi_base() const = 0; virtual u16 get_isr() const = 0; diff --git a/Kernel/Interrupts/IRQHandler.h b/Kernel/Interrupts/IRQHandler.h index a5c61755702..15661618e8d 100644 --- a/Kernel/Interrupts/IRQHandler.h +++ b/Kernel/Interrupts/IRQHandler.h @@ -17,8 +17,8 @@ class IRQHandler : public GenericInterruptHandler { public: virtual ~IRQHandler(); - virtual bool handle_interrupt(const RegisterState& regs) override { return handle_irq(regs); } - virtual bool handle_irq(const RegisterState&) = 0; + virtual bool handle_interrupt(RegisterState const& regs) override { return handle_irq(regs); } + virtual bool handle_irq(RegisterState const&) = 0; void enable_irq(); void disable_irq(); diff --git a/Kernel/Interrupts/InterruptManagement.h b/Kernel/Interrupts/InterruptManagement.h index b17bbabd8d9..8d20b05e6a9 100644 --- a/Kernel/Interrupts/InterruptManagement.h +++ b/Kernel/Interrupts/InterruptManagement.h @@ -56,7 +56,7 @@ public: RefPtr get_responsible_irq_controller(u8 interrupt_vector); RefPtr get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector); - const Vector& isa_overrides() const { return m_isa_interrupt_overrides; } + Vector const& isa_overrides() const { return m_isa_interrupt_overrides; } u8 get_mapped_interrupt_vector(u8 original_irq); u8 get_irq_vector(u8 mapped_interrupt_vector); diff --git a/Kernel/Interrupts/PIC.cpp b/Kernel/Interrupts/PIC.cpp index 03fe0034bc4..906cdc20188 100644 --- a/Kernel/Interrupts/PIC.cpp +++ b/Kernel/Interrupts/PIC.cpp @@ -45,7 +45,7 @@ bool PIC::is_enabled() const return !is_all_masked(m_cached_irq_mask) && !is_hard_disabled(); } -void PIC::disable(const GenericInterruptHandler& handler) +void PIC::disable(GenericInterruptHandler const& handler) { InterruptDisabler disabler; VERIFY(!is_hard_disabled()); @@ -71,7 +71,7 @@ UNMAP_AFTER_INIT PIC::PIC() initialize(); } -void PIC::spurious_eoi(const GenericInterruptHandler& handler) const +void PIC::spurious_eoi(GenericInterruptHandler const& handler) const { VERIFY(handler.type() == HandlerType::SpuriousInterruptHandler); if (handler.interrupt_number() == 7) @@ -87,7 +87,7 @@ bool PIC::is_vector_enabled(u8 irq) const return m_cached_irq_mask & (1 << irq); } -void PIC::enable(const GenericInterruptHandler& handler) +void PIC::enable(GenericInterruptHandler const& handler) { InterruptDisabler disabler; VERIFY(!is_hard_disabled()); @@ -114,7 +114,7 @@ void PIC::enable_vector(u8 irq) m_cached_irq_mask &= ~(1 << irq); } -void PIC::eoi(const GenericInterruptHandler& handler) const +void PIC::eoi(GenericInterruptHandler const& handler) const { InterruptDisabler disabler; VERIFY(!is_hard_disabled()); diff --git a/Kernel/Interrupts/PIC.h b/Kernel/Interrupts/PIC.h index 933d7aa28dc..2e540e2991f 100644 --- a/Kernel/Interrupts/PIC.h +++ b/Kernel/Interrupts/PIC.h @@ -17,13 +17,13 @@ static constexpr size_t pic_disabled_vector_end = 0x2f; class PIC final : public IRQController { public: PIC(); - virtual void enable(const GenericInterruptHandler&) override; - virtual void disable(const GenericInterruptHandler&) override; + virtual void enable(GenericInterruptHandler const&) override; + virtual void disable(GenericInterruptHandler const&) override; virtual void hard_disable() override; - virtual void eoi(const GenericInterruptHandler&) const override; + virtual void eoi(GenericInterruptHandler const&) const override; virtual bool is_vector_enabled(u8 number) const override; virtual bool is_enabled() const override; - virtual void spurious_eoi(const GenericInterruptHandler&) const override; + virtual void spurious_eoi(GenericInterruptHandler const&) const override; virtual u16 get_isr() const override; virtual u16 get_irr() const override; virtual u32 gsi_base() const override { return 0; } diff --git a/Kernel/Interrupts/SharedIRQHandler.cpp b/Kernel/Interrupts/SharedIRQHandler.cpp index b35bba7ec6d..995a13309e5 100644 --- a/Kernel/Interrupts/SharedIRQHandler.cpp +++ b/Kernel/Interrupts/SharedIRQHandler.cpp @@ -62,7 +62,7 @@ SharedIRQHandler::~SharedIRQHandler() disable_interrupt_vector(); } -bool SharedIRQHandler::handle_interrupt(const RegisterState& regs) +bool SharedIRQHandler::handle_interrupt(RegisterState const& regs) { VERIFY_INTERRUPTS_DISABLED(); diff --git a/Kernel/Interrupts/SharedIRQHandler.h b/Kernel/Interrupts/SharedIRQHandler.h index 6c7c65b13ed..95623957aa9 100644 --- a/Kernel/Interrupts/SharedIRQHandler.h +++ b/Kernel/Interrupts/SharedIRQHandler.h @@ -18,7 +18,7 @@ class SharedIRQHandler final : public GenericInterruptHandler { public: static void initialize(u8 interrupt_number); virtual ~SharedIRQHandler(); - virtual bool handle_interrupt(const RegisterState& regs) override; + virtual bool handle_interrupt(RegisterState const& regs) override; void register_handler(GenericInterruptHandler&); void unregister_handler(GenericInterruptHandler&); diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.cpp b/Kernel/Interrupts/SpuriousInterruptHandler.cpp index 0b2d3adbe8f..6e78212a10a 100644 --- a/Kernel/Interrupts/SpuriousInterruptHandler.cpp +++ b/Kernel/Interrupts/SpuriousInterruptHandler.cpp @@ -69,7 +69,7 @@ SpuriousInterruptHandler::SpuriousInterruptHandler(u8 irq) SpuriousInterruptHandler::~SpuriousInterruptHandler() = default; -bool SpuriousInterruptHandler::handle_interrupt(const RegisterState& state) +bool SpuriousInterruptHandler::handle_interrupt(RegisterState const& state) { // Actually check if IRQ7 or IRQ15 are spurious, and if not, call the real handler to handle the IRQ. if (m_responsible_irq_controller->get_isr() & (1 << interrupt_number())) { diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.h b/Kernel/Interrupts/SpuriousInterruptHandler.h index 9a7aafa55e6..f1c1e1ac547 100644 --- a/Kernel/Interrupts/SpuriousInterruptHandler.h +++ b/Kernel/Interrupts/SpuriousInterruptHandler.h @@ -19,7 +19,7 @@ public: static void initialize_for_disabled_master_pic(); static void initialize_for_disabled_slave_pic(); virtual ~SpuriousInterruptHandler(); - virtual bool handle_interrupt(const RegisterState& regs) override; + virtual bool handle_interrupt(RegisterState const& regs) override; void register_handler(GenericInterruptHandler&); void unregister_handler(GenericInterruptHandler&); diff --git a/Kernel/Interrupts/UnhandledInterruptHandler.cpp b/Kernel/Interrupts/UnhandledInterruptHandler.cpp index ee46a493c3d..17571047d3e 100644 --- a/Kernel/Interrupts/UnhandledInterruptHandler.cpp +++ b/Kernel/Interrupts/UnhandledInterruptHandler.cpp @@ -13,7 +13,7 @@ UnhandledInterruptHandler::UnhandledInterruptHandler(u8 interrupt_vector) { } -bool UnhandledInterruptHandler::handle_interrupt(const RegisterState&) +bool UnhandledInterruptHandler::handle_interrupt(RegisterState const&) { PANIC("Interrupt: Unhandled vector {} was invoked for handle_interrupt(RegisterState&).", interrupt_number()); } diff --git a/Kernel/Interrupts/UnhandledInterruptHandler.h b/Kernel/Interrupts/UnhandledInterruptHandler.h index 2508b3e35a5..134ea32ec43 100644 --- a/Kernel/Interrupts/UnhandledInterruptHandler.h +++ b/Kernel/Interrupts/UnhandledInterruptHandler.h @@ -15,7 +15,7 @@ public: explicit UnhandledInterruptHandler(u8 interrupt_vector); virtual ~UnhandledInterruptHandler(); - virtual bool handle_interrupt(const RegisterState&) override; + virtual bool handle_interrupt(RegisterState const&) override; [[noreturn]] virtual bool eoi() override; diff --git a/Kernel/KBufferBuilder.cpp b/Kernel/KBufferBuilder.cpp index edc6fe227e3..fe93103a865 100644 --- a/Kernel/KBufferBuilder.cpp +++ b/Kernel/KBufferBuilder.cpp @@ -80,7 +80,7 @@ ErrorOr KBufferBuilder::append(StringView str) return {}; } -ErrorOr KBufferBuilder::append(const char* characters, int length) +ErrorOr KBufferBuilder::append(char const* characters, int length) { if (!length) return {}; diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h index 83450515f08..d96eed409d6 100644 --- a/Kernel/KBufferBuilder.h +++ b/Kernel/KBufferBuilder.h @@ -27,13 +27,13 @@ public: ErrorOr append(StringView); ErrorOr append(char); - ErrorOr append(const char*, int); + ErrorOr append(char const*, int); ErrorOr append_escaped_for_json(StringView); ErrorOr append_bytes(ReadonlyBytes); template - ErrorOr appendff(CheckedFormatString&& fmtstr, const Parameters&... parameters) + ErrorOr appendff(CheckedFormatString&& fmtstr, Parameters const&... parameters) { // FIXME: This really not ideal, but vformat expects StringBuilder. StringBuilder builder; diff --git a/Kernel/KString.h b/Kernel/KString.h index bc2beef1bc7..2639f9617b2 100644 --- a/Kernel/KString.h +++ b/Kernel/KString.h @@ -24,7 +24,7 @@ public: [[nodiscard]] static ErrorOr> vformatted(StringView fmtstr, AK::TypeErasedFormatParams&); template - [[nodiscard]] static ErrorOr> formatted(CheckedFormatString&& fmtstr, const Parameters&... parameters) + [[nodiscard]] static ErrorOr> formatted(CheckedFormatString&& fmtstr, Parameters const&... parameters) { AK::VariadicFormatParams variadic_format_parameters { parameters... }; return vformatted(fmtstr.view(), variadic_format_parameters); diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp index 8c56961436c..d6c4798fd21 100644 --- a/Kernel/KSyms.cpp +++ b/Kernel/KSyms.cpp @@ -37,14 +37,14 @@ UNMAP_AFTER_INIT static u8 parse_hex_digit(char nibble) FlatPtr address_for_kernel_symbol(StringView name) { for (size_t i = 0; i < s_symbol_count; ++i) { - const auto& symbol = s_symbols[i]; + auto const& symbol = s_symbols[i]; if (name == symbol.name) return symbol.address; } return 0; } -const KernelSymbol* symbolicate_kernel_address(FlatPtr address) +KernelSymbol const* symbolicate_kernel_address(FlatPtr address) { if (address < g_lowest_kernel_symbol_address || address > g_highest_kernel_symbol_address) return nullptr; @@ -116,7 +116,7 @@ NEVER_INLINE static void dump_backtrace_impl(FlatPtr base_pointer, bool use_ksym struct RecognizedSymbol { FlatPtr address; - const KernelSymbol* symbol { nullptr }; + KernelSymbol const* symbol { nullptr }; }; constexpr size_t max_recognized_symbol_count = 256; RecognizedSymbol recognized_symbols[max_recognized_symbol_count]; diff --git a/Kernel/KSyms.h b/Kernel/KSyms.h index 2bc6699695b..ff01f38edfb 100644 --- a/Kernel/KSyms.h +++ b/Kernel/KSyms.h @@ -12,7 +12,7 @@ namespace Kernel { struct KernelSymbol { FlatPtr address; - const char* name; + char const* name; }; enum class PrintToScreen { @@ -21,7 +21,7 @@ enum class PrintToScreen { }; FlatPtr address_for_kernel_symbol(StringView name); -const KernelSymbol* symbolicate_kernel_address(FlatPtr); +KernelSymbol const* symbolicate_kernel_address(FlatPtr); void load_kernel_symbol_table(); extern bool g_kernel_symbols_available; diff --git a/Kernel/Library/ThreadSafeNonnullRefPtr.h b/Kernel/Library/ThreadSafeNonnullRefPtr.h index 932717e5f9b..de7e08cbc2c 100644 --- a/Kernel/Library/ThreadSafeNonnullRefPtr.h +++ b/Kernel/Library/ThreadSafeNonnullRefPtr.h @@ -82,13 +82,13 @@ public: { VERIFY(!(m_bits & 1)); } - ALWAYS_INLINE NonnullRefPtr(const NonnullRefPtr& other) + ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) : m_bits((FlatPtr)other.add_ref()) { VERIFY(!(m_bits & 1)); } template - ALWAYS_INLINE NonnullRefPtr(const NonnullRefPtr& other) requires(IsConvertible) + ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) requires(IsConvertible) : m_bits((FlatPtr)other.add_ref()) { VERIFY(!(m_bits & 1)); @@ -102,18 +102,18 @@ public: } template - NonnullRefPtr(const OwnPtr&) = delete; + NonnullRefPtr(OwnPtr const&) = delete; template - NonnullRefPtr& operator=(const OwnPtr&) = delete; + NonnullRefPtr& operator=(OwnPtr const&) = delete; template - NonnullRefPtr(const RefPtr&) = delete; + NonnullRefPtr(RefPtr const&) = delete; template - NonnullRefPtr& operator=(const RefPtr&) = delete; - NonnullRefPtr(const RefPtr&) = delete; - NonnullRefPtr& operator=(const RefPtr&) = delete; + NonnullRefPtr& operator=(RefPtr const&) = delete; + NonnullRefPtr(RefPtr const&) = delete; + NonnullRefPtr& operator=(RefPtr const&) = delete; - NonnullRefPtr& operator=(const NonnullRefPtr& other) + NonnullRefPtr& operator=(NonnullRefPtr const& other) { if (this != &other) assign(other.add_ref()); @@ -121,7 +121,7 @@ public: } template - NonnullRefPtr& operator=(const NonnullRefPtr& other) requires(IsConvertible) + NonnullRefPtr& operator=(NonnullRefPtr const& other) requires(IsConvertible) { assign(other.add_ref()); return *this; @@ -324,7 +324,7 @@ inline NonnullRefPtr adopt_ref(T& object) template struct Formatter> : Formatter { - ErrorOr format(FormatBuilder& builder, const NonnullRefPtr& value) + ErrorOr format(FormatBuilder& builder, NonnullRefPtr const& value) { return Formatter::format(builder, value.ptr()); } @@ -342,8 +342,8 @@ template struct Traits> : public GenericTraits> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const NonnullRefPtr& p) { return ptr_hash(p.ptr()); } - static bool equals(const NonnullRefPtr& a, const NonnullRefPtr& b) { return a.ptr() == b.ptr(); } + static unsigned hash(NonnullRefPtr const& p) { return ptr_hash(p.ptr()); } + static bool equals(NonnullRefPtr const& a, NonnullRefPtr const& b) { return a.ptr() == b.ptr(); } }; using AK::adopt_ref; diff --git a/Kernel/Library/ThreadSafeRefPtr.h b/Kernel/Library/ThreadSafeRefPtr.h index 7bb5312dfe5..b1e341d7e90 100644 --- a/Kernel/Library/ThreadSafeRefPtr.h +++ b/Kernel/Library/ThreadSafeRefPtr.h @@ -151,12 +151,12 @@ public: : m_bits(other.leak_ref_raw()) { } - ALWAYS_INLINE RefPtr(const NonnullRefPtr& other) + ALWAYS_INLINE RefPtr(NonnullRefPtr const& other) : m_bits(PtrTraits::as_bits(const_cast(other.add_ref()))) { } template - ALWAYS_INLINE RefPtr(const NonnullRefPtr& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr(NonnullRefPtr const& other) requires(IsConvertible) : m_bits(PtrTraits::as_bits(const_cast(other.add_ref()))) { } @@ -171,12 +171,12 @@ public: : m_bits(PtrTraits::template convert_from(other.leak_ref_raw())) { } - RefPtr(const RefPtr& other) + RefPtr(RefPtr const& other) : m_bits(other.add_ref_raw()) { } template> - RefPtr(const RefPtr& other) requires(IsConvertible) + RefPtr(RefPtr const& other) requires(IsConvertible) : m_bits(other.add_ref_raw()) { } @@ -189,9 +189,9 @@ public: } template - RefPtr(const OwnPtr&) = delete; + RefPtr(OwnPtr const&) = delete; template - RefPtr& operator=(const OwnPtr&) = delete; + RefPtr& operator=(OwnPtr const&) = delete; void swap(RefPtr& other) { @@ -234,20 +234,20 @@ public: return *this; } - ALWAYS_INLINE RefPtr& operator=(const NonnullRefPtr& other) + ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr const& other) { assign_raw(PtrTraits::as_bits(other.add_ref())); return *this; } template - ALWAYS_INLINE RefPtr& operator=(const NonnullRefPtr& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr const& other) requires(IsConvertible) { assign_raw(PtrTraits::as_bits(other.add_ref())); return *this; } - ALWAYS_INLINE RefPtr& operator=(const RefPtr& other) + ALWAYS_INLINE RefPtr& operator=(RefPtr const& other) { if (this != &other) assign_raw(other.add_ref_raw()); @@ -255,7 +255,7 @@ public: } template - ALWAYS_INLINE RefPtr& operator=(const RefPtr& other) requires(IsConvertible) + ALWAYS_INLINE RefPtr& operator=(RefPtr const& other) requires(IsConvertible) { assign_raw(other.add_ref_raw()); return *this; @@ -347,8 +347,8 @@ public: bool operator==(std::nullptr_t) const { return is_null(); } bool operator!=(std::nullptr_t) const { return !is_null(); } - bool operator==(const RefPtr& other) const { return as_ptr() == other.as_ptr(); } - bool operator!=(const RefPtr& other) const { return as_ptr() != other.as_ptr(); } + bool operator==(RefPtr const& other) const { return as_ptr() == other.as_ptr(); } + bool operator!=(RefPtr const& other) const { return as_ptr() != other.as_ptr(); } bool operator==(RefPtr& other) { return as_ptr() == other.as_ptr(); } bool operator!=(RefPtr& other) { return as_ptr() != other.as_ptr(); } @@ -456,18 +456,18 @@ template struct Traits> : public GenericTraits> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const RefPtr& p) { return ptr_hash(p.ptr()); } - static bool equals(const RefPtr& a, const RefPtr& b) { return a.ptr() == b.ptr(); } + static unsigned hash(RefPtr const& p) { return ptr_hash(p.ptr()); } + static bool equals(RefPtr const& a, RefPtr const& b) { return a.ptr() == b.ptr(); } }; template -inline NonnullRefPtr static_ptr_cast(const NonnullRefPtr& ptr) +inline NonnullRefPtr static_ptr_cast(NonnullRefPtr const& ptr) { return NonnullRefPtr(static_cast(*ptr)); } template> -inline RefPtr static_ptr_cast(const RefPtr& ptr) +inline RefPtr static_ptr_cast(RefPtr const& ptr) { return RefPtr(static_cast(ptr.ptr())); } diff --git a/Kernel/Library/ThreadSafeWeakPtr.h b/Kernel/Library/ThreadSafeWeakPtr.h index ba8cda9d1e8..cd25b8e5582 100644 --- a/Kernel/Library/ThreadSafeWeakPtr.h +++ b/Kernel/Library/ThreadSafeWeakPtr.h @@ -19,7 +19,7 @@ public: WeakPtr() = default; template - WeakPtr(const WeakPtr& other) requires(IsBaseOf) + WeakPtr(WeakPtr const& other) requires(IsBaseOf) : m_link(other.m_link) { } @@ -38,9 +38,9 @@ public: } template - WeakPtr& operator=(const WeakPtr& other) requires(IsBaseOf) + WeakPtr& operator=(WeakPtr const& other) requires(IsBaseOf) { - if ((const void*)this != (const void*)&other) + if ((void const*)this != (void const*)&other) m_link = other.m_link; return *this; } @@ -65,7 +65,7 @@ public: } template - WeakPtr(const RefPtr& object) requires(IsBaseOf) + WeakPtr(RefPtr const& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -74,7 +74,7 @@ public: } template - WeakPtr(const NonnullRefPtr& object) requires(IsBaseOf) + WeakPtr(NonnullRefPtr const& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -100,7 +100,7 @@ public: } template - WeakPtr& operator=(const RefPtr& object) requires(IsBaseOf) + WeakPtr& operator=(RefPtr const& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -112,7 +112,7 @@ public: } template - WeakPtr& operator=(const NonnullRefPtr& object) requires(IsBaseOf) + WeakPtr& operator=(NonnullRefPtr const& object) requires(IsBaseOf) { object.do_while_locked([&](U* obj) { if (obj) @@ -156,7 +156,7 @@ public: [[nodiscard]] RefPtr take_link() { return move(m_link); } private: - WeakPtr(const RefPtr& link) + WeakPtr(RefPtr const& link) : m_link(link) { } diff --git a/Kernel/Locking/MutexProtected.h b/Kernel/Locking/MutexProtected.h index 8fe7fa31d1f..9271d3edfb9 100644 --- a/Kernel/Locking/MutexProtected.h +++ b/Kernel/Locking/MutexProtected.h @@ -66,7 +66,7 @@ public: template void for_each_shared(Callback callback, LockLocation const& location = LockLocation::current()) const { - with_shared([&](const auto& value) { + with_shared([&](auto const& value) { for (auto& item : value) callback(item); }, diff --git a/Kernel/Locking/SpinlockProtected.h b/Kernel/Locking/SpinlockProtected.h index dd0344708c8..1072c425cc9 100644 --- a/Kernel/Locking/SpinlockProtected.h +++ b/Kernel/Locking/SpinlockProtected.h @@ -69,7 +69,7 @@ public: template void for_each_const(Callback callback) const { - with([&](const auto& value) { + with([&](auto const& value) { for (auto& item : value) callback(item); }); diff --git a/Kernel/Memory/AddressSpace.cpp b/Kernel/Memory/AddressSpace.cpp index d5fdd97e05e..a96b703157c 100644 --- a/Kernel/Memory/AddressSpace.cpp +++ b/Kernel/Memory/AddressSpace.cpp @@ -245,7 +245,7 @@ ErrorOr> AddressSpace::find_regions_intersecting(VirtualRange co if (!found_region) return regions; for (auto iter = m_regions.begin_from((*found_region)->vaddr().get()); !iter.is_end(); ++iter) { - const auto& iter_range = (*iter)->range(); + auto const& iter_range = (*iter)->range(); if (iter_range.base() < range.end() && iter_range.end() > range.base()) { TRY(regions.try_append(*iter)); @@ -267,7 +267,7 @@ ErrorOr AddressSpace::add_region(NonnullOwnPtr region) } // Carve out a virtual address range from a region and return the two regions on either side -ErrorOr> AddressSpace::try_split_region_around_range(const Region& source_region, VirtualRange const& desired_range) +ErrorOr> AddressSpace::try_split_region_around_range(Region const& source_region, VirtualRange const& desired_range) { VirtualRange old_region_range = source_region.range(); auto remaining_ranges_after_unmap = old_region_range.carve(desired_range); @@ -343,10 +343,10 @@ size_t AddressSpace::amount_dirty_private() const ErrorOr AddressSpace::amount_clean_inode() const { SpinlockLocker lock(m_lock); - HashTable vmobjects; + HashTable vmobjects; for (auto const& region : m_regions) { if (region->vmobject().is_inode()) - TRY(vmobjects.try_set(&static_cast(region->vmobject()))); + TRY(vmobjects.try_set(&static_cast(region->vmobject()))); } size_t amount = 0; for (auto& vmobject : vmobjects) diff --git a/Kernel/Memory/AddressSpace.h b/Kernel/Memory/AddressSpace.h index b09f5f3d2d3..0c08647749f 100644 --- a/Kernel/Memory/AddressSpace.h +++ b/Kernel/Memory/AddressSpace.h @@ -22,14 +22,14 @@ public: ~AddressSpace(); PageDirectory& page_directory() { return *m_page_directory; } - const PageDirectory& page_directory() const { return *m_page_directory; } + PageDirectory const& page_directory() const { return *m_page_directory; } ErrorOr add_region(NonnullOwnPtr); size_t region_count() const { return m_regions.size(); } RedBlackTree>& regions() { return m_regions; } - const RedBlackTree>& regions() const { return m_regions; } + RedBlackTree> const& regions() const { return m_regions; } void dump_regions(); diff --git a/Kernel/Memory/MappedROM.h b/Kernel/Memory/MappedROM.h index e80870c8f2f..486251df5ea 100644 --- a/Kernel/Memory/MappedROM.h +++ b/Kernel/Memory/MappedROM.h @@ -14,8 +14,8 @@ namespace Kernel::Memory { class MappedROM { public: - const u8* base() const { return region->vaddr().offset(offset).as_ptr(); } - const u8* end() const { return base() + size; } + u8 const* base() const { return region->vaddr().offset(offset).as_ptr(); } + u8 const* end() const { return base() + size; } OwnPtr region; size_t size { 0 }; size_t offset { 0 }; @@ -33,7 +33,7 @@ public: return {}; } - PhysicalAddress paddr_of(const u8* ptr) const { return paddr.offset(ptr - this->base()); } + PhysicalAddress paddr_of(u8 const* ptr) const { return paddr.offset(ptr - this->base()); } }; } diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index 3d5a27b0277..f5cdfbe825b 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -672,7 +672,7 @@ void MemoryManager::validate_syscall_preconditions(AddressSpace& space, Register // to avoid excessive spinlock recursion in this extremely common path. SpinlockLocker lock(space.get_lock()); - auto unlock_and_handle_crash = [&lock, ®s](const char* description, int signal) { + auto unlock_and_handle_crash = [&lock, ®s](char const* description, int signal) { lock.unlock(); handle_crash(regs, description, signal); }; diff --git a/Kernel/Memory/PageDirectory.h b/Kernel/Memory/PageDirectory.h index eaabce7dcc1..233565e3e11 100644 --- a/Kernel/Memory/PageDirectory.h +++ b/Kernel/Memory/PageDirectory.h @@ -50,7 +50,7 @@ public: VirtualRangeAllocator const& range_allocator() const { return m_range_allocator; } AddressSpace* address_space() { return m_space; } - const AddressSpace* address_space() const { return m_space; } + AddressSpace const* address_space() const { return m_space; } void set_space(Badge, AddressSpace& space) { m_space = &space; } diff --git a/Kernel/Memory/RingBuffer.cpp b/Kernel/Memory/RingBuffer.cpp index ca0f38602eb..045f61e6d5c 100644 --- a/Kernel/Memory/RingBuffer.cpp +++ b/Kernel/Memory/RingBuffer.cpp @@ -23,7 +23,7 @@ RingBuffer::RingBuffer(NonnullOwnPtr region, size_t capacity) { } -bool RingBuffer::copy_data_in(const UserOrKernelBuffer& buffer, size_t offset, size_t length, PhysicalAddress& start_of_copied_data, size_t& bytes_copied) +bool RingBuffer::copy_data_in(UserOrKernelBuffer const& buffer, size_t offset, size_t length, PhysicalAddress& start_of_copied_data, size_t& bytes_copied) { size_t start_of_free_area = (m_start_of_used + m_num_used_bytes) % m_capacity_in_bytes; bytes_copied = min(m_capacity_in_bytes - m_num_used_bytes, min(m_capacity_in_bytes - start_of_free_area, length)); diff --git a/Kernel/Memory/RingBuffer.h b/Kernel/Memory/RingBuffer.h index 0e36428e58e..eb97c532534 100644 --- a/Kernel/Memory/RingBuffer.h +++ b/Kernel/Memory/RingBuffer.h @@ -16,7 +16,7 @@ public: static ErrorOr> try_create(StringView region_name, size_t capacity); bool has_space() const { return m_num_used_bytes < m_capacity_in_bytes; } - bool copy_data_in(const UserOrKernelBuffer& buffer, size_t offset, size_t length, PhysicalAddress& start_of_copied_data, size_t& bytes_copied); + bool copy_data_in(UserOrKernelBuffer const& buffer, size_t offset, size_t length, PhysicalAddress& start_of_copied_data, size_t& bytes_copied); ErrorOr copy_data_out(size_t size, UserOrKernelBuffer& buffer) const; ErrorOr reserve_space(size_t size); void reclaim_space(PhysicalAddress chunk_start, size_t chunk_size); diff --git a/Kernel/Memory/ScatterGatherList.h b/Kernel/Memory/ScatterGatherList.h index f90876957a4..6fedb75cad6 100644 --- a/Kernel/Memory/ScatterGatherList.h +++ b/Kernel/Memory/ScatterGatherList.h @@ -19,7 +19,7 @@ namespace Kernel::Memory { class ScatterGatherList : public RefCounted { public: static RefPtr try_create(AsyncBlockDeviceRequest&, Span> allocated_pages, size_t device_block_size); - const VMObject& vmobject() const { return m_vm_object; } + VMObject const& vmobject() const { return m_vm_object; } VirtualAddress dma_region() const { return m_dma_region->vaddr(); } size_t scatters_count() const { return m_vm_object->physical_pages().size(); } diff --git a/Kernel/MiniStdLib.cpp b/Kernel/MiniStdLib.cpp index 0bd0768b5ba..4211a70d898 100644 --- a/Kernel/MiniStdLib.cpp +++ b/Kernel/MiniStdLib.cpp @@ -8,7 +8,7 @@ extern "C" { -void* memcpy(void* dest_ptr, const void* src_ptr, size_t n) +void* memcpy(void* dest_ptr, void const* src_ptr, size_t n) { #if ARCH(I386) || ARCH(X86_64) size_t dest = (size_t)dest_ptr; @@ -45,13 +45,13 @@ void* memcpy(void* dest_ptr, const void* src_ptr, size_t n) return dest_ptr; } -void* memmove(void* dest, const void* src, size_t n) +void* memmove(void* dest, void const* src, size_t n) { if (dest < src) return memcpy(dest, src, n); u8* pd = (u8*)dest; - const u8* ps = (const u8*)src; + u8 const* ps = (u8 const*)src; for (pd += n, ps += n; n--;) *--pd = *--ps; return dest; @@ -95,7 +95,7 @@ void* memset(void* dest_ptr, int c, size_t n) return dest_ptr; } -size_t strlen(const char* str) +size_t strlen(char const* str) { size_t len = 0; while (*(str++)) @@ -103,7 +103,7 @@ size_t strlen(const char* str) return len; } -size_t strnlen(const char* str, size_t maxlen) +size_t strnlen(char const* str, size_t maxlen) { size_t len = 0; for (; len < maxlen && *str; str++) @@ -111,19 +111,19 @@ size_t strnlen(const char* str, size_t maxlen) return len; } -int strcmp(const char* s1, const char* s2) +int strcmp(char const* s1, char const* s2) { for (; *s1 == *s2; ++s1, ++s2) { if (*s1 == 0) return 0; } - return *(const u8*)s1 < *(const u8*)s2 ? -1 : 1; + return *(u8 const*)s1 < *(u8 const*)s2 ? -1 : 1; } -int memcmp(const void* v1, const void* v2, size_t n) +int memcmp(void const* v1, void const* v2, size_t n) { - auto const* s1 = (const u8*)v1; - auto const* s2 = (const u8*)v2; + auto const* s1 = (u8 const*)v1; + auto const* s2 = (u8 const*)v2; while (n-- > 0) { if (*s1++ != *s2++) return s1[-1] < s2[-1] ? -1 : 1; @@ -131,20 +131,20 @@ int memcmp(const void* v1, const void* v2, size_t n) return 0; } -int strncmp(const char* s1, const char* s2, size_t n) +int strncmp(char const* s1, char const* s2, size_t n) { if (!n) return 0; do { if (*s1 != *s2++) - return *(const unsigned char*)s1 - *(const unsigned char*)--s2; + return *(unsigned char const*)s1 - *(unsigned char const*)--s2; if (*s1++ == 0) break; } while (--n); return 0; } -char* strstr(const char* haystack, const char* needle) +char* strstr(char const* haystack, char const* needle) { char nch; char hch; diff --git a/Kernel/Net/ARP.h b/Kernel/Net/ARP.h index 8d56810b393..fe984b94df1 100644 --- a/Kernel/Net/ARP.h +++ b/Kernel/Net/ARP.h @@ -43,17 +43,17 @@ public: u16 operation() const { return m_operation; } void set_operation(u16 w) { m_operation = w; } - const MACAddress& sender_hardware_address() const { return m_sender_hardware_address; } - void set_sender_hardware_address(const MACAddress& address) { m_sender_hardware_address = address; } + MACAddress const& sender_hardware_address() const { return m_sender_hardware_address; } + void set_sender_hardware_address(MACAddress const& address) { m_sender_hardware_address = address; } - const IPv4Address& sender_protocol_address() const { return m_sender_protocol_address; } - void set_sender_protocol_address(const IPv4Address& address) { m_sender_protocol_address = address; } + IPv4Address const& sender_protocol_address() const { return m_sender_protocol_address; } + void set_sender_protocol_address(IPv4Address const& address) { m_sender_protocol_address = address; } - const MACAddress& target_hardware_address() const { return m_target_hardware_address; } - void set_target_hardware_address(const MACAddress& address) { m_target_hardware_address = address; } + MACAddress const& target_hardware_address() const { return m_target_hardware_address; } + void set_target_hardware_address(MACAddress const& address) { m_target_hardware_address = address; } - const IPv4Address& target_protocol_address() const { return m_target_protocol_address; } - void set_target_protocol_address(const IPv4Address& address) { m_target_protocol_address = address; } + IPv4Address const& target_protocol_address() const { return m_target_protocol_address; } + void set_target_protocol_address(IPv4Address const& address) { m_target_protocol_address = address; } private: NetworkOrdered m_hardware_type { ARPHardwareType::Ethernet }; diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h index 63df81bcdaf..8468d0b588d 100644 --- a/Kernel/Net/EthernetFrameHeader.h +++ b/Kernel/Net/EthernetFrameHeader.h @@ -17,15 +17,15 @@ public: ~EthernetFrameHeader() = default; MACAddress destination() const { return m_destination; } - void set_destination(const MACAddress& address) { m_destination = address; } + void set_destination(MACAddress const& address) { m_destination = address; } MACAddress source() const { return m_source; } - void set_source(const MACAddress& address) { m_source = address; } + void set_source(MACAddress const& address) { m_source = address; } u16 ether_type() const { return m_ether_type; } void set_ether_type(u16 ether_type) { m_ether_type = ether_type; } - const void* payload() const { return &m_payload[0]; } + void const* payload() const { return &m_payload[0]; } void* payload() { return &m_payload[0]; } private: diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h index 0b0e807ce83..8f5ea3623a8 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -30,7 +30,7 @@ public: u16 checksum() const { return m_checksum; } void set_checksum(u16 w) { m_checksum = w; } - const void* payload() const { return this + 1; } + void const* payload() const { return this + 1; } void* payload() { return this + 1; } private: @@ -47,5 +47,5 @@ struct [[gnu::packed]] ICMPEchoPacket { NetworkOrdered identifier; NetworkOrdered sequence_number; void* payload() { return this + 1; } - const void* payload() const { return this + 1; } + void const* payload() const { return this + 1; } }; diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h index c5e22c4a46a..621ee71c481 100644 --- a/Kernel/Net/IPv4.h +++ b/Kernel/Net/IPv4.h @@ -24,7 +24,7 @@ enum class IPv4PacketFlags : u16 { MoreFragments = 0x2000, }; -NetworkOrdered internet_checksum(const void*, size_t); +NetworkOrdered internet_checksum(void const*, size_t); class [[gnu::packed]] IPv4Packet { public: @@ -52,14 +52,14 @@ public: u16 checksum() const { return m_checksum; } void set_checksum(u16 checksum) { m_checksum = checksum; } - const IPv4Address& source() const { return m_source; } - void set_source(const IPv4Address& address) { m_source = address; } + IPv4Address const& source() const { return m_source; } + void set_source(IPv4Address const& address) { m_source = address; } - const IPv4Address& destination() const { return m_destination; } - void set_destination(const IPv4Address& address) { m_destination = address; } + IPv4Address const& destination() const { return m_destination; } + void set_destination(IPv4Address const& address) { m_destination = address; } void* payload() { return this + 1; } - const void* payload() const { return this + 1; } + void const* payload() const { return this + 1; } u16 flags_and_fragment() const { return m_flags_and_fragment; } u16 fragment_offset() const { return ((u16)m_flags_and_fragment & 0x1fff); } @@ -106,10 +106,10 @@ private: static_assert(AssertSize()); -inline NetworkOrdered internet_checksum(const void* ptr, size_t count) +inline NetworkOrdered internet_checksum(void const* ptr, size_t count) { u32 checksum = 0; - auto* w = (const u16*)ptr; + auto* w = (u16 const*)ptr; while (count > 1) { checksum += AK::convert_between_host_and_network_endian(*w++); if (checksum & 0x80000000) diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 4204ae8f6cf..842e9a8f921 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -94,7 +94,7 @@ void IPv4Socket::get_peer_address(sockaddr* address, socklen_t* address_size) *address_size = sizeof(sockaddr_in); } -ErrorOr IPv4Socket::bind(Userspace user_address, socklen_t address_size) +ErrorOr IPv4Socket::bind(Userspace user_address, socklen_t address_size) { VERIFY(setup_state() == SetupState::Unstarted); if (address_size != sizeof(sockaddr_in)) @@ -114,7 +114,7 @@ ErrorOr IPv4Socket::bind(Userspace user_address, socklen_ } } - m_local_address = IPv4Address((const u8*)&address.sin_addr.s_addr); + m_local_address = IPv4Address((u8 const*)&address.sin_addr.s_addr); m_local_port = requested_local_port; dbgln_if(IPV4_SOCKET_DEBUG, "IPv4Socket::bind {}({}) to {}:{}", class_name(), this, m_local_address, m_local_port); @@ -138,12 +138,12 @@ ErrorOr IPv4Socket::listen(size_t backlog) return protocol_listen(result.did_allocate); } -ErrorOr IPv4Socket::connect(OpenFileDescription& description, Userspace address, socklen_t address_size, ShouldBlock should_block) +ErrorOr IPv4Socket::connect(OpenFileDescription& description, Userspace address, socklen_t address_size, ShouldBlock should_block) { if (address_size != sizeof(sockaddr_in)) return set_so_error(EINVAL); u16 sa_family_copy; - auto* user_address = reinterpret_cast(address.unsafe_userspace_ptr()); + auto* user_address = reinterpret_cast(address.unsafe_userspace_ptr()); SOCKET_TRY(copy_from_user(&sa_family_copy, &user_address->sa_family, sizeof(u16))); if (sa_family_copy != AF_INET) return set_so_error(EINVAL); @@ -153,7 +153,7 @@ ErrorOr IPv4Socket::connect(OpenFileDescription& description, Userspace IPv4Socket::connect(OpenFileDescription& description, Userspace IPv4Socket::sendto(OpenFileDescription&, const UserOrKernelBuffer& data, size_t data_length, [[maybe_unused]] int flags, Userspace addr, socklen_t addr_length) +ErrorOr IPv4Socket::sendto(OpenFileDescription&, UserOrKernelBuffer const& data, size_t data_length, [[maybe_unused]] int flags, Userspace addr, socklen_t addr_length) { MutexLocker locker(mutex()); @@ -196,14 +196,14 @@ ErrorOr IPv4Socket::sendto(OpenFileDescription&, const UserOrKernelBuffe if (addr) { sockaddr_in ia {}; - SOCKET_TRY(copy_from_user(&ia, Userspace(addr.ptr()))); + SOCKET_TRY(copy_from_user(&ia, Userspace(addr.ptr()))); if (ia.sin_family != AF_INET) { dmesgln("sendto: Bad address family: {} is not AF_INET", ia.sin_family); return set_so_error(EAFNOSUPPORT); } - m_peer_address = IPv4Address((const u8*)&ia.sin_addr.s_addr); + m_peer_address = IPv4Address((u8 const*)&ia.sin_addr.s_addr); m_peer_port = ntohs(ia.sin_port); } @@ -413,7 +413,7 @@ ErrorOr IPv4Socket::recvfrom(OpenFileDescription& description, UserOrKer return total_nreceived; } -bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, ReadonlyBytes packet, const Time& packet_timestamp) +bool IPv4Socket::did_receive(IPv4Address const& source_address, u16 source_port, ReadonlyBytes packet, Time const& packet_timestamp) { MutexLocker locker(mutex()); @@ -468,7 +468,7 @@ bool IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, return true; } -ErrorOr> IPv4Socket::pseudo_path(const OpenFileDescription&) const +ErrorOr> IPv4Socket::pseudo_path(OpenFileDescription const&) const { if (m_role == Role::None) return KString::try_create("socket"sv); @@ -500,7 +500,7 @@ ErrorOr> IPv4Socket::pseudo_path(const OpenFileDescriptio return KString::try_create(builder.string_view()); } -ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace user_value, socklen_t user_value_size) +ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace user_value, socklen_t user_value_size) { if (level != IPPROTO_IP) return Socket::setsockopt(level, option, user_value, user_value_size); @@ -512,7 +512,7 @@ ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace(user_value))); + TRY(copy_from_user(&value, static_ptr_cast(user_value))); if (value < 0 || value > 255) return EINVAL; m_ttl = value; @@ -522,7 +522,7 @@ ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace(user_value))); + TRY(copy_from_user(&value, static_ptr_cast(user_value))); if (value < 0 || value > 255) return EINVAL; m_type_of_service = value; @@ -532,7 +532,7 @@ ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace(user_value))); + TRY(copy_from_user(&value, static_ptr_cast(user_value))); if (value != 0 && value != 1) return EINVAL; m_multicast_loop = value; @@ -542,10 +542,10 @@ ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace(user_value))); + TRY(copy_from_user(&mreq, static_ptr_cast(user_value))); if (mreq.imr_interface.s_addr != INADDR_ANY) return ENOTSUP; - IPv4Address address { (const u8*)&mreq.imr_multiaddr.s_addr }; + IPv4Address address { (u8 const*)&mreq.imr_multiaddr.s_addr }; if (!m_multicast_memberships.contains_slow(address)) m_multicast_memberships.append(address); return {}; @@ -554,10 +554,10 @@ ErrorOr IPv4Socket::setsockopt(int level, int option, Userspace(user_value))); + TRY(copy_from_user(&mreq, static_ptr_cast(user_value))); if (mreq.imr_interface.s_addr != INADDR_ANY) return ENOTSUP; - IPv4Address address { (const u8*)&mreq.imr_multiaddr.s_addr }; + IPv4Address address { (u8 const*)&mreq.imr_multiaddr.s_addr }; m_multicast_memberships.remove_first_matching([&address](auto& a) { return a == address; }); return {}; } @@ -596,7 +596,7 @@ ErrorOr IPv4Socket::getsockopt(OpenFileDescription& description, int level case IP_MULTICAST_LOOP: { if (size < 1) return EINVAL; - TRY(copy_to_user(static_ptr_cast(value), (const u8*)&m_multicast_loop)); + TRY(copy_to_user(static_ptr_cast(value), (u8 const*)&m_multicast_loop)); size = 1; return copy_to_user(value_size, &size); } diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 73c77fae53f..967419251ab 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -32,36 +32,36 @@ public: virtual ~IPv4Socket() override; virtual ErrorOr close() override; - virtual ErrorOr bind(Userspace, socklen_t) override; - virtual ErrorOr connect(OpenFileDescription&, Userspace, socklen_t, ShouldBlock = ShouldBlock::Yes) override; + virtual ErrorOr bind(Userspace, socklen_t) override; + virtual ErrorOr connect(OpenFileDescription&, Userspace, socklen_t, ShouldBlock = ShouldBlock::Yes) override; virtual ErrorOr listen(size_t) override; virtual void get_local_address(sockaddr*, socklen_t*) override; virtual void get_peer_address(sockaddr*, socklen_t*) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr sendto(OpenFileDescription&, const UserOrKernelBuffer&, size_t, int, Userspace, socklen_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int, Userspace, socklen_t) override; virtual ErrorOr recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace, Userspace, Time&) override; - virtual ErrorOr setsockopt(int level, int option, Userspace, socklen_t) override; + virtual ErrorOr setsockopt(int level, int option, Userspace, socklen_t) override; virtual ErrorOr getsockopt(OpenFileDescription&, int level, int option, Userspace, Userspace) override; virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; - bool did_receive(const IPv4Address& peer_address, u16 peer_port, ReadonlyBytes, const Time&); + bool did_receive(IPv4Address const& peer_address, u16 peer_port, ReadonlyBytes, Time const&); - const IPv4Address& local_address() const { return m_local_address; } + IPv4Address const& local_address() const { return m_local_address; } u16 local_port() const { return m_local_port; } void set_local_port(u16 port) { m_local_port = port; } bool has_specific_local_address() { return m_local_address.to_u32() != 0; } - const IPv4Address& peer_address() const { return m_peer_address; } + IPv4Address const& peer_address() const { return m_peer_address; } u16 peer_port() const { return m_peer_port; } void set_peer_port(u16 port) { m_peer_port = port; } - const Vector& multicast_memberships() const { return m_multicast_memberships; } + Vector const& multicast_memberships() const { return m_multicast_memberships; } IPv4SocketTuple tuple() const { return IPv4SocketTuple(m_local_address, m_local_port, m_peer_address, m_peer_port); } - ErrorOr> pseudo_path(const OpenFileDescription& description) const override; + ErrorOr> pseudo_path(OpenFileDescription const& description) const override; u8 type_of_service() const { return m_type_of_service; } u8 ttl() const { return m_ttl; } @@ -81,7 +81,7 @@ protected: virtual ErrorOr protocol_bind() { return {}; } virtual ErrorOr protocol_listen([[maybe_unused]] bool did_allocate_port) { return {}; } virtual ErrorOr protocol_receive(ReadonlyBytes /* raw_ipv4_packet */, UserOrKernelBuffer&, size_t, int) { return ENOTIMPL; } - virtual ErrorOr protocol_send(const UserOrKernelBuffer&, size_t) { return ENOTIMPL; } + virtual ErrorOr protocol_send(UserOrKernelBuffer const&, size_t) { return ENOTIMPL; } virtual ErrorOr protocol_connect(OpenFileDescription&, ShouldBlock) { return {}; } virtual ErrorOr protocol_allocate_local_port() { return ENOPROTOOPT; } virtual ErrorOr protocol_size(ReadonlyBytes /* raw_ipv4_packet */) { return ENOTIMPL; } diff --git a/Kernel/Net/IPv4SocketTuple.h b/Kernel/Net/IPv4SocketTuple.h index a63d3aca717..c763a4ab7ff 100644 --- a/Kernel/Net/IPv4SocketTuple.h +++ b/Kernel/Net/IPv4SocketTuple.h @@ -29,7 +29,7 @@ public: IPv4Address peer_address() const { return m_peer_address; }; u16 peer_port() const { return m_peer_port; }; - bool operator==(const IPv4SocketTuple& other) const + bool operator==(IPv4SocketTuple const& other) const { return other.local_address() == m_local_address && other.local_port() == m_local_port && other.peer_address() == m_peer_address && other.peer_port() == m_peer_port; }; @@ -57,7 +57,7 @@ namespace AK { template<> struct Traits : public GenericTraits { - static unsigned hash(const Kernel::IPv4SocketTuple& tuple) + static unsigned hash(Kernel::IPv4SocketTuple const& tuple) { auto h1 = pair_int_hash(tuple.local_address().to_u32(), tuple.local_port()); auto h2 = pair_int_hash(tuple.peer_address().to_u32(), tuple.peer_port()); diff --git a/Kernel/Net/Intel/E1000ENetworkAdapter.cpp b/Kernel/Net/Intel/E1000ENetworkAdapter.cpp index 82726a9af16..7d0f2cfb709 100644 --- a/Kernel/Net/Intel/E1000ENetworkAdapter.cpp +++ b/Kernel/Net/Intel/E1000ENetworkAdapter.cpp @@ -222,7 +222,7 @@ UNMAP_AFTER_INIT bool E1000ENetworkAdapter::initialize() detect_eeprom(); dmesgln("E1000e: Has EEPROM? {}", m_has_eeprom); read_mac_address(); - const auto& mac = mac_address(); + auto const& mac = mac_address(); dmesgln("E1000e: MAC address: {}", mac.to_string()); initialize_rx_descriptors(); diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.cpp b/Kernel/Net/Intel/E1000NetworkAdapter.cpp index 2c4b04af4e5..e0ca57a69db 100644 --- a/Kernel/Net/Intel/E1000NetworkAdapter.cpp +++ b/Kernel/Net/Intel/E1000NetworkAdapter.cpp @@ -213,7 +213,7 @@ UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize() detect_eeprom(); dmesgln("E1000: Has EEPROM? {}", m_has_eeprom); read_mac_address(); - const auto& mac = mac_address(); + auto const& mac = mac_address(); dmesgln("E1000: MAC address: {}", mac.to_string()); initialize_rx_descriptors(); @@ -238,7 +238,7 @@ UNMAP_AFTER_INIT E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, UNMAP_AFTER_INIT E1000NetworkAdapter::~E1000NetworkAdapter() = default; -bool E1000NetworkAdapter::handle_irq(const RegisterState&) +bool E1000NetworkAdapter::handle_irq(RegisterState const&) { u32 status = in32(REG_INTERRUPT_CAUSE_READ); @@ -370,7 +370,7 @@ void E1000NetworkAdapter::out8(u16 address, u8 data) { dbgln_if(E1000_DEBUG, "E1000: OUT8 {:#02x} @ {:#04x}", data, address); if (m_use_mmio) { - auto* ptr = (volatile u8*)(m_mmio_base.get() + address); + auto* ptr = (u8 volatile*)(m_mmio_base.get() + address); *ptr = data; return; } @@ -381,7 +381,7 @@ void E1000NetworkAdapter::out16(u16 address, u16 data) { dbgln_if(E1000_DEBUG, "E1000: OUT16 {:#04x} @ {:#04x}", data, address); if (m_use_mmio) { - auto* ptr = (volatile u16*)(m_mmio_base.get() + address); + auto* ptr = (u16 volatile*)(m_mmio_base.get() + address); *ptr = data; return; } @@ -392,7 +392,7 @@ void E1000NetworkAdapter::out32(u16 address, u32 data) { dbgln_if(E1000_DEBUG, "E1000: OUT32 {:#08x} @ {:#04x}", data, address); if (m_use_mmio) { - auto* ptr = (volatile u32*)(m_mmio_base.get() + address); + auto* ptr = (u32 volatile*)(m_mmio_base.get() + address); *ptr = data; return; } @@ -403,7 +403,7 @@ u8 E1000NetworkAdapter::in8(u16 address) { dbgln_if(E1000_DEBUG, "E1000: IN8 @ {:#04x}", address); if (m_use_mmio) - return *(volatile u8*)(m_mmio_base.get() + address); + return *(u8 volatile*)(m_mmio_base.get() + address); return m_io_base.offset(address).in(); } @@ -411,7 +411,7 @@ u16 E1000NetworkAdapter::in16(u16 address) { dbgln_if(E1000_DEBUG, "E1000: IN16 @ {:#04x}", address); if (m_use_mmio) - return *(volatile u16*)(m_mmio_base.get() + address); + return *(u16 volatile*)(m_mmio_base.get() + address); return m_io_base.offset(address).in(); } @@ -419,7 +419,7 @@ u32 E1000NetworkAdapter::in32(u16 address) { dbgln_if(E1000_DEBUG, "E1000: IN32 @ {:#04x}", address); if (m_use_mmio) - return *(volatile u32*)(m_mmio_base.get() + address); + return *(u32 volatile*)(m_mmio_base.get() + address); return m_io_base.offset(address).in(); } diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.h b/Kernel/Net/Intel/E1000NetworkAdapter.h index b0905e231a9..ba7afbf3f2c 100644 --- a/Kernel/Net/Intel/E1000NetworkAdapter.h +++ b/Kernel/Net/Intel/E1000NetworkAdapter.h @@ -38,7 +38,7 @@ protected: void setup_link(); E1000NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr); - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; virtual StringView class_name() const override { return "E1000NetworkAdapter"sv; } struct [[gnu::packed]] e1000_rx_desc { diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 57b811637aa..b2c2d11db79 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -27,16 +27,16 @@ static MutexProtected& all_sockets() return *s_list; } -void LocalSocket::for_each(Function callback) +void LocalSocket::for_each(Function callback) { - all_sockets().for_each_shared([&](const auto& socket) { + all_sockets().for_each_shared([&](auto const& socket) { callback(socket); }); } -ErrorOr LocalSocket::try_for_each(Function(const LocalSocket&)> callback) +ErrorOr LocalSocket::try_for_each(Function(LocalSocket const&)> callback) { - return all_sockets().with_shared([&](const auto& sockets) -> ErrorOr { + return all_sockets().with_shared([&](auto const& sockets) -> ErrorOr { for (auto& socket : sockets) TRY(callback(socket)); return {}; @@ -115,7 +115,7 @@ void LocalSocket::get_peer_address(sockaddr* address, socklen_t* address_size) get_local_address(address, address_size); } -ErrorOr LocalSocket::bind(Userspace user_address, socklen_t address_size) +ErrorOr LocalSocket::bind(Userspace user_address, socklen_t address_size) { VERIFY(setup_state() == SetupState::Unstarted); if (address_size != sizeof(sockaddr_un)) @@ -153,13 +153,13 @@ ErrorOr LocalSocket::bind(Userspace user_address, socklen return {}; } -ErrorOr LocalSocket::connect(OpenFileDescription& description, Userspace address, socklen_t address_size, ShouldBlock) +ErrorOr LocalSocket::connect(OpenFileDescription& description, Userspace address, socklen_t address_size, ShouldBlock) { VERIFY(!m_bound); if (address_size != sizeof(sockaddr_un)) return set_so_error(EINVAL); u16 sa_family_copy; - auto* user_address = reinterpret_cast(address.unsafe_userspace_ptr()); + auto* user_address = reinterpret_cast(address.unsafe_userspace_ptr()); SOCKET_TRY(copy_from_user(&sa_family_copy, &user_address->sa_family, sizeof(u16))); if (sa_family_copy != AF_LOCAL) return set_so_error(EINVAL); @@ -268,7 +268,7 @@ void LocalSocket::detach(OpenFileDescription& description) evaluate_block_conditions(); } -bool LocalSocket::can_read(const OpenFileDescription& description, u64) const +bool LocalSocket::can_read(OpenFileDescription const& description, u64) const { auto role = this->role(description); if (role == Role::Listener) @@ -280,7 +280,7 @@ bool LocalSocket::can_read(const OpenFileDescription& description, u64) const return false; } -bool LocalSocket::has_attached_peer(const OpenFileDescription& description) const +bool LocalSocket::has_attached_peer(OpenFileDescription const& description) const { auto role = this->role(description); if (role == Role::Accepted) @@ -290,7 +290,7 @@ bool LocalSocket::has_attached_peer(const OpenFileDescription& description) cons return false; } -bool LocalSocket::can_write(const OpenFileDescription& description, u64) const +bool LocalSocket::can_write(OpenFileDescription const& description, u64) const { auto role = this->role(description); if (role == Role::Accepted) @@ -300,7 +300,7 @@ bool LocalSocket::can_write(const OpenFileDescription& description, u64) const return false; } -ErrorOr LocalSocket::sendto(OpenFileDescription& description, const UserOrKernelBuffer& data, size_t data_size, int, Userspace, socklen_t) +ErrorOr LocalSocket::sendto(OpenFileDescription& description, UserOrKernelBuffer const& data, size_t data_size, int, Userspace, socklen_t) { if (!has_attached_peer(description)) return set_so_error(EPIPE); @@ -365,7 +365,7 @@ StringView LocalSocket::socket_path() const return m_path->view(); } -ErrorOr> LocalSocket::pseudo_path(const OpenFileDescription& description) const +ErrorOr> LocalSocket::pseudo_path(OpenFileDescription const& description) const { StringBuilder builder; TRY(builder.try_append("socket:")); @@ -469,7 +469,7 @@ ErrorOr LocalSocket::chown(OpenFileDescription&, UserID uid, GroupID gid) return {}; } -NonnullRefPtrVector& LocalSocket::recvfd_queue_for(const OpenFileDescription& description) +NonnullRefPtrVector& LocalSocket::recvfd_queue_for(OpenFileDescription const& description) { auto role = this->role(description); if (role == Role::Connected) @@ -479,7 +479,7 @@ NonnullRefPtrVector& LocalSocket::recvfd_queue_for(const Op VERIFY_NOT_REACHED(); } -NonnullRefPtrVector& LocalSocket::sendfd_queue_for(const OpenFileDescription& description) +NonnullRefPtrVector& LocalSocket::sendfd_queue_for(OpenFileDescription const& description) { auto role = this->role(description); if (role == Role::Connected) @@ -503,7 +503,7 @@ ErrorOr LocalSocket::sendfd(OpenFileDescription const& socket_description, return {}; } -ErrorOr> LocalSocket::recvfd(const OpenFileDescription& socket_description) +ErrorOr> LocalSocket::recvfd(OpenFileDescription const& socket_description) { MutexLocker locker(mutex()); auto role = this->role(socket_description); diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index 4bc5c3e4a32..1eea1eb23bc 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -27,25 +27,25 @@ public: virtual ~LocalSocket() override; ErrorOr sendfd(OpenFileDescription const& socket_description, NonnullRefPtr passing_description); - ErrorOr> recvfd(const OpenFileDescription& socket_description); + ErrorOr> recvfd(OpenFileDescription const& socket_description); - static void for_each(Function); - static ErrorOr try_for_each(Function(const LocalSocket&)>); + static void for_each(Function); + static ErrorOr try_for_each(Function(LocalSocket const&)>); StringView socket_path() const; - ErrorOr> pseudo_path(const OpenFileDescription& description) const override; + ErrorOr> pseudo_path(OpenFileDescription const& description) const override; // ^Socket - virtual ErrorOr bind(Userspace, socklen_t) override; - virtual ErrorOr connect(OpenFileDescription&, Userspace, socklen_t, ShouldBlock = ShouldBlock::Yes) override; + virtual ErrorOr bind(Userspace, socklen_t) override; + virtual ErrorOr connect(OpenFileDescription&, Userspace, socklen_t, ShouldBlock = ShouldBlock::Yes) override; virtual ErrorOr listen(size_t) override; virtual void get_local_address(sockaddr*, socklen_t*) override; virtual void get_peer_address(sockaddr*, socklen_t*) override; virtual ErrorOr attach(OpenFileDescription&) override; virtual void detach(OpenFileDescription&) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr sendto(OpenFileDescription&, const UserOrKernelBuffer&, size_t, int, Userspace, socklen_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int, Userspace, socklen_t) override; virtual ErrorOr recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace, Userspace, Time&) override; virtual ErrorOr getsockopt(OpenFileDescription&, int level, int option, Userspace, Userspace) override; virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; @@ -56,11 +56,11 @@ private: explicit LocalSocket(int type, NonnullOwnPtr client_buffer, NonnullOwnPtr server_buffer); virtual StringView class_name() const override { return "LocalSocket"sv; } virtual bool is_local() const override { return true; } - bool has_attached_peer(const OpenFileDescription&) const; + bool has_attached_peer(OpenFileDescription const&) const; DoubleBuffer* receive_buffer_for(OpenFileDescription&); DoubleBuffer* send_buffer_for(OpenFileDescription&); - NonnullRefPtrVector& sendfd_queue_for(const OpenFileDescription&); - NonnullRefPtrVector& recvfd_queue_for(const OpenFileDescription&); + NonnullRefPtrVector& sendfd_queue_for(OpenFileDescription const&); + NonnullRefPtrVector& recvfd_queue_for(OpenFileDescription const&); void set_connect_side_role(Role connect_side_role, bool force_evaluate_block_conditions = false) { @@ -86,7 +86,7 @@ private: Role m_connect_side_role { Role::None }; OpenFileDescription* m_connect_side_fd { nullptr }; - virtual Role role(const OpenFileDescription& description) const override + virtual Role role(OpenFileDescription const& description) const override { if (m_connect_side_fd == &description) return m_connect_side_role; diff --git a/Kernel/Net/NE2000/NetworkAdapter.cpp b/Kernel/Net/NE2000/NetworkAdapter.cpp index 83146b94844..1cc1ef25e99 100644 --- a/Kernel/Net/NE2000/NetworkAdapter.cpp +++ b/Kernel/Net/NE2000/NetworkAdapter.cpp @@ -187,7 +187,7 @@ UNMAP_AFTER_INIT NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address UNMAP_AFTER_INIT NE2000NetworkAdapter::~NE2000NetworkAdapter() = default; -bool NE2000NetworkAdapter::handle_irq(const RegisterState&) +bool NE2000NetworkAdapter::handle_irq(RegisterState const&) { u8 status = in8(REG_RW_INTERRUPTSTATUS); diff --git a/Kernel/Net/NE2000/NetworkAdapter.h b/Kernel/Net/NE2000/NetworkAdapter.h index f901a934ea1..b4900cb0945 100644 --- a/Kernel/Net/NE2000/NetworkAdapter.h +++ b/Kernel/Net/NE2000/NetworkAdapter.h @@ -42,7 +42,7 @@ public: private: NE2000NetworkAdapter(PCI::Address, u8, NonnullOwnPtr); - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; virtual StringView class_name() const override { return "NE2000NetworkAdapter"sv; } int ram_test(); diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp index d471878bee7..4c64f006345 100644 --- a/Kernel/Net/NetworkAdapter.cpp +++ b/Kernel/Net/NetworkAdapter.cpp @@ -28,7 +28,7 @@ void NetworkAdapter::send_packet(ReadonlyBytes packet) send_raw(packet); } -void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet) +void NetworkAdapter::send(MACAddress const& destination, ARPPacket const& packet) { size_t size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(ARPPacket); auto buffer_result = NetworkByteBuffer::create_zeroed(size_in_bytes); @@ -41,7 +41,7 @@ void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet eth->set_destination(destination); eth->set_ether_type(EtherType::ARP); memcpy(eth->payload(), &packet, sizeof(ARPPacket)); - send_packet({ (const u8*)eth, size_in_bytes }); + send_packet({ (u8 const*)eth, size_in_bytes }); } void NetworkAdapter::fill_in_ipv4_header(PacketWithTimestamp& packet, IPv4Address const& source_ipv4, MACAddress const& destination_mac, IPv4Address const& destination_ipv4, IPv4Protocol protocol, size_t payload_size, u8 type_of_service, u8 ttl) @@ -149,17 +149,17 @@ void NetworkAdapter::release_packet_buffer(PacketWithTimestamp& packet) m_unused_packets.append(packet); } -void NetworkAdapter::set_ipv4_address(const IPv4Address& address) +void NetworkAdapter::set_ipv4_address(IPv4Address const& address) { m_ipv4_address = address; } -void NetworkAdapter::set_ipv4_netmask(const IPv4Address& netmask) +void NetworkAdapter::set_ipv4_netmask(IPv4Address const& netmask) { m_ipv4_netmask = netmask; } -void NetworkAdapter::set_ipv4_gateway(const IPv4Address& gateway) +void NetworkAdapter::set_ipv4_gateway(IPv4Address const& gateway) { m_ipv4_gateway = gateway; } diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 0c69b6230fc..8ccee2a6131 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -64,11 +64,11 @@ public: } virtual bool link_full_duplex() { return false; } - void set_ipv4_address(const IPv4Address&); - void set_ipv4_netmask(const IPv4Address&); - void set_ipv4_gateway(const IPv4Address&); + void set_ipv4_address(IPv4Address const&); + void set_ipv4_netmask(IPv4Address const&); + void set_ipv4_gateway(IPv4Address const&); - void send(const MACAddress&, const ARPPacket&); + void send(MACAddress const&, ARPPacket const&); void fill_in_ipv4_header(PacketWithTimestamp&, IPv4Address const&, MACAddress const&, IPv4Address const&, IPv4Protocol, size_t, u8 type_of_service, u8 ttl); size_t dequeue_packet(u8* buffer, size_t buffer_size, Time& packet_timestamp); @@ -95,7 +95,7 @@ public: protected: NetworkAdapter(NonnullOwnPtr); - void set_mac_address(const MACAddress& mac_address) { m_mac_address = mac_address; } + void set_mac_address(MACAddress const& mac_address) { m_mac_address = mac_address; } void did_receive(ReadonlyBytes); virtual void send_raw(ReadonlyBytes) = 0; diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index b499e3fb394..53df9665b5b 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -658,7 +658,7 @@ void retransmit_tcp_packets() // We must keep the sockets alive until after we've unlocked the hash table // in case retransmit_packets() realizes that it wants to close the socket. NonnullRefPtrVector sockets; - TCPSocket::sockets_for_retransmit().for_each_shared([&](const auto& socket) { + TCPSocket::sockets_for_retransmit().for_each_shared([&](auto const& socket) { // We ignore allocation failures above the first 16 guaranteed socket slots, as // we will just retransmit their packets the next time around (void)sockets.try_append(socket); diff --git a/Kernel/Net/NetworkingManagement.h b/Kernel/Net/NetworkingManagement.h index 43bb8a64551..00015d47a2f 100644 --- a/Kernel/Net/NetworkingManagement.h +++ b/Kernel/Net/NetworkingManagement.h @@ -33,7 +33,7 @@ public: void for_each(Function); ErrorOr try_for_each(Function(NetworkAdapter&)>); - RefPtr from_ipv4_address(const IPv4Address&) const; + RefPtr from_ipv4_address(IPv4Address const&) const; RefPtr lookup_by_name(StringView) const; NonnullRefPtr loopback_adapter() const; diff --git a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp index 2b00bf52b5b..6481280a750 100644 --- a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp +++ b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp @@ -156,7 +156,7 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre reset(); read_mac_address(); - const auto& mac = mac_address(); + auto const& mac = mac_address(); dmesgln("RTL8139: MAC address: {}", mac.to_string()); enable_irq(); @@ -164,7 +164,7 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre UNMAP_AFTER_INIT RTL8139NetworkAdapter::~RTL8139NetworkAdapter() = default; -bool RTL8139NetworkAdapter::handle_irq(const RegisterState&) +bool RTL8139NetworkAdapter::handle_irq(RegisterState const&) { bool was_handled = false; for (;;) { @@ -324,8 +324,8 @@ void RTL8139NetworkAdapter::receive() { auto* start_of_packet = m_rx_buffer->vaddr().as_ptr() + m_rx_buffer_offset; - u16 status = *(const u16*)(start_of_packet + 0); - u16 length = *(const u16*)(start_of_packet + 2); + u16 status = *(u16 const*)(start_of_packet + 0); + u16 length = *(u16 const*)(start_of_packet + 2); dbgln_if(RTL8139_DEBUG, "RTL8139: receive, status={:#04x}, length={}, offset={}", status, length, m_rx_buffer_offset); @@ -338,7 +338,7 @@ void RTL8139NetworkAdapter::receive() // we never have to worry about the packet wrapping around the buffer, // since we set RXCFG_WRAP_INHIBIT, which allows the rtl8139 to write data // past the end of the allotted space. - memcpy(m_packet_buffer->vaddr().as_ptr(), (const u8*)(start_of_packet + 4), length - 4); + memcpy(m_packet_buffer->vaddr().as_ptr(), (u8 const*)(start_of_packet + 4), length - 4); // let the card know that we've read this data m_rx_buffer_offset = ((m_rx_buffer_offset + length + 4 + 3) & ~3) % RX_BUFFER_SIZE; out16(REG_CAPR, m_rx_buffer_offset - 0x10); diff --git a/Kernel/Net/Realtek/RTL8139NetworkAdapter.h b/Kernel/Net/Realtek/RTL8139NetworkAdapter.h index 2046cf9c11c..8613d89cae6 100644 --- a/Kernel/Net/Realtek/RTL8139NetworkAdapter.h +++ b/Kernel/Net/Realtek/RTL8139NetworkAdapter.h @@ -35,7 +35,7 @@ public: private: RTL8139NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr); - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; virtual StringView class_name() const override { return "RTL8139NetworkAdapter"sv; } void reset(); diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp index 5ddc016dcd4..0d1fcc39450 100644 --- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp +++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp @@ -1127,7 +1127,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_tx_descriptors() UNMAP_AFTER_INIT RTL8168NetworkAdapter::~RTL8168NetworkAdapter() = default; -bool RTL8168NetworkAdapter::handle_irq(const RegisterState&) +bool RTL8168NetworkAdapter::handle_irq(RegisterState const&) { bool was_handled = false; for (;;) { diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h index dfc404aae63..01106f3640c 100644 --- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h +++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h @@ -40,7 +40,7 @@ private: RTL8168NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr); - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; virtual StringView class_name() const override { return "RTL8168NetworkAdapter"sv; } bool determine_supported_version() const; diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp index 46d57744ded..e8a0aaed863 100644 --- a/Kernel/Net/Routing.cpp +++ b/Kernel/Net/Routing.cpp @@ -70,7 +70,7 @@ protected: { VERIFY(b.blocker_type() == Thread::Blocker::Type::Routing); auto& blocker = static_cast(b); - auto maybe_mac_address = arp_table().with([&](auto const& table) -> auto { + auto maybe_mac_address = arp_table().with([&](auto const& table) -> auto{ return table.get(blocker.ip_address()); }); if (!maybe_mac_address.has_value()) @@ -94,7 +94,7 @@ bool ARPTableBlocker::setup_blocker() void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason) { - auto addr = arp_table().with([&](auto const& table) -> auto { + auto addr = arp_table().with([&](auto const& table) -> auto{ return table.get(ip_address()); }); @@ -232,7 +232,7 @@ RoutingDecision route_to(IPv4Address const& target, IPv4Address const& source, R return { adapter, multicast_ethernet_address(target) }; { - auto addr = arp_table().with([&](auto const& table) -> auto { + auto addr = arp_table().with([&](auto const& table) -> auto{ return table.get(next_hop_ip); }); if (addr.has_value()) { diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index 77654ef8ac3..3673969a5e9 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -74,7 +74,7 @@ ErrorOr Socket::queue_connection_from(NonnullRefPtr peer) return {}; } -ErrorOr Socket::setsockopt(int level, int option, Userspace user_value, socklen_t user_value_size) +ErrorOr Socket::setsockopt(int level, int option, Userspace user_value, socklen_t user_value_size) { MutexLocker locker(mutex()); @@ -95,7 +95,7 @@ ErrorOr Socket::setsockopt(int level, int option, Userspace u case SO_BINDTODEVICE: { if (user_value_size != IFNAMSIZ) return EINVAL; - auto user_string = static_ptr_cast(user_value); + auto user_string = static_ptr_cast(user_value); auto ifname = TRY(try_copy_kstring_from_user(user_string, user_value_size)); auto device = NetworkingManagement::the().lookup_by_name(ifname->view()); if (!device) @@ -242,7 +242,7 @@ ErrorOr Socket::read(OpenFileDescription& description, u64, UserOrKernel return recvfrom(description, buffer, size, 0, {}, 0, t); } -ErrorOr Socket::write(OpenFileDescription& description, u64, const UserOrKernelBuffer& data, size_t size) +ErrorOr Socket::write(OpenFileDescription& description, u64, UserOrKernelBuffer const& data, size_t size) { if (is_shut_down_for_writing()) return set_so_error(EPIPE); diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 979df8b27c0..6c0685b9809 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -68,7 +68,7 @@ public: SetupState setup_state() const { return m_setup_state; } void set_setup_state(SetupState setup_state); - virtual Role role(const OpenFileDescription&) const { return m_role; } + virtual Role role(OpenFileDescription const&) const { return m_role; } bool is_connected() const { return m_connected; } void set_connected(bool); @@ -78,17 +78,17 @@ public: ErrorOr shutdown(int how); - virtual ErrorOr bind(Userspace, socklen_t) = 0; - virtual ErrorOr connect(OpenFileDescription&, Userspace, socklen_t, ShouldBlock) = 0; + virtual ErrorOr bind(Userspace, socklen_t) = 0; + virtual ErrorOr connect(OpenFileDescription&, Userspace, socklen_t, ShouldBlock) = 0; virtual ErrorOr listen(size_t) = 0; virtual void get_local_address(sockaddr*, socklen_t*) = 0; virtual void get_peer_address(sockaddr*, socklen_t*) = 0; virtual bool is_local() const { return false; } virtual bool is_ipv4() const { return false; } - virtual ErrorOr sendto(OpenFileDescription&, const UserOrKernelBuffer&, size_t, int flags, Userspace, socklen_t) = 0; + virtual ErrorOr sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int flags, Userspace, socklen_t) = 0; virtual ErrorOr recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace, Userspace, Time&) = 0; - virtual ErrorOr setsockopt(int level, int option, Userspace, socklen_t); + virtual ErrorOr setsockopt(int level, int option, Userspace, socklen_t); virtual ErrorOr getsockopt(OpenFileDescription&, int level, int option, Userspace, Userspace); ProcessID origin_pid() const { return m_origin.pid; } @@ -97,21 +97,21 @@ public: ProcessID acceptor_pid() const { return m_acceptor.pid; } UserID acceptor_uid() const { return m_acceptor.uid; } GroupID acceptor_gid() const { return m_acceptor.gid; } - const RefPtr bound_interface() const { return m_bound_interface; } + RefPtr const bound_interface() const { return m_bound_interface; } Mutex& mutex() { return m_mutex; } // ^File virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override final; - virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override final; + virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override final; virtual ErrorOr stat() const override; - virtual ErrorOr> pseudo_path(const OpenFileDescription&) const override = 0; + virtual ErrorOr> pseudo_path(OpenFileDescription const&) const override = 0; bool has_receive_timeout() const { return m_receive_timeout != Time::zero(); } - const Time& receive_timeout() const { return m_receive_timeout; } + Time const& receive_timeout() const { return m_receive_timeout; } bool has_send_timeout() const { return m_send_timeout != Time::zero(); } - const Time& send_timeout() const { return m_send_timeout; } + Time const& send_timeout() const { return m_send_timeout; } bool wants_timestamp() const { return m_timestamp; } diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h index be1a0d04786..a517089b8e4 100644 --- a/Kernel/Net/TCP.h +++ b/Kernel/Net/TCP.h @@ -78,7 +78,7 @@ public: u16 urgent() const { return m_urgent; } void set_urgent(u16 urgent) { m_urgent = urgent; } - const void* payload() const { return ((const u8*)this) + header_size(); } + void const* payload() const { return ((u8 const*)this) + header_size(); } void* payload() { return ((u8*)this) + header_size(); } private: diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index d52acd51660..8ff2944678e 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -22,16 +22,16 @@ namespace Kernel { -void TCPSocket::for_each(Function callback) +void TCPSocket::for_each(Function callback) { - sockets_by_tuple().for_each_shared([&](const auto& it) { + sockets_by_tuple().for_each_shared([&](auto const& it) { callback(*it.value); }); } -ErrorOr TCPSocket::try_for_each(Function(const TCPSocket&)> callback) +ErrorOr TCPSocket::try_for_each(Function(TCPSocket const&)> callback) { - return sockets_by_tuple().with_shared([&](const auto& sockets) -> ErrorOr { + return sockets_by_tuple().with_shared([&](auto const& sockets) -> ErrorOr { for (auto& it : sockets) TRY(callback(*it.value)); return {}; @@ -102,9 +102,9 @@ MutexProtected>& TCPSocket::sockets_by_tupl return *s_socket_tuples; } -RefPtr TCPSocket::from_tuple(const IPv4SocketTuple& tuple) +RefPtr TCPSocket::from_tuple(IPv4SocketTuple const& tuple) { - return sockets_by_tuple().with_shared([&](const auto& table) -> RefPtr { + return sockets_by_tuple().with_shared([&](auto const& table) -> RefPtr { auto exact_match = table.get(tuple); if (exact_match.has_value()) return { *exact_match.value() }; @@ -122,7 +122,7 @@ RefPtr TCPSocket::from_tuple(const IPv4SocketTuple& tuple) return {}; }); } -ErrorOr> TCPSocket::try_create_client(const IPv4Address& new_local_address, u16 new_local_port, const IPv4Address& new_peer_address, u16 new_peer_port) +ErrorOr> TCPSocket::try_create_client(IPv4Address const& new_local_address, u16 new_local_port, IPv4Address const& new_peer_address, u16 new_peer_port) { auto tuple = IPv4SocketTuple(new_local_address, new_local_port, new_peer_address, new_peer_port); return sockets_by_tuple().with_exclusive([&](auto& table) -> ErrorOr> { @@ -184,15 +184,15 @@ ErrorOr> TCPSocket::try_create(int protocol, NonnullOwn ErrorOr TCPSocket::protocol_size(ReadonlyBytes raw_ipv4_packet) { - auto& ipv4_packet = *reinterpret_cast(raw_ipv4_packet.data()); - auto& tcp_packet = *static_cast(ipv4_packet.payload()); + auto& ipv4_packet = *reinterpret_cast(raw_ipv4_packet.data()); + auto& tcp_packet = *static_cast(ipv4_packet.payload()); return raw_ipv4_packet.size() - sizeof(IPv4Packet) - tcp_packet.header_size(); } ErrorOr TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags) { - auto& ipv4_packet = *reinterpret_cast(raw_ipv4_packet.data()); - auto& tcp_packet = *static_cast(ipv4_packet.payload()); + auto& ipv4_packet = *reinterpret_cast(raw_ipv4_packet.data()); + auto& tcp_packet = *static_cast(ipv4_packet.payload()); size_t payload_size = raw_ipv4_packet.size() - sizeof(IPv4Packet) - tcp_packet.header_size(); dbgln_if(TCP_SOCKET_DEBUG, "payload_size {}, will it fit in {}?", payload_size, buffer_size); VERIFY(buffer_size >= payload_size); @@ -200,7 +200,7 @@ ErrorOr TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserO return payload_size; } -ErrorOr TCPSocket::protocol_send(const UserOrKernelBuffer& data, size_t data_length) +ErrorOr TCPSocket::protocol_send(UserOrKernelBuffer const& data, size_t data_length) { RoutingDecision routing_decision = route_to(peer_address(), local_address(), bound_interface()); if (routing_decision.is_zero()) @@ -218,7 +218,7 @@ ErrorOr TCPSocket::send_ack(bool allow_duplicate) return send_tcp_packet(TCPFlags::ACK); } -ErrorOr TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload, size_t payload_size, RoutingDecision* user_routing_decision) +ErrorOr TCPSocket::send_tcp_packet(u16 flags, UserOrKernelBuffer const* payload, size_t payload_size, RoutingDecision* user_routing_decision) { RoutingDecision routing_decision = user_routing_decision ? *user_routing_decision : route_to(peer_address(), local_address(), bound_interface()); if (routing_decision.is_zero()) @@ -226,7 +226,7 @@ ErrorOr TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* pa auto ipv4_payload_offset = routing_decision.adapter->ipv4_payload_offset(); - const bool has_mss_option = flags == TCPFlags::SYN; + bool const has_mss_option = flags == TCPFlags::SYN; const size_t options_size = has_mss_option ? sizeof(TCPOptionMSS) : 0; const size_t tcp_header_size = sizeof(TCPPacket) + options_size; const size_t buffer_size = ipv4_payload_offset + tcp_header_size + payload_size; @@ -291,7 +291,7 @@ ErrorOr TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* pa return {}; } -void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) +void TCPSocket::receive_tcp_packet(TCPPacket const& packet, u16 size) { if (packet.has_ack()) { u32 ack_number = packet.ack_number(); @@ -349,7 +349,7 @@ bool TCPSocket::should_delay_next_ack() const return true; } -NetworkOrdered TCPSocket::compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket& packet, u16 payload_size) +NetworkOrdered TCPSocket::compute_tcp_checksum(IPv4Address const& source, IPv4Address const& destination, TCPPacket const& packet, u16 payload_size) { struct [[gnu::packed]] PseudoHeader { IPv4Address source; @@ -382,7 +382,7 @@ NetworkOrdered TCPSocket::compute_tcp_checksum(const IPv4Address& source, c checksum = (checksum >> 16) + (checksum & 0xffff); } if (payload_size & 1) { - u16 expanded_byte = ((const u8*)packet.payload())[payload_size - 1] << 8; + u16 expanded_byte = ((u8 const*)packet.payload())[payload_size - 1] << 8; checksum += expanded_byte; if (checksum > 0xffff) checksum = (checksum >> 16) + (checksum & 0xffff); @@ -623,7 +623,7 @@ void TCPSocket::retransmit_packets() }); } -bool TCPSocket::can_write(const OpenFileDescription& file_description, u64 size) const +bool TCPSocket::can_write(OpenFileDescription const& file_description, u64 size) const { if (!IPv4Socket::can_write(file_description, size)) return false; diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index 9c30d1ebd59..400cf799d92 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -18,8 +18,8 @@ namespace Kernel { class TCPSocket final : public IPv4Socket { public: - static void for_each(Function); - static ErrorOr try_for_each(Function(const TCPSocket&)>); + static void for_each(Function); + static ErrorOr try_for_each(Function(TCPSocket const&)>); static ErrorOr> try_create(int protocol, NonnullOwnPtr receive_buffer); virtual ~TCPSocket() override; @@ -140,13 +140,13 @@ public: u32 duplicate_acks() const { return m_duplicate_acks; } ErrorOr send_ack(bool allow_duplicate = false); - ErrorOr send_tcp_packet(u16 flags, const UserOrKernelBuffer* = nullptr, size_t = 0, RoutingDecision* = nullptr); - void receive_tcp_packet(const TCPPacket&, u16 size); + ErrorOr send_tcp_packet(u16 flags, UserOrKernelBuffer const* = nullptr, size_t = 0, RoutingDecision* = nullptr); + void receive_tcp_packet(TCPPacket const&, u16 size); bool should_delay_next_ack() const; static MutexProtected>& sockets_by_tuple(); - static RefPtr from_tuple(const IPv4SocketTuple& tuple); + static RefPtr from_tuple(IPv4SocketTuple const& tuple); static MutexProtected>>& closing_sockets(); @@ -160,7 +160,7 @@ public: virtual ErrorOr close() override; - virtual bool can_write(const OpenFileDescription&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; static NetworkOrdered compute_tcp_checksum(IPv4Address const& source, IPv4Address const& destination, TCPPacket const&, u16 payload_size); @@ -174,7 +174,7 @@ private: virtual void shut_down_for_writing() override; virtual ErrorOr protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override; - virtual ErrorOr protocol_send(const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr protocol_send(UserOrKernelBuffer const&, size_t) override; virtual ErrorOr protocol_connect(OpenFileDescription&, ShouldBlock) override; virtual ErrorOr protocol_allocate_local_port() override; virtual ErrorOr protocol_size(ReadonlyBytes raw_ipv4_packet) override; diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index 38122e877b7..eb57919b00e 100644 --- a/Kernel/Net/UDP.h +++ b/Kernel/Net/UDP.h @@ -27,7 +27,7 @@ public: u16 checksum() const { return m_checksum; } void set_checksum(u16 checksum) { m_checksum = checksum; } - const void* payload() const { return this + 1; } + void const* payload() const { return this + 1; } void* payload() { return this + 1; } private: diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index b9ba5f45ebe..ab198f77b45 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -15,16 +15,16 @@ namespace Kernel { -void UDPSocket::for_each(Function callback) +void UDPSocket::for_each(Function callback) { - sockets_by_port().for_each_shared([&](const auto& socket) { + sockets_by_port().for_each_shared([&](auto const& socket) { callback(*socket.value); }); } -ErrorOr UDPSocket::try_for_each(Function(const UDPSocket&)> callback) +ErrorOr UDPSocket::try_for_each(Function(UDPSocket const&)> callback) { - return sockets_by_port().with_shared([&](const auto& sockets) -> ErrorOr { + return sockets_by_port().with_shared([&](auto const& sockets) -> ErrorOr { for (auto& socket : sockets) TRY(callback(*socket.value)); return {}; @@ -40,7 +40,7 @@ MutexProtected>& UDPSocket::sockets_by_port() RefPtr UDPSocket::from_port(u16 port) { - return sockets_by_port().with_shared([&](const auto& table) -> RefPtr { + return sockets_by_port().with_shared([&](auto const& table) -> RefPtr { auto it = table.find(port); if (it == table.end()) return {}; @@ -67,22 +67,22 @@ ErrorOr> UDPSocket::try_create(int protocol, NonnullOwn ErrorOr UDPSocket::protocol_size(ReadonlyBytes raw_ipv4_packet) { - auto& ipv4_packet = *(const IPv4Packet*)(raw_ipv4_packet.data()); - auto& udp_packet = *static_cast(ipv4_packet.payload()); + auto& ipv4_packet = *(IPv4Packet const*)(raw_ipv4_packet.data()); + auto& udp_packet = *static_cast(ipv4_packet.payload()); return udp_packet.length() - sizeof(UDPPacket); } ErrorOr UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags) { - auto& ipv4_packet = *(const IPv4Packet*)(raw_ipv4_packet.data()); - auto& udp_packet = *static_cast(ipv4_packet.payload()); + auto& ipv4_packet = *(IPv4Packet const*)(raw_ipv4_packet.data()); + auto& udp_packet = *static_cast(ipv4_packet.payload()); VERIFY(udp_packet.length() >= sizeof(UDPPacket)); // FIXME: This should be rejected earlier. size_t read_size = min(buffer_size, udp_packet.length() - sizeof(UDPPacket)); SOCKET_TRY(buffer.write(udp_packet.payload(), read_size)); return read_size; } -ErrorOr UDPSocket::protocol_send(const UserOrKernelBuffer& data, size_t data_length) +ErrorOr UDPSocket::protocol_send(UserOrKernelBuffer const& data, size_t data_length) { auto routing_decision = route_to(peer_address(), local_address(), bound_interface()); if (routing_decision.is_zero()) diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index 40bfef5779b..d4980c9e37a 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -18,8 +18,8 @@ public: virtual ~UDPSocket() override; static RefPtr from_port(u16); - static void for_each(Function); - static ErrorOr try_for_each(Function(const UDPSocket&)>); + static void for_each(Function); + static ErrorOr try_for_each(Function(UDPSocket const&)>); private: explicit UDPSocket(int protocol, NonnullOwnPtr receive_buffer); @@ -27,7 +27,7 @@ private: static MutexProtected>& sockets_by_port(); virtual ErrorOr protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override; - virtual ErrorOr protocol_send(const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr protocol_send(UserOrKernelBuffer const&, size_t) override; virtual ErrorOr protocol_size(ReadonlyBytes raw_ipv4_packet) override; virtual ErrorOr protocol_connect(OpenFileDescription&, ShouldBlock) override; virtual ErrorOr protocol_allocate_local_port() override; diff --git a/Kernel/Panic.cpp b/Kernel/Panic.cpp index 34100a1bdb1..f2f20accc66 100644 --- a/Kernel/Panic.cpp +++ b/Kernel/Panic.cpp @@ -24,7 +24,7 @@ namespace Kernel { Processor::halt(); } -void __panic(const char* file, unsigned int line, const char* function) +void __panic(char const* file, unsigned int line, char const* function) { // Avoid lock ranking checks on crashing paths, just try to get some debugging messages out. auto* thread = Thread::current(); diff --git a/Kernel/Panic.h b/Kernel/Panic.h index 96f5034b8df..152a41db552 100644 --- a/Kernel/Panic.h +++ b/Kernel/Panic.h @@ -8,7 +8,7 @@ namespace Kernel { -[[noreturn]] void __panic(const char* file, unsigned int line, const char* function); +[[noreturn]] void __panic(char const* file, unsigned int line, char const* function); #define PANIC(...) \ do { \ diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 98c155fd583..4ae7df427b2 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -72,7 +72,7 @@ static Vector raw_backtrace(Fl return backtrace; } -ErrorOr PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID tid, const RegisterState& regs, +ErrorOr PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID tid, RegisterState const& regs, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr arg6) { return append_with_ip_and_bp(pid, tid, regs.ip(), regs.bp(), type, lost_samples, arg1, arg2, arg3, arg4, arg5, arg6); @@ -338,7 +338,7 @@ OwnPtr PerformanceEventBuffer::try_create_with_size(size return adopt_own_if_nonnull(new (nothrow) PerformanceEventBuffer(buffer_or_error.release_value())); } -ErrorOr PerformanceEventBuffer::add_process(const Process& process, ProcessEventType event_type) +ErrorOr PerformanceEventBuffer::add_process(Process const& process, ProcessEventType event_type) { SpinlockLocker locker(process.address_space().get_lock()); diff --git a/Kernel/PerformanceEventBuffer.h b/Kernel/PerformanceEventBuffer.h index 7570dd136b8..bd246176b87 100644 --- a/Kernel/PerformanceEventBuffer.h +++ b/Kernel/PerformanceEventBuffer.h @@ -113,7 +113,7 @@ public: ErrorOr append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread = Thread::current(), FlatPtr arg4 = 0, u64 arg5 = 0, ErrorOr arg6 = 0); ErrorOr append_with_ip_and_bp(ProcessID pid, ThreadID tid, FlatPtr eip, FlatPtr ebp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr arg6 = 0); - ErrorOr append_with_ip_and_bp(ProcessID pid, ThreadID tid, const RegisterState& regs, + ErrorOr append_with_ip_and_bp(ProcessID pid, ThreadID tid, RegisterState const& regs, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr arg6 = 0); void clear() @@ -123,14 +123,14 @@ public: size_t capacity() const { return m_buffer->size() / sizeof(PerformanceEvent); } size_t count() const { return m_count; } - const PerformanceEvent& at(size_t index) const + PerformanceEvent const& at(size_t index) const { return const_cast(*this).at(index); } ErrorOr to_json(KBufferBuilder&) const; - ErrorOr add_process(const Process&, ProcessEventType event_type); + ErrorOr add_process(Process const&, ProcessEventType event_type); ErrorOr register_string(NonnullOwnPtr); diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h index 159a11e2f90..a2f5d77786b 100644 --- a/Kernel/PerformanceManager.h +++ b/Kernel/PerformanceManager.h @@ -56,7 +56,7 @@ public: } } - inline static void add_cpu_sample_event(Thread& current_thread, const RegisterState& regs, u32 lost_time) + inline static void add_cpu_sample_event(Thread& current_thread, RegisterState const& regs, u32 lost_time) { if (current_thread.is_profiling_suppressed()) return; @@ -107,7 +107,7 @@ public: } } - inline static void add_page_fault_event(Thread& thread, const RegisterState& regs) + inline static void add_page_fault_event(Thread& thread, RegisterState const& regs) { if (thread.is_profiling_suppressed()) return; @@ -117,7 +117,7 @@ public: } } - inline static void add_syscall_event(Thread& thread, const RegisterState& regs) + inline static void add_syscall_event(Thread& thread, RegisterState const& regs) { if (thread.is_profiling_suppressed()) return; @@ -127,7 +127,7 @@ public: } } - inline static void add_read_event(Thread& thread, int fd, size_t size, const OpenFileDescription& file_description, u64 start_timestamp, ErrorOr result) + inline static void add_read_event(Thread& thread, int fd, size_t size, OpenFileDescription const& file_description, u64 start_timestamp, ErrorOr result) { if (thread.is_profiling_suppressed()) return; diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h index e1f66d6a6aa..8a4fbaef256 100644 --- a/Kernel/PhysicalAddress.h +++ b/Kernel/PhysicalAddress.h @@ -40,17 +40,17 @@ public: // NOLINTNEXTLINE(readability-make-member-function-const) const PhysicalAddress shouldn't be allowed to modify the underlying memory [[nodiscard]] u8* as_ptr() { return reinterpret_cast(m_address); } - [[nodiscard]] const u8* as_ptr() const { return reinterpret_cast(m_address); } + [[nodiscard]] u8 const* as_ptr() const { return reinterpret_cast(m_address); } [[nodiscard]] PhysicalAddress page_base() const { return PhysicalAddress(physical_page_base(m_address)); } [[nodiscard]] PhysicalPtr offset_in_page() const { return PhysicalAddress(m_address & 0xfff).get(); } - bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; } - bool operator!=(const PhysicalAddress& other) const { return m_address != other.m_address; } - bool operator>(const PhysicalAddress& other) const { return m_address > other.m_address; } - bool operator>=(const PhysicalAddress& other) const { return m_address >= other.m_address; } - bool operator<(const PhysicalAddress& other) const { return m_address < other.m_address; } - bool operator<=(const PhysicalAddress& other) const { return m_address <= other.m_address; } + bool operator==(PhysicalAddress const& other) const { return m_address == other.m_address; } + bool operator!=(PhysicalAddress const& other) const { return m_address != other.m_address; } + bool operator>(PhysicalAddress const& other) const { return m_address > other.m_address; } + bool operator>=(PhysicalAddress const& other) const { return m_address >= other.m_address; } + bool operator<(PhysicalAddress const& other) const { return m_address < other.m_address; } + bool operator<=(PhysicalAddress const& other) const { return m_address <= other.m_address; } private: PhysicalPtr m_address { 0 }; diff --git a/Kernel/Prekernel/UBSanitizer.cpp b/Kernel/Prekernel/UBSanitizer.cpp index 52a92e317fb..d03c3581d30 100644 --- a/Kernel/Prekernel/UBSanitizer.cpp +++ b/Kernel/Prekernel/UBSanitizer.cpp @@ -13,7 +13,7 @@ Atomic AK::UBSanitizer::g_ubsan_is_deadly { true }; extern "C" { -static void print_location(const SourceLocation&) +static void print_location(SourceLocation const&) { #if ARCH(I386) || ARCH(X86_64) asm volatile("cli; hlt"); @@ -22,110 +22,110 @@ static void print_location(const SourceLocation&) #endif } -void __ubsan_handle_load_invalid_value(const InvalidValueData&, ValueHandle) __attribute__((used)); -void __ubsan_handle_load_invalid_value(const InvalidValueData& data, ValueHandle) +void __ubsan_handle_load_invalid_value(InvalidValueData const&, ValueHandle) __attribute__((used)); +void __ubsan_handle_load_invalid_value(InvalidValueData const& data, ValueHandle) { print_location(data.location); } -void __ubsan_handle_nonnull_arg(const NonnullArgData&) __attribute__((used)); -void __ubsan_handle_nonnull_arg(const NonnullArgData& data) +void __ubsan_handle_nonnull_arg(NonnullArgData const&) __attribute__((used)); +void __ubsan_handle_nonnull_arg(NonnullArgData const& data) { print_location(data.location); } -void __ubsan_handle_nullability_arg(const NonnullArgData&) __attribute__((used)); -void __ubsan_handle_nullability_arg(const NonnullArgData& data) +void __ubsan_handle_nullability_arg(NonnullArgData const&) __attribute__((used)); +void __ubsan_handle_nullability_arg(NonnullArgData const& data) { print_location(data.location); } -void __ubsan_handle_nonnull_return_v1(const NonnullReturnData&, const SourceLocation&) __attribute__((used)); -void __ubsan_handle_nonnull_return_v1(const NonnullReturnData&, const SourceLocation& location) +void __ubsan_handle_nonnull_return_v1(NonnullReturnData const&, SourceLocation const&) __attribute__((used)); +void __ubsan_handle_nonnull_return_v1(NonnullReturnData const&, SourceLocation const& location) { print_location(location); } -void __ubsan_handle_nullability_return_v1(const NonnullReturnData& data, const SourceLocation& location) __attribute__((used)); -void __ubsan_handle_nullability_return_v1(const NonnullReturnData&, const SourceLocation& location) +void __ubsan_handle_nullability_return_v1(NonnullReturnData const& data, SourceLocation const& location) __attribute__((used)); +void __ubsan_handle_nullability_return_v1(NonnullReturnData const&, SourceLocation const& location) { print_location(location); } -void __ubsan_handle_vla_bound_not_positive(const VLABoundData&, ValueHandle) __attribute__((used)); -void __ubsan_handle_vla_bound_not_positive(const VLABoundData& data, ValueHandle) +void __ubsan_handle_vla_bound_not_positive(VLABoundData const&, ValueHandle) __attribute__((used)); +void __ubsan_handle_vla_bound_not_positive(VLABoundData const& data, ValueHandle) { print_location(data.location); } -void __ubsan_handle_add_overflow(const OverflowData&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); -void __ubsan_handle_add_overflow(const OverflowData& data, ValueHandle, ValueHandle) +void __ubsan_handle_add_overflow(OverflowData const&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); +void __ubsan_handle_add_overflow(OverflowData const& data, ValueHandle, ValueHandle) { print_location(data.location); } -void __ubsan_handle_sub_overflow(const OverflowData&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); -void __ubsan_handle_sub_overflow(const OverflowData& data, ValueHandle, ValueHandle) +void __ubsan_handle_sub_overflow(OverflowData const&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); +void __ubsan_handle_sub_overflow(OverflowData const& data, ValueHandle, ValueHandle) { print_location(data.location); } -void __ubsan_handle_negate_overflow(const OverflowData&, ValueHandle) __attribute__((used)); -void __ubsan_handle_negate_overflow(const OverflowData& data, ValueHandle) +void __ubsan_handle_negate_overflow(OverflowData const&, ValueHandle) __attribute__((used)); +void __ubsan_handle_negate_overflow(OverflowData const& data, ValueHandle) { print_location(data.location); } -void __ubsan_handle_mul_overflow(const OverflowData&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); -void __ubsan_handle_mul_overflow(const OverflowData& data, ValueHandle, ValueHandle) +void __ubsan_handle_mul_overflow(OverflowData const&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); +void __ubsan_handle_mul_overflow(OverflowData const& data, ValueHandle, ValueHandle) { print_location(data.location); } -void __ubsan_handle_shift_out_of_bounds(const ShiftOutOfBoundsData&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); -void __ubsan_handle_shift_out_of_bounds(const ShiftOutOfBoundsData& data, ValueHandle, ValueHandle) +void __ubsan_handle_shift_out_of_bounds(ShiftOutOfBoundsData const&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); +void __ubsan_handle_shift_out_of_bounds(ShiftOutOfBoundsData const& data, ValueHandle, ValueHandle) { print_location(data.location); } -void __ubsan_handle_divrem_overflow(const OverflowData&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); -void __ubsan_handle_divrem_overflow(const OverflowData& data, ValueHandle, ValueHandle) +void __ubsan_handle_divrem_overflow(OverflowData const&, ValueHandle lhs, ValueHandle rhs) __attribute__((used)); +void __ubsan_handle_divrem_overflow(OverflowData const& data, ValueHandle, ValueHandle) { print_location(data.location); } -void __ubsan_handle_out_of_bounds(const OutOfBoundsData&, ValueHandle) __attribute__((used)); -void __ubsan_handle_out_of_bounds(const OutOfBoundsData& data, ValueHandle) +void __ubsan_handle_out_of_bounds(OutOfBoundsData const&, ValueHandle) __attribute__((used)); +void __ubsan_handle_out_of_bounds(OutOfBoundsData const& data, ValueHandle) { print_location(data.location); } -void __ubsan_handle_type_mismatch_v1(const TypeMismatchData&, ValueHandle) __attribute__((used)); -void __ubsan_handle_type_mismatch_v1(const TypeMismatchData& data, ValueHandle) +void __ubsan_handle_type_mismatch_v1(TypeMismatchData const&, ValueHandle) __attribute__((used)); +void __ubsan_handle_type_mismatch_v1(TypeMismatchData const& data, ValueHandle) { print_location(data.location); } -void __ubsan_handle_alignment_assumption(const AlignmentAssumptionData&, ValueHandle, ValueHandle, ValueHandle) __attribute__((used)); -void __ubsan_handle_alignment_assumption(const AlignmentAssumptionData& data, ValueHandle, ValueHandle, ValueHandle) +void __ubsan_handle_alignment_assumption(AlignmentAssumptionData const&, ValueHandle, ValueHandle, ValueHandle) __attribute__((used)); +void __ubsan_handle_alignment_assumption(AlignmentAssumptionData const& data, ValueHandle, ValueHandle, ValueHandle) { print_location(data.location); } -void __ubsan_handle_builtin_unreachable(const UnreachableData&) __attribute__((used)); -void __ubsan_handle_builtin_unreachable(const UnreachableData& data) +void __ubsan_handle_builtin_unreachable(UnreachableData const&) __attribute__((used)); +void __ubsan_handle_builtin_unreachable(UnreachableData const& data) { print_location(data.location); } -void __ubsan_handle_missing_return(const UnreachableData&) __attribute__((used)); -void __ubsan_handle_missing_return(const UnreachableData& data) +void __ubsan_handle_missing_return(UnreachableData const&) __attribute__((used)); +void __ubsan_handle_missing_return(UnreachableData const& data) { print_location(data.location); } -void __ubsan_handle_implicit_conversion(const ImplicitConversionData&, ValueHandle, ValueHandle) __attribute__((used)); -void __ubsan_handle_implicit_conversion(const ImplicitConversionData& data, ValueHandle, ValueHandle) +void __ubsan_handle_implicit_conversion(ImplicitConversionData const&, ValueHandle, ValueHandle) __attribute__((used)); +void __ubsan_handle_implicit_conversion(ImplicitConversionData const& data, ValueHandle, ValueHandle) { print_location(data.location); } @@ -136,8 +136,8 @@ void __ubsan_handle_invalid_builtin(const InvalidBuiltinData data) print_location(data.location); } -void __ubsan_handle_pointer_overflow(const PointerOverflowData&, ValueHandle, ValueHandle) __attribute__((used)); -void __ubsan_handle_pointer_overflow(const PointerOverflowData& data, ValueHandle, ValueHandle) +void __ubsan_handle_pointer_overflow(PointerOverflowData const&, ValueHandle, ValueHandle) __attribute__((used)); +void __ubsan_handle_pointer_overflow(PointerOverflowData const& data, ValueHandle, ValueHandle) { print_location(data.location); } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 135e7ebcb89..1057328ab2f 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -412,7 +412,7 @@ void Process::crash(int signal, FlatPtr ip, bool out_of_memory) RefPtr Process::from_pid(ProcessID pid) { - return all_instances().with([&](const auto& list) -> RefPtr { + return all_instances().with([&](auto const& list) -> RefPtr { for (auto const& process : list) { if (process.pid() == pid) return &process; @@ -421,7 +421,7 @@ RefPtr Process::from_pid(ProcessID pid) }); } -const Process::OpenFileDescriptionAndFlags* Process::OpenFileDescriptions::get_if_valid(size_t i) const +Process::OpenFileDescriptionAndFlags const* Process::OpenFileDescriptions::get_if_valid(size_t i) const { if (m_fds_metadatas.size() <= i) return nullptr; @@ -442,7 +442,7 @@ Process::OpenFileDescriptionAndFlags* Process::OpenFileDescriptions::get_if_vali return nullptr; } -const Process::OpenFileDescriptionAndFlags& Process::OpenFileDescriptions::at(size_t i) const +Process::OpenFileDescriptionAndFlags const& Process::OpenFileDescriptions::at(size_t i) const { VERIFY(m_fds_metadatas[i].is_allocated()); return m_fds_metadatas[i]; @@ -466,14 +466,14 @@ ErrorOr> Process::OpenFileDescriptions::open_ return description.release_nonnull(); } -void Process::OpenFileDescriptions::enumerate(Function callback) const +void Process::OpenFileDescriptions::enumerate(Function callback) const { for (auto const& file_description_metadata : m_fds_metadatas) { callback(file_description_metadata); } } -ErrorOr Process::OpenFileDescriptions::try_enumerate(Function(const OpenFileDescriptionAndFlags&)> callback) const +ErrorOr Process::OpenFileDescriptions::try_enumerate(Function(OpenFileDescriptionAndFlags const&)> callback) const { for (auto const& file_description_metadata : m_fds_metadatas) { TRY(callback(file_description_metadata)); @@ -709,7 +709,7 @@ void Process::die() dbgln("Failed to add thread {} to coredump due to OOM", thread.tid()); }); - all_instances().with([&](const auto& list) { + all_instances().with([&](auto const& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; @@ -820,7 +820,7 @@ void Process::stop_tracing() m_tracer = nullptr; } -void Process::tracer_trap(Thread& thread, const RegisterState& regs) +void Process::tracer_trap(Thread& thread, RegisterState const& regs) { VERIFY(m_tracer.ptr()); m_tracer->set_regs(regs); diff --git a/Kernel/Process.h b/Kernel/Process.h index 5d19121267d..2a4b2639299 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -261,18 +261,18 @@ public: bool is_traced() const { return !!m_tracer; } ErrorOr start_tracing_from(ProcessID tracer); void stop_tracing(); - void tracer_trap(Thread&, const RegisterState&); + void tracer_trap(Thread&, RegisterState const&); ErrorOr sys$emuctl(); ErrorOr sys$yield(); ErrorOr sys$sync(); ErrorOr sys$beep(); ErrorOr sys$get_process_name(Userspace buffer, size_t buffer_size); - ErrorOr sys$set_process_name(Userspace user_name, size_t user_name_length); + ErrorOr sys$set_process_name(Userspace user_name, size_t user_name_length); ErrorOr sys$create_inode_watcher(u32 flags); - ErrorOr sys$inode_watcher_add_watch(Userspace user_params); + ErrorOr sys$inode_watcher_add_watch(Userspace user_params); ErrorOr sys$inode_watcher_remove_watch(int fd, int wd); - ErrorOr sys$dbgputstr(Userspace, size_t); + ErrorOr sys$dbgputstr(Userspace, size_t); ErrorOr sys$dump_backtrace(); ErrorOr sys$gettid(); ErrorOr sys$setsid(); @@ -290,53 +290,53 @@ public: ErrorOr sys$getresgid(Userspace, Userspace, Userspace); ErrorOr sys$getrusage(int, Userspace); ErrorOr sys$umask(mode_t); - ErrorOr sys$open(Userspace); + ErrorOr sys$open(Userspace); ErrorOr sys$close(int fd); ErrorOr sys$read(int fd, Userspace, size_t); ErrorOr sys$pread(int fd, Userspace, size_t, Userspace); ErrorOr sys$readv(int fd, Userspace iov, int iov_count); - ErrorOr sys$write(int fd, Userspace, size_t); + ErrorOr sys$write(int fd, Userspace, size_t); ErrorOr sys$writev(int fd, Userspace iov, int iov_count); ErrorOr sys$fstat(int fd, Userspace); - ErrorOr sys$stat(Userspace); + ErrorOr sys$stat(Userspace); ErrorOr sys$lseek(int fd, Userspace, int whence); ErrorOr sys$ftruncate(int fd, Userspace); ErrorOr sys$kill(pid_t pid_or_pgid, int sig); [[noreturn]] void sys$exit(int status); ErrorOr sys$sigreturn(RegisterState& registers); - ErrorOr sys$waitid(Userspace); - ErrorOr sys$mmap(Userspace); - ErrorOr sys$mremap(Userspace); + ErrorOr sys$waitid(Userspace); + ErrorOr sys$mmap(Userspace); + ErrorOr sys$mremap(Userspace); ErrorOr sys$munmap(Userspace, size_t); - ErrorOr sys$set_mmap_name(Userspace); + ErrorOr sys$set_mmap_name(Userspace); ErrorOr sys$mprotect(Userspace, size_t, int prot); ErrorOr sys$madvise(Userspace, size_t, int advice); ErrorOr sys$msyscall(Userspace); ErrorOr sys$msync(Userspace, size_t, int flags); ErrorOr sys$purge(int mode); - ErrorOr sys$poll(Userspace); + ErrorOr sys$poll(Userspace); ErrorOr sys$get_dir_entries(int fd, Userspace, size_t); ErrorOr sys$getcwd(Userspace, size_t); - ErrorOr sys$chdir(Userspace, size_t); + ErrorOr sys$chdir(Userspace, size_t); ErrorOr sys$fchdir(int fd); - ErrorOr sys$adjtime(Userspace, Userspace); + ErrorOr sys$adjtime(Userspace, Userspace); ErrorOr sys$clock_gettime(clockid_t, Userspace); - ErrorOr sys$clock_settime(clockid_t, Userspace); - ErrorOr sys$clock_nanosleep(Userspace); + ErrorOr sys$clock_settime(clockid_t, Userspace); + ErrorOr sys$clock_nanosleep(Userspace); ErrorOr sys$gethostname(Userspace, size_t); - ErrorOr sys$sethostname(Userspace, size_t); + ErrorOr sys$sethostname(Userspace, size_t); ErrorOr sys$uname(Userspace); - ErrorOr sys$readlink(Userspace); + ErrorOr sys$readlink(Userspace); ErrorOr sys$fork(RegisterState&); - ErrorOr sys$execve(Userspace); + ErrorOr sys$execve(Userspace); ErrorOr sys$dup2(int old_fd, int new_fd); - ErrorOr sys$sigaction(int signum, Userspace act, Userspace old_act); - ErrorOr sys$sigaltstack(Userspace ss, Userspace old_ss); - ErrorOr sys$sigprocmask(int how, Userspace set, Userspace old_set); + ErrorOr sys$sigaction(int signum, Userspace act, Userspace old_act); + ErrorOr sys$sigaltstack(Userspace ss, Userspace old_ss); + ErrorOr sys$sigprocmask(int how, Userspace set, Userspace old_set); ErrorOr sys$sigpending(Userspace); - ErrorOr sys$sigtimedwait(Userspace, Userspace, Userspace); + ErrorOr sys$sigtimedwait(Userspace, Userspace, Userspace); ErrorOr sys$getgroups(size_t, Userspace); - ErrorOr sys$setgroups(size_t, Userspace); + ErrorOr sys$setgroups(size_t, Userspace); ErrorOr sys$pipe(int pipefd[2], int flags); ErrorOr sys$killpg(pid_t pgrp, int sig); ErrorOr sys$seteuid(UserID); @@ -347,70 +347,70 @@ public: ErrorOr sys$setresuid(UserID, UserID, UserID); ErrorOr sys$setresgid(GroupID, GroupID, GroupID); ErrorOr sys$alarm(unsigned seconds); - ErrorOr sys$access(Userspace pathname, size_t path_length, int mode); + ErrorOr sys$access(Userspace pathname, size_t path_length, int mode); ErrorOr sys$fcntl(int fd, int cmd, u32 extra_arg); ErrorOr sys$ioctl(int fd, unsigned request, FlatPtr arg); - ErrorOr sys$mkdir(Userspace pathname, size_t path_length, mode_t mode); + ErrorOr sys$mkdir(Userspace pathname, size_t path_length, mode_t mode); ErrorOr sys$times(Userspace); - ErrorOr sys$utime(Userspace pathname, size_t path_length, Userspace); - ErrorOr sys$link(Userspace); - ErrorOr sys$unlink(Userspace pathname, size_t path_length); - ErrorOr sys$symlink(Userspace); - ErrorOr sys$rmdir(Userspace pathname, size_t path_length); - ErrorOr sys$mount(Userspace); - ErrorOr sys$umount(Userspace mountpoint, size_t mountpoint_length); + ErrorOr sys$utime(Userspace pathname, size_t path_length, Userspace); + ErrorOr sys$link(Userspace); + ErrorOr sys$unlink(Userspace pathname, size_t path_length); + ErrorOr sys$symlink(Userspace); + ErrorOr sys$rmdir(Userspace pathname, size_t path_length); + ErrorOr sys$mount(Userspace); + ErrorOr sys$umount(Userspace mountpoint, size_t mountpoint_length); ErrorOr sys$chmod(Userspace); ErrorOr sys$fchmod(int fd, mode_t); - ErrorOr sys$chown(Userspace); + ErrorOr sys$chown(Userspace); ErrorOr sys$fchown(int fd, UserID, GroupID); ErrorOr sys$fsync(int fd); ErrorOr sys$socket(int domain, int type, int protocol); - ErrorOr sys$bind(int sockfd, Userspace addr, socklen_t); + ErrorOr sys$bind(int sockfd, Userspace addr, socklen_t); ErrorOr sys$listen(int sockfd, int backlog); - ErrorOr sys$accept4(Userspace); - ErrorOr sys$connect(int sockfd, Userspace, socklen_t); + ErrorOr sys$accept4(Userspace); + ErrorOr sys$connect(int sockfd, Userspace, socklen_t); ErrorOr sys$shutdown(int sockfd, int how); ErrorOr sys$sendmsg(int sockfd, Userspace, int flags); ErrorOr sys$recvmsg(int sockfd, Userspace, int flags); - ErrorOr sys$getsockopt(Userspace); - ErrorOr sys$setsockopt(Userspace); - ErrorOr sys$getsockname(Userspace); - ErrorOr sys$getpeername(Userspace); - ErrorOr sys$socketpair(Userspace); + ErrorOr sys$getsockopt(Userspace); + ErrorOr sys$setsockopt(Userspace); + ErrorOr sys$getsockname(Userspace); + ErrorOr sys$getpeername(Userspace); + ErrorOr sys$socketpair(Userspace); ErrorOr sys$sched_setparam(pid_t pid, Userspace); ErrorOr sys$sched_getparam(pid_t pid, Userspace); - ErrorOr sys$create_thread(void* (*)(void*), Userspace); + ErrorOr sys$create_thread(void* (*)(void*), Userspace); [[noreturn]] void sys$exit_thread(Userspace, Userspace, size_t); ErrorOr sys$join_thread(pid_t tid, Userspace exit_value); ErrorOr sys$detach_thread(pid_t tid); - ErrorOr sys$set_thread_name(pid_t tid, Userspace buffer, size_t buffer_size); + ErrorOr sys$set_thread_name(pid_t tid, Userspace buffer, size_t buffer_size); ErrorOr sys$get_thread_name(pid_t tid, Userspace buffer, size_t buffer_size); ErrorOr sys$kill_thread(pid_t tid, int signal); - ErrorOr sys$rename(Userspace); - ErrorOr sys$mknod(Userspace); - ErrorOr sys$realpath(Userspace); + ErrorOr sys$rename(Userspace); + ErrorOr sys$mknod(Userspace); + ErrorOr sys$realpath(Userspace); ErrorOr sys$getrandom(Userspace, size_t, unsigned int); - ErrorOr sys$getkeymap(Userspace); - ErrorOr sys$setkeymap(Userspace); + ErrorOr sys$getkeymap(Userspace); + ErrorOr sys$setkeymap(Userspace); ErrorOr sys$profiling_enable(pid_t, Userspace); ErrorOr sys$profiling_disable(pid_t); ErrorOr sys$profiling_free_buffer(pid_t); - ErrorOr sys$futex(Userspace); - ErrorOr sys$pledge(Userspace); - ErrorOr sys$unveil(Userspace); + ErrorOr sys$futex(Userspace); + ErrorOr sys$pledge(Userspace); + ErrorOr sys$unveil(Userspace); ErrorOr sys$perf_event(int type, FlatPtr arg1, FlatPtr arg2); ErrorOr sys$perf_register_string(Userspace, size_t); ErrorOr sys$get_stack_bounds(Userspace stack_base, Userspace stack_size); - ErrorOr sys$ptrace(Userspace); + ErrorOr sys$ptrace(Userspace); ErrorOr sys$sendfd(int sockfd, int fd); ErrorOr sys$recvfd(int sockfd, int options); ErrorOr sys$sysconf(int name); ErrorOr sys$disown(ProcessID); - ErrorOr sys$allocate_tls(Userspace initial_data, size_t); + ErrorOr sys$allocate_tls(Userspace initial_data, size_t); ErrorOr sys$prctl(int option, FlatPtr arg1, FlatPtr arg2); - ErrorOr sys$set_coredump_metadata(Userspace); + ErrorOr sys$set_coredump_metadata(Userspace); ErrorOr sys$anon_create(size_t, int options); - ErrorOr sys$statvfs(Userspace user_params); + ErrorOr sys$statvfs(Userspace user_params); ErrorOr sys$fstatvfs(int fd, statvfs* buf); ErrorOr sys$map_time_page(); @@ -433,7 +433,7 @@ public: NonnullRefPtr current_directory(); Custody* executable() { return m_executable.ptr(); } - const Custody* executable() const { return m_executable.ptr(); } + Custody const* executable() const { return m_executable.ptr(); } static constexpr size_t max_arguments_size = Thread::default_userspace_stack_size / 8; static constexpr size_t max_environment_size = Thread::default_userspace_stack_size / 8; @@ -489,8 +489,8 @@ public: m_wait_for_tracer_at_next_execve = val; } - ErrorOr peek_user_data(Span destination, Userspace address); - ErrorOr peek_user_data(Userspace address); + ErrorOr peek_user_data(Span destination, Userspace address); + ErrorOr peek_user_data(Userspace address); ErrorOr poke_user_data(Userspace address, FlatPtr data); void disowned_by_waiter(Process& process); @@ -510,7 +510,7 @@ public: ErrorOr set_coredump_property(NonnullOwnPtr key, NonnullOwnPtr value); ErrorOr try_set_coredump_property(StringView key, StringView value); - const NonnullRefPtrVector& threads_for_coredump(Badge) const { return m_threads_for_coredump; } + NonnullRefPtrVector const& threads_for_coredump(Badge) const { return m_threads_for_coredump; } PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; } PerformanceEventBuffer const* perf_events() const { return m_perf_event_buffer; } @@ -524,7 +524,7 @@ public: ErrorOr require_no_promises() const; ErrorOr validate_mmap_prot(int prot, bool map_stack, bool map_anonymous, Memory::Region const* region = nullptr) const; - ErrorOr validate_inode_mmap_prot(int prot, const Inode& inode, bool map_shared) const; + ErrorOr validate_inode_mmap_prot(int prot, Inode const& inode, bool map_shared) const; private: friend class MemoryManager; @@ -548,7 +548,7 @@ private: void delete_perf_events_buffer(); ErrorOr do_exec(NonnullRefPtr main_program_description, NonnullOwnPtrVector arguments, NonnullOwnPtrVector environment, RefPtr interpreter_description, Thread*& new_main_thread, u32& prev_flags, const ElfW(Ehdr) & main_program_header); - ErrorOr do_write(OpenFileDescription&, const UserOrKernelBuffer&, size_t); + ErrorOr do_write(OpenFileDescription&, UserOrKernelBuffer const&, size_t); ErrorOr do_statvfs(FileSystem const& path, Custody const*, statvfs* buf); @@ -561,8 +561,8 @@ private: ErrorOr do_waitid(Variant, NonnullRefPtr> waitee, int options); - static ErrorOr> get_syscall_path_argument(Userspace user_path, size_t path_length); - static ErrorOr> get_syscall_path_argument(const Syscall::StringArgument&); + static ErrorOr> get_syscall_path_argument(Userspace user_path, size_t path_length); + static ErrorOr> get_syscall_path_argument(Syscall::StringArgument const&); bool has_tracee_thread(ProcessID tracer_pid); @@ -584,10 +584,10 @@ public: mode_t binary_link_required_mode() const; ErrorOr procfs_get_thread_stack(ThreadID thread_id, KBufferBuilder& builder) const; ErrorOr traverse_stacks_directory(FileSystemID, Function(FileSystem::DirectoryEntryView const&)> callback) const; - ErrorOr> lookup_stacks_directory(const ProcFS&, StringView name) const; + ErrorOr> lookup_stacks_directory(ProcFS const&, StringView name) const; ErrorOr procfs_get_file_description_link(unsigned fd, KBufferBuilder& builder) const; ErrorOr traverse_file_descriptions_directory(FileSystemID, Function(FileSystem::DirectoryEntryView const&)> callback) const; - ErrorOr> lookup_file_descriptions_directory(const ProcFS&, StringView name) const; + ErrorOr> lookup_file_descriptions_directory(ProcFS const&, StringView name) const; private: inline PerformanceEventBuffer* current_perf_events_buffer() @@ -632,7 +632,7 @@ public: } OpenFileDescription* description() { return m_description; } - const OpenFileDescription* description() const { return m_description; } + OpenFileDescription const* description() const { return m_description; } u32 flags() const { return m_flags; } void set_flags(u32 flags) { m_flags = flags; } @@ -653,10 +653,10 @@ public: public: OpenFileDescriptions() { } - ALWAYS_INLINE const OpenFileDescriptionAndFlags& operator[](size_t i) const { return at(i); } + ALWAYS_INLINE OpenFileDescriptionAndFlags const& operator[](size_t i) const { return at(i); } ALWAYS_INLINE OpenFileDescriptionAndFlags& operator[](size_t i) { return at(i); } - ErrorOr try_clone(const Kernel::Process::OpenFileDescriptions& other) + ErrorOr try_clone(Kernel::Process::OpenFileDescriptions const& other) { TRY(try_resize(other.m_fds_metadatas.size())); @@ -666,14 +666,14 @@ public: return {}; } - const OpenFileDescriptionAndFlags& at(size_t i) const; + OpenFileDescriptionAndFlags const& at(size_t i) const; OpenFileDescriptionAndFlags& at(size_t i); OpenFileDescriptionAndFlags const* get_if_valid(size_t i) const; OpenFileDescriptionAndFlags* get_if_valid(size_t i); - void enumerate(Function) const; - ErrorOr try_enumerate(Function(const OpenFileDescriptionAndFlags&)>) const; + void enumerate(Function) const; + ErrorOr try_enumerate(Function(OpenFileDescriptionAndFlags const&)>) const; void change_each(Function); ErrorOr allocate(int first_candidate_fd = 0); @@ -746,7 +746,7 @@ public: } virtual InodeIndex component_index() const override; - virtual ErrorOr> to_inode(const ProcFS& procfs_instance) const override; + virtual ErrorOr> to_inode(ProcFS const& procfs_instance) const override; virtual ErrorOr traverse_as_directory(FileSystemID, Function(FileSystem::DirectoryEntryView const&)>) const override; virtual mode_t required_mode() const override { return 0555; } @@ -790,7 +790,7 @@ private: MutexProtected m_fds; - const bool m_is_kernel_process; + bool const m_is_kernel_process; Atomic m_state { State::Running }; bool m_profiling { false }; Atomic m_is_stopped { false }; @@ -865,7 +865,7 @@ template Callback> inline void Process::for_each(Callback callback) { VERIFY_INTERRUPTS_DISABLED(); - Process::all_instances().with([&](const auto& list) { + Process::all_instances().with([&](auto const& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; @@ -879,7 +879,7 @@ template Callback> inline void Process::for_each_child(Callback callback) { ProcessID my_pid = pid(); - Process::all_instances().with([&](const auto& list) { + Process::all_instances().with([&](auto const& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; @@ -920,7 +920,7 @@ inline IterationDecision Process::for_each_thread(Callback callback) template Callback> inline void Process::for_each_in_pgrp(ProcessGroupID pgid, Callback callback) { - Process::all_instances().with([&](const auto& list) { + Process::all_instances().with([&](auto const& list) { for (auto it = list.begin(); it != list.end();) { auto& process = *it; ++it; @@ -988,17 +988,17 @@ inline void Process::for_each_in_pgrp(ProcessGroupID pgid, Callback callback) }); } -inline bool InodeMetadata::may_read(const Process& process) const +inline bool InodeMetadata::may_read(Process const& process) const { return may_read(process.euid(), process.egid(), process.extra_gids()); } -inline bool InodeMetadata::may_write(const Process& process) const +inline bool InodeMetadata::may_write(Process const& process) const { return may_write(process.euid(), process.egid(), process.extra_gids()); } -inline bool InodeMetadata::may_execute(const Process& process) const +inline bool InodeMetadata::may_execute(Process const& process) const { return may_execute(process.euid(), process.egid(), process.extra_gids()); } @@ -1016,7 +1016,7 @@ inline ProcessID Thread::pid() const #define VERIFY_NO_PROCESS_BIG_LOCK(process) \ VERIFY(!process->big_lock().is_exclusively_locked_by_current_thread()); -inline static ErrorOr> try_copy_kstring_from_user(const Kernel::Syscall::StringArgument& string) +inline static ErrorOr> try_copy_kstring_from_user(Kernel::Syscall::StringArgument const& string) { Userspace characters((FlatPtr)string.characters); return try_copy_kstring_from_user(characters, string.length); diff --git a/Kernel/ProcessExposed.cpp b/Kernel/ProcessExposed.cpp index 59824d47680..603e281d5e1 100644 --- a/Kernel/ProcessExposed.cpp +++ b/Kernel/ProcessExposed.cpp @@ -95,7 +95,7 @@ ProcFSExposedDirectory::ProcFSExposedDirectory(StringView name) { } -ProcFSExposedDirectory::ProcFSExposedDirectory(StringView name, const ProcFSExposedDirectory& parent_directory) +ProcFSExposedDirectory::ProcFSExposedDirectory(StringView name, ProcFSExposedDirectory const& parent_directory) : ProcFSExposedComponent(name) , m_parent_directory(parent_directory) { @@ -156,7 +156,7 @@ ErrorOr ProcFSSystemBoolean::try_generate(KBufferBuilder& builder) return builder.appendff("{}\n", static_cast(value())); } -ErrorOr ProcFSSystemBoolean::write_bytes(off_t, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription*) +ErrorOr ProcFSSystemBoolean::write_bytes(off_t, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription*) { if (count != 1) return EINVAL; @@ -200,22 +200,22 @@ ErrorOr ProcFSExposedLink::read_bytes(off_t offset, size_t count, UserOr return nread; } -ErrorOr> ProcFSExposedLink::to_inode(const ProcFS& procfs_instance) const +ErrorOr> ProcFSExposedLink::to_inode(ProcFS const& procfs_instance) const { return TRY(ProcFSLinkInode::try_create(procfs_instance, *this)); } -ErrorOr> ProcFSExposedComponent::to_inode(const ProcFS& procfs_instance) const +ErrorOr> ProcFSExposedComponent::to_inode(ProcFS const& procfs_instance) const { return TRY(ProcFSGlobalInode::try_create(procfs_instance, *this)); } -ErrorOr> ProcFSExposedDirectory::to_inode(const ProcFS& procfs_instance) const +ErrorOr> ProcFSExposedDirectory::to_inode(ProcFS const& procfs_instance) const { return TRY(ProcFSDirectoryInode::try_create(procfs_instance, *this)); } -void ProcFSExposedDirectory::add_component(const ProcFSExposedComponent&) +void ProcFSExposedDirectory::add_component(ProcFSExposedComponent const&) { TODO(); } diff --git a/Kernel/ProcessExposed.h b/Kernel/ProcessExposed.h index 146a4690e52..0f798ba1669 100644 --- a/Kernel/ProcessExposed.h +++ b/Kernel/ProcessExposed.h @@ -68,7 +68,7 @@ public: virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { VERIFY_NOT_REACHED(); } virtual ErrorOr traverse_as_directory(FileSystemID, Function(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); } virtual ErrorOr> lookup(StringView) { VERIFY_NOT_REACHED(); }; - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) { return EROFS; } + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; } virtual ErrorOr truncate(u64) { return EPERM; } virtual ErrorOr set_mtime(time_t) { return ENOTIMPL; } @@ -83,7 +83,7 @@ public: return {}; } - virtual ErrorOr> to_inode(const ProcFS& procfs_instance) const; + virtual ErrorOr> to_inode(ProcFS const& procfs_instance) const; virtual InodeIndex component_index() const { return m_component_index; } @@ -106,7 +106,7 @@ class ProcFSExposedDirectory public: virtual ErrorOr traverse_as_directory(FileSystemID, Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; - void add_component(const ProcFSExposedComponent&); + void add_component(ProcFSExposedComponent const&); virtual void prepare_for_deletion() override { @@ -116,18 +116,18 @@ public: } virtual mode_t required_mode() const override { return 0555; } - virtual ErrorOr> to_inode(const ProcFS& procfs_instance) const override final; + virtual ErrorOr> to_inode(ProcFS const& procfs_instance) const override final; protected: explicit ProcFSExposedDirectory(StringView name); - ProcFSExposedDirectory(StringView name, const ProcFSExposedDirectory& parent_directory); + ProcFSExposedDirectory(StringView name, ProcFSExposedDirectory const& parent_directory); NonnullRefPtrVector m_components; WeakPtr m_parent_directory; }; class ProcFSExposedLink : public ProcFSExposedComponent { public: - virtual ErrorOr> to_inode(const ProcFS& procfs_instance) const override final; + virtual ErrorOr> to_inode(ProcFS const& procfs_instance) const override final; virtual ErrorOr read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* description) const override; @@ -195,7 +195,7 @@ private: virtual ErrorOr try_generate(KBufferBuilder&) override final; // ^ProcFSExposedComponent - virtual ErrorOr write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) override final; + virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override final; virtual mode_t required_mode() const override final { return 0644; } virtual ErrorOr truncate(u64) override final; virtual ErrorOr set_mtime(time_t) override final; diff --git a/Kernel/ProcessGroup.h b/Kernel/ProcessGroup.h index 5d9309ceb8a..901e4986eab 100644 --- a/Kernel/ProcessGroup.h +++ b/Kernel/ProcessGroup.h @@ -28,7 +28,7 @@ public: static ErrorOr> try_find_or_create(ProcessGroupID); static RefPtr from_pgid(ProcessGroupID); - const ProcessGroupID& pgid() const { return m_pgid; } + ProcessGroupID const& pgid() const { return m_pgid; } private: ProcessGroup(ProcessGroupID pgid) diff --git a/Kernel/ProcessProcFSTraits.cpp b/Kernel/ProcessProcFSTraits.cpp index 0bdbf1fdf17..97335f88911 100644 --- a/Kernel/ProcessProcFSTraits.cpp +++ b/Kernel/ProcessProcFSTraits.cpp @@ -36,7 +36,7 @@ InodeIndex Process::ProcessProcFSTraits::component_index() const return SegmentedProcFSIndex::build_segmented_index_for_pid_directory(process->pid()); } -ErrorOr> Process::ProcessProcFSTraits::to_inode(const ProcFS& procfs_instance) const +ErrorOr> Process::ProcessProcFSTraits::to_inode(ProcFS const& procfs_instance) const { auto process = m_process.strong_ref(); if (!process) diff --git a/Kernel/ProcessSpecificExposed.cpp b/Kernel/ProcessSpecificExposed.cpp index 388eb3e9ba5..f101084e74f 100644 --- a/Kernel/ProcessSpecificExposed.cpp +++ b/Kernel/ProcessSpecificExposed.cpp @@ -57,7 +57,7 @@ ErrorOr Process::traverse_stacks_directory(FileSystemID fsid, Function> Process::lookup_stacks_directory(const ProcFS& procfs, StringView name) const +ErrorOr> Process::lookup_stacks_directory(ProcFS const& procfs, StringView name) const { auto maybe_needle = name.to_uint(); if (!maybe_needle.has_value()) @@ -65,7 +65,7 @@ ErrorOr> Process::lookup_stacks_directory(const ProcFS& pro auto needle = maybe_needle.release_value(); ErrorOr> thread_stack_inode { ENOENT }; - for_each_thread([&](const Thread& thread) { + for_each_thread([&](Thread const& thread) { int tid = thread.tid().value(); VERIFY(!(tid < 0)); if (needle == (unsigned)tid) { @@ -110,7 +110,7 @@ ErrorOr Process::traverse_file_descriptions_directory(FileSystemID fsid, F return {}; } -ErrorOr> Process::lookup_file_descriptions_directory(const ProcFS& procfs, StringView name) const +ErrorOr> Process::lookup_file_descriptions_directory(ProcFS const& procfs, StringView name) const { auto maybe_index = name.to_uint(); if (!maybe_index.has_value()) diff --git a/Kernel/Random.h b/Kernel/Random.h index ea4e25a7b3f..8aaf0eaaf72 100644 --- a/Kernel/Random.h +++ b/Kernel/Random.h @@ -67,7 +67,7 @@ public: if (pool == 0) { m_p0_len++; } - m_pools[pool].update(reinterpret_cast(&event_data), sizeof(T)); + m_pools[pool].update(reinterpret_cast(&event_data), sizeof(T)); } [[nodiscard]] bool is_seeded() const diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index d5d94a62af0..96950860040 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -27,7 +27,7 @@ namespace Kernel { RecursiveSpinlock g_scheduler_lock; -static u32 time_slice_for(const Thread& thread) +static u32 time_slice_for(Thread const& thread) { // One time slice unit == 4ms (assuming 250 ticks/second) if (thread.is_idle_thread()) @@ -282,7 +282,7 @@ void Scheduler::context_switch(Thread* thread) from_thread->set_state(Thread::State::Runnable); #ifdef LOG_EVERY_CONTEXT_SWITCH - const auto msg = "Scheduler[{}]: {} -> {} [prio={}] {:#04x}:{:p}"; + auto const msg = "Scheduler[{}]: {} -> {} [prio={}] {:#04x}:{:p}"; dbgln(msg, Processor::current_id(), from_thread->tid().value(), @@ -438,7 +438,7 @@ void Scheduler::add_time_scheduled(u64 time_to_add, bool is_kernel) }); } -void Scheduler::timer_tick(const RegisterState& regs) +void Scheduler::timer_tick(RegisterState const& regs) { VERIFY_INTERRUPTS_DISABLED(); VERIFY(Processor::current_in_irq()); diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index 1cff99c0191..a1d4abde606 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -34,7 +34,7 @@ public: static void initialize(); static Thread* create_ap_idle_thread(u32 cpu); static void set_idle_thread(Thread* idle_thread); - static void timer_tick(const RegisterState&); + static void timer_tick(RegisterState const&); [[noreturn]] static void start(); static void pick_next(); static void yield(); diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index 0f3c21c249f..ca52b59216e 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -12,7 +12,7 @@ #include #include -ErrorOr> try_copy_kstring_from_user(Userspace user_str, size_t user_str_size) +ErrorOr> try_copy_kstring_from_user(Userspace user_str, size_t user_str_size) { bool is_user = Kernel::Memory::is_user_range(user_str.vaddr(), user_str_size); if (!is_user) @@ -21,7 +21,7 @@ ErrorOr> try_copy_kstring_from_user(Userspace(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); + dbgln("copy_kstring_from_user({:p}, {}) failed at {} (strnlen)", static_cast(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); return EFAULT; } char* buffer; @@ -33,7 +33,7 @@ ErrorOr> try_copy_kstring_from_user(Userspace(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); + dbgln("copy_kstring_from_user({:p}, {}) failed at {} (memcpy)", static_cast(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); return EFAULT; } return new_string; @@ -62,7 +62,7 @@ ErrorOr