diff options
1665 files changed, 8491 insertions, 8491 deletions
diff --git a/AK/Atomic.h b/AK/Atomic.h index c28dfbf4e5..ec0b20f945 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<T, DefaultMemoryOrder> { 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<T*, DefaultMemoryOrder> { 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 7cdb6df2d4..6b3fdb09dc 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 028fe5d1ed..d3b8f67450 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 54f63f6358..97257c5136 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 813385ac6e..b5d470b747 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<bool VALUE> Optional<size_t> 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<size_t>::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 71d451f76d..d981b69c86 100644 --- a/AK/ByteReader.h +++ b/AK/ByteReader.h @@ -18,34 +18,34 @@ struct ByteReader { __builtin_memcpy(addr, &value, sizeof(T)); } template<typename T> - requires(IsTriviallyConstructible<T>) static void load(const u8* addr, T& value) + requires(IsTriviallyConstructible<T>) static void load(u8 const* addr, T& value) { __builtin_memcpy(&value, addr, sizeof(T)); } template<typename T> - static T* load_pointer(const u8* address) + static T* load_pointer(u8 const* address) { FlatPtr value; load<FlatPtr>(address, value); return reinterpret_cast<T*>(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 feba84b3ef..5cf1d987f2 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<typename T> -constexpr Checked<T> operator+(const Checked<T>& a, const Checked<T>& b) +constexpr Checked<T> operator+(Checked<T> const& a, Checked<T> const& b) { Checked<T> c { a }; c.add(b.value()); @@ -327,7 +327,7 @@ constexpr Checked<T> operator+(const Checked<T>& a, const Checked<T>& b) } template<typename T> -constexpr Checked<T> operator-(const Checked<T>& a, const Checked<T>& b) +constexpr Checked<T> operator-(Checked<T> const& a, Checked<T> const& b) { Checked<T> c { a }; c.sub(b.value()); @@ -335,7 +335,7 @@ constexpr Checked<T> operator-(const Checked<T>& a, const Checked<T>& b) } template<typename T> -constexpr Checked<T> operator*(const Checked<T>& a, const Checked<T>& b) +constexpr Checked<T> operator*(Checked<T> const& a, Checked<T> const& b) { Checked<T> c { a }; c.mul(b.value()); @@ -343,7 +343,7 @@ constexpr Checked<T> operator*(const Checked<T>& a, const Checked<T>& b) } template<typename T> -constexpr Checked<T> operator/(const Checked<T>& a, const Checked<T>& b) +constexpr Checked<T> operator/(Checked<T> const& a, Checked<T> const& b) { Checked<T> c { a }; c.div(b.value()); @@ -351,73 +351,73 @@ constexpr Checked<T> operator/(const Checked<T>& a, const Checked<T>& b) } template<typename T> -constexpr bool operator<(const Checked<T>& a, T b) +constexpr bool operator<(Checked<T> const& a, T b) { return a.value() < b; } template<typename T> -constexpr bool operator>(const Checked<T>& a, T b) +constexpr bool operator>(Checked<T> const& a, T b) { return a.value() > b; } template<typename T> -constexpr bool operator>=(const Checked<T>& a, T b) +constexpr bool operator>=(Checked<T> const& a, T b) { return a.value() >= b; } template<typename T> -constexpr bool operator<=(const Checked<T>& a, T b) +constexpr bool operator<=(Checked<T> const& a, T b) { return a.value() <= b; } template<typename T> -constexpr bool operator==(const Checked<T>& a, T b) +constexpr bool operator==(Checked<T> const& a, T b) { return a.value() == b; } template<typename T> -constexpr bool operator!=(const Checked<T>& a, T b) +constexpr bool operator!=(Checked<T> const& a, T b) { return a.value() != b; } template<typename T> -constexpr bool operator<(T a, const Checked<T>& b) +constexpr bool operator<(T a, Checked<T> const& b) { return a < b.value(); } template<typename T> -constexpr bool operator>(T a, const Checked<T>& b) +constexpr bool operator>(T a, Checked<T> const& b) { return a > b.value(); } template<typename T> -constexpr bool operator>=(T a, const Checked<T>& b) +constexpr bool operator>=(T a, Checked<T> const& b) { return a >= b.value(); } template<typename T> -constexpr bool operator<=(T a, const Checked<T>& b) +constexpr bool operator<=(T a, Checked<T> const& b) { return a <= b.value(); } template<typename T> -constexpr bool operator==(T a, const Checked<T>& b) +constexpr bool operator==(T a, Checked<T> const& b) { return a == b.value(); } template<typename T> -constexpr bool operator!=(T a, const Checked<T>& b) +constexpr bool operator!=(T a, Checked<T> const& b) { return a != b.value(); } diff --git a/AK/CheckedFormatString.h b/AK/CheckedFormatString.h index cf83944533..5113691cff 100644 --- a/AK/CheckedFormatString.h +++ b/AK/CheckedFormatString.h @@ -45,7 +45,7 @@ template<typename... Args> void compiletime_fail(Args...); template<size_t N> -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<size_t N> -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<typename... Args> struct CheckedFormatString { template<size_t N> - 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<size_t N, size_t param_count> - 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<N>(fmt); if (check.unclosed_braces != 0) diff --git a/AK/CircularDeque.h b/AK/CircularDeque.h index 5e6732a2f4..7174ddcaf1 100644 --- a/AK/CircularDeque.h +++ b/AK/CircularDeque.h @@ -17,7 +17,7 @@ public: template<typename U = T> 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 e6d9b23826..1819e6254f 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 8c9a835b61..d4ab79d9b3 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 728ae33c77..365c19b3b4 100644 --- a/AK/Complex.h +++ b/AK/Complex.h @@ -61,7 +61,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T>& operator=(const Complex<U>& other) + constexpr Complex<T>& operator=(Complex<U> const& other) { m_real = other.real(); m_imag = other.imag(); @@ -77,7 +77,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator+=(const Complex<U>& x) + constexpr Complex<T> operator+=(Complex<U> const& x) { m_real += x.real(); m_imag += x.imag(); @@ -92,7 +92,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator-=(const Complex<U>& x) + constexpr Complex<T> operator-=(Complex<U> const& x) { m_real -= x.real(); m_imag -= x.imag(); @@ -107,7 +107,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator*=(const Complex<U>& x) + constexpr Complex<T> operator*=(Complex<U> const& x) { const T real = m_real; m_real = real * x.real() - m_imag * x.imag(); @@ -124,7 +124,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator/=(const Complex<U>& x) + constexpr Complex<T> operator/=(Complex<U> const& x) { const T real = m_real; const T divisor = x.real() * x.real() + x.imag() * x.imag(); @@ -142,7 +142,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator+(const Complex<U>& a) + constexpr Complex<T> operator+(Complex<U> const& a) { Complex<T> x = *this; x += a; @@ -158,7 +158,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator-(const Complex<U>& a) + constexpr Complex<T> operator-(Complex<U> const& a) { Complex<T> x = *this; x -= a; @@ -174,7 +174,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator*(const Complex<U>& a) + constexpr Complex<T> operator*(Complex<U> const& a) { Complex<T> x = *this; x *= a; @@ -190,7 +190,7 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr Complex<T> operator/(const Complex<U>& a) + constexpr Complex<T> operator/(Complex<U> const& a) { Complex<T> x = *this; x /= a; @@ -206,13 +206,13 @@ public: } template<AK::Concepts::Arithmetic U> - constexpr bool operator==(const Complex<U>& a) const + constexpr bool operator==(Complex<U> const& a) const { return (this->real() == a.real()) && (this->imag() == a.imag()); } template<AK::Concepts::Arithmetic U> - constexpr bool operator!=(const Complex<U>& a) const + constexpr bool operator!=(Complex<U> const& a) const { return !(*this == a); } @@ -234,7 +234,7 @@ private: // reverse associativity operators for scalars template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U> -constexpr Complex<T> operator+(const U& b, const Complex<T>& a) +constexpr Complex<T> operator+(const U& b, Complex<T> const& a) { Complex<T> x = a; x += b; @@ -242,7 +242,7 @@ constexpr Complex<T> operator+(const U& b, const Complex<T>& a) } template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U> -constexpr Complex<T> operator-(const U& b, const Complex<T>& a) +constexpr Complex<T> operator-(const U& b, Complex<T> const& a) { Complex<T> x = a; x -= b; @@ -250,7 +250,7 @@ constexpr Complex<T> operator-(const U& b, const Complex<T>& a) } template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U> -constexpr Complex<T> operator*(const U& b, const Complex<T>& a) +constexpr Complex<T> operator*(const U& b, Complex<T> const& a) { Complex<T> x = a; x *= b; @@ -258,7 +258,7 @@ constexpr Complex<T> operator*(const U& b, const Complex<T>& a) } template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U> -constexpr Complex<T> operator/(const U& b, const Complex<T>& a) +constexpr Complex<T> operator/(const U& b, Complex<T> const& a) { Complex<T> x = a; x /= b; @@ -272,15 +272,15 @@ template<AK::Concepts::Arithmetic T> static constinit Complex<T> complex_imag_unit = Complex<T>((T)0, (T)1); template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U> -static constexpr bool approx_eq(const Complex<T>& a, const Complex<U>& b, const double margin = 0.000001) +static constexpr bool approx_eq(Complex<T> const& a, Complex<U> const& b, double const margin = 0.000001) { - const auto x = const_cast<Complex<T>&>(a) - const_cast<Complex<U>&>(b); + auto const x = const_cast<Complex<T>&>(a) - const_cast<Complex<U>&>(b); return x.magnitude() <= margin; } // complex version of exp() template<AK::Concepts::Arithmetic T> -static constexpr Complex<T> cexp(const Complex<T>& a) +static constexpr Complex<T> cexp(Complex<T> const& a) { // FIXME: this can probably be faster and not use so many "expensive" trigonometric functions return exp(a.real()) * Complex<T>(cos(a.imag()), sin(a.imag())); diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 95ebd53d39..89ebbad2d3 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, "'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; } - 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<<b' is only available for DistinctNumeric types with 'Shift'."); return this->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<DistinctNumeric<T, X, Incr, Cmp, Bool, Flags, Shift, Arith>> : template<typename T, typename X, auto... Args> struct Traits<AK::DistinctNumeric<T, X, Args...>> : public GenericTraits<AK::DistinctNumeric<T, X, Args...>> { static constexpr bool is_trivial() { return true; } - static constexpr auto hash(const DistinctNumeric<T, X, Args...>& d) { return Traits<T>::hash(d.value()); } + static constexpr auto hash(DistinctNumeric<T, X, Args...> const& d) { return Traits<T>::hash(d.value()); } }; using AK::DistinctNumeric; diff --git a/AK/DoublyLinkedList.h b/AK/DoublyLinkedList.h index f2425fdede..9d22d31e22 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -15,8 +15,8 @@ namespace AK { template<typename ListType, typename ElementType> 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 adf3d82257..dbddd3f713 100644 --- a/AK/Endian.h +++ b/AK/Endian.h @@ -89,7 +89,7 @@ template<typename T> class [[gnu::packed]] LittleEndian { public: friend InputStream& operator>><T>(InputStream&, LittleEndian<T>&); - friend OutputStream& operator<<<T>(OutputStream&, LittleEndian<T>); + friend OutputStream& operator<< <T>(OutputStream&, LittleEndian<T>); constexpr LittleEndian() = default; @@ -117,7 +117,7 @@ template<typename T> class [[gnu::packed]] BigEndian { public: friend InputStream& operator>><T>(InputStream&, BigEndian<T>&); - friend OutputStream& operator<<<T>(OutputStream&, BigEndian<T>); + friend OutputStream& operator<< <T>(OutputStream&, BigEndian<T>); constexpr BigEndian() = default; diff --git a/AK/FixedArray.h b/AK/FixedArray.h index 5708a67b69..c7e52a189d 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<size_t N> - static ErrorOr<FixedArray<T>> try_create(T(&&array)[N]) + static ErrorOr<FixedArray<T>> try_create(T (&&array)[N]) { if (N == 0) return FixedArray<T>(); diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index 0bb1b63c52..7e4465876f 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -15,8 +15,8 @@ namespace AK { struct FlyStringImplTraits : public Traits<StringImpl*> { - 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>, 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 8c8d55dad0..c81eb65e48 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>(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<FlyString> : public GenericTraits<FlyString> { - 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 ecd0948d31..cad570e6b4 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -51,8 +51,8 @@ static constexpr size_t convert_unsigned_to_string(u64 value, Array<u8, 128>& 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<u8, 128>& bu ErrorOr<void> 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<void> 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<void> 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<size_t, size_t>(used_by_padding, 2); + auto const used_by_left_padding = used_by_padding / 2; + auto const used_by_right_padding = ceil_div<size_t, size_t>(used_by_padding, 2); TRY(put_padding(fill, used_by_left_padding)); TRY(m_builder.try_append(value)); @@ -252,7 +252,7 @@ ErrorOr<void> FormatBuilder::put_u64( Array<u8, 128> 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<void> 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<void> { + auto const put_prefix = [&]() -> ErrorOr<void> { if (is_negative) TRY(m_builder.try_append('-')); else if (sign_mode == SignMode::Always) @@ -302,28 +302,28 @@ ErrorOr<void> FormatBuilder::put_u64( return {}; }; - const auto put_digits = [&]() -> ErrorOr<void> { + auto const put_digits = [&]() -> ErrorOr<void> { 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<size_t, size_t>(used_by_padding, 2); + auto const used_by_left_padding = used_by_padding / 2; + auto const used_by_right_padding = ceil_div<size_t, size_t>(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<void> 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<u64>(value), base, prefix, upper_case, zero_pad, align, min_width, fill, sign_mode, is_negative)); @@ -702,7 +702,7 @@ ErrorOr<void> Formatter<T>::format(FormatBuilder& builder, T value) m_mode = Mode::String; Formatter<StringView> formatter { *this }; - return formatter.format(builder, StringView { reinterpret_cast<const char*>(&value), 1 }); + return formatter.format(builder, StringView { reinterpret_cast<char const*>(&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<size_t>(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 661a37ce24..ddd612968d 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<const u8*>(value)); + return visitor(*static_cast<u8 const*>(value)); case TypeErasedParameter::Type::UInt16: - return visitor(*static_cast<const u16*>(value)); + return visitor(*static_cast<u16 const*>(value)); case TypeErasedParameter::Type::UInt32: - return visitor(*static_cast<const u32*>(value)); + return visitor(*static_cast<u32 const*>(value)); case TypeErasedParameter::Type::UInt64: - return visitor(*static_cast<const u64*>(value)); + return visitor(*static_cast<u64 const*>(value)); case TypeErasedParameter::Type::Int8: - return visitor(*static_cast<const i8*>(value)); + return visitor(*static_cast<i8 const*>(value)); case TypeErasedParameter::Type::Int16: - return visitor(*static_cast<const i16*>(value)); + return visitor(*static_cast<i16 const*>(value)); case TypeErasedParameter::Type::Int32: - return visitor(*static_cast<const i32*>(value)); + return visitor(*static_cast<i32 const*>(value)); case TypeErasedParameter::Type::Int64: - return visitor(*static_cast<const i64*>(value)); + return visitor(*static_cast<i64 const*>(value)); default: TODO(); } @@ -127,7 +127,7 @@ struct TypeErasedParameter { // FIXME: Getters and setters. - const void* value; + void const* value; Type type; ErrorOr<void> (*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<typename T> -ErrorOr<void> __format_value(TypeErasedFormatParams& params, FormatBuilder& builder, FormatParser& parser, const void* value) +ErrorOr<void> __format_value(TypeErasedFormatParams& params, FormatBuilder& builder, FormatParser& parser, void const* value) { Formatter<T> 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<Parameters>(), __format_value<Parameters> }... }) { this->set_parameters(m_data); @@ -396,8 +396,8 @@ struct Formatter<Bytes> : Formatter<ReadonlyBytes> { }; template<> -struct Formatter<const char*> : Formatter<StringView> { - ErrorOr<void> format(FormatBuilder& builder, const char* value) +struct Formatter<char const*> : Formatter<StringView> { + ErrorOr<void> format(FormatBuilder& builder, char const* value) { if (m_mode == Mode::Pointer) { Formatter<FlatPtr> formatter { *this }; @@ -407,14 +407,14 @@ struct Formatter<const char*> : Formatter<StringView> { } }; template<> -struct Formatter<char*> : Formatter<const char*> { +struct Formatter<char*> : Formatter<char const*> { }; template<size_t Size> -struct Formatter<char[Size]> : Formatter<const char*> { +struct Formatter<char[Size]> : Formatter<char const*> { }; template<size_t Size> struct Formatter<unsigned char[Size]> : Formatter<StringView> { - ErrorOr<void> format(FormatBuilder& builder, const unsigned char* value) + ErrorOr<void> format(FormatBuilder& builder, unsigned char const* value) { if (m_mode == Mode::Pointer) { Formatter<FlatPtr> formatter { *this }; @@ -535,14 +535,14 @@ ErrorOr<void> vformat(StringBuilder&, StringView fmtstr, TypeErasedFormatParams& void vout(FILE*, StringView fmtstr, TypeErasedFormatParams&, bool newline = false); template<typename... Parameters> -void out(FILE* file, CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) +void out(FILE* file, CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_params { parameters... }; vout(file, fmtstr.view(), variadic_format_params); } template<typename... Parameters> -void outln(FILE* file, CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) +void outln(FILE* file, CheckedFormatString<Parameters...>&& 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<Parameters...>&& fmtstr, const Parame inline void outln(FILE* file) { fputc('\n', file); } template<typename... Parameters> -void out(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { out(stdout, move(fmtstr), parameters...); } +void out(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { out(stdout, move(fmtstr), parameters...); } template<typename... Parameters> -void outln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { outln(stdout, move(fmtstr), parameters...); } +void outln(CheckedFormatString<Parameters...>&& 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<typename... Parameters> -void warn(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) +void warn(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { out(stderr, move(fmtstr), parameters...); } template<typename... Parameters> -void warnln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { outln(stderr, move(fmtstr), parameters...); } +void warnln(CheckedFormatString<Parameters...>&& 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<typename... Parameters> -void dbgln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) +void dbgln(CheckedFormatString<Parameters...>&& 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<typename... Parameters> -void dmesgln(CheckedFormatString<Parameters...>&& fmt, const Parameters&... parameters) +void dmesgln(CheckedFormatString<Parameters...>&& 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<typename... Parameters> -void critical_dmesgln(CheckedFormatString<Parameters...>&& fmt, const Parameters&... parameters) +void critical_dmesgln(CheckedFormatString<Parameters...>&& 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<FormatString> : Formatter<StringView> { template<typename... Parameters> - ErrorOr<void> format(FormatBuilder& builder, StringView fmtstr, const Parameters&... parameters) + ErrorOr<void> 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 d6e977a007..29049257b4 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 57649f9840..5db2bdc5ea 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 e869b44800..f20e446589 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 87d66c2523..4590f932d0 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<Concepts::HashCompatible<K> Key> - requires(IsSame<KeyTraits, Traits<K>>) Optional<typename Traits<V>::PeekType> get(const Key& key) const requires(!IsPointer<typename Traits<V>::PeekType>) + requires(IsSame<KeyTraits, Traits<K>>) Optional<typename Traits<V>::PeekType> get(Key const& key) + const requires(!IsPointer<typename Traits<V>::PeekType>) { auto it = find(key); if (it == end()) @@ -161,7 +162,8 @@ public: } template<Concepts::HashCompatible<K> Key> - requires(IsSame<KeyTraits, Traits<K>>) Optional<typename Traits<V>::ConstPeekType> get(const Key& key) const requires(IsPointer<typename Traits<V>::PeekType>) + requires(IsSame<KeyTraits, Traits<K>>) Optional<typename Traits<V>::ConstPeekType> get(Key const& key) + const requires(IsPointer<typename Traits<V>::PeekType>) { auto it = find(key); if (it == end()) @@ -170,7 +172,8 @@ public: } template<Concepts::HashCompatible<K> Key> - requires(IsSame<KeyTraits, Traits<K>>) Optional<typename Traits<V>::PeekType> get(const Key& key) requires(!IsConst<typename Traits<V>::PeekType>) + requires(IsSame<KeyTraits, Traits<K>>) Optional<typename Traits<V>::PeekType> get(Key const& key) + requires(!IsConst<typename Traits<V>::PeekType>) { auto it = find(key); if (it == end()) diff --git a/AK/HashTable.h b/AK/HashTable.h index d4dc8aa7e4..14478b4701 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 dfd0d410ef..666dcdf70d 100644 --- a/AK/Hex.cpp +++ b/AK/Hex.cpp @@ -21,11 +21,11 @@ ErrorOr<ByteBuffer> 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 03a6f61cab..8f72f8d3a0 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<u32> 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<IPv4Address> : public GenericTraits<IPv4Address> { - 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 b485443980..f946a5f527 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<T, Container, member>::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<T, Container, member>::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<T, Container, member>::next(m_value); diff --git a/AK/IntrusiveRedBlackTree.h b/AK/IntrusiveRedBlackTree.h index 56424ec846..5bc0f79ec0 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 953c091967..76b078386a 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 3a757765a1..7c24a4149b 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<void> add(const JsonValue& value) + ErrorOr<void> add(JsonValue const& value) { TRY(begin_item()); value.serialize(m_builder); @@ -73,7 +73,7 @@ public: } #ifndef KERNEL - ErrorOr<void> add(const String& value) + ErrorOr<void> add(String const& value) { TRY(begin_item()); if constexpr (IsLegacyBuilder<Builder>) { @@ -89,7 +89,7 @@ public: } #endif - ErrorOr<void> add(const char* value) + ErrorOr<void> add(char const* value) { TRY(begin_item()); if constexpr (IsLegacyBuilder<Builder>) { diff --git a/AK/JsonObjectSerializer.h b/AK/JsonObjectSerializer.h index 05d9e12c9c..0869205517 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<void> add(StringView key, const JsonValue& value) + ErrorOr<void> add(StringView key, JsonValue const& value) { TRY(begin_item(key)); value.serialize(m_builder); @@ -68,7 +68,7 @@ public: } #ifndef KERNEL - ErrorOr<void> add(StringView key, const String& value) + ErrorOr<void> add(StringView key, String const& value) { TRY(begin_item(key)); if constexpr (IsLegacyBuilder<Builder>) { @@ -84,7 +84,7 @@ public: } #endif - ErrorOr<void> add(StringView key, const char* value) + ErrorOr<void> add(StringView key, char const* value) { TRY(begin_item(key)); if constexpr (IsLegacyBuilder<Builder>) { diff --git a/AK/JsonPath.cpp b/AK/JsonPath.cpp index 5ad87517b5..9ad6618474 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 ab93c2d8ca..dbb52f0ac8 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<JsonPathElement> { 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 b29cf1a9b0..9a6536b619 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 328d7ee0d9..c52d0bb471 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 5bff252328..69b48576bc 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 d91cc5b24a..6caeeac73c 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<MACAddress> : public GenericTraits<MACAddress> { - 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 ee49e116e7..d97b7c0d1a 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<typename HaystackIterT> -inline Optional<size_t> memmem(const HaystackIterT& haystack_begin, const HaystackIterT& haystack_end, Span<const u8> needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) +inline Optional<size_t> memmem(HaystackIterT const& haystack_begin, HaystackIterT const& haystack_end, Span<const u8> needle) requires(requires { (*haystack_begin).data(); (*haystack_begin).size(); }) { auto prepare_kmp_partial_table = [&] { Vector<int, 64> table; @@ -100,7 +100,7 @@ inline Optional<size_t> memmem(const HaystackIterT& haystack_begin, const Haysta return {}; } -inline Optional<size_t> memmem_optional(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) +inline Optional<size_t> 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<size_t> memmem_optional(const void* haystack, size_t haystack_le } // Fallback to KMP. - Array<Span<const u8>, 1> spans { Span<const u8> { (const u8*)haystack, haystack_length } }; - return memmem(spans.begin(), spans.end(), { (const u8*)needle, needle_length }); + Array<Span<const u8>, 1> spans { Span<const u8> { (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 6cee4fe846..83cad05308 100644 --- a/AK/Memory.h +++ b/AK/Memory.h @@ -16,7 +16,7 @@ # include <string.h> #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<const char*>(b1); - auto* c2 = static_cast<const char*>(b2); + auto* c1 = static_cast<char const*>(b1); + auto* c2 = static_cast<char const*>(b2); u8 res = 0; for (size_t i = 0; i < len; i++) { diff --git a/AK/MemoryStream.h b/AK/MemoryStream.h index 2b58ce1462..c4fd384f0c 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 b3bbbda6d9..646386576b 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 87be16e261..ad374dcad5 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -57,25 +57,25 @@ public: #endif } - NonnullOwnPtr(const NonnullOwnPtr&) = delete; + NonnullOwnPtr(NonnullOwnPtr const&) = delete; template<typename U> - NonnullOwnPtr(const NonnullOwnPtr<U>&) = delete; - NonnullOwnPtr& operator=(const NonnullOwnPtr&) = delete; + NonnullOwnPtr(NonnullOwnPtr<U> const&) = delete; + NonnullOwnPtr& operator=(NonnullOwnPtr const&) = delete; template<typename U> - NonnullOwnPtr& operator=(const NonnullOwnPtr<U>&) = delete; + NonnullOwnPtr& operator=(NonnullOwnPtr<U> const&) = delete; template<typename U, typename PtrTraits = RefPtrTraits<U>> - NonnullOwnPtr(const RefPtr<U, PtrTraits>&) = delete; + NonnullOwnPtr(RefPtr<U, PtrTraits> const&) = delete; template<typename U> - NonnullOwnPtr(const NonnullRefPtr<U>&) = delete; + NonnullOwnPtr(NonnullRefPtr<U> const&) = delete; template<typename U> - NonnullOwnPtr(const WeakPtr<U>&) = delete; + NonnullOwnPtr(WeakPtr<U> const&) = delete; template<typename U, typename PtrTraits = RefPtrTraits<U>> - NonnullOwnPtr& operator=(const RefPtr<U, PtrTraits>&) = delete; + NonnullOwnPtr& operator=(RefPtr<U, PtrTraits> const&) = delete; template<typename U> - NonnullOwnPtr& operator=(const NonnullRefPtr<U>&) = delete; + NonnullOwnPtr& operator=(NonnullRefPtr<U> const&) = delete; template<typename U> - NonnullOwnPtr& operator=(const WeakPtr<U>&) = delete; + NonnullOwnPtr& operator=(WeakPtr<U> const&) = delete; NonnullOwnPtr& operator=(NonnullOwnPtr&& other) { @@ -178,8 +178,8 @@ template<typename T> struct Traits<NonnullOwnPtr<T>> : public GenericTraits<NonnullOwnPtr<T>> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const NonnullOwnPtr<T>& p) { return ptr_hash((FlatPtr)p.ptr()); } - static bool equals(const NonnullOwnPtr<T>& a, const NonnullOwnPtr<T>& b) { return a.ptr() == b.ptr(); } + static unsigned hash(NonnullOwnPtr<T> const& p) { return ptr_hash((FlatPtr)p.ptr()); } + static bool equals(NonnullOwnPtr<T> const& a, NonnullOwnPtr<T> const& b) { return a.ptr() == b.ptr(); } }; template<typename T, typename U> diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 6db27644d3..b71f85c002 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -22,8 +22,8 @@ public: : Base(static_cast<Base&&>(other)) { } - NonnullPtrVector(const Vector<PtrType>& other) - : Base(static_cast<const Base&>(other)) + NonnullPtrVector(Vector<PtrType> const& other) + : Base(static_cast<Base const&>(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 4640518c2a..2aab1d65ea 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -104,16 +104,16 @@ public: } template<typename U> - NonnullRefPtr(const OwnPtr<U>&) = delete; + NonnullRefPtr(OwnPtr<U> const&) = delete; template<typename U> - NonnullRefPtr& operator=(const OwnPtr<U>&) = delete; + NonnullRefPtr& operator=(OwnPtr<U> const&) = delete; template<typename U> - NonnullRefPtr(const RefPtr<U>&) = delete; + NonnullRefPtr(RefPtr<U> const&) = delete; template<typename U> - NonnullRefPtr& operator=(const RefPtr<U>&) = delete; - NonnullRefPtr(const RefPtr<T>&) = delete; - NonnullRefPtr& operator=(const RefPtr<T>&) = delete; + NonnullRefPtr& operator=(RefPtr<U> const&) = delete; + NonnullRefPtr(RefPtr<T> const&) = delete; + NonnullRefPtr& operator=(RefPtr<T> const&) = delete; NonnullRefPtr& operator=(NonnullRefPtr const& other) { @@ -270,8 +270,8 @@ template<typename T> struct Traits<NonnullRefPtr<T>> : public GenericTraits<NonnullRefPtr<T>> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const NonnullRefPtr<T>& p) { return ptr_hash(p.ptr()); } - static bool equals(const NonnullRefPtr<T>& a, const NonnullRefPtr<T>& b) { return a.ptr() == b.ptr(); } + static unsigned hash(NonnullRefPtr<T> const& p) { return ptr_hash(p.ptr()); } + static bool equals(NonnullRefPtr<T> const& a, NonnullRefPtr<T> const& b) { return a.ptr() == b.ptr(); } }; using AK::adopt_ref; diff --git a/AK/NumberFormat.h b/AK/NumberFormat.h index d63d424277..ce778eccc7 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 1eb888583c..4f6b1fbc64 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -47,29 +47,29 @@ public: #endif } - OwnPtr(const OwnPtr&) = delete; + OwnPtr(OwnPtr const&) = delete; template<typename U> - OwnPtr(const OwnPtr<U>&) = delete; - OwnPtr& operator=(const OwnPtr&) = delete; + OwnPtr(OwnPtr<U> const&) = delete; + OwnPtr& operator=(OwnPtr const&) = delete; template<typename U> - OwnPtr& operator=(const OwnPtr<U>&) = delete; + OwnPtr& operator=(OwnPtr<U> const&) = delete; template<typename U> - OwnPtr(const NonnullOwnPtr<U>&) = delete; + OwnPtr(NonnullOwnPtr<U> const&) = delete; template<typename U> - OwnPtr& operator=(const NonnullOwnPtr<U>&) = delete; + OwnPtr& operator=(NonnullOwnPtr<U> const&) = delete; template<typename U> - OwnPtr(const RefPtr<U>&) = delete; + OwnPtr(RefPtr<U> const&) = delete; template<typename U> - OwnPtr(const NonnullRefPtr<U>&) = delete; + OwnPtr(NonnullRefPtr<U> const&) = delete; template<typename U> - OwnPtr(const WeakPtr<U>&) = delete; + OwnPtr(WeakPtr<U> const&) = delete; template<typename U> - OwnPtr& operator=(const RefPtr<U>&) = delete; + OwnPtr& operator=(RefPtr<U> const&) = delete; template<typename U> - OwnPtr& operator=(const NonnullRefPtr<U>&) = delete; + OwnPtr& operator=(NonnullRefPtr<U> const&) = delete; template<typename U> - OwnPtr& operator=(const WeakPtr<U>&) = delete; + OwnPtr& operator=(WeakPtr<U> const&) = delete; OwnPtr& operator=(OwnPtr&& other) { @@ -232,8 +232,8 @@ template<typename T> struct Traits<OwnPtr<T>> : public GenericTraits<OwnPtr<T>> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const OwnPtr<T>& p) { return ptr_hash(p.ptr()); } - static bool equals(const OwnPtr<T>& a, const OwnPtr<T>& b) { return a.ptr() == b.ptr(); } + static unsigned hash(OwnPtr<T> const& p) { return ptr_hash(p.ptr()); } + static bool equals(OwnPtr<T> const& a, OwnPtr<T> const& b) { return a.ptr() == b.ptr(); } }; } diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 51b46b4b47..eb344c5eb8 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -14,7 +14,7 @@ #include <wchar.h> #ifdef __serenity__ -extern "C" size_t strlen(const char*); +extern "C" size_t strlen(char const*); #else # include <string.h> #endif @@ -24,8 +24,8 @@ namespace PrintfImplementation { template<typename PutChFunc, typename T, typename CharType> 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 PutChFunc, typename ArgumentListRefT, template<typename T, typename U = ArgumentListRefT> 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<const wchar_t*>()(ap); + wchar_t const* sp = NextArgument<wchar_t const*>()(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<const char*>()(ap); + char const* sp = NextArgument<char const*>()(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<i64>()(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<int>()(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<u64>()(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<u32>()(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<u64>()(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<u64>()(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<double>()(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<u32>()(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<u64>()(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<u32>()(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<u64>()(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<u32>()(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<int*>()(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<FlatPtr>()(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<FlatPtr>()(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<int>()(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 PutChFunc, template<typename T, typename U, template<typename X, typename Y> typename V, typename C = char> typename Impl = PrintfImpl, typename ArgumentListT = va_list, template<typename T, typename V = decltype(declval<ArgumentListT&>())> typename NextArgument = VaArgNextArgument, typename CharType = char> -ALWAYS_INLINE int printf_internal(PutChFunc putch, IdentityType<CharType>* buffer, const CharType*& fmt, ArgumentListT ap) +ALWAYS_INLINE int printf_internal(PutChFunc putch, IdentityType<CharType>* buffer, CharType const*& fmt, ArgumentListT ap) { int ret = 0; CharType* bufptr = buffer; Impl<PutChFunc, ArgumentListT&, NextArgument, CharType> 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 c1544b402e..9c7880123c 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<T*>(static_cast<FlatPtr>(m_ptr)); } - operator T const *() const { return reinterpret_cast<T const*>(static_cast<FlatPtr>(m_ptr)); } + operator T const*() const { return reinterpret_cast<T const*>(static_cast<FlatPtr>(m_ptr)); } T& operator[](size_t index) { return static_cast<T*>(*this)[index]; } T const& operator[](size_t index) const { return static_cast<T const*>(*this)[index]; } diff --git a/AK/RedBlackTree.h b/AK/RedBlackTree.h index 2740113420..11994bd4b4 100644 --- a/AK/RedBlackTree.h +++ b/AK/RedBlackTree.h @@ -404,7 +404,7 @@ template<typename TreeType, typename ElementType> 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 3696082e14..53a2fc2a8f 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<typename T> struct Traits<RefPtr<T>> : public GenericTraits<RefPtr<T>> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const RefPtr<T>& p) { return ptr_hash(p.ptr()); } - static bool equals(const RefPtr<T>& a, const RefPtr<T>& b) { return a.ptr() == b.ptr(); } + static unsigned hash(RefPtr<T> const& p) { return ptr_hash(p.ptr()); } + static bool equals(RefPtr<T> const& a, RefPtr<T> const& b) { return a.ptr() == b.ptr(); } }; template<typename T, typename U> -inline NonnullRefPtr<T> static_ptr_cast(const NonnullRefPtr<U>& ptr) +inline NonnullRefPtr<T> static_ptr_cast(NonnullRefPtr<U> const& ptr) { return NonnullRefPtr<T>(static_cast<const T&>(*ptr)); } template<typename T, typename U, typename PtrTraits = RefPtrTraits<T>> -inline RefPtr<T> static_ptr_cast(const RefPtr<U>& ptr) +inline RefPtr<T> static_ptr_cast(RefPtr<U> const& ptr) { return RefPtr<T, PtrTraits>(static_cast<const T*>(ptr.ptr())); } diff --git a/AK/Result.h b/AK/Result.h index 85c4f90722..c4ff023759 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 566a098df1..04e0fc3def 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 418027862c..7fabbd348a 100644 --- a/AK/ScopeLogger.h +++ b/AK/ScopeLogger.h @@ -15,7 +15,7 @@ namespace AK { template<bool = true> 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 513215e374..284aa3c3d4 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -18,7 +18,7 @@ template<typename ListType, typename ElementType> 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 00dfc3ca1f..3e875a2973 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 1a90897b65..c70d713144 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 1a255ede40..c9b64f0b26 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -75,19 +75,19 @@ constexpr SizeType array_size(T (&)[N]) } template<typename T> -constexpr T min(const T& a, const IdentityType<T>& b) +constexpr T min(const T& a, IdentityType<T> const& b) { return b < a ? b : a; } template<typename T> -constexpr T max(const T& a, const IdentityType<T>& b) +constexpr T max(const T& a, IdentityType<T> const& b) { return a < b ? b : a; } template<typename T> -constexpr T clamp(const T& value, const IdentityType<T>& min, const IdentityType<T>& max) +constexpr T clamp(const T& value, IdentityType<T> const& min, IdentityType<T> const& max) { VERIFY(max >= min); if (value > max) diff --git a/AK/String.cpp b/AK/String.cpp index 1e18bca9a2..66c01a2149 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<StringView> String::split_view(Function<bool(char)> separator, bool keep_ return v; } -Vector<StringView> String::split_view(const char separator, bool keep_empty) const +Vector<StringView> 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 e4221f037f..9160105a93 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<String&>(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<StringImpl&>(impl)) { } - String(const StringImpl* impl) + String(StringImpl const* impl) : m_impl(const_cast<StringImpl*>(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<class SeparatorType, class CollectionType> - [[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<const String, const char>; + using ConstIterator = SimpleIterator<const String, char const>; [[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<String&>(other).m_impl; @@ -265,17 +265,17 @@ public: [[nodiscard]] ByteBuffer to_byte_buffer() const; template<typename BufferType> - [[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<typename... Parameters> - [[nodiscard]] static String formatted(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) + [[nodiscard]] static String formatted(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_parameters { parameters... }; return vformatted(fmtstr.view(), variadic_format_parameters); @@ -320,7 +320,7 @@ private: template<> struct Traits<String> : public GenericTraits<String> { - 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<String> { @@ -328,10 +328,10 @@ struct CaseInsensitiveStringTraits : public Traits<String> { 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 9ea6362d59..c31d709ca9 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -48,7 +48,7 @@ NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*& return new_stringimpl; } -RefPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, ShouldChomp should_chomp) +RefPtr<StringImpl> StringImpl::create(char const* cstring, size_t length, ShouldChomp should_chomp) { if (!cstring) return nullptr; @@ -73,7 +73,7 @@ RefPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, Should return new_stringimpl; } -RefPtr<StringImpl> StringImpl::create(const char* cstring, ShouldChomp shouldChomp) +RefPtr<StringImpl> StringImpl::create(char const* cstring, ShouldChomp shouldChomp) { if (!cstring) return nullptr; @@ -86,7 +86,7 @@ RefPtr<StringImpl> StringImpl::create(const char* cstring, ShouldChomp shouldCho RefPtr<StringImpl> StringImpl::create(ReadonlyBytes bytes, ShouldChomp shouldChomp) { - return StringImpl::create(reinterpret_cast<const char*>(bytes.data()), bytes.size(), shouldChomp); + return StringImpl::create(reinterpret_cast<char const*>(bytes.data()), bytes.size(), shouldChomp); } RefPtr<StringImpl> StringImpl::create_lowercased(char const* cstring, size_t length) diff --git a/AK/StringImpl.h b/AK/StringImpl.h index a06f976ab0..c89f0e1202 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<StringImpl> { public: static NonnullRefPtr<StringImpl> create_uninitialized(size_t length, char*& buffer); - static RefPtr<StringImpl> create(const char* cstring, ShouldChomp = NoChomp); - static RefPtr<StringImpl> create(const char* cstring, size_t length, ShouldChomp = NoChomp); + static RefPtr<StringImpl> create(char const* cstring, ShouldChomp = NoChomp); + static RefPtr<StringImpl> create(char const* cstring, size_t length, ShouldChomp = NoChomp); static RefPtr<StringImpl> create(ReadonlyBytes, ShouldChomp = NoChomp); static RefPtr<StringImpl> create_lowercased(char const* cstring, size_t length); static RefPtr<StringImpl> 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 927b3b6ee1..2c66ec68d5 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<T> 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<T> 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<T> 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<T>::max(); for (size_t i = 0; i < count; i++) { @@ -204,7 +204,7 @@ Optional<T> 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<T>::max(); for (size_t i = 0; i < count; i++) { diff --git a/AK/StringUtils.h b/AK/StringUtils.h index 775e28ac6c..9ba0012041 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 64aea8f227..fdcb6f4b8f 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> StringView::split_view(const char separator, bool keep_empty) const +Vector<StringView> 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<long> StringView::to_uint() const; template Optional<long long> 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 d37ee4d8c9..05331e0580 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<uintptr_t>::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<uintptr_t>::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<const char*>(bytes.data())) + : m_characters(reinterpret_cast<char const*>(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<const StringView, const char>; + using ConstIterator = SimpleIterator<const StringView, char const>; [[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<StringView> { # 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 825002ed30..bb01b1e907 100644 --- a/AK/Time.cpp +++ b/AK/Time.cpp @@ -182,7 +182,7 @@ timeval Time::to_timeval() const return { static_cast<time_t>(m_seconds), static_cast<suseconds_t>(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); } @@ -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<typename TimevalType> -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<typename TimevalType> -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<typename TimespecType> -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<typename TimespecType> -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<typename TimespecType, typename TimevalType> -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<typename TimevalType, typename TimespecType> -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<typename TimespecType, typename TimevalType> -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; @@ -40,7 +40,7 @@ public: } template<typename It> - 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<typename It> - const BaseType& traverse_until_last_accessible_node(It& it, const It& end) const { return const_cast<Trie*>(this)->traverse_until_last_accessible_node(it, end); } + BaseType const& traverse_until_last_accessible_node(It& it, It const& end) const { return const_cast<Trie*>(this)->traverse_until_last_accessible_node(it, end); } template<typename It> - 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<Trie*>(this)->traverse_until_last_accessible_node(it, end); } template<typename It> - 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<Trie*>(this)->traverse_until_last_accessible_node(it, end); @@ -71,10 +71,10 @@ public: Optional<MetadataType> metadata() const requires(!IsNullPointer<MetadataType>) { return m_metadata; } void set_metadata(MetadataType metadata) requires(!IsNullPointer<MetadataType>) { m_metadata = move(metadata); } - const MetadataType& metadata_value() const requires(!IsNullPointer<MetadataType>) { return m_metadata.value(); } + MetadataType const& metadata_value() const requires(!IsNullPointer<MetadataType>) { return m_metadata.value(); } MetadataType& metadata_value() requires(!IsNullPointer<MetadataType>) { return m_metadata.value(); } - const ValueType& value() const { return m_value; } + ValueType const& value() const { return m_value; } ValueType& value() { return m_value; } ErrorOr<Trie*> ensure_child(ValueType value, Optional<MetadataType> metadata = {}) @@ -99,11 +99,10 @@ public: template<typename It, typename ProvideMetadataFunction> ErrorOr<BaseType*> insert( - It& it, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>) + It& it, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>) { Trie* last_root_node = &traverse_until_last_accessible_node(it, end); - auto invoke_provide_missing_metadata = [&]<typename... Ts>(Ts && ... args)->ErrorOr<Optional<MetadataType>> - { + auto invoke_provide_missing_metadata = [&]<typename... Ts>(Ts&&... args) -> ErrorOr<Optional<MetadataType>> { if constexpr (SameAs<MetadataType, decltype(provide_missing_metadata(forward<Ts>(args)...))>) return Optional<MetadataType>(provide_missing_metadata(forward<Ts>(args)...)); else @@ -120,7 +119,7 @@ public: } template<typename It> - ErrorOr<BaseType*> insert(It& it, const It& end) requires(IsNullPointer<MetadataType>) + ErrorOr<BaseType*> insert(It& it, It const& end) requires(IsNullPointer<MetadataType>) { Trie* last_root_node = &traverse_until_last_accessible_node(it, end); for (; it != end; ++it) { @@ -134,14 +133,14 @@ public: template<typename It, typename ProvideMetadataFunction> ErrorOr<BaseType*> insert( - const It& begin, const It& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>) + It const& begin, It const& end, MetadataType metadata, ProvideMetadataFunction provide_missing_metadata) requires(!IsNullPointer<MetadataType>) { auto it = begin; return insert(it, end, move(metadata), move(provide_missing_metadata)); } template<typename It> - ErrorOr<BaseType*> insert(const It& begin, const It& end) requires(IsNullPointer<MetadataType>) + ErrorOr<BaseType*> insert(It const& begin, It const& end) requires(IsNullPointer<MetadataType>) { auto it = begin; return insert(it, end); diff --git a/AK/Tuple.h b/AK/Tuple.h index 9bdec66f15..ff628facff 100644 --- a/AK/Tuple.h +++ b/AK/Tuple.h @@ -122,7 +122,7 @@ struct Tuple : Detail::Tuple<Ts...> { { } - Tuple(const Tuple& other) + Tuple(Tuple const& other) : Tuple(other, Indices()) { } @@ -133,7 +133,7 @@ struct Tuple : Detail::Tuple<Ts...> { return *this; } - Tuple& operator=(const Tuple& other) + Tuple& operator=(Tuple const& other) { set(other, Indices()); return *this; @@ -185,7 +185,7 @@ private: } template<unsigned... Is> - Tuple(const Tuple& other, IndexSequence<Is...>) + Tuple(Tuple const& other, IndexSequence<Is...>) : Detail::Tuple<Ts...>(other.get<Is>()...) { } @@ -197,7 +197,7 @@ private: } template<unsigned... Is> - void set(const Tuple& other, IndexSequence<Is...>) + void set(Tuple const& other, IndexSequence<Is...>) { ((get<Is>() = other.get<Is>()), ...); } diff --git a/AK/Types.h b/AK/Types.h index 8610a69e0d..bf223afca9 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 70724e42d9..2dedbacfb4 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 0d2f4cc257..9880dc75d7 100644 --- a/AK/UFixedBigInt.h +++ b/AK/UFixedBigInt.h @@ -83,7 +83,7 @@ public: } Span<const u8> bytes() const { - return Span<const u8>(reinterpret_cast<const u8*>(this), sizeof(R)); + return Span<const u8>(reinterpret_cast<u8 const*>(this), sizeof(R)); } template<Unsigned U> @@ -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<Unsigned U, Unsigned T> -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<(const U a, const UFixedBigInt<T>& b) { return b >= a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<(const U a, UFixedBigInt<T> const& b) { return b >= a; } template<Unsigned U, Unsigned T> -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>(const U a, const UFixedBigInt<T>& b) { return b <= a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>(const U a, UFixedBigInt<T> const& b) { return b <= a; } template<Unsigned U, Unsigned T> -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<=(const U a, const UFixedBigInt<T>& b) { return b > a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator<=(const U a, UFixedBigInt<T> const& b) { return b > a; } template<Unsigned U, Unsigned T> -requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>=(const U a, const UFixedBigInt<T>& b) { return b < a; } +requires(sizeof(U) < sizeof(T) * 2) constexpr bool operator>=(const U a, UFixedBigInt<T> const& b) { return b < a; } template<Unsigned T> struct Formatter<UFixedBigInt<T>> : StandardFormatter { diff --git a/AK/UUID.cpp b/AK/UUID.cpp index c04f10cd88..3c08fc7c52 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 267862424e..f741df9b9c 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<typename T, typename U> -inline Userspace<T> static_ptr_cast(const Userspace<U>& ptr) +inline Userspace<T> static_ptr_cast(Userspace<U> const& ptr) { #ifdef KERNEL auto casted_ptr = static_cast<T>(ptr.unsafe_userspace_ptr()); diff --git a/AK/Utf32View.h b/AK/Utf32View.h index 75c7d2c0d9..249407f8c5 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 4c559a886d..7d93d73b78 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 f63ac2c178..19dd62ff1d 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<u32> 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 8425f79f7c..c0919ab01e 100644 --- a/AK/Variant.h +++ b/AK/Variant.h @@ -62,7 +62,7 @@ struct Variant<IndexType, InitialIndex, F, Ts...> { Variant<IndexType, InitialIndex + 1, Ts...>::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<F const*>(old_data)); @@ -75,7 +75,7 @@ template<typename IndexType, IndexType InitialIndex> struct Variant<IndexType, InitialIndex> { 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<typename IndexType, typename... Ts> @@ -97,7 +97,7 @@ struct VisitImpl { } template<typename Self, typename Visitor, IndexType CurrentIndex = 0> - 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<Ts...>::template Type<CurrentIndex>; @@ -239,7 +239,7 @@ public: } template<typename... NewTs> - Variant(const Variant<NewTs...>& old) requires((can_contain<NewTs>() && ...)) + Variant(Variant<NewTs...> const& old) requires((can_contain<NewTs>() && ...)) : Variant(old.template downcast<Ts...>()) { } @@ -254,8 +254,8 @@ public: } #ifdef AK_HAS_CONDITIONALLY_TRIVIAL - Variant(const Variant&) requires(!(IsCopyConstructible<Ts> && ...)) = delete; - Variant(const Variant&) = default; + Variant(Variant const&) requires(!(IsCopyConstructible<Ts> && ...)) = delete; + Variant(Variant const&) = default; Variant(Variant&&) requires(!(IsMoveConstructible<Ts> && ...)) = delete; Variant(Variant&&) = default; @@ -263,14 +263,14 @@ public: ~Variant() requires(!(IsDestructible<Ts> && ...)) = delete; ~Variant() = default; - Variant& operator=(const Variant&) requires(!(IsCopyConstructible<Ts> && ...) || !(IsDestructible<Ts> && ...)) = delete; - Variant& operator=(const Variant&) = default; + Variant& operator=(Variant const&) requires(!(IsCopyConstructible<Ts> && ...) || !(IsDestructible<Ts> && ...)) = delete; + Variant& operator=(Variant const&) = default; Variant& operator=(Variant&&) requires(!(IsMoveConstructible<Ts> && ...) || !(IsDestructible<Ts> && ...)) = 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<Ts> && ...)) #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<Ts> && ...) || !(IsTriviallyDestructible<Ts> && ...)) #endif @@ -418,7 +418,7 @@ public: Variant<NewTs...> downcast() const& { Variant<NewTs...> instance { Variant<NewTs...>::invalid_index, Detail::VariantConstructTag {} }; - visit([&](const auto& value) { + visit([&](auto const& value) { if constexpr (Variant<NewTs...>::template can_contain<RemoveCVReference<decltype(value)>>()) instance.set(value, Detail::VariantNoClearTag {}); }); diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index a7e3346abe..a6efeb8103 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -23,7 +23,7 @@ public: WeakPtr() = default; template<typename U> - WeakPtr(const WeakPtr<U>& other) requires(IsBaseOf<T, U>) + WeakPtr(WeakPtr<U> const& other) requires(IsBaseOf<T, U>) : m_link(other.m_link) { } @@ -42,9 +42,9 @@ public: } template<typename U> - WeakPtr& operator=(const WeakPtr<U>& other) requires(IsBaseOf<T, U>) + WeakPtr& operator=(WeakPtr<U> const& other) requires(IsBaseOf<T, U>) { - 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<typename U> - WeakPtr& operator=(const RefPtr<U>& object) requires(IsBaseOf<T, U>) + WeakPtr& operator=(RefPtr<U> const& object) requires(IsBaseOf<T, U>) { if (object) m_link = object->template make_weak_ptr<U>().take_link(); @@ -109,7 +109,7 @@ public: } template<typename U> - WeakPtr& operator=(const NonnullRefPtr<U>& object) requires(IsBaseOf<T, U>) + WeakPtr& operator=(NonnullRefPtr<U> const& object) requires(IsBaseOf<T, U>) { m_link = object->template make_weak_ptr<U>().take_link(); return *this; @@ -141,7 +141,7 @@ public: [[nodiscard]] RefPtr<WeakLink> take_link() { return move(m_link); } private: - WeakPtr(const RefPtr<WeakLink>& link) + WeakPtr(RefPtr<WeakLink> const& link) : m_link(link) { } diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp index d6635f9ee2..cba00d3607 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 79b81aef21..2ef6b341aa 100644 --- a/AK/kstdio.h +++ b/AK/kstdio.h @@ -13,20 +13,20 @@ # include <AK/Types.h> # include <stdarg.h> 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 <stdio.h> -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<size_t N> -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 9a2ce68152..0c2cf8f9b4 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 a212bdd65f..ba04a9843a 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 921eb4ee8a..de41ae6f73 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 de6e1c6a43..2d7a848459 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 b23f134f95..f1bc6f0d90 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 83a322bc47..2b4794e851 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 4bb284f7cd..1012ad4e3b 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 5035ae5ab8..5f7310daa3 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 38c953b600..31ec573299 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 f7a5a1e50c..c26963ef53 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 79cef0a166..7b77cda167 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 92d2f3a7d8..9c9fe88ae9 100644 --- a/Kernel/Arch/aarch64/Utils.cpp +++ b/Kernel/Arch/aarch64/Utils.cpp @@ -7,14 +7,14 @@ #include <Kernel/Arch/aarch64/UART.h> #include <Kernel/Arch/aarch64/Utils.h> -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 0c25610654..da5eea7ad7 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 74264c2fa1..0d2fb587cd 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<bool> safe_atomic_compare_exchange_relaxed(volatile u32*, u32&, u32); -Optional<bool> safe_atomic_compare_exchange_relaxed(volatile u32*, u32&, u32) { return {}; } +Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile*, u32&, u32); +Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile*, u32&, u32) { return {}; } -Optional<u32> safe_atomic_load_relaxed(volatile u32*); -Optional<u32> safe_atomic_load_relaxed(volatile u32*) { return {}; } +Optional<u32> safe_atomic_load_relaxed(u32 volatile*); +Optional<u32> safe_atomic_load_relaxed(u32 volatile*) { return {}; } -Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32*, u32); -Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32*, u32) { return {}; } +Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile*, u32); +Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile*, u32) { return {}; } -Optional<u32> safe_atomic_exchange_relaxed(volatile u32*, u32); -Optional<u32> safe_atomic_exchange_relaxed(volatile u32*, u32) { return {}; } +Optional<u32> safe_atomic_exchange_relaxed(u32 volatile*, u32); +Optional<u32> 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 bce753da49..a5fc1e16f8 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<const u8*>(&serenity_boot_logo_start), serenity_boot_logo_size); + Prekernel::BootPPMParser logo_parser(reinterpret_cast<u8 const*>(&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 99d579c287..caa946fd28 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 5dd0c8ac22..f38dfc89bd 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 d0e241e987..7c8e7e2cf9 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<Memory::PageDirectory>, const PageDirectoryEntry& other) { m_raw = other.m_raw; } + void copy_from(Badge<Memory::PageDirectory>, 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 39418ae8dd..60740dc9dd 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<IteratorFunction<Processor&> Callback> static inline IterationDecision for_each(Callback callback) diff --git a/Kernel/Arch/x86/RegisterState.h b/Kernel/Arch/x86/RegisterState.h index bc48812bac..42af83a5a1 100644 --- a/Kernel/Arch/x86/RegisterState.h +++ b/Kernel/Arch/x86/RegisterState.h @@ -128,7 +128,7 @@ static_assert(AssertSize<RegisterState, REGISTER_STATE_SIZE>()); static_assert(AssertSize<RegisterState, REGISTER_STATE_SIZE>()); #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 df90e847b3..df5be2d770 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<u32> safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val) __attribute__((used)); -[[nodiscard]] Optional<u32> safe_atomic_exchange_relaxed(volatile u32* var, u32 val) __attribute__((used)); -[[nodiscard]] Optional<u32> safe_atomic_load_relaxed(volatile u32* var) __attribute__((used)); -[[nodiscard]] bool safe_atomic_store_relaxed(volatile u32* var, u32 val) __attribute__((used)); -[[nodiscard]] Optional<bool> safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) __attribute__((used)); +[[nodiscard]] Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional<u32> safe_atomic_exchange_relaxed(u32 volatile* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional<u32> safe_atomic_load_relaxed(u32 volatile* var) __attribute__((used)); +[[nodiscard]] bool safe_atomic_store_relaxed(u32 volatile* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional<bool> safe_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val) __attribute__((used)); -[[nodiscard]] ALWAYS_INLINE Optional<u32> safe_atomic_fetch_and_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional<u32> 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<u32> safe_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional<u32> 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<u32> safe_atomic_fetch_or_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional<u32> 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<u32> safe_atomic_fetch_xor_relaxed(volatile u32* var, u32 val) +[[nodiscard]] ALWAYS_INLINE Optional<u32> 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 ef735ad1f3..03e2a943b9 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 48e99953d2..33ddaf6917 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 53afe555d2..c334ffc584 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 7a0cf0e404..e87601130d 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 a0e3908eb9..1cf3a1e6be 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<u32> Processor::g_total_processors; -READONLY_AFTER_INIT static volatile bool s_smp_enabled; +READONLY_AFTER_INIT static bool volatile s_smp_enabled; static Atomic<ProcessorMessage*> s_message_pool; Atomic<u32> 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 6a93fef67d..b7acc471e6 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<char*>(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<u32> safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val) +NEVER_INLINE Optional<u32> safe_atomic_fetch_add_relaxed(u32 volatile* var, u32 val) { u32 result; bool error; @@ -230,7 +230,7 @@ NEVER_INLINE Optional<u32> safe_atomic_fetch_add_relaxed(volatile u32* var, u32 } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE Optional<u32> safe_atomic_exchange_relaxed(volatile u32* var, u32 val) +NEVER_INLINE Optional<u32> safe_atomic_exchange_relaxed(u32 volatile* var, u32 val) { u32 result; bool error; @@ -250,7 +250,7 @@ NEVER_INLINE Optional<u32> safe_atomic_exchange_relaxed(volatile u32* var, u32 v } CODE_SECTION(".text.safemem.atomic") -NEVER_INLINE Optional<u32> safe_atomic_load_relaxed(volatile u32* var) +NEVER_INLINE Optional<u32> safe_atomic_load_relaxed(u32 volatile* var) { u32 result; bool error; @@ -270,7 +270,7 @@ NEVER_INLINE Optional<u32> 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<bool> safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) +NEVER_INLINE Optional<bool> 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 c292984c96..9c74d12c4e 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<bool>(expr)) [[unlikely]] \ diff --git a/Kernel/BootInfo.h b/Kernel/BootInfo.h index 48330cce7d..d19faec40f 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 febee0a068..4cfb166381 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 c4a9d6e79b..16a11ed8e1 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 7fe347ef0b..069ae33804 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> PCIDeviceSysFSDirectory::create(const SysFSDirectory& parent_directory, Address address) +UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> 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<KString> device_directory_name, const SysFSDirectory& parent_directory, Address address) +UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> 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> PCIDeviceAttributeSysFSComponent::create(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width) +NonnullRefPtr<PCIDeviceAttributeSysFSComponent> 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 4f549c45c3..80c09e46e5 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<PCIDeviceSysFSDirectory> create(const SysFSDirectory&, Address); - const Address& address() const { return m_address; } + static NonnullRefPtr<PCIDeviceSysFSDirectory> 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<KString> device_directory_name, const SysFSDirectory&, Address); + PCIDeviceSysFSDirectory(NonnullOwnPtr<KString> device_directory_name, SysFSDirectory const&, Address); Address m_address; @@ -38,7 +38,7 @@ private: class PCIDeviceAttributeSysFSComponent : public SysFSComponent { public: - static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width); + static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width); virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override; virtual ~PCIDeviceAttributeSysFSComponent() {}; @@ -47,7 +47,7 @@ public: protected: ErrorOr<NonnullOwnPtr<KBuffer>> 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<PCIDeviceSysFSDirectory> 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 f478cd6622..488e3b59c4 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.cpp +++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp @@ -476,7 +476,7 @@ ErrorOr<void> 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 0cd243cc92..66279b510e 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<void> create_structures(); void setup_schedule(); diff --git a/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h b/Kernel/Bus/USB/UHCI/UHCIDescriptorTypes.h index 3f95302b11..8cae746922 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 37336461a8..2ac68482ba 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 a8e7eba762..15329fc391 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 c01b3904e7..62dc28e116 100644 --- a/Kernel/Bus/USB/USBTransfer.cpp +++ b/Kernel/Bus/USB/USBTransfer.cpp @@ -26,7 +26,7 @@ Transfer::Transfer(Pipe& pipe, u16 len, NonnullOwnPtr<Memory::Region> 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 f4c6570a85..78487da9fc 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 b13729d8ec..1908f117af 100644 --- a/Kernel/Bus/VirtIO/ConsolePort.cpp +++ b/Kernel/Bus/VirtIO/ConsolePort.cpp @@ -92,7 +92,7 @@ void ConsolePort::handle_queue_update(Badge<VirtIO::Console>, 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<size_t> 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<size_t> ConsolePort::write(OpenFileDescription& desc, u64, const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> 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 beed06e1a2..f5c9088ced 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override; static unsigned next_device_id; diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp index 06f5850bcd..9296dc4213 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<u8>(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<u16>(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<u32>(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 e42be0bb97..3c8fe360bc 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<Queue> m_queues; Vector<Configuration> 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 cb31571e4a..9f18278906 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 fab091b700..12a5940e15 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 8f9d24bdd4..1369b02b8f 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<KString> CommandLine::build_commandline(StringVie return KString::must_create(builder.string_view()); } -UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector<StringView>& args) +UNMAP_AFTER_INIT void CommandLine::add_arguments(Vector<StringView> 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<KString> 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 0fe2ef1169..a52e2daa35 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<StringView>& args); + void add_arguments(Vector<StringView> const& args); static NonnullOwnPtr<KString> build_commandline(StringView cmdline_from_bootloader); NonnullOwnPtr<KString> m_string; HashMap<StringView, StringView> 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 ed690703a5..4aa7c2ff89 100644 --- a/Kernel/Devices/AsyncDeviceRequest.h +++ b/Kernel/Devices/AsyncDeviceRequest.h @@ -99,7 +99,7 @@ public: } template<typename... Args> - ErrorOr<void> read_from_buffer(const UserOrKernelBuffer& buffer, Args... args) + ErrorOr<void> read_from_buffer(UserOrKernelBuffer const& buffer, Args... args) { if (in_target_context(buffer)) return buffer.read(forward<Args>(args)...); @@ -108,7 +108,7 @@ public: } template<size_t BUFFER_BYTES, typename... Args> - ErrorOr<size_t> read_from_buffer_buffered(const UserOrKernelBuffer& buffer, Args... args) + ErrorOr<size_t> read_from_buffer_buffered(UserOrKernelBuffer const& buffer, Args... args) { if (in_target_context(buffer)) return buffer.read_buffered<BUFFER_BYTES>(forward<Args>(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 cd38567a3a..1b14493113 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<void> initialize(); diff --git a/Kernel/Devices/Audio/Channel.cpp b/Kernel/Devices/Audio/Channel.cpp index ac390d7aed..a0585b4759 100644 --- a/Kernel/Devices/Audio/Channel.cpp +++ b/Kernel/Devices/Audio/Channel.cpp @@ -50,7 +50,7 @@ ErrorOr<void> 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 affd85a8ff..6ef85eee72 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned, Userspace<void*>) override; diff --git a/Kernel/Devices/BlockDevice.cpp b/Kernel/Devices/BlockDevice.cpp index a9e8f2d802..894e4a9462 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<BlockDevice&>(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>(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 018a19551a..2af743f03f 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 5de75013af..2d68440992 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<size_t> ConsoleDevice::read(OpenFileDescription&, u64, Kernel::UserOrKer return 0; } -ErrorOr<size_t> ConsoleDevice::write(OpenFileDescription&, u64, const Kernel::UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> 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 7af4d41bb8..e0df08ca32 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<size_t> read(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const Kernel::UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, Kernel::UserOrKernelBuffer const&, size_t) override; virtual StringView class_name() const override { return "Console"sv; } void put_char(char); - const CircularQueue<char, 16384>& logbuffer() const { return m_logbuffer; } + CircularQueue<char, 16384> const& logbuffer() const { return m_logbuffer; } private: ConsoleDevice(); diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index 65454e1d9b..5c7ee8ab07 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -146,12 +146,12 @@ Device::~Device() VERIFY(m_state == State::BeingRemoved); } -ErrorOr<NonnullOwnPtr<KString>> Device::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> Device::pseudo_path(OpenFileDescription const&) const { return KString::formatted("device:{},{}", major(), minor()); } -void Device::process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest& completed_request) +void Device::process_next_queued_request(Badge<AsyncDeviceRequest>, 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 9546c0927c..8002d069ec 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<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr<NonnullOwnPtr<KString>> 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<AsyncDeviceRequest>, const AsyncDeviceRequest&); + void process_next_queued_request(Badge<AsyncDeviceRequest>, AsyncDeviceRequest const&); template<typename AsyncRequestType, typename... Args> ErrorOr<NonnullRefPtr<AsyncRequestType>> try_make_request(Args&&... args) diff --git a/Kernel/Devices/DeviceControlDevice.cpp b/Kernel/Devices/DeviceControlDevice.cpp index a78d03f40b..0e5f4c5cf7 100644 --- a/Kernel/Devices/DeviceControlDevice.cpp +++ b/Kernel/Devices/DeviceControlDevice.cpp @@ -17,7 +17,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<DeviceControlDevice> 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 8eeb0670f8..5e86a73650 100644 --- a/Kernel/Devices/DeviceControlDevice.h +++ b/Kernel/Devices/DeviceControlDevice.h @@ -23,9 +23,9 @@ private: // ^CharacterDevice virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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<size_t> 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 14cbaa817b..1073c58800 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<size_t> FullDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer& return size; } -ErrorOr<size_t> FullDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size) +ErrorOr<size_t> 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 2206f789d2..8329d4f9fc 100644 --- a/Kernel/Devices/FullDevice.h +++ b/Kernel/Devices/FullDevice.h @@ -22,9 +22,9 @@ private: // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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<size_t> 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 923ab83dd3..5bbedce798 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 db88181837..ee1179cb54 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 238a60894b..273fde6661 100644 --- a/Kernel/Devices/HID/KeyboardDevice.h +++ b/Kernel/Devices/HID/KeyboardDevice.h @@ -26,9 +26,9 @@ public: // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual ErrorOr<size_t> 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<size_t> 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 1aff69396f..0adaee5034 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 d80d4fcce3..d7317a6799 100644 --- a/Kernel/Devices/HID/MouseDevice.h +++ b/Kernel/Devices/HID/MouseDevice.h @@ -24,9 +24,9 @@ public: // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual ErrorOr<size_t> 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<size_t> 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 23f696fa30..8dcd080e21 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<NonnullRefPtr<PS2KeyboardDevice>> PS2KeyboardDevice::try_to_initialize(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> PS2KeyboardDevice::try_to_initialize(I8042Controller const& ps2_controller) { auto keyboard_device = TRY(DeviceManagement::try_create_device<PS2KeyboardDevice>(ps2_controller)); @@ -102,7 +102,7 @@ UNMAP_AFTER_INIT ErrorOr<void> 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 737b870bcd..0bb1da70a6 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<NonnullRefPtr<PS2KeyboardDevice>> try_to_initialize(const I8042Controller&); + static ErrorOr<NonnullRefPtr<PS2KeyboardDevice>> try_to_initialize(I8042Controller const&); virtual ~PS2KeyboardDevice() override; ErrorOr<void> 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 13fc67035f..da70343295 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<void> PS2MouseDevice::set_sample_rate(u8 rate) return {}; } -UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2MouseDevice>> PS2MouseDevice::try_to_initialize(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<PS2MouseDevice>> PS2MouseDevice::try_to_initialize(I8042Controller const& ps2_controller) { auto mouse_device = TRY(DeviceManagement::try_create_device<PS2MouseDevice>(ps2_controller)); TRY(mouse_device->initialize()); diff --git a/Kernel/Devices/HID/PS2MouseDevice.h b/Kernel/Devices/HID/PS2MouseDevice.h index 6822b7ef9d..bac8c127b6 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<NonnullRefPtr<PS2MouseDevice>> try_to_initialize(const I8042Controller&); + static ErrorOr<NonnullRefPtr<PS2MouseDevice>> try_to_initialize(I8042Controller const&); ErrorOr<void> 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<u8> read_from_device(); ErrorOr<u8> send_command(u8 command); ErrorOr<u8> send_command(u8 command, u8 data); - MousePacket parse_data_packet(const RawPacket&); + MousePacket parse_data_packet(RawPacket const&); ErrorOr<void> set_sample_rate(u8); ErrorOr<u8> get_device_id(); diff --git a/Kernel/Devices/HID/VMWareMouseDevice.cpp b/Kernel/Devices/HID/VMWareMouseDevice.cpp index aaeeb4f9c6..ccc66d684d 100644 --- a/Kernel/Devices/HID/VMWareMouseDevice.cpp +++ b/Kernel/Devices/HID/VMWareMouseDevice.cpp @@ -11,7 +11,7 @@ namespace Kernel { -UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<VMWareMouseDevice>> VMWareMouseDevice::try_to_initialize(const I8042Controller& ps2_controller) +UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<VMWareMouseDevice>> 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 64680d54ff..f004682aa3 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<NonnullRefPtr<VMWareMouseDevice>> try_to_initialize(const I8042Controller&); + static ErrorOr<NonnullRefPtr<VMWareMouseDevice>> 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 8d2af84c92..5c1ae79c0f 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; }; diff --git a/Kernel/Devices/KCOVInstance.h b/Kernel/Devices/KCOVInstance.h index 097e7b6468..3cfc9c7ab2 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 2efa9614a0..2755149e4e 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual ErrorOr<size_t> 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 4a30e9a09e..d8eeba1f36 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<size_t> NullDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer&, return 0; } -ErrorOr<size_t> NullDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t buffer_size) +ErrorOr<size_t> 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 a906fba13d..23b647cfe5 100644 --- a/Kernel/Devices/NullDevice.h +++ b/Kernel/Devices/NullDevice.h @@ -22,9 +22,9 @@ private: NullDevice(); // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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<size_t> 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 9734349d27..7e7c988cdd 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<size_t> RandomDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer }); } -ErrorOr<size_t> RandomDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size) +ErrorOr<size_t> 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 93f523a3ea..a86ba9f854 100644 --- a/Kernel/Devices/RandomDevice.h +++ b/Kernel/Devices/RandomDevice.h @@ -22,9 +22,9 @@ private: // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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<size_t> 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 50d603e118..96db5b6904 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<size_t> 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<size_t> SerialDevice::write(OpenFileDescription& description, u64, const UserOrKernelBuffer& buffer, size_t size) +ErrorOr<size_t> 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 4da3c7439d..5827e17e85 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr<size_t> 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 1d001630cf..f4d59a8677 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<size_t> ZeroDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer& return size; } -ErrorOr<size_t> ZeroDevice::write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t size) +ErrorOr<size_t> ZeroDevice::write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t size) { return size; } diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h index aab5633abf..d10be8387f 100644 --- a/Kernel/Devices/ZeroDevice.h +++ b/Kernel/Devices/ZeroDevice.h @@ -22,9 +22,9 @@ private: // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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<size_t> 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 864568b593..498bf0f538 100644 --- a/Kernel/DoubleBuffer.cpp +++ b/Kernel/DoubleBuffer.cpp @@ -45,7 +45,7 @@ void DoubleBuffer::flip() compute_lockfree_metadata(); } -ErrorOr<size_t> DoubleBuffer::write(const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> DoubleBuffer::write(UserOrKernelBuffer const& data, size_t size) { if (!size) return 0; diff --git a/Kernel/DoubleBuffer.h b/Kernel/DoubleBuffer.h index 2d735b34dc..32d92933d5 100644 --- a/Kernel/DoubleBuffer.h +++ b/Kernel/DoubleBuffer.h @@ -17,8 +17,8 @@ namespace Kernel { class DoubleBuffer { public: static ErrorOr<NonnullOwnPtr<DoubleBuffer>> try_create(size_t capacity = 65536); - ErrorOr<size_t> write(const UserOrKernelBuffer&, size_t); - ErrorOr<size_t> write(const u8* data, size_t size) + ErrorOr<size_t> write(UserOrKernelBuffer const&, size_t); + ErrorOr<size_t> write(u8 const* data, size_t size) { return write(UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>(data)), size); } diff --git a/Kernel/FileSystem/AnonymousFile.cpp b/Kernel/FileSystem/AnonymousFile.cpp index 3e7955e972..5d46a5e6fb 100644 --- a/Kernel/FileSystem/AnonymousFile.cpp +++ b/Kernel/FileSystem/AnonymousFile.cpp @@ -28,7 +28,7 @@ ErrorOr<Memory::Region*> AnonymousFile::mmap(Process& process, OpenFileDescripti return process.address_space().allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared); } -ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> 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 4703a87831..d03342ec7d 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<NonnullOwnPtr<KString>> 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<NonnullOwnPtr<KString>> 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; } - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; } explicit AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject>); diff --git a/Kernel/FileSystem/BlockBasedFileSystem.cpp b/Kernel/FileSystem/BlockBasedFileSystem.cpp index 1325c12d48..1ae40139dd 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<typename Callback> @@ -129,7 +129,7 @@ ErrorOr<void> BlockBasedFileSystem::initialize() return {}; } -ErrorOr<void> BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, u64 offset, bool allow_cache) +ErrorOr<void> 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<void> BlockBasedFileSystem::raw_read(BlockIndex index, UserOrKernelBuffe return {}; } -ErrorOr<void> BlockBasedFileSystem::raw_write(BlockIndex index, const UserOrKernelBuffer& buffer) +ErrorOr<void> 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<void> BlockBasedFileSystem::raw_read_blocks(BlockIndex index, size_t cou return {}; } -ErrorOr<void> BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer& buffer) +ErrorOr<void> 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<void> BlockBasedFileSystem::raw_write_blocks(BlockIndex index, size_t co return {}; } -ErrorOr<void> BlockBasedFileSystem::write_blocks(BlockIndex index, unsigned count, const UserOrKernelBuffer& data, bool allow_cache) +ErrorOr<void> 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 235ab2935c..5a11fbc8cb 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.h +++ b/Kernel/FileSystem/BlockBasedFileSystem.h @@ -30,13 +30,13 @@ protected: ErrorOr<void> read_blocks(BlockIndex, unsigned count, UserOrKernelBuffer&, bool allow_cache = true) const; ErrorOr<void> raw_read(BlockIndex, UserOrKernelBuffer&); - ErrorOr<void> raw_write(BlockIndex, const UserOrKernelBuffer&); + ErrorOr<void> raw_write(BlockIndex, UserOrKernelBuffer const&); ErrorOr<void> raw_read_blocks(BlockIndex index, size_t count, UserOrKernelBuffer&); - ErrorOr<void> raw_write_blocks(BlockIndex index, size_t count, const UserOrKernelBuffer&); + ErrorOr<void> raw_write_blocks(BlockIndex index, size_t count, UserOrKernelBuffer const&); - ErrorOr<void> write_block(BlockIndex, const UserOrKernelBuffer&, size_t count, u64 offset = 0, bool allow_cache = true); - ErrorOr<void> write_blocks(BlockIndex, unsigned count, const UserOrKernelBuffer&, bool allow_cache = true); + ErrorOr<void> write_block(BlockIndex, UserOrKernelBuffer const&, size_t count, u64 offset = 0, bool allow_cache = true); + ErrorOr<void> 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 d09a58862f..edd2f205cc 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -83,7 +83,7 @@ ErrorOr<size_t> DevPtsFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, Op VERIFY_NOT_REACHED(); } -ErrorOr<size_t> DevPtsFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr<size_t> 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 94b94e1b4f..fc030dc121 100644 --- a/Kernel/FileSystem/DevPtsFS.h +++ b/Kernel/FileSystem/DevPtsFS.h @@ -52,7 +52,7 @@ private: virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override; virtual ErrorOr<void> flush_metadata() override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr<void> remove_child(StringView name) override; diff --git a/Kernel/FileSystem/DevTmpFS.cpp b/Kernel/FileSystem/DevTmpFS.cpp index 151bd6d12b..1f881154bf 100644 --- a/Kernel/FileSystem/DevTmpFS.cpp +++ b/Kernel/FileSystem/DevTmpFS.cpp @@ -71,7 +71,7 @@ ErrorOr<void> DevTmpFSInode::flush_metadata() return {}; } -ErrorOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { VERIFY_NOT_REACHED(); } @@ -318,7 +318,7 @@ ErrorOr<size_t> DevTmpFSDeviceInode::read_bytes(off_t offset, size_t count, User return result.value(); } -ErrorOr<size_t> DevTmpFSDeviceInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* description) +ErrorOr<size_t> 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 c3d872fc4a..91ca9cdd54 100644 --- a/Kernel/FileSystem/DevTmpFS.h +++ b/Kernel/FileSystem/DevTmpFS.h @@ -53,7 +53,7 @@ protected: virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override; virtual ErrorOr<void> flush_metadata() override; virtual InodeMetadata metadata() const override final; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr<void> remove_child(StringView name) override; @@ -96,10 +96,10 @@ private: // ^Inode virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; NonnullOwnPtr<KString> 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<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; NonnullOwnPtr<KString> m_name; OwnPtr<KString> m_link; diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 27eb4766f0..b016a2403c 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -69,7 +69,7 @@ ErrorOr<void> 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<void> Ext2FSInode::write_indirect_block(BlockBasedFileSystem::BlockIndex block, Span<BlockBasedFileSystem::BlockIndex> 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<void> Ext2FSInode::write_indirect_block(BlockBasedFileSystem::BlockIndex ErrorOr<void> Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, Span<BlockBasedFileSystem::BlockIndex> blocks_indices, Vector<Ext2FS::BlockIndex>& 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<void> 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<void> Ext2FSInode::grow_doubly_indirect_block(BlockBasedFileSystem::Bloc ErrorOr<void> 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<void> Ext2FSInode::shrink_doubly_indirect_block(BlockBasedFileSystem::Bl ErrorOr<void> Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::BlockIndex block, size_t old_blocks_length, Span<BlockBasedFileSystem::BlockIndex> blocks_indices, Vector<Ext2FS::BlockIndex>& 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<void> 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<void> Ext2FSInode::grow_triply_indirect_block(BlockBasedFileSystem::Bloc ErrorOr<void> 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<void> 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<void> 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<u64>(fs().block_size())); + auto const old_block_count = ceil_div(size(), static_cast<u64>(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<Ext2FS::BlockIndex> new_meta_blocks; if (new_shape.meta_blocks > old_shape.meta_blocks) { @@ -813,7 +813,7 @@ ErrorOr<size_t> 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<off_t>(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<size_t> 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<void> Ext2FSInode::resize(u64 new_size) return {}; } -ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& data, OpenFileDescription* description) +ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& data, OpenFileDescription* description) { VERIFY(offset >= 0); @@ -960,7 +960,7 @@ ErrorOr<size_t> 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<u64>(offset) + count, size()); TRY(resize(new_size)); @@ -1003,7 +1003,7 @@ ErrorOr<size_t> 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<void> 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<u8*>((const u8*)&e2inode)); + auto buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>((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 4dd6ad904b..90563b9548 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -40,7 +40,7 @@ private: virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override; virtual ErrorOr<void> flush_metadata() override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr<void> add_child(Inode& child, StringView name, mode_t) override; virtual ErrorOr<void> remove_child(StringView name) override; @@ -69,7 +69,7 @@ private: ErrorOr<Vector<BlockBasedFileSystem::BlockIndex>> 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<BlockBasedFileSystem::BlockIndex> 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<Ext2FS&>(Inode::fs()); } -inline const Ext2FS& Ext2FSInode::fs() const +inline Ext2FS const& Ext2FSInode::fs() const { - return static_cast<const Ext2FS&>(Inode::fs()); + return static_cast<Ext2FS const&>(Inode::fs()); } } diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 0d0e63df2c..c4f573a418 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<size_t> FIFO::read(OpenFileDescription& fd, u64, UserOrKernelBuffer& buf return m_buffer->read(buffer, size); } -ErrorOr<size_t> FIFO::write(OpenFileDescription& fd, u64, const UserOrKernelBuffer& buffer, size_t size) +ErrorOr<size_t> 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<size_t> FIFO::write(OpenFileDescription& fd, u64, const UserOrKernelBuff return m_buffer->write(buffer, size); } -ErrorOr<NonnullOwnPtr<KString>> FIFO::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> 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 106cf51080..bce07e5793 100644 --- a/Kernel/FileSystem/FIFO.h +++ b/Kernel/FileSystem/FIFO.h @@ -40,12 +40,12 @@ public: private: // ^File - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; virtual ErrorOr<struct stat> stat() const override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual bool can_write(const OpenFileDescription&, u64) const override; - virtual ErrorOr<NonnullOwnPtr<KString>> 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<NonnullOwnPtr<KString>> 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 05dedd9d90..bb9065a8a7 100644 --- a/Kernel/FileSystem/File.h +++ b/Kernel/FileSystem/File.h @@ -81,20 +81,20 @@ public: virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options); virtual ErrorOr<void> 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<void> attach(OpenFileDescription&); virtual void detach(OpenFileDescription&); virtual void did_seek(OpenFileDescription&, off_t) { } virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) = 0; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) = 0; virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg); virtual ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared); virtual ErrorOr<struct stat> stat() const { return EBADF; } // Although this might be better described "name" or "description", these terms already have other meanings. - virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const = 0; + virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const = 0; virtual ErrorOr<void> truncate(u64) { return EINVAL; } virtual ErrorOr<void> sync() { return EINVAL; } diff --git a/Kernel/FileSystem/FileBackedFileSystem.h b/Kernel/FileSystem/FileBackedFileSystem.h index 95cfc42337..47bd36ea60 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 96bf7385a3..f7f5e1a188 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<Kernel::InodeIdentifier> : public GenericTraits<Kernel::InodeIdentifier> { - 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 ed688363ac..4c08f6fbee 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<ISO::FileFlags>(entry.file_type), ISO::FileFlags::Directory)) { return DT_DIR; @@ -493,7 +493,7 @@ ErrorOr<void> ISO9660Inode::flush_metadata() return {}; } -ErrorOr<size_t> ISO9660Inode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr<size_t> 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 94f2027484..48e4c6941f 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.h +++ b/Kernel/FileSystem/ISO9660FileSystem.h @@ -352,7 +352,7 @@ public: virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override; virtual ErrorOr<void> flush_metadata() override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr<void> remove_child(StringView name) override; diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index bfe2e4210d..04857e8a04 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -63,7 +63,7 @@ ErrorOr<NonnullOwnPtr<KBuffer>> 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 d5d06b8a02..84c8eca1b7 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -54,7 +54,7 @@ public: virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const = 0; virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const = 0; virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) = 0; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) = 0; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) = 0; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) = 0; virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) = 0; virtual ErrorOr<void> remove_child(StringView name) = 0; diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index eeccf5fcae..bbc030908e 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -37,7 +37,7 @@ ErrorOr<size_t> InodeFile::read(OpenFileDescription& description, u64 offset, Us return nread; } -ErrorOr<size_t> InodeFile::write(OpenFileDescription& description, u64 offset, const UserOrKernelBuffer& data, size_t count) +ErrorOr<size_t> InodeFile::write(OpenFileDescription& description, u64 offset, UserOrKernelBuffer const& data, size_t count) { if (Checked<off_t>::addition_would_overflow(offset, count)) return EOVERFLOW; @@ -91,7 +91,7 @@ ErrorOr<Memory::Region*> InodeFile::mmap(Process& process, OpenFileDescription& return process.address_space().allocate_region_with_vmobject(range, vmobject.release_nonnull(), offset, path->view(), prot, shared); } -ErrorOr<NonnullOwnPtr<KString>> InodeFile::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> 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 478fe9347d..5f9dce10de 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; virtual ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override; virtual ErrorOr<struct stat> stat() const override { return inode().metadata().stat(); } - virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override; virtual ErrorOr<void> truncate(u64) override; virtual ErrorOr<void> sync() override; diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index 2af6d5f6c3..585bbe6905 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 1dc23b6d72..93e5ed2742 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<GroupID const> eg) const { diff --git a/Kernel/FileSystem/InodeWatcher.cpp b/Kernel/FileSystem/InodeWatcher.cpp index e3563f599b..e2a033ec14 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<void> InodeWatcher::close() return {}; } -ErrorOr<NonnullOwnPtr<KString>> InodeWatcher::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> 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 a003d58b90..fb01da67e4 100644 --- a/Kernel/FileSystem/InodeWatcher.h +++ b/Kernel/FileSystem/InodeWatcher.h @@ -43,14 +43,14 @@ public: static ErrorOr<NonnullRefPtr<InodeWatcher>> 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<size_t> 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<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EIO; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EIO; } virtual ErrorOr<void> close() override; - virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr<NonnullOwnPtr<KString>> 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 37e1a6eb0c..f4381c7dce 100644 --- a/Kernel/FileSystem/OpenFileDescription.cpp +++ b/Kernel/FileSystem/OpenFileDescription.cpp @@ -175,7 +175,7 @@ ErrorOr<size_t> OpenFileDescription::read(UserOrKernelBuffer& buffer, size_t cou return nread; } -ErrorOr<size_t> OpenFileDescription::write(const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> OpenFileDescription::write(UserOrKernelBuffer const& data, size_t size) { auto offset = TRY(m_state.with([&](auto& state) -> ErrorOr<off_t> { if (Checked<off_t>::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<const Device*>(m_file.ptr()); + return static_cast<Device const*>(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<const InodeWatcher*>(m_file.ptr()); + return static_cast<InodeWatcher const*>(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<const MasterPTY*>(m_file.ptr()); + return static_cast<MasterPTY const*>(m_file.ptr()); } MasterPTY* OpenFileDescription::master_pty() @@ -413,11 +413,11 @@ Socket* OpenFileDescription::socket() return static_cast<Socket*>(m_file.ptr()); } -const Socket* OpenFileDescription::socket() const +Socket const* OpenFileDescription::socket() const { if (!is_socket()) return nullptr; - return static_cast<const Socket*>(m_file.ptr()); + return static_cast<Socket const*>(m_file.ptr()); } void OpenFileDescription::set_file_flags(u32 flags) diff --git a/Kernel/FileSystem/OpenFileDescription.h b/Kernel/FileSystem/OpenFileDescription.h index acc6df00fe..3d0c7b2c94 100644 --- a/Kernel/FileSystem/OpenFileDescription.h +++ b/Kernel/FileSystem/OpenFileDescription.h @@ -42,7 +42,7 @@ public: ErrorOr<off_t> seek(off_t, int whence); ErrorOr<size_t> read(UserOrKernelBuffer&, size_t); - ErrorOr<size_t> write(const UserOrKernelBuffer& data, size_t); + ErrorOr<size_t> write(UserOrKernelBuffer const& data, size_t); ErrorOr<struct stat> 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<Memory::Region*> 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 a4f34c3437..3d079183be 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<const char*>(&number), sizeof(number)); + (void)m_builder.append(reinterpret_cast<char const*>(&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<void> Plan9FS::post_message(Message& message, RefPtr<ReceiveCompletion> 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<size_t> Plan9FSInode::read_bytes(off_t offset, size_t size, UserOrKernel return nread; } -ErrorOr<size_t> Plan9FSInode::write_bytes(off_t offset, size_t size, const UserOrKernelBuffer& data, OpenFileDescription*) +ErrorOr<size_t> 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 df0cf3d9ca..f992c3a0fb 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<ReceiveCompletion>& completion() const { return m_completion; } + NonnullRefPtr<ReceiveCompletion> 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<void> post_message(Message&, RefPtr<ReceiveCompletion>); ErrorOr<void> do_read(u8* buffer, size_t); ErrorOr<void> read_and_dispatch_one_message(); @@ -157,7 +157,7 @@ public: virtual InodeMetadata metadata() const override; virtual ErrorOr<void> flush_metadata() override; virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& data, OpenFileDescription*) override; virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; @@ -211,7 +211,7 @@ private: Plan9FS& fs() { return reinterpret_cast<Plan9FS&>(Inode::fs()); } Plan9FS& fs() const { - return const_cast<Plan9FS&>(reinterpret_cast<const Plan9FS&>(Inode::fs())); + return const_cast<Plan9FS&>(reinterpret_cast<Plan9FS const&>(Inode::fs())); } }; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 5d8a007529..a6f3b98027 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<ProcFS&>(fs), index) { } @@ -93,12 +93,12 @@ ErrorOr<void> ProcFSInode::chown(UserID, GroupID) return EPERM; } -ErrorOr<NonnullRefPtr<ProcFSGlobalInode>> ProcFSGlobalInode::try_create(const ProcFS& fs, const ProcFSExposedComponent& component) +ErrorOr<NonnullRefPtr<ProcFSGlobalInode>> 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<size_t> ProcFSGlobalInode::write_bytes(off_t offset, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription* fd) +ErrorOr<size_t> 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<NonnullRefPtr<ProcFSDirectoryInode>> ProcFSDirectoryInode::try_create(const ProcFS& procfs, const ProcFSExposedComponent& component) +ErrorOr<NonnullRefPtr<ProcFSDirectoryInode>> 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<NonnullRefPtr<Inode>> ProcFSDirectoryInode::lookup(StringView name) return component->to_inode(procfs()); } -ErrorOr<NonnullRefPtr<ProcFSLinkInode>> ProcFSLinkInode::try_create(const ProcFS& procfs, const ProcFSExposedComponent& component) +ErrorOr<NonnullRefPtr<ProcFSLinkInode>> 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<size_t> ProcFSProcessAssociatedInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) +ErrorOr<size_t> ProcFSProcessAssociatedInode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return ENOTSUP; } -ErrorOr<NonnullRefPtr<ProcFSProcessDirectoryInode>> ProcFSProcessDirectoryInode::try_create(const ProcFS& procfs, ProcessID pid) +ErrorOr<NonnullRefPtr<ProcFSProcessDirectoryInode>> 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<NonnullRefPtr<Inode>> ProcFSProcessDirectoryInode::lookup(StringView nam return ENOENT; } -ErrorOr<NonnullRefPtr<ProcFSProcessSubDirectoryInode>> ProcFSProcessSubDirectoryInode::try_create(const ProcFS& procfs, SegmentedProcFSIndex::ProcessSubDirectory sub_directory_type, ProcessID pid) +ErrorOr<NonnullRefPtr<ProcFSProcessSubDirectoryInode>> 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<NonnullRefPtr<Inode>> ProcFSProcessSubDirectoryInode::lookup(StringView } } -ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_file_description_link(const ProcFS& procfs, unsigned file_description_index, ProcessID pid) +ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> 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<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_thread_stack(const ProcFS& procfs, ThreadID stack_thread_index, ProcessID pid) +ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> 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<NonnullRefPtr<ProcFSProcessPropertyInode>> ProcFSProcessPropertyInode::try_create_for_pid_property(const ProcFS& procfs, SegmentedProcFSIndex::MainProcessProperty main_property_type, ProcessID pid) +ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> 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 cc83c98cf0..96c8e46237 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<ProcFS&>(Inode::fs()); } ProcFS const& procfs() const { return static_cast<ProcFS const&>(Inode::fs()); } @@ -68,17 +68,17 @@ class ProcFSGlobalInode : public ProcFSInode { friend class ProcFS; public: - static ErrorOr<NonnullRefPtr<ProcFSGlobalInode>> try_create(const ProcFS&, const ProcFSExposedComponent&); + static ErrorOr<NonnullRefPtr<ProcFSGlobalInode>> 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<void> attach(OpenFileDescription& description) override final; virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override final; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override final; + virtual ErrorOr<size_t> 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<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; @@ -93,10 +93,10 @@ class ProcFSLinkInode : public ProcFSGlobalInode { friend class ProcFS; public: - static ErrorOr<NonnullRefPtr<ProcFSLinkInode>> try_create(const ProcFS&, const ProcFSExposedComponent&); + static ErrorOr<NonnullRefPtr<ProcFSLinkInode>> 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<NonnullRefPtr<ProcFSDirectoryInode>> try_create(const ProcFS&, const ProcFSExposedComponent&); + static ErrorOr<NonnullRefPtr<ProcFSDirectoryInode>> 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<void> traverse_as_directory(Function<ErrorOr<void>(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<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override final; + virtual ErrorOr<size_t> 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<NonnullRefPtr<ProcFSProcessDirectoryInode>> try_create(const ProcFS&, ProcessID); + static ErrorOr<NonnullRefPtr<ProcFSProcessDirectoryInode>> try_create(ProcFS const&, ProcessID); private: - ProcFSProcessDirectoryInode(const ProcFS&, ProcessID); + ProcFSProcessDirectoryInode(ProcFS const&, ProcessID); // ^Inode virtual ErrorOr<void> 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<NonnullRefPtr<ProcFSProcessSubDirectoryInode>> try_create(const ProcFS&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); + static ErrorOr<NonnullRefPtr<ProcFSProcessSubDirectoryInode>> try_create(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); private: - ProcFSProcessSubDirectoryInode(const ProcFS&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); + ProcFSProcessSubDirectoryInode(ProcFS const&, SegmentedProcFSIndex::ProcessSubDirectory, ProcessID); // ^Inode virtual ErrorOr<void> 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<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_file_description_link(const ProcFS&, unsigned, ProcessID); - static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_thread_stack(const ProcFS&, ThreadID, ProcessID); - static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_pid_property(const ProcFS&, SegmentedProcFSIndex::MainProcessProperty, ProcessID); + static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_file_description_link(ProcFS const&, unsigned, ProcessID); + static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> try_create_for_thread_stack(ProcFS const&, ThreadID, ProcessID); + static ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> 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<void> 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 0b44c20d68..e4b54416ea 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<TmpFSInode> parent) +TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent) : Inode(fs, fs.next_inode_index()) , m_metadata(metadata) , m_parent(move(parent)) @@ -106,7 +106,7 @@ ErrorOr<size_t> TmpFSInode::read_bytes(off_t offset, size_t size, UserOrKernelBu return size; } -ErrorOr<size_t> TmpFSInode::write_bytes(off_t offset, size_t size, const UserOrKernelBuffer& buffer, OpenFileDescription*) +ErrorOr<size_t> 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 1166eac6e9..1ca5754743 100644 --- a/Kernel/FileSystem/TmpFS.h +++ b/Kernel/FileSystem/TmpFS.h @@ -44,7 +44,7 @@ public: virtual ~TmpFSInode() override; TmpFS& fs() { return static_cast<TmpFS&>(Inode::fs()); } - const TmpFS& fs() const { return static_cast<const TmpFS&>(Inode::fs()); } + TmpFS const& fs() const { return static_cast<TmpFS const&>(Inode::fs()); } // ^Inode virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; @@ -52,7 +52,7 @@ public: virtual ErrorOr<void> traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr<NonnullRefPtr<Inode>> lookup(StringView name) override; virtual ErrorOr<void> flush_metadata() override; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr<void> add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr<void> remove_child(StringView name) override; @@ -64,7 +64,7 @@ public: virtual ErrorOr<void> set_mtime(time_t) override; private: - TmpFSInode(TmpFS& fs, const InodeMetadata& metadata, WeakPtr<TmpFSInode> parent); + TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent); static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create(TmpFS&, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent); static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create_root(TmpFS&); diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index e2c464a86d..3b20e78859 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -571,7 +571,7 @@ ErrorOr<void> 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<void> 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<u8*>((const u8*)target.characters_without_null_termination())); + auto target_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>((u8 const*)target.characters_without_null_termination())); TRY(inode->write_bytes(0, target.length(), target_buffer, nullptr)); return {}; } @@ -838,7 +838,7 @@ ErrorOr<NonnullRefPtr<Custody>> 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 61ebc2ce12..169439e4c9 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -68,7 +68,7 @@ public: ErrorOr<void> mknod(StringView path, mode_t, dev_t, Custody& base); ErrorOr<NonnullRefPtr<Custody>> open_directory(StringView path, Custody& base); - ErrorOr<void> for_each_mount(Function<ErrorOr<void>(const Mount&)>) const; + ErrorOr<void> for_each_mount(Function<ErrorOr<void>(Mount const&)>) const; InodeIdentifier root_inode_id() const; diff --git a/Kernel/Firmware/ACPI/Parser.cpp b/Kernel/Firmware/ACPI/Parser.cpp index 26811aa91f..41ebbecd12 100644 --- a/Kernel/Firmware/ACPI/Parser.cpp +++ b/Kernel/Firmware/ACPI/Parser.cpp @@ -117,7 +117,7 @@ void Parser::enumerate_static_tables(Function<void(StringView, PhysicalAddress, static bool match_table_signature(PhysicalAddress table_header, StringView signature); static Optional<PhysicalAddress> search_table_in_xsdt(PhysicalAddress xsdt, StringView signature); static Optional<PhysicalAddress> 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<PhysicalAddress> 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 77ba39b590..05356fd73e 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<PhysicalAddress> 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<Structures::FADT> 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 933c35b5b3..1883afc775 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 6445c93a32..c7b6222e3e 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<FutexQueue*()>& get_target_queue, u32 requeue_count, bool& is_empty, bool& is_empty_target) +u32 FutexQueue::wake_n_requeue(u32 wake_count, Function<FutexQueue*()> 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<FutexQueue*()>& ge return did_wake + did_requeue; } -u32 FutexQueue::wake_n(u32 wake_count, const Optional<u32>& bitset, bool& is_empty) +u32 FutexQueue::wake_n(u32 wake_count, Optional<u32> const& bitset, bool& is_empty) { if (wake_count == 0) { is_empty = false; diff --git a/Kernel/FutexQueue.h b/Kernel/FutexQueue.h index 28a3a600c9..ded3a93c38 100644 --- a/Kernel/FutexQueue.h +++ b/Kernel/FutexQueue.h @@ -21,12 +21,12 @@ public: FutexQueue(); virtual ~FutexQueue(); - u32 wake_n_requeue(u32, const Function<FutexQueue*()>&, u32, bool&, bool&); - u32 wake_n(u32, const Optional<u32>&, bool&); + u32 wake_n_requeue(u32, Function<FutexQueue*()> const&, u32, bool&, bool&); + u32 wake_n(u32, Optional<u32> const&, bool&); u32 wake_all(bool&); template<class... Args> - Thread::BlockResult wait_on(const Thread::BlockTimeout& timeout, Args&&... args) + Thread::BlockResult wait_on(Thread::BlockTimeout const& timeout, Args&&... args) { return Thread::current()->block<Thread::FutexBlocker>(timeout, *this, forward<Args>(args)...); } diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index 08be0a82ec..ea0c333178 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -84,7 +84,7 @@ private: virtual ErrorOr<void> try_generate(KBufferBuilder& builder) override { auto array = TRY(JsonArraySerializer<>::try_create(builder)); - TRY(arp_table().with([&](const auto& table) -> ErrorOr<void> { + TRY(arp_table().with([&](auto const& table) -> ErrorOr<void> { 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<ProcFSNetworkDirectory> must_create(const ProcFSRootDirectory& parent_directory); + static NonnullRefPtr<ProcFSNetworkDirectory> must_create(ProcFSRootDirectory const& parent_directory); private: - ProcFSNetworkDirectory(const ProcFSRootDirectory& parent_directory); + ProcFSNetworkDirectory(ProcFSRootDirectory const& parent_directory); }; class ProcFSSystemDirectory : public ProcFSExposedDirectory { public: - static NonnullRefPtr<ProcFSSystemDirectory> must_create(const ProcFSRootDirectory& parent_directory); + static NonnullRefPtr<ProcFSSystemDirectory> must_create(ProcFSRootDirectory const& parent_directory); private: - ProcFSSystemDirectory(const ProcFSRootDirectory& parent_directory); + ProcFSSystemDirectory(ProcFSRootDirectory const& parent_directory); }; UNMAP_AFTER_INIT NonnullRefPtr<ProcFSAdapters> ProcFSAdapters::must_create() @@ -230,7 +230,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<ProcFSUDP> ProcFSUDP::must_create() return adopt_ref_if_nonnull(new (nothrow) ProcFSUDP).release_nonnull(); } -UNMAP_AFTER_INIT NonnullRefPtr<ProcFSNetworkDirectory> ProcFSNetworkDirectory::must_create(const ProcFSRootDirectory& parent_directory) +UNMAP_AFTER_INIT NonnullRefPtr<ProcFSNetworkDirectory> 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<ProcFSDumpKmallocStacks> must_create(const ProcFSSystemDirectory&); + static NonnullRefPtr<ProcFSDumpKmallocStacks> 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<ProcFSUBSanDeadly> must_create(const ProcFSSystemDirectory&); + static NonnullRefPtr<ProcFSUBSanDeadly> 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<ProcFSCapsLockRemap> must_create(const ProcFSSystemDirectory&); + static NonnullRefPtr<ProcFSCapsLockRemap> 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> ProcFSDumpKmallocStacks::must_create(const ProcFSSystemDirectory&) +UNMAP_AFTER_INIT NonnullRefPtr<ProcFSDumpKmallocStacks> ProcFSDumpKmallocStacks::must_create(ProcFSSystemDirectory const&) { return adopt_ref_if_nonnull(new (nothrow) ProcFSDumpKmallocStacks).release_nonnull(); } -UNMAP_AFTER_INIT NonnullRefPtr<ProcFSUBSanDeadly> ProcFSUBSanDeadly::must_create(const ProcFSSystemDirectory&) +UNMAP_AFTER_INIT NonnullRefPtr<ProcFSUBSanDeadly> ProcFSUBSanDeadly::must_create(ProcFSSystemDirectory const&) { return adopt_ref_if_nonnull(new (nothrow) ProcFSUBSanDeadly).release_nonnull(); } -UNMAP_AFTER_INIT NonnullRefPtr<ProcFSCapsLockRemap> ProcFSCapsLockRemap::must_create(const ProcFSSystemDirectory&) +UNMAP_AFTER_INIT NonnullRefPtr<ProcFSCapsLockRemap> 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<KBufferBuilder>& array, const Process& process) -> ErrorOr<void> { + auto build_process = [&](JsonArraySerializer<KBufferBuilder>& array, Process const& process) -> ErrorOr<void> { 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> ProcFSSystemDirectory::must_create(const ProcFSRootDirectory& parent_directory) +UNMAP_AFTER_INIT NonnullRefPtr<ProcFSSystemDirectory> 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> 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 c9b16957a0..853abe0c76 100644 --- a/Kernel/Graphics/FramebufferDevice.cpp +++ b/Kernel/Graphics/FramebufferDevice.cpp @@ -19,7 +19,7 @@ namespace Kernel { -NonnullRefPtr<FramebufferDevice> FramebufferDevice::create(const GenericGraphicsAdapter& adapter, PhysicalAddress paddr, size_t width, size_t height, size_t pitch) +NonnullRefPtr<FramebufferDevice> 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<FramebufferDevice>(adapter, paddr, width, height, pitch); // FIXME: Find a way to propagate errors @@ -112,7 +112,7 @@ UNMAP_AFTER_INIT ErrorOr<void> 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 207155db76..acdc4e3ec8 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<FramebufferDevice> create(const GenericGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t); + static NonnullRefPtr<FramebufferDevice> create(GenericGraphicsAdapter const&, PhysicalAddress, size_t, size_t, size_t); virtual ErrorOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override; @@ -50,7 +50,7 @@ private: virtual ErrorOr<void> flush_head_buffer(size_t head) override; virtual ErrorOr<void> 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 6d622542ef..9d57383965 100644 --- a/Kernel/Graphics/GenericFramebufferDevice.cpp +++ b/Kernel/Graphics/GenericFramebufferDevice.cpp @@ -149,7 +149,7 @@ ErrorOr<void> 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 0c26985b75..1d230d4451 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; } protected: virtual bool multihead_support() const = 0; @@ -61,7 +61,7 @@ protected: ErrorOr<void> verify_head_index(int head_index) const; - GenericFramebufferDevice(const GenericGraphicsAdapter&); + GenericFramebufferDevice(GenericGraphicsAdapter const&); mutable WeakPtr<GenericGraphicsAdapter> 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 3c3fae30ba..a158d2f79b 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::PLLSettings> IntelNativeGraphicsAdapter::create_pll_settings(u64 target_frequency, u64 reference_clock, const PLLMaxSettings& limits) +Optional<IntelNativeGraphicsAdapter::PLLSettings> 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 bf886a6ffb..825f443b97 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<size_t> milliseconds_timeout); - Optional<PLLSettings> create_pll_settings(u64 target_frequency, u64 reference_clock, const PLLMaxSettings&); + Optional<PLLSettings> 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 038d83e741..de72726084 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h +++ b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h @@ -112,10 +112,10 @@ public: OwnPtr<Memory::Region> 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<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; } - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; } virtual StringView class_name() const override { return "virgl3d"; } virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; diff --git a/Kernel/Heap/Heap.h b/Kernel/Heap/Heap.h index 147e37ac4f..ef50d23636 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 be0e9ab66a..d0f5fdf63b 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 f7c62fc046..adb698fb18 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 b1244e2ab8..e54437c1fd 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<volatile u32*>(m_apic_base->vaddr().offset(offset).as_ptr()) = value; + *reinterpret_cast<u32 volatile*>(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<volatile u32*>(m_apic_base->vaddr().offset(offset).as_ptr()); + return *reinterpret_cast<u32 volatile*>(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<volatile tpe*>(reinterpret_cast<ptrdiff_t>(vaddr) \ + reinterpret_cast<tpe volatile*>(reinterpret_cast<ptrdiff_t>(vaddr) \ + reinterpret_cast<ptrdiff_t>(&varname) \ - reinterpret_cast<ptrdiff_t>(&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<const void*>(apic_ap_start), apic_ap_start_size); + memcpy(apic_startup_region_ptr, reinterpret_cast<void const*>(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 adcc64f6b8..f64bca7844 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 109c378fee..e2c3716294 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 abc052ccd0..f17be74382 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<int> 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 4977668664..2c11987905 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 89af65922a..016fc80d23 100644 --- a/Kernel/Interrupts/IRQController.h +++ b/Kernel/Interrupts/IRQController.h @@ -20,14 +20,14 @@ class IRQController : public RefCounted<IRQController> { 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 a5c6175570..15661618e8 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 b17bbabd8d..8d20b05e6a 100644 --- a/Kernel/Interrupts/InterruptManagement.h +++ b/Kernel/Interrupts/InterruptManagement.h @@ -56,7 +56,7 @@ public: RefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector); RefPtr<IRQController> get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector); - const Vector<ISAInterruptOverrideMetadata>& isa_overrides() const { return m_isa_interrupt_overrides; } + Vector<ISAInterruptOverrideMetadata> 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 03fe0034bc..906cdc2018 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 933d7aa28d..2e540e2991 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 b35bba7ec6..995a13309e 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 6c7c65b13e..95623957aa 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 0b2d3adbe8..6e78212a10 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 9a7aafa55e..f1c1e1ac54 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 ee46a493c3..17571047d3 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 2508b3e35a..134ea32ec4 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 edc6fe227e..fe93103a86 100644 --- a/Kernel/KBufferBuilder.cpp +++ b/Kernel/KBufferBuilder.cpp @@ -80,7 +80,7 @@ ErrorOr<void> KBufferBuilder::append(StringView str) return {}; } -ErrorOr<void> KBufferBuilder::append(const char* characters, int length) +ErrorOr<void> KBufferBuilder::append(char const* characters, int length) { if (!length) return {}; diff --git a/Kernel/KBufferBuilder.h b/Kernel/KBufferBuilder.h index 83450515f0..d96eed409d 100644 --- a/Kernel/KBufferBuilder.h +++ b/Kernel/KBufferBuilder.h @@ -27,13 +27,13 @@ public: ErrorOr<void> append(StringView); ErrorOr<void> append(char); - ErrorOr<void> append(const char*, int); + ErrorOr<void> append(char const*, int); ErrorOr<void> append_escaped_for_json(StringView); ErrorOr<void> append_bytes(ReadonlyBytes); template<typename... Parameters> - ErrorOr<void> appendff(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) + ErrorOr<void> appendff(CheckedFormatString<Parameters...>&& 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 bc2beef1bc..2639f9617b 100644 --- a/Kernel/KString.h +++ b/Kernel/KString.h @@ -24,7 +24,7 @@ public: [[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> vformatted(StringView fmtstr, AK::TypeErasedFormatParams&); template<typename... Parameters> - [[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> formatted(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) + [[nodiscard]] static ErrorOr<NonnullOwnPtr<KString>> formatted(CheckedFormatString<Parameters...>&& 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 8c56961436..d6c4798fd2 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 2bc6699695..ff01f38edf 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 932717e5f9..de7e08cbc2 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<typename U> - ALWAYS_INLINE NonnullRefPtr(const NonnullRefPtr<U>& other) requires(IsConvertible<U*, T*>) + ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) : m_bits((FlatPtr)other.add_ref()) { VERIFY(!(m_bits & 1)); @@ -102,18 +102,18 @@ public: } template<typename U> - NonnullRefPtr(const OwnPtr<U>&) = delete; + NonnullRefPtr(OwnPtr<U> const&) = delete; template<typename U> - NonnullRefPtr& operator=(const OwnPtr<U>&) = delete; + NonnullRefPtr& operator=(OwnPtr<U> const&) = delete; template<typename U> - NonnullRefPtr(const RefPtr<U>&) = delete; + NonnullRefPtr(RefPtr<U> const&) = delete; template<typename U> - NonnullRefPtr& operator=(const RefPtr<U>&) = delete; - NonnullRefPtr(const RefPtr<T>&) = delete; - NonnullRefPtr& operator=(const RefPtr<T>&) = delete; + NonnullRefPtr& operator=(RefPtr<U> const&) = delete; + NonnullRefPtr(RefPtr<T> const&) = delete; + NonnullRefPtr& operator=(RefPtr<T> 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<typename U> - NonnullRefPtr& operator=(const NonnullRefPtr<U>& other) requires(IsConvertible<U*, T*>) + NonnullRefPtr& operator=(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) { assign(other.add_ref()); return *this; @@ -324,7 +324,7 @@ inline NonnullRefPtr<T> adopt_ref(T& object) template<typename T> struct Formatter<NonnullRefPtr<T>> : Formatter<const T*> { - ErrorOr<void> format(FormatBuilder& builder, const NonnullRefPtr<T>& value) + ErrorOr<void> format(FormatBuilder& builder, NonnullRefPtr<T> const& value) { return Formatter<const T*>::format(builder, value.ptr()); } @@ -342,8 +342,8 @@ template<typename T> struct Traits<NonnullRefPtr<T>> : public GenericTraits<NonnullRefPtr<T>> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const NonnullRefPtr<T>& p) { return ptr_hash(p.ptr()); } - static bool equals(const NonnullRefPtr<T>& a, const NonnullRefPtr<T>& b) { return a.ptr() == b.ptr(); } + static unsigned hash(NonnullRefPtr<T> const& p) { return ptr_hash(p.ptr()); } + static bool equals(NonnullRefPtr<T> const& a, NonnullRefPtr<T> const& b) { return a.ptr() == b.ptr(); } }; using AK::adopt_ref; diff --git a/Kernel/Library/ThreadSafeRefPtr.h b/Kernel/Library/ThreadSafeRefPtr.h index 7bb5312dfe..b1e341d7e9 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<T>& other) + ALWAYS_INLINE RefPtr(NonnullRefPtr<T> const& other) : m_bits(PtrTraits::as_bits(const_cast<T*>(other.add_ref()))) { } template<typename U> - ALWAYS_INLINE RefPtr(const NonnullRefPtr<U>& other) requires(IsConvertible<U*, T*>) + ALWAYS_INLINE RefPtr(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) : m_bits(PtrTraits::as_bits(const_cast<U*>(other.add_ref()))) { } @@ -171,12 +171,12 @@ public: : m_bits(PtrTraits::template convert_from<U, P>(other.leak_ref_raw())) { } - RefPtr(const RefPtr& other) + RefPtr(RefPtr const& other) : m_bits(other.add_ref_raw()) { } template<typename U, typename P = RefPtrTraits<U>> - RefPtr(const RefPtr<U, P>& other) requires(IsConvertible<U*, T*>) + RefPtr(RefPtr<U, P> const& other) requires(IsConvertible<U*, T*>) : m_bits(other.add_ref_raw()) { } @@ -189,9 +189,9 @@ public: } template<typename U> - RefPtr(const OwnPtr<U>&) = delete; + RefPtr(OwnPtr<U> const&) = delete; template<typename U> - RefPtr& operator=(const OwnPtr<U>&) = delete; + RefPtr& operator=(OwnPtr<U> const&) = delete; void swap(RefPtr& other) { @@ -234,20 +234,20 @@ public: return *this; } - ALWAYS_INLINE RefPtr& operator=(const NonnullRefPtr<T>& other) + ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr<T> const& other) { assign_raw(PtrTraits::as_bits(other.add_ref())); return *this; } template<typename U> - ALWAYS_INLINE RefPtr& operator=(const NonnullRefPtr<U>& other) requires(IsConvertible<U*, T*>) + ALWAYS_INLINE RefPtr& operator=(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) { 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<typename U> - ALWAYS_INLINE RefPtr& operator=(const RefPtr<U>& other) requires(IsConvertible<U*, T*>) + ALWAYS_INLINE RefPtr& operator=(RefPtr<U> const& other) requires(IsConvertible<U*, T*>) { 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<typename T> struct Traits<RefPtr<T>> : public GenericTraits<RefPtr<T>> { using PeekType = T*; using ConstPeekType = const T*; - static unsigned hash(const RefPtr<T>& p) { return ptr_hash(p.ptr()); } - static bool equals(const RefPtr<T>& a, const RefPtr<T>& b) { return a.ptr() == b.ptr(); } + static unsigned hash(RefPtr<T> const& p) { return ptr_hash(p.ptr()); } + static bool equals(RefPtr<T> const& a, RefPtr<T> const& b) { return a.ptr() == b.ptr(); } }; template<typename T, typename U> -inline NonnullRefPtr<T> static_ptr_cast(const NonnullRefPtr<U>& ptr) +inline NonnullRefPtr<T> static_ptr_cast(NonnullRefPtr<U> const& ptr) { return NonnullRefPtr<T>(static_cast<const T&>(*ptr)); } template<typename T, typename U, typename PtrTraits = RefPtrTraits<T>> -inline RefPtr<T> static_ptr_cast(const RefPtr<U>& ptr) +inline RefPtr<T> static_ptr_cast(RefPtr<U> const& ptr) { return RefPtr<T, PtrTraits>(static_cast<const T*>(ptr.ptr())); } diff --git a/Kernel/Library/ThreadSafeWeakPtr.h b/Kernel/Library/ThreadSafeWeakPtr.h index ba8cda9d1e..cd25b8e558 100644 --- a/Kernel/Library/ThreadSafeWeakPtr.h +++ b/Kernel/Library/ThreadSafeWeakPtr.h @@ -19,7 +19,7 @@ public: WeakPtr() = default; template<typename U> - WeakPtr(const WeakPtr<U>& other) requires(IsBaseOf<T, U>) + WeakPtr(WeakPtr<U> const& other) requires(IsBaseOf<T, U>) : m_link(other.m_link) { } @@ -38,9 +38,9 @@ public: } template<typename U> - WeakPtr& operator=(const WeakPtr<U>& other) requires(IsBaseOf<T, U>) + WeakPtr& operator=(WeakPtr<U> const& other) requires(IsBaseOf<T, U>) { - 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<typename U> - WeakPtr(const RefPtr<U>& object) requires(IsBaseOf<T, U>) + WeakPtr(RefPtr<U> const& object) requires(IsBaseOf<T, U>) { object.do_while_locked([&](U* obj) { if (obj) @@ -74,7 +74,7 @@ public: } template<typename U> - WeakPtr(const NonnullRefPtr<U>& object) requires(IsBaseOf<T, U>) + WeakPtr(NonnullRefPtr<U> const& object) requires(IsBaseOf<T, U>) { object.do_while_locked([&](U* obj) { if (obj) @@ -100,7 +100,7 @@ public: } template<typename U> - WeakPtr& operator=(const RefPtr<U>& object) requires(IsBaseOf<T, U>) + WeakPtr& operator=(RefPtr<U> const& object) requires(IsBaseOf<T, U>) { object.do_while_locked([&](U* obj) { if (obj) @@ -112,7 +112,7 @@ public: } template<typename U> - WeakPtr& operator=(const NonnullRefPtr<U>& object) requires(IsBaseOf<T, U>) + WeakPtr& operator=(NonnullRefPtr<U> const& object) requires(IsBaseOf<T, U>) { object.do_while_locked([&](U* obj) { if (obj) @@ -156,7 +156,7 @@ public: [[nodiscard]] RefPtr<WeakLink> take_link() { return move(m_link); } private: - WeakPtr(const RefPtr<WeakLink>& link) + WeakPtr(RefPtr<WeakLink> const& link) : m_link(link) { } diff --git a/Kernel/Locking/MutexProtected.h b/Kernel/Locking/MutexProtected.h index 8fe7fa31d1..9271d3edfb 100644 --- a/Kernel/Locking/MutexProtected.h +++ b/Kernel/Locking/MutexProtected.h @@ -66,7 +66,7 @@ public: template<typename Callback> 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 dd0344708c..1072c425cc 100644 --- a/Kernel/Locking/SpinlockProtected.h +++ b/Kernel/Locking/SpinlockProtected.h @@ -69,7 +69,7 @@ public: template<typename Callback> 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 d5fdd97e05..a96b703157 100644 --- a/Kernel/Memory/AddressSpace.cpp +++ b/Kernel/Memory/AddressSpace.cpp @@ -245,7 +245,7 @@ ErrorOr<Vector<Region*>> 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<Region*> AddressSpace::add_region(NonnullOwnPtr<Region> region) } // Carve out a virtual address range from a region and return the two regions on either side -ErrorOr<Vector<Region*, 2>> AddressSpace::try_split_region_around_range(const Region& source_region, VirtualRange const& desired_range) +ErrorOr<Vector<Region*, 2>> 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<size_t> AddressSpace::amount_clean_inode() const { SpinlockLocker lock(m_lock); - HashTable<const InodeVMObject*> vmobjects; + HashTable<InodeVMObject const*> vmobjects; for (auto const& region : m_regions) { if (region->vmobject().is_inode()) - TRY(vmobjects.try_set(&static_cast<const InodeVMObject&>(region->vmobject()))); + TRY(vmobjects.try_set(&static_cast<InodeVMObject const&>(region->vmobject()))); } size_t amount = 0; for (auto& vmobject : vmobjects) diff --git a/Kernel/Memory/AddressSpace.h b/Kernel/Memory/AddressSpace.h index b09f5f3d2d..0c08647749 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<Region*> add_region(NonnullOwnPtr<Region>); size_t region_count() const { return m_regions.size(); } RedBlackTree<FlatPtr, NonnullOwnPtr<Region>>& regions() { return m_regions; } - const RedBlackTree<FlatPtr, NonnullOwnPtr<Region>>& regions() const { return m_regions; } + RedBlackTree<FlatPtr, NonnullOwnPtr<Region>> const& regions() const { return m_regions; } void dump_regions(); diff --git a/Kernel/Memory/MappedROM.h b/Kernel/Memory/MappedROM.h index e80870c8f2..486251df5e 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> 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 3d5a27b027..f5cdfbe825 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 eaabce7dcc..233565e3e1 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>, AddressSpace& space) { m_space = &space; } diff --git a/Kernel/Memory/RingBuffer.cpp b/Kernel/Memory/RingBuffer.cpp index ca0f38602e..045f61e6d5 100644 --- a/Kernel/Memory/RingBuffer.cpp +++ b/Kernel/Memory/RingBuffer.cpp @@ -23,7 +23,7 @@ RingBuffer::RingBuffer(NonnullOwnPtr<Memory::Region> 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 0e36428e58..eb97c53253 100644 --- a/Kernel/Memory/RingBuffer.h +++ b/Kernel/Memory/RingBuffer.h @@ -16,7 +16,7 @@ public: static ErrorOr<NonnullOwnPtr<RingBuffer>> 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<size_t> copy_data_out(size_t size, UserOrKernelBuffer& buffer) const; ErrorOr<PhysicalAddress> 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 f90876957a..6fedb75cad 100644 --- a/Kernel/Memory/ScatterGatherList.h +++ b/Kernel/Memory/ScatterGatherList.h @@ -19,7 +19,7 @@ namespace Kernel::Memory { class ScatterGatherList : public RefCounted<ScatterGatherList> { public: static RefPtr<ScatterGatherList> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<PhysicalPage>> 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 0bd0768b5b..4211a70d89 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 8d56810b39..fe984b94df 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<u16> m_hardware_type { ARPHardwareType::Ethernet }; diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h index 63df81bcda..8468d0b588 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 0b0e807ce8..8f5ea3623a 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<u16> identifier; NetworkOrdered<u16> 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 c5e22c4a46..621ee71c48 100644 --- a/Kernel/Net/IPv4.h +++ b/Kernel/Net/IPv4.h @@ -24,7 +24,7 @@ enum class IPv4PacketFlags : u16 { MoreFragments = 0x2000, }; -NetworkOrdered<u16> internet_checksum(const void*, size_t); +NetworkOrdered<u16> 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<IPv4Packet, 20>()); -inline NetworkOrdered<u16> internet_checksum(const void* ptr, size_t count) +inline NetworkOrdered<u16> 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 4204ae8f6c..842e9a8f92 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<void> IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t address_size) +ErrorOr<void> IPv4Socket::bind(Userspace<sockaddr const*> user_address, socklen_t address_size) { VERIFY(setup_state() == SetupState::Unstarted); if (address_size != sizeof(sockaddr_in)) @@ -114,7 +114,7 @@ ErrorOr<void> IPv4Socket::bind(Userspace<const sockaddr*> 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<void> IPv4Socket::listen(size_t backlog) return protocol_listen(result.did_allocate); } -ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<const sockaddr*> address, socklen_t address_size, ShouldBlock should_block) +ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<sockaddr const*> 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<const sockaddr*>(address.unsafe_userspace_ptr()); + auto* user_address = reinterpret_cast<sockaddr const*>(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<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<co sockaddr_in safe_address {}; SOCKET_TRY(copy_from_user(&safe_address, (sockaddr_in const*)user_address, sizeof(sockaddr_in))); - m_peer_address = IPv4Address((const u8*)&safe_address.sin_addr.s_addr); + m_peer_address = IPv4Address((u8 const*)&safe_address.sin_addr.s_addr); if (m_peer_address == IPv4Address { 0, 0, 0, 0 }) m_peer_address = IPv4Address { 127, 0, 0, 1 }; m_peer_port = ntohs(safe_address.sin_port); @@ -161,7 +161,7 @@ ErrorOr<void> IPv4Socket::connect(OpenFileDescription& description, Userspace<co return protocol_connect(description, should_block); } -bool IPv4Socket::can_read(const OpenFileDescription&, u64) const +bool IPv4Socket::can_read(OpenFileDescription const&, u64) const { if (m_role == Role::Listener) return can_accept(); @@ -170,7 +170,7 @@ bool IPv4Socket::can_read(const OpenFileDescription&, u64) const return m_can_read; } -bool IPv4Socket::can_write(const OpenFileDescription&, u64) const +bool IPv4Socket::can_write(OpenFileDescription const&, u64) const { return true; } @@ -187,7 +187,7 @@ PortAllocationResult IPv4Socket::allocate_local_port_if_needed() return { m_local_port, true }; } -ErrorOr<size_t> IPv4Socket::sendto(OpenFileDescription&, const UserOrKernelBuffer& data, size_t data_length, [[maybe_unused]] int flags, Userspace<const sockaddr*> addr, socklen_t addr_length) +ErrorOr<size_t> IPv4Socket::sendto(OpenFileDescription&, UserOrKernelBuffer const& data, size_t data_length, [[maybe_unused]] int flags, Userspace<sockaddr const*> addr, socklen_t addr_length) { MutexLocker locker(mutex()); @@ -196,14 +196,14 @@ ErrorOr<size_t> IPv4Socket::sendto(OpenFileDescription&, const UserOrKernelBuffe if (addr) { sockaddr_in ia {}; - SOCKET_TRY(copy_from_user(&ia, Userspace<const sockaddr_in*>(addr.ptr()))); + SOCKET_TRY(copy_from_user(&ia, Userspace<sockaddr_in const*>(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<size_t> 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<NonnullOwnPtr<KString>> IPv4Socket::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> IPv4Socket::pseudo_path(OpenFileDescription const&) const { if (m_role == Role::None) return KString::try_create("socket"sv); @@ -500,7 +500,7 @@ ErrorOr<NonnullOwnPtr<KString>> IPv4Socket::pseudo_path(const OpenFileDescriptio return KString::try_create(builder.string_view()); } -ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void*> user_value, socklen_t user_value_size) +ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<void const*> 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<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void if (user_value_size < sizeof(int)) return EINVAL; int value; - TRY(copy_from_user(&value, static_ptr_cast<const int*>(user_value))); + TRY(copy_from_user(&value, static_ptr_cast<int const*>(user_value))); if (value < 0 || value > 255) return EINVAL; m_ttl = value; @@ -522,7 +522,7 @@ ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void if (user_value_size < sizeof(int)) return EINVAL; int value; - TRY(copy_from_user(&value, static_ptr_cast<const int*>(user_value))); + TRY(copy_from_user(&value, static_ptr_cast<int const*>(user_value))); if (value < 0 || value > 255) return EINVAL; m_type_of_service = value; @@ -532,7 +532,7 @@ ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void if (user_value_size != 1) return EINVAL; u8 value; - TRY(copy_from_user(&value, static_ptr_cast<const u8*>(user_value))); + TRY(copy_from_user(&value, static_ptr_cast<u8 const*>(user_value))); if (value != 0 && value != 1) return EINVAL; m_multicast_loop = value; @@ -542,10 +542,10 @@ ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void if (user_value_size != sizeof(ip_mreq)) return EINVAL; ip_mreq mreq; - TRY(copy_from_user(&mreq, static_ptr_cast<const ip_mreq*>(user_value))); + TRY(copy_from_user(&mreq, static_ptr_cast<ip_mreq const*>(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<void> IPv4Socket::setsockopt(int level, int option, Userspace<const void if (user_value_size != sizeof(ip_mreq)) return EINVAL; ip_mreq mreq; - TRY(copy_from_user(&mreq, static_ptr_cast<const ip_mreq*>(user_value))); + TRY(copy_from_user(&mreq, static_ptr_cast<ip_mreq const*>(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<void> IPv4Socket::getsockopt(OpenFileDescription& description, int level case IP_MULTICAST_LOOP: { if (size < 1) return EINVAL; - TRY(copy_to_user(static_ptr_cast<u8*>(value), (const u8*)&m_multicast_loop)); + TRY(copy_to_user(static_ptr_cast<u8*>(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 73c77fae53..967419251a 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -32,36 +32,36 @@ public: virtual ~IPv4Socket() override; virtual ErrorOr<void> close() override; - virtual ErrorOr<void> bind(Userspace<const sockaddr*>, socklen_t) override; - virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<const sockaddr*>, socklen_t, ShouldBlock = ShouldBlock::Yes) override; + virtual ErrorOr<void> bind(Userspace<sockaddr const*>, socklen_t) override; + virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t, ShouldBlock = ShouldBlock::Yes) override; virtual ErrorOr<void> 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<size_t> sendto(OpenFileDescription&, const UserOrKernelBuffer&, size_t, int, Userspace<const sockaddr*>, socklen_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr<size_t> sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int, Userspace<sockaddr const*>, socklen_t) override; virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&) override; - virtual ErrorOr<void> setsockopt(int level, int option, Userspace<const void*>, socklen_t) override; + virtual ErrorOr<void> setsockopt(int level, int option, Userspace<void const*>, socklen_t) override; virtual ErrorOr<void> getsockopt(OpenFileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>) override; virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> 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<IPv4Address>& multicast_memberships() const { return m_multicast_memberships; } + Vector<IPv4Address> 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<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription& description) const override; + ErrorOr<NonnullOwnPtr<KString>> 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<void> protocol_bind() { return {}; } virtual ErrorOr<void> protocol_listen([[maybe_unused]] bool did_allocate_port) { return {}; } virtual ErrorOr<size_t> protocol_receive(ReadonlyBytes /* raw_ipv4_packet */, UserOrKernelBuffer&, size_t, int) { return ENOTIMPL; } - virtual ErrorOr<size_t> protocol_send(const UserOrKernelBuffer&, size_t) { return ENOTIMPL; } + virtual ErrorOr<size_t> protocol_send(UserOrKernelBuffer const&, size_t) { return ENOTIMPL; } virtual ErrorOr<void> protocol_connect(OpenFileDescription&, ShouldBlock) { return {}; } virtual ErrorOr<u16> protocol_allocate_local_port() { return ENOPROTOOPT; } virtual ErrorOr<size_t> protocol_size(ReadonlyBytes /* raw_ipv4_packet */) { return ENOTIMPL; } diff --git a/Kernel/Net/IPv4SocketTuple.h b/Kernel/Net/IPv4SocketTuple.h index a63d3aca71..c763a4ab7f 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<Kernel::IPv4SocketTuple> : public GenericTraits<Kernel::IPv4SocketTuple> { - 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 82726a9af1..7d0f2cfb70 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 2c4b04af4e..e0ca57a69d 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<u8>(); } @@ -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<u16>(); } @@ -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<u32>(); } diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.h b/Kernel/Net/Intel/E1000NetworkAdapter.h index b0905e231a..ba7afbf3f2 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<KString>); - 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 57b811637a..b2c2d11db7 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -27,16 +27,16 @@ static MutexProtected<LocalSocket::List>& all_sockets() return *s_list; } -void LocalSocket::for_each(Function<void(const LocalSocket&)> callback) +void LocalSocket::for_each(Function<void(LocalSocket const&)> callback) { - all_sockets().for_each_shared([&](const auto& socket) { + all_sockets().for_each_shared([&](auto const& socket) { callback(socket); }); } -ErrorOr<void> LocalSocket::try_for_each(Function<ErrorOr<void>(const LocalSocket&)> callback) +ErrorOr<void> LocalSocket::try_for_each(Function<ErrorOr<void>(LocalSocket const&)> callback) { - return all_sockets().with_shared([&](const auto& sockets) -> ErrorOr<void> { + return all_sockets().with_shared([&](auto const& sockets) -> ErrorOr<void> { 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<void> LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t address_size) +ErrorOr<void> LocalSocket::bind(Userspace<sockaddr const*> user_address, socklen_t address_size) { VERIFY(setup_state() == SetupState::Unstarted); if (address_size != sizeof(sockaddr_un)) @@ -153,13 +153,13 @@ ErrorOr<void> LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen return {}; } -ErrorOr<void> LocalSocket::connect(OpenFileDescription& description, Userspace<const sockaddr*> address, socklen_t address_size, ShouldBlock) +ErrorOr<void> LocalSocket::connect(OpenFileDescription& description, Userspace<sockaddr const*> 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<const sockaddr*>(address.unsafe_userspace_ptr()); + auto* user_address = reinterpret_cast<sockaddr const*>(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<size_t> LocalSocket::sendto(OpenFileDescription& description, const UserOrKernelBuffer& data, size_t data_size, int, Userspace<const sockaddr*>, socklen_t) +ErrorOr<size_t> LocalSocket::sendto(OpenFileDescription& description, UserOrKernelBuffer const& data, size_t data_size, int, Userspace<sockaddr const*>, 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<NonnullOwnPtr<KString>> LocalSocket::pseudo_path(const OpenFileDescription& description) const +ErrorOr<NonnullOwnPtr<KString>> LocalSocket::pseudo_path(OpenFileDescription const& description) const { StringBuilder builder; TRY(builder.try_append("socket:")); @@ -469,7 +469,7 @@ ErrorOr<void> LocalSocket::chown(OpenFileDescription&, UserID uid, GroupID gid) return {}; } -NonnullRefPtrVector<OpenFileDescription>& LocalSocket::recvfd_queue_for(const OpenFileDescription& description) +NonnullRefPtrVector<OpenFileDescription>& LocalSocket::recvfd_queue_for(OpenFileDescription const& description) { auto role = this->role(description); if (role == Role::Connected) @@ -479,7 +479,7 @@ NonnullRefPtrVector<OpenFileDescription>& LocalSocket::recvfd_queue_for(const Op VERIFY_NOT_REACHED(); } -NonnullRefPtrVector<OpenFileDescription>& LocalSocket::sendfd_queue_for(const OpenFileDescription& description) +NonnullRefPtrVector<OpenFileDescription>& LocalSocket::sendfd_queue_for(OpenFileDescription const& description) { auto role = this->role(description); if (role == Role::Connected) @@ -503,7 +503,7 @@ ErrorOr<void> LocalSocket::sendfd(OpenFileDescription const& socket_description, return {}; } -ErrorOr<NonnullRefPtr<OpenFileDescription>> LocalSocket::recvfd(const OpenFileDescription& socket_description) +ErrorOr<NonnullRefPtr<OpenFileDescription>> 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 4bc5c3e4a3..1eea1eb23b 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -27,25 +27,25 @@ public: virtual ~LocalSocket() override; ErrorOr<void> sendfd(OpenFileDescription const& socket_description, NonnullRefPtr<OpenFileDescription> passing_description); - ErrorOr<NonnullRefPtr<OpenFileDescription>> recvfd(const OpenFileDescription& socket_description); + ErrorOr<NonnullRefPtr<OpenFileDescription>> recvfd(OpenFileDescription const& socket_description); - static void for_each(Function<void(const LocalSocket&)>); - static ErrorOr<void> try_for_each(Function<ErrorOr<void>(const LocalSocket&)>); + static void for_each(Function<void(LocalSocket const&)>); + static ErrorOr<void> try_for_each(Function<ErrorOr<void>(LocalSocket const&)>); StringView socket_path() const; - ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription& description) const override; + ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const& description) const override; // ^Socket - virtual ErrorOr<void> bind(Userspace<const sockaddr*>, socklen_t) override; - virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<const sockaddr*>, socklen_t, ShouldBlock = ShouldBlock::Yes) override; + virtual ErrorOr<void> bind(Userspace<sockaddr const*>, socklen_t) override; + virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t, ShouldBlock = ShouldBlock::Yes) override; virtual ErrorOr<void> listen(size_t) override; virtual void get_local_address(sockaddr*, socklen_t*) override; virtual void get_peer_address(sockaddr*, socklen_t*) override; virtual ErrorOr<void> 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<size_t> sendto(OpenFileDescription&, const UserOrKernelBuffer&, size_t, int, Userspace<const sockaddr*>, socklen_t) override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; + virtual ErrorOr<size_t> sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int, Userspace<sockaddr const*>, socklen_t) override; virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&) override; virtual ErrorOr<void> getsockopt(OpenFileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>) override; virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; @@ -56,11 +56,11 @@ private: explicit LocalSocket(int type, NonnullOwnPtr<DoubleBuffer> client_buffer, NonnullOwnPtr<DoubleBuffer> 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<OpenFileDescription>& sendfd_queue_for(const OpenFileDescription&); - NonnullRefPtrVector<OpenFileDescription>& recvfd_queue_for(const OpenFileDescription&); + NonnullRefPtrVector<OpenFileDescription>& sendfd_queue_for(OpenFileDescription const&); + NonnullRefPtrVector<OpenFileDescription>& 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 83146b9484..1cc1ef25e9 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 f901a934ea..b4900cb094 100644 --- a/Kernel/Net/NE2000/NetworkAdapter.h +++ b/Kernel/Net/NE2000/NetworkAdapter.h @@ -42,7 +42,7 @@ public: private: NE2000NetworkAdapter(PCI::Address, u8, NonnullOwnPtr<KString>); - 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 d471878bee..4c64f00634 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 0c69b6230f..8ccee2a613 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<KString>); - 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 b499e3fb39..53df9665b5 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<TCPSocket, 16> 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 43bb8a6455..00015d47a2 100644 --- a/Kernel/Net/NetworkingManagement.h +++ b/Kernel/Net/NetworkingManagement.h @@ -33,7 +33,7 @@ public: void for_each(Function<void(NetworkAdapter&)>); ErrorOr<void> try_for_each(Function<ErrorOr<void>(NetworkAdapter&)>); - RefPtr<NetworkAdapter> from_ipv4_address(const IPv4Address&) const; + RefPtr<NetworkAdapter> from_ipv4_address(IPv4Address const&) const; RefPtr<NetworkAdapter> lookup_by_name(StringView) const; NonnullRefPtr<NetworkAdapter> loopback_adapter() const; diff --git a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp index 2b00bf52b5..6481280a75 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 2046cf9c11..8613d89cae 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<KString>); - 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 5ddc016dcd..0d1fcc3945 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 dfc404aae6..01106f3640 100644 --- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h +++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h @@ -40,7 +40,7 @@ private: RTL8168NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr<KString>); - 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 46d57744de..e8a0aaed86 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<ARPTableBlocker&>(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 77654ef8ac..3673969a5e 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -74,7 +74,7 @@ ErrorOr<void> Socket::queue_connection_from(NonnullRefPtr<Socket> peer) return {}; } -ErrorOr<void> Socket::setsockopt(int level, int option, Userspace<const void*> user_value, socklen_t user_value_size) +ErrorOr<void> Socket::setsockopt(int level, int option, Userspace<void const*> user_value, socklen_t user_value_size) { MutexLocker locker(mutex()); @@ -95,7 +95,7 @@ ErrorOr<void> Socket::setsockopt(int level, int option, Userspace<const void*> u case SO_BINDTODEVICE: { if (user_value_size != IFNAMSIZ) return EINVAL; - auto user_string = static_ptr_cast<const char*>(user_value); + auto user_string = static_ptr_cast<char const*>(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<size_t> Socket::read(OpenFileDescription& description, u64, UserOrKernel return recvfrom(description, buffer, size, 0, {}, 0, t); } -ErrorOr<size_t> Socket::write(OpenFileDescription& description, u64, const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> 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 979df8b27c..6c0685b980 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<void> shutdown(int how); - virtual ErrorOr<void> bind(Userspace<const sockaddr*>, socklen_t) = 0; - virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<const sockaddr*>, socklen_t, ShouldBlock) = 0; + virtual ErrorOr<void> bind(Userspace<sockaddr const*>, socklen_t) = 0; + virtual ErrorOr<void> connect(OpenFileDescription&, Userspace<sockaddr const*>, socklen_t, ShouldBlock) = 0; virtual ErrorOr<void> 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<size_t> sendto(OpenFileDescription&, const UserOrKernelBuffer&, size_t, int flags, Userspace<const sockaddr*>, socklen_t) = 0; + virtual ErrorOr<size_t> sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int flags, Userspace<sockaddr const*>, socklen_t) = 0; virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&) = 0; - virtual ErrorOr<void> setsockopt(int level, int option, Userspace<const void*>, socklen_t); + virtual ErrorOr<void> setsockopt(int level, int option, Userspace<void const*>, socklen_t); virtual ErrorOr<void> getsockopt(OpenFileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>); 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<NetworkAdapter> bound_interface() const { return m_bound_interface; } + RefPtr<NetworkAdapter> const bound_interface() const { return m_bound_interface; } Mutex& mutex() { return m_mutex; } // ^File virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override final; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override final; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override final; virtual ErrorOr<struct stat> stat() const override; - virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override = 0; + virtual ErrorOr<NonnullOwnPtr<KString>> 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 be1a0d0478..a517089b8e 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 d52acd5166..8ff2944678 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -22,16 +22,16 @@ namespace Kernel { -void TCPSocket::for_each(Function<void(const TCPSocket&)> callback) +void TCPSocket::for_each(Function<void(TCPSocket const&)> callback) { - sockets_by_tuple().for_each_shared([&](const auto& it) { + sockets_by_tuple().for_each_shared([&](auto const& it) { callback(*it.value); }); } -ErrorOr<void> TCPSocket::try_for_each(Function<ErrorOr<void>(const TCPSocket&)> callback) +ErrorOr<void> TCPSocket::try_for_each(Function<ErrorOr<void>(TCPSocket const&)> callback) { - return sockets_by_tuple().with_shared([&](const auto& sockets) -> ErrorOr<void> { + return sockets_by_tuple().with_shared([&](auto const& sockets) -> ErrorOr<void> { for (auto& it : sockets) TRY(callback(*it.value)); return {}; @@ -102,9 +102,9 @@ MutexProtected<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tupl return *s_socket_tuples; } -RefPtr<TCPSocket> TCPSocket::from_tuple(const IPv4SocketTuple& tuple) +RefPtr<TCPSocket> TCPSocket::from_tuple(IPv4SocketTuple const& tuple) { - return sockets_by_tuple().with_shared([&](const auto& table) -> RefPtr<TCPSocket> { + return sockets_by_tuple().with_shared([&](auto const& table) -> RefPtr<TCPSocket> { auto exact_match = table.get(tuple); if (exact_match.has_value()) return { *exact_match.value() }; @@ -122,7 +122,7 @@ RefPtr<TCPSocket> TCPSocket::from_tuple(const IPv4SocketTuple& tuple) return {}; }); } -ErrorOr<NonnullRefPtr<TCPSocket>> TCPSocket::try_create_client(const IPv4Address& new_local_address, u16 new_local_port, const IPv4Address& new_peer_address, u16 new_peer_port) +ErrorOr<NonnullRefPtr<TCPSocket>> 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<NonnullRefPtr<TCPSocket>> { @@ -184,15 +184,15 @@ ErrorOr<NonnullRefPtr<TCPSocket>> TCPSocket::try_create(int protocol, NonnullOwn ErrorOr<size_t> TCPSocket::protocol_size(ReadonlyBytes raw_ipv4_packet) { - auto& ipv4_packet = *reinterpret_cast<const IPv4Packet*>(raw_ipv4_packet.data()); - auto& tcp_packet = *static_cast<const TCPPacket*>(ipv4_packet.payload()); + auto& ipv4_packet = *reinterpret_cast<IPv4Packet const*>(raw_ipv4_packet.data()); + auto& tcp_packet = *static_cast<TCPPacket const*>(ipv4_packet.payload()); return raw_ipv4_packet.size() - sizeof(IPv4Packet) - tcp_packet.header_size(); } ErrorOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags) { - auto& ipv4_packet = *reinterpret_cast<const IPv4Packet*>(raw_ipv4_packet.data()); - auto& tcp_packet = *static_cast<const TCPPacket*>(ipv4_packet.payload()); + auto& ipv4_packet = *reinterpret_cast<IPv4Packet const*>(raw_ipv4_packet.data()); + auto& tcp_packet = *static_cast<TCPPacket const*>(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<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserO return payload_size; } -ErrorOr<size_t> TCPSocket::protocol_send(const UserOrKernelBuffer& data, size_t data_length) +ErrorOr<size_t> 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<void> TCPSocket::send_ack(bool allow_duplicate) return send_tcp_packet(TCPFlags::ACK); } -ErrorOr<void> TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload, size_t payload_size, RoutingDecision* user_routing_decision) +ErrorOr<void> 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<void> 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<void> 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<u16> TCPSocket::compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket& packet, u16 payload_size) +NetworkOrdered<u16> 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<u16> 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 9c30d1ebd5..400cf799d9 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<void(const TCPSocket&)>); - static ErrorOr<void> try_for_each(Function<ErrorOr<void>(const TCPSocket&)>); + static void for_each(Function<void(TCPSocket const&)>); + static ErrorOr<void> try_for_each(Function<ErrorOr<void>(TCPSocket const&)>); static ErrorOr<NonnullRefPtr<TCPSocket>> try_create(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer); virtual ~TCPSocket() override; @@ -140,13 +140,13 @@ public: u32 duplicate_acks() const { return m_duplicate_acks; } ErrorOr<void> send_ack(bool allow_duplicate = false); - ErrorOr<void> send_tcp_packet(u16 flags, const UserOrKernelBuffer* = nullptr, size_t = 0, RoutingDecision* = nullptr); - void receive_tcp_packet(const TCPPacket&, u16 size); + ErrorOr<void> 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<HashMap<IPv4SocketTuple, TCPSocket*>>& sockets_by_tuple(); - static RefPtr<TCPSocket> from_tuple(const IPv4SocketTuple& tuple); + static RefPtr<TCPSocket> from_tuple(IPv4SocketTuple const& tuple); static MutexProtected<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& closing_sockets(); @@ -160,7 +160,7 @@ public: virtual ErrorOr<void> close() override; - virtual bool can_write(const OpenFileDescription&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; static NetworkOrdered<u16> 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<size_t> protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override; - virtual ErrorOr<size_t> protocol_send(const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> protocol_send(UserOrKernelBuffer const&, size_t) override; virtual ErrorOr<void> protocol_connect(OpenFileDescription&, ShouldBlock) override; virtual ErrorOr<u16> protocol_allocate_local_port() override; virtual ErrorOr<size_t> protocol_size(ReadonlyBytes raw_ipv4_packet) override; diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index 38122e877b..eb57919b00 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 b9ba5f45eb..ab198f77b4 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -15,16 +15,16 @@ namespace Kernel { -void UDPSocket::for_each(Function<void(const UDPSocket&)> callback) +void UDPSocket::for_each(Function<void(UDPSocket const&)> callback) { - sockets_by_port().for_each_shared([&](const auto& socket) { + sockets_by_port().for_each_shared([&](auto const& socket) { callback(*socket.value); }); } -ErrorOr<void> UDPSocket::try_for_each(Function<ErrorOr<void>(const UDPSocket&)> callback) +ErrorOr<void> UDPSocket::try_for_each(Function<ErrorOr<void>(UDPSocket const&)> callback) { - return sockets_by_port().with_shared([&](const auto& sockets) -> ErrorOr<void> { + return sockets_by_port().with_shared([&](auto const& sockets) -> ErrorOr<void> { for (auto& socket : sockets) TRY(callback(*socket.value)); return {}; @@ -40,7 +40,7 @@ MutexProtected<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port() RefPtr<UDPSocket> UDPSocket::from_port(u16 port) { - return sockets_by_port().with_shared([&](const auto& table) -> RefPtr<UDPSocket> { + return sockets_by_port().with_shared([&](auto const& table) -> RefPtr<UDPSocket> { auto it = table.find(port); if (it == table.end()) return {}; @@ -67,22 +67,22 @@ ErrorOr<NonnullRefPtr<UDPSocket>> UDPSocket::try_create(int protocol, NonnullOwn ErrorOr<size_t> UDPSocket::protocol_size(ReadonlyBytes raw_ipv4_packet) { - auto& ipv4_packet = *(const IPv4Packet*)(raw_ipv4_packet.data()); - auto& udp_packet = *static_cast<const UDPPacket*>(ipv4_packet.payload()); + auto& ipv4_packet = *(IPv4Packet const*)(raw_ipv4_packet.data()); + auto& udp_packet = *static_cast<UDPPacket const*>(ipv4_packet.payload()); return udp_packet.length() - sizeof(UDPPacket); } ErrorOr<size_t> 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<const UDPPacket*>(ipv4_packet.payload()); + auto& ipv4_packet = *(IPv4Packet const*)(raw_ipv4_packet.data()); + auto& udp_packet = *static_cast<UDPPacket const*>(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<size_t> UDPSocket::protocol_send(const UserOrKernelBuffer& data, size_t data_length) +ErrorOr<size_t> 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 40bfef5779..d4980c9e37 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -18,8 +18,8 @@ public: virtual ~UDPSocket() override; static RefPtr<UDPSocket> from_port(u16); - static void for_each(Function<void(const UDPSocket&)>); - static ErrorOr<void> try_for_each(Function<ErrorOr<void>(const UDPSocket&)>); + static void for_each(Function<void(UDPSocket const&)>); + static ErrorOr<void> try_for_each(Function<ErrorOr<void>(UDPSocket const&)>); private: explicit UDPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer); @@ -27,7 +27,7 @@ private: static MutexProtected<HashMap<u16, UDPSocket*>>& sockets_by_port(); virtual ErrorOr<size_t> protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override; - virtual ErrorOr<size_t> protocol_send(const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> protocol_send(UserOrKernelBuffer const&, size_t) override; virtual ErrorOr<size_t> protocol_size(ReadonlyBytes raw_ipv4_packet) override; virtual ErrorOr<void> protocol_connect(OpenFileDescription&, ShouldBlock) override; virtual ErrorOr<u16> protocol_allocate_local_port() override; diff --git a/Kernel/Panic.cpp b/Kernel/Panic.cpp index 34100a1bdb..f2f20accc6 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 96f5034b8d..152a41db55 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 98c155fd58..4ae7df427b 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -72,7 +72,7 @@ static Vector<FlatPtr, PerformanceEvent::max_stack_frame_count> raw_backtrace(Fl return backtrace; } -ErrorOr<void> PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID tid, const RegisterState& regs, +ErrorOr<void> 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<FlatPtr> 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> PerformanceEventBuffer::try_create_with_size(size return adopt_own_if_nonnull(new (nothrow) PerformanceEventBuffer(buffer_or_error.release_value())); } -ErrorOr<void> PerformanceEventBuffer::add_process(const Process& process, ProcessEventType event_type) +ErrorOr<void> 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 7570dd136b..bd246176b8 100644 --- a/Kernel/PerformanceEventBuffer.h +++ b/Kernel/PerformanceEventBuffer.h @@ -113,7 +113,7 @@ public: ErrorOr<void> append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread = Thread::current(), FlatPtr arg4 = 0, u64 arg5 = 0, ErrorOr<FlatPtr> arg6 = 0); ErrorOr<void> 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<FlatPtr> arg6 = 0); - ErrorOr<void> append_with_ip_and_bp(ProcessID pid, ThreadID tid, const RegisterState& regs, + ErrorOr<void> 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<FlatPtr> 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<PerformanceEventBuffer&>(*this).at(index); } ErrorOr<void> to_json(KBufferBuilder&) const; - ErrorOr<void> add_process(const Process&, ProcessEventType event_type); + ErrorOr<void> add_process(Process const&, ProcessEventType event_type); ErrorOr<FlatPtr> register_string(NonnullOwnPtr<KString>); diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h index 159a11e2f9..a2f5d77786 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<FlatPtr> result) + inline static void add_read_event(Thread& thread, int fd, size_t size, OpenFileDescription const& file_description, u64 start_timestamp, ErrorOr<FlatPtr> result) { if (thread.is_profiling_suppressed()) return; diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h index e1f66d6a6a..8a4fbaef25 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<u8*>(m_address); } - [[nodiscard]] const u8* as_ptr() const { return reinterpret_cast<u8 const*>(m_address); } + [[nodiscard]] u8 const* as_ptr() const { return reinterpret_cast<u8 const*>(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 52a92e317f..d03c3581d3 100644 --- a/Kernel/Prekernel/UBSanitizer.cpp +++ b/Kernel/Prekernel/UBSanitizer.cpp @@ -13,7 +13,7 @@ Atomic<bool> 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 135e7ebcb8..1057328ab2 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> Process::from_pid(ProcessID pid) { - return all_instances().with([&](const auto& list) -> RefPtr<Process> { + return all_instances().with([&](auto const& list) -> RefPtr<Process> { for (auto const& process : list) { if (process.pid() == pid) return &process; @@ -421,7 +421,7 @@ RefPtr<Process> 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<NonnullRefPtr<OpenFileDescription>> Process::OpenFileDescriptions::open_ return description.release_nonnull(); } -void Process::OpenFileDescriptions::enumerate(Function<void(const OpenFileDescriptionAndFlags&)> callback) const +void Process::OpenFileDescriptions::enumerate(Function<void(OpenFileDescriptionAndFlags const&)> callback) const { for (auto const& file_description_metadata : m_fds_metadatas) { callback(file_description_metadata); } } -ErrorOr<void> Process::OpenFileDescriptions::try_enumerate(Function<ErrorOr<void>(const OpenFileDescriptionAndFlags&)> callback) const +ErrorOr<void> Process::OpenFileDescriptions::try_enumerate(Function<ErrorOr<void>(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 5d19121267..2a4b263929 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -261,18 +261,18 @@ public: bool is_traced() const { return !!m_tracer; } ErrorOr<void> start_tracing_from(ProcessID tracer); void stop_tracing(); - void tracer_trap(Thread&, const RegisterState&); + void tracer_trap(Thread&, RegisterState const&); ErrorOr<FlatPtr> sys$emuctl(); ErrorOr<FlatPtr> sys$yield(); ErrorOr<FlatPtr> sys$sync(); ErrorOr<FlatPtr> sys$beep(); ErrorOr<FlatPtr> sys$get_process_name(Userspace<char*> buffer, size_t buffer_size); - ErrorOr<FlatPtr> sys$set_process_name(Userspace<const char*> user_name, size_t user_name_length); + ErrorOr<FlatPtr> sys$set_process_name(Userspace<char const*> user_name, size_t user_name_length); ErrorOr<FlatPtr> sys$create_inode_watcher(u32 flags); - ErrorOr<FlatPtr> sys$inode_watcher_add_watch(Userspace<const Syscall::SC_inode_watcher_add_watch_params*> user_params); + ErrorOr<FlatPtr> sys$inode_watcher_add_watch(Userspace<Syscall::SC_inode_watcher_add_watch_params const*> user_params); ErrorOr<FlatPtr> sys$inode_watcher_remove_watch(int fd, int wd); - ErrorOr<FlatPtr> sys$dbgputstr(Userspace<const char*>, size_t); + ErrorOr<FlatPtr> sys$dbgputstr(Userspace<char const*>, size_t); ErrorOr<FlatPtr> sys$dump_backtrace(); ErrorOr<FlatPtr> sys$gettid(); ErrorOr<FlatPtr> sys$setsid(); @@ -290,53 +290,53 @@ public: ErrorOr<FlatPtr> sys$getresgid(Userspace<GroupID*>, Userspace<GroupID*>, Userspace<GroupID*>); ErrorOr<FlatPtr> sys$getrusage(int, Userspace<rusage*>); ErrorOr<FlatPtr> sys$umask(mode_t); - ErrorOr<FlatPtr> sys$open(Userspace<const Syscall::SC_open_params*>); + ErrorOr<FlatPtr> sys$open(Userspace<Syscall::SC_open_params const*>); ErrorOr<FlatPtr> sys$close(int fd); ErrorOr<FlatPtr> sys$read(int fd, Userspace<u8*>, size_t); ErrorOr<FlatPtr> sys$pread(int fd, Userspace<u8*>, size_t, Userspace<off_t const*>); ErrorOr<FlatPtr> sys$readv(int fd, Userspace<const struct iovec*> iov, int iov_count); - ErrorOr<FlatPtr> sys$write(int fd, Userspace<const u8*>, size_t); + ErrorOr<FlatPtr> sys$write(int fd, Userspace<u8 const*>, size_t); ErrorOr<FlatPtr> sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count); ErrorOr<FlatPtr> sys$fstat(int fd, Userspace<stat*>); - ErrorOr<FlatPtr> sys$stat(Userspace<const Syscall::SC_stat_params*>); + ErrorOr<FlatPtr> sys$stat(Userspace<Syscall::SC_stat_params const*>); ErrorOr<FlatPtr> sys$lseek(int fd, Userspace<off_t*>, int whence); ErrorOr<FlatPtr> sys$ftruncate(int fd, Userspace<off_t const*>); ErrorOr<FlatPtr> sys$kill(pid_t pid_or_pgid, int sig); [[noreturn]] void sys$exit(int status); ErrorOr<FlatPtr> sys$sigreturn(RegisterState& registers); - ErrorOr<FlatPtr> sys$waitid(Userspace<const Syscall::SC_waitid_params*>); - ErrorOr<FlatPtr> sys$mmap(Userspace<const Syscall::SC_mmap_params*>); - ErrorOr<FlatPtr> sys$mremap(Userspace<const Syscall::SC_mremap_params*>); + ErrorOr<FlatPtr> sys$waitid(Userspace<Syscall::SC_waitid_params const*>); + ErrorOr<FlatPtr> sys$mmap(Userspace<Syscall::SC_mmap_params const*>); + ErrorOr<FlatPtr> sys$mremap(Userspace<Syscall::SC_mremap_params const*>); ErrorOr<FlatPtr> sys$munmap(Userspace<void*>, size_t); - ErrorOr<FlatPtr> sys$set_mmap_name(Userspace<const Syscall::SC_set_mmap_name_params*>); + ErrorOr<FlatPtr> sys$set_mmap_name(Userspace<Syscall::SC_set_mmap_name_params const*>); ErrorOr<FlatPtr> sys$mprotect(Userspace<void*>, size_t, int prot); ErrorOr<FlatPtr> sys$madvise(Userspace<void*>, size_t, int advice); ErrorOr<FlatPtr> sys$msyscall(Userspace<void*>); ErrorOr<FlatPtr> sys$msync(Userspace<void*>, size_t, int flags); ErrorOr<FlatPtr> sys$purge(int mode); - ErrorOr<FlatPtr> sys$poll(Userspace<const Syscall::SC_poll_params*>); + ErrorOr<FlatPtr> sys$poll(Userspace<Syscall::SC_poll_params const*>); ErrorOr<FlatPtr> sys$get_dir_entries(int fd, Userspace<void*>, size_t); ErrorOr<FlatPtr> sys$getcwd(Userspace<char*>, size_t); - ErrorOr<FlatPtr> sys$chdir(Userspace<const char*>, size_t); + ErrorOr<FlatPtr> sys$chdir(Userspace<char const*>, size_t); ErrorOr<FlatPtr> sys$fchdir(int fd); - ErrorOr<FlatPtr> sys$adjtime(Userspace<const timeval*>, Userspace<timeval*>); + ErrorOr<FlatPtr> sys$adjtime(Userspace<timeval const*>, Userspace<timeval*>); ErrorOr<FlatPtr> sys$clock_gettime(clockid_t, Userspace<timespec*>); - ErrorOr<FlatPtr> sys$clock_settime(clockid_t, Userspace<const timespec*>); - ErrorOr<FlatPtr> sys$clock_nanosleep(Userspace<const Syscall::SC_clock_nanosleep_params*>); + ErrorOr<FlatPtr> sys$clock_settime(clockid_t, Userspace<timespec const*>); + ErrorOr<FlatPtr> sys$clock_nanosleep(Userspace<Syscall::SC_clock_nanosleep_params const*>); ErrorOr<FlatPtr> sys$gethostname(Userspace<char*>, size_t); - ErrorOr<FlatPtr> sys$sethostname(Userspace<const char*>, size_t); + ErrorOr<FlatPtr> sys$sethostname(Userspace<char const*>, size_t); ErrorOr<FlatPtr> sys$uname(Userspace<utsname*>); - ErrorOr<FlatPtr> sys$readlink(Userspace<const Syscall::SC_readlink_params*>); + ErrorOr<FlatPtr> sys$readlink(Userspace<Syscall::SC_readlink_params const*>); ErrorOr<FlatPtr> sys$fork(RegisterState&); - ErrorOr<FlatPtr> sys$execve(Userspace<const Syscall::SC_execve_params*>); + ErrorOr<FlatPtr> sys$execve(Userspace<Syscall::SC_execve_params const*>); ErrorOr<FlatPtr> sys$dup2(int old_fd, int new_fd); - ErrorOr<FlatPtr> sys$sigaction(int signum, Userspace<const sigaction*> act, Userspace<sigaction*> old_act); - ErrorOr<FlatPtr> sys$sigaltstack(Userspace<const stack_t*> ss, Userspace<stack_t*> old_ss); - ErrorOr<FlatPtr> sys$sigprocmask(int how, Userspace<const sigset_t*> set, Userspace<sigset_t*> old_set); + ErrorOr<FlatPtr> sys$sigaction(int signum, Userspace<sigaction const*> act, Userspace<sigaction*> old_act); + ErrorOr<FlatPtr> sys$sigaltstack(Userspace<stack_t const*> ss, Userspace<stack_t*> old_ss); + ErrorOr<FlatPtr> sys$sigprocmask(int how, Userspace<sigset_t const*> set, Userspace<sigset_t*> old_set); ErrorOr<FlatPtr> sys$sigpending(Userspace<sigset_t*>); - ErrorOr<FlatPtr> sys$sigtimedwait(Userspace<sigset_t const*>, Userspace<siginfo_t*>, Userspace<const timespec*>); + ErrorOr<FlatPtr> sys$sigtimedwait(Userspace<sigset_t const*>, Userspace<siginfo_t*>, Userspace<timespec const*>); ErrorOr<FlatPtr> sys$getgroups(size_t, Userspace<gid_t*>); - ErrorOr<FlatPtr> sys$setgroups(size_t, Userspace<const gid_t*>); + ErrorOr<FlatPtr> sys$setgroups(size_t, Userspace<gid_t const*>); ErrorOr<FlatPtr> sys$pipe(int pipefd[2], int flags); ErrorOr<FlatPtr> sys$killpg(pid_t pgrp, int sig); ErrorOr<FlatPtr> sys$seteuid(UserID); @@ -347,70 +347,70 @@ public: ErrorOr<FlatPtr> sys$setresuid(UserID, UserID, UserID); ErrorOr<FlatPtr> sys$setresgid(GroupID, GroupID, GroupID); ErrorOr<FlatPtr> sys$alarm(unsigned seconds); - ErrorOr<FlatPtr> sys$access(Userspace<const char*> pathname, size_t path_length, int mode); + ErrorOr<FlatPtr> sys$access(Userspace<char const*> pathname, size_t path_length, int mode); ErrorOr<FlatPtr> sys$fcntl(int fd, int cmd, u32 extra_arg); ErrorOr<FlatPtr> sys$ioctl(int fd, unsigned request, FlatPtr arg); - ErrorOr<FlatPtr> sys$mkdir(Userspace<const char*> pathname, size_t path_length, mode_t mode); + ErrorOr<FlatPtr> sys$mkdir(Userspace<char const*> pathname, size_t path_length, mode_t mode); ErrorOr<FlatPtr> sys$times(Userspace<tms*>); - ErrorOr<FlatPtr> sys$utime(Userspace<const char*> pathname, size_t path_length, Userspace<const struct utimbuf*>); - ErrorOr<FlatPtr> sys$link(Userspace<const Syscall::SC_link_params*>); - ErrorOr<FlatPtr> sys$unlink(Userspace<const char*> pathname, size_t path_length); - ErrorOr<FlatPtr> sys$symlink(Userspace<const Syscall::SC_symlink_params*>); - ErrorOr<FlatPtr> sys$rmdir(Userspace<const char*> pathname, size_t path_length); - ErrorOr<FlatPtr> sys$mount(Userspace<const Syscall::SC_mount_params*>); - ErrorOr<FlatPtr> sys$umount(Userspace<const char*> mountpoint, size_t mountpoint_length); + ErrorOr<FlatPtr> sys$utime(Userspace<char const*> pathname, size_t path_length, Userspace<const struct utimbuf*>); + ErrorOr<FlatPtr> sys$link(Userspace<Syscall::SC_link_params const*>); + ErrorOr<FlatPtr> sys$unlink(Userspace<char const*> pathname, size_t path_length); + ErrorOr<FlatPtr> sys$symlink(Userspace<Syscall::SC_symlink_params const*>); + ErrorOr<FlatPtr> sys$rmdir(Userspace<char const*> pathname, size_t path_length); + ErrorOr<FlatPtr> sys$mount(Userspace<Syscall::SC_mount_params const*>); + ErrorOr<FlatPtr> sys$umount(Userspace<char const*> mountpoint, size_t mountpoint_length); ErrorOr<FlatPtr> sys$chmod(Userspace<Syscall::SC_chmod_params const*>); ErrorOr<FlatPtr> sys$fchmod(int fd, mode_t); - ErrorOr<FlatPtr> sys$chown(Userspace<const Syscall::SC_chown_params*>); + ErrorOr<FlatPtr> sys$chown(Userspace<Syscall::SC_chown_params const*>); ErrorOr<FlatPtr> sys$fchown(int fd, UserID, GroupID); ErrorOr<FlatPtr> sys$fsync(int fd); ErrorOr<FlatPtr> sys$socket(int domain, int type, int protocol); - ErrorOr<FlatPtr> sys$bind(int sockfd, Userspace<const sockaddr*> addr, socklen_t); + ErrorOr<FlatPtr> sys$bind(int sockfd, Userspace<sockaddr const*> addr, socklen_t); ErrorOr<FlatPtr> sys$listen(int sockfd, int backlog); - ErrorOr<FlatPtr> sys$accept4(Userspace<const Syscall::SC_accept4_params*>); - ErrorOr<FlatPtr> sys$connect(int sockfd, Userspace<const sockaddr*>, socklen_t); + ErrorOr<FlatPtr> sys$accept4(Userspace<Syscall::SC_accept4_params const*>); + ErrorOr<FlatPtr> sys$connect(int sockfd, Userspace<sockaddr const*>, socklen_t); ErrorOr<FlatPtr> sys$shutdown(int sockfd, int how); ErrorOr<FlatPtr> sys$sendmsg(int sockfd, Userspace<const struct msghdr*>, int flags); ErrorOr<FlatPtr> sys$recvmsg(int sockfd, Userspace<struct msghdr*>, int flags); - ErrorOr<FlatPtr> sys$getsockopt(Userspace<const Syscall::SC_getsockopt_params*>); - ErrorOr<FlatPtr> sys$setsockopt(Userspace<const Syscall::SC_setsockopt_params*>); - ErrorOr<FlatPtr> sys$getsockname(Userspace<const Syscall::SC_getsockname_params*>); - ErrorOr<FlatPtr> sys$getpeername(Userspace<const Syscall::SC_getpeername_params*>); - ErrorOr<FlatPtr> sys$socketpair(Userspace<const Syscall::SC_socketpair_params*>); + ErrorOr<FlatPtr> sys$getsockopt(Userspace<Syscall::SC_getsockopt_params const*>); + ErrorOr<FlatPtr> sys$setsockopt(Userspace<Syscall::SC_setsockopt_params const*>); + ErrorOr<FlatPtr> sys$getsockname(Userspace<Syscall::SC_getsockname_params const*>); + ErrorOr<FlatPtr> sys$getpeername(Userspace<Syscall::SC_getpeername_params const*>); + ErrorOr<FlatPtr> sys$socketpair(Userspace<Syscall::SC_socketpair_params const*>); ErrorOr<FlatPtr> sys$sched_setparam(pid_t pid, Userspace<const struct sched_param*>); ErrorOr<FlatPtr> sys$sched_getparam(pid_t pid, Userspace<struct sched_param*>); - ErrorOr<FlatPtr> sys$create_thread(void* (*)(void*), Userspace<const Syscall::SC_create_thread_params*>); + ErrorOr<FlatPtr> sys$create_thread(void* (*)(void*), Userspace<Syscall::SC_create_thread_params const*>); [[noreturn]] void sys$exit_thread(Userspace<void*>, Userspace<void*>, size_t); ErrorOr<FlatPtr> sys$join_thread(pid_t tid, Userspace<void**> exit_value); ErrorOr<FlatPtr> sys$detach_thread(pid_t tid); - ErrorOr<FlatPtr> sys$set_thread_name(pid_t tid, Userspace<const char*> buffer, size_t buffer_size); + ErrorOr<FlatPtr> sys$set_thread_name(pid_t tid, Userspace<char const*> buffer, size_t buffer_size); ErrorOr<FlatPtr> sys$get_thread_name(pid_t tid, Userspace<char*> buffer, size_t buffer_size); ErrorOr<FlatPtr> sys$kill_thread(pid_t tid, int signal); - ErrorOr<FlatPtr> sys$rename(Userspace<const Syscall::SC_rename_params*>); - ErrorOr<FlatPtr> sys$mknod(Userspace<const Syscall::SC_mknod_params*>); - ErrorOr<FlatPtr> sys$realpath(Userspace<const Syscall::SC_realpath_params*>); + ErrorOr<FlatPtr> sys$rename(Userspace<Syscall::SC_rename_params const*>); + ErrorOr<FlatPtr> sys$mknod(Userspace<Syscall::SC_mknod_params const*>); + ErrorOr<FlatPtr> sys$realpath(Userspace<Syscall::SC_realpath_params const*>); ErrorOr<FlatPtr> sys$getrandom(Userspace<void*>, size_t, unsigned int); - ErrorOr<FlatPtr> sys$getkeymap(Userspace<const Syscall::SC_getkeymap_params*>); - ErrorOr<FlatPtr> sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*>); + ErrorOr<FlatPtr> sys$getkeymap(Userspace<Syscall::SC_getkeymap_params const*>); + ErrorOr<FlatPtr> sys$setkeymap(Userspace<Syscall::SC_setkeymap_params const*>); ErrorOr<FlatPtr> sys$profiling_enable(pid_t, Userspace<u64 const*>); ErrorOr<FlatPtr> sys$profiling_disable(pid_t); ErrorOr<FlatPtr> sys$profiling_free_buffer(pid_t); - ErrorOr<FlatPtr> sys$futex(Userspace<const Syscall::SC_futex_params*>); - ErrorOr<FlatPtr> sys$pledge(Userspace<const Syscall::SC_pledge_params*>); - ErrorOr<FlatPtr> sys$unveil(Userspace<const Syscall::SC_unveil_params*>); + ErrorOr<FlatPtr> sys$futex(Userspace<Syscall::SC_futex_params const*>); + ErrorOr<FlatPtr> sys$pledge(Userspace<Syscall::SC_pledge_params const*>); + ErrorOr<FlatPtr> sys$unveil(Userspace<Syscall::SC_unveil_params const*>); ErrorOr<FlatPtr> sys$perf_event(int type, FlatPtr arg1, FlatPtr arg2); ErrorOr<FlatPtr> sys$perf_register_string(Userspace<char const*>, size_t); ErrorOr<FlatPtr> sys$get_stack_bounds(Userspace<FlatPtr*> stack_base, Userspace<size_t*> stack_size); - ErrorOr<FlatPtr> sys$ptrace(Userspace<const Syscall::SC_ptrace_params*>); + ErrorOr<FlatPtr> sys$ptrace(Userspace<Syscall::SC_ptrace_params const*>); ErrorOr<FlatPtr> sys$sendfd(int sockfd, int fd); ErrorOr<FlatPtr> sys$recvfd(int sockfd, int options); ErrorOr<FlatPtr> sys$sysconf(int name); ErrorOr<FlatPtr> sys$disown(ProcessID); - ErrorOr<FlatPtr> sys$allocate_tls(Userspace<const char*> initial_data, size_t); + ErrorOr<FlatPtr> sys$allocate_tls(Userspace<char const*> initial_data, size_t); ErrorOr<FlatPtr> sys$prctl(int option, FlatPtr arg1, FlatPtr arg2); - ErrorOr<FlatPtr> sys$set_coredump_metadata(Userspace<const Syscall::SC_set_coredump_metadata_params*>); + ErrorOr<FlatPtr> sys$set_coredump_metadata(Userspace<Syscall::SC_set_coredump_metadata_params const*>); ErrorOr<FlatPtr> sys$anon_create(size_t, int options); - ErrorOr<FlatPtr> sys$statvfs(Userspace<const Syscall::SC_statvfs_params*> user_params); + ErrorOr<FlatPtr> sys$statvfs(Userspace<Syscall::SC_statvfs_params const*> user_params); ErrorOr<FlatPtr> sys$fstatvfs(int fd, statvfs* buf); ErrorOr<FlatPtr> sys$map_time_page(); @@ -433,7 +433,7 @@ public: NonnullRefPtr<Custody> 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<void> peek_user_data(Span<u8> destination, Userspace<const u8*> address); - ErrorOr<FlatPtr> peek_user_data(Userspace<const FlatPtr*> address); + ErrorOr<void> peek_user_data(Span<u8> destination, Userspace<u8 const*> address); + ErrorOr<FlatPtr> peek_user_data(Userspace<FlatPtr const*> address); ErrorOr<void> poke_user_data(Userspace<FlatPtr*> address, FlatPtr data); void disowned_by_waiter(Process& process); @@ -510,7 +510,7 @@ public: ErrorOr<void> set_coredump_property(NonnullOwnPtr<KString> key, NonnullOwnPtr<KString> value); ErrorOr<void> try_set_coredump_property(StringView key, StringView value); - const NonnullRefPtrVector<Thread>& threads_for_coredump(Badge<Coredump>) const { return m_threads_for_coredump; } + NonnullRefPtrVector<Thread> const& threads_for_coredump(Badge<Coredump>) 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<void> require_no_promises() const; ErrorOr<void> validate_mmap_prot(int prot, bool map_stack, bool map_anonymous, Memory::Region const* region = nullptr) const; - ErrorOr<void> validate_inode_mmap_prot(int prot, const Inode& inode, bool map_shared) const; + ErrorOr<void> 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<void> do_exec(NonnullRefPtr<OpenFileDescription> main_program_description, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment, RefPtr<OpenFileDescription> interpreter_description, Thread*& new_main_thread, u32& prev_flags, const ElfW(Ehdr) & main_program_header); - ErrorOr<FlatPtr> do_write(OpenFileDescription&, const UserOrKernelBuffer&, size_t); + ErrorOr<FlatPtr> do_write(OpenFileDescription&, UserOrKernelBuffer const&, size_t); ErrorOr<FlatPtr> do_statvfs(FileSystem const& path, Custody const*, statvfs* buf); @@ -561,8 +561,8 @@ private: ErrorOr<siginfo_t> do_waitid(Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> waitee, int options); - static ErrorOr<NonnullOwnPtr<KString>> get_syscall_path_argument(Userspace<const char*> user_path, size_t path_length); - static ErrorOr<NonnullOwnPtr<KString>> get_syscall_path_argument(const Syscall::StringArgument&); + static ErrorOr<NonnullOwnPtr<KString>> get_syscall_path_argument(Userspace<char const*> user_path, size_t path_length); + static ErrorOr<NonnullOwnPtr<KString>> 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<void> procfs_get_thread_stack(ThreadID thread_id, KBufferBuilder& builder) const; ErrorOr<void> traverse_stacks_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const; - ErrorOr<NonnullRefPtr<Inode>> lookup_stacks_directory(const ProcFS&, StringView name) const; + ErrorOr<NonnullRefPtr<Inode>> lookup_stacks_directory(ProcFS const&, StringView name) const; ErrorOr<size_t> procfs_get_file_description_link(unsigned fd, KBufferBuilder& builder) const; ErrorOr<void> traverse_file_descriptions_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const; - ErrorOr<NonnullRefPtr<Inode>> lookup_file_descriptions_directory(const ProcFS&, StringView name) const; + ErrorOr<NonnullRefPtr<Inode>> 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<void> try_clone(const Kernel::Process::OpenFileDescriptions& other) + ErrorOr<void> 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<void(const OpenFileDescriptionAndFlags&)>) const; - ErrorOr<void> try_enumerate(Function<ErrorOr<void>(const OpenFileDescriptionAndFlags&)>) const; + void enumerate(Function<void(OpenFileDescriptionAndFlags const&)>) const; + ErrorOr<void> try_enumerate(Function<ErrorOr<void>(OpenFileDescriptionAndFlags const&)>) const; void change_each(Function<void(OpenFileDescriptionAndFlags&)>); ErrorOr<ScopedDescriptionAllocation> allocate(int first_candidate_fd = 0); @@ -746,7 +746,7 @@ public: } virtual InodeIndex component_index() const override; - virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(const ProcFS& procfs_instance) const override; + virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const override; virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual mode_t required_mode() const override { return 0555; } @@ -790,7 +790,7 @@ private: MutexProtected<OpenFileDescriptions> m_fds; - const bool m_is_kernel_process; + bool const m_is_kernel_process; Atomic<State> m_state { State::Running }; bool m_profiling { false }; Atomic<bool, AK::MemoryOrder::memory_order_relaxed> m_is_stopped { false }; @@ -865,7 +865,7 @@ template<IteratorFunction<Process&> 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<IteratorFunction<Process&> 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<IteratorFunction<Process&> 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<NonnullOwnPtr<KString>> try_copy_kstring_from_user(const Kernel::Syscall::StringArgument& string) +inline static ErrorOr<NonnullOwnPtr<KString>> try_copy_kstring_from_user(Kernel::Syscall::StringArgument const& string) { Userspace<char const*> characters((FlatPtr)string.characters); return try_copy_kstring_from_user(characters, string.length); diff --git a/Kernel/ProcessExposed.cpp b/Kernel/ProcessExposed.cpp index 59824d4768..603e281d5e 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<void> ProcFSSystemBoolean::try_generate(KBufferBuilder& builder) return builder.appendff("{}\n", static_cast<int>(value())); } -ErrorOr<size_t> ProcFSSystemBoolean::write_bytes(off_t, size_t count, const UserOrKernelBuffer& buffer, OpenFileDescription*) +ErrorOr<size_t> ProcFSSystemBoolean::write_bytes(off_t, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription*) { if (count != 1) return EINVAL; @@ -200,22 +200,22 @@ ErrorOr<size_t> ProcFSExposedLink::read_bytes(off_t offset, size_t count, UserOr return nread; } -ErrorOr<NonnullRefPtr<Inode>> ProcFSExposedLink::to_inode(const ProcFS& procfs_instance) const +ErrorOr<NonnullRefPtr<Inode>> ProcFSExposedLink::to_inode(ProcFS const& procfs_instance) const { return TRY(ProcFSLinkInode::try_create(procfs_instance, *this)); } -ErrorOr<NonnullRefPtr<Inode>> ProcFSExposedComponent::to_inode(const ProcFS& procfs_instance) const +ErrorOr<NonnullRefPtr<Inode>> ProcFSExposedComponent::to_inode(ProcFS const& procfs_instance) const { return TRY(ProcFSGlobalInode::try_create(procfs_instance, *this)); } -ErrorOr<NonnullRefPtr<Inode>> ProcFSExposedDirectory::to_inode(const ProcFS& procfs_instance) const +ErrorOr<NonnullRefPtr<Inode>> 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 146a4690e5..0f798ba166 100644 --- a/Kernel/ProcessExposed.h +++ b/Kernel/ProcessExposed.h @@ -68,7 +68,7 @@ public: virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { VERIFY_NOT_REACHED(); } virtual ErrorOr<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); } virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> lookup(StringView) { VERIFY_NOT_REACHED(); }; - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) { return EROFS; } + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) { return EROFS; } virtual ErrorOr<void> truncate(u64) { return EPERM; } virtual ErrorOr<void> set_mtime(time_t) { return ENOTIMPL; } @@ -83,7 +83,7 @@ public: return {}; } - virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(const ProcFS& procfs_instance) const; + virtual ErrorOr<NonnullRefPtr<Inode>> 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<void> traverse_as_directory(FileSystemID, Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> 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<NonnullRefPtr<Inode>> to_inode(const ProcFS& procfs_instance) const override final; + virtual ErrorOr<NonnullRefPtr<Inode>> 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<ProcFSExposedComponent> m_components; WeakPtr<ProcFSExposedDirectory> m_parent_directory; }; class ProcFSExposedLink : public ProcFSExposedComponent { public: - virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(const ProcFS& procfs_instance) const override final; + virtual ErrorOr<NonnullRefPtr<Inode>> to_inode(ProcFS const& procfs_instance) const override final; virtual ErrorOr<size_t> read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription* description) const override; @@ -195,7 +195,7 @@ private: virtual ErrorOr<void> try_generate(KBufferBuilder&) override final; // ^ProcFSExposedComponent - virtual ErrorOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) override final; + virtual ErrorOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override final; virtual mode_t required_mode() const override final { return 0644; } virtual ErrorOr<void> truncate(u64) override final; virtual ErrorOr<void> set_mtime(time_t) override final; diff --git a/Kernel/ProcessGroup.h b/Kernel/ProcessGroup.h index 5d9309ceb8..901e4986ea 100644 --- a/Kernel/ProcessGroup.h +++ b/Kernel/ProcessGroup.h @@ -28,7 +28,7 @@ public: static ErrorOr<NonnullRefPtr<ProcessGroup>> try_find_or_create(ProcessGroupID); static RefPtr<ProcessGroup> 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 0bdbf1fdf1..97335f8891 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<NonnullRefPtr<Inode>> Process::ProcessProcFSTraits::to_inode(const ProcFS& procfs_instance) const +ErrorOr<NonnullRefPtr<Inode>> 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 388eb3e9ba..f101084e74 100644 --- a/Kernel/ProcessSpecificExposed.cpp +++ b/Kernel/ProcessSpecificExposed.cpp @@ -57,7 +57,7 @@ ErrorOr<void> Process::traverse_stacks_directory(FileSystemID fsid, Function<Err }); } -ErrorOr<NonnullRefPtr<Inode>> Process::lookup_stacks_directory(const ProcFS& procfs, StringView name) const +ErrorOr<NonnullRefPtr<Inode>> 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<NonnullRefPtr<Inode>> Process::lookup_stacks_directory(const ProcFS& pro auto needle = maybe_needle.release_value(); ErrorOr<NonnullRefPtr<ProcFSProcessPropertyInode>> 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<void> Process::traverse_file_descriptions_directory(FileSystemID fsid, F return {}; } -ErrorOr<NonnullRefPtr<Inode>> Process::lookup_file_descriptions_directory(const ProcFS& procfs, StringView name) const +ErrorOr<NonnullRefPtr<Inode>> 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 ea4e25a7b3..8aaf0eaaf7 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<const u8*>(&event_data), sizeof(T)); + m_pools[pool].update(reinterpret_cast<u8 const*>(&event_data), sizeof(T)); } [[nodiscard]] bool is_seeded() const diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index d5d94a62af..9695086004 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 1cff99c019..a1d4abde60 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 0f3c21c249..ca52b59216 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -12,7 +12,7 @@ #include <Kernel/Memory/MemoryManager.h> #include <Kernel/StdLib.h> -ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<const char*> user_str, size_t user_str_size) +ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<char const*> 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<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<con void* fault_at; ssize_t length = Kernel::safe_strnlen(user_str.unsafe_userspace_ptr(), user_str_size, fault_at); if (length < 0) { - dbgln("copy_kstring_from_user({:p}, {}) failed at {} (strnlen)", static_cast<const void*>(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); + dbgln("copy_kstring_from_user({:p}, {}) failed at {} (strnlen)", static_cast<void const*>(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); return EFAULT; } char* buffer; @@ -33,7 +33,7 @@ ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<con return new_string; if (!Kernel::safe_memcpy(buffer, user_str.unsafe_userspace_ptr(), (size_t)length, fault_at)) { - dbgln("copy_kstring_from_user({:p}, {}) failed at {} (memcpy)", static_cast<const void*>(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); + dbgln("copy_kstring_from_user({:p}, {}) failed at {} (memcpy)", static_cast<void const*>(user_str.unsafe_userspace_ptr()), user_str_size, VirtualAddress { fault_at }); return EFAULT; } return new_string; @@ -62,7 +62,7 @@ ErrorOr<Time> copy_time_from_user<const timespec>(Userspace<timespec const*> src template<> ErrorOr<Time> copy_time_from_user<timespec>(Userspace<timespec*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); } -Optional<u32> user_atomic_fetch_add_relaxed(volatile u32* var, u32 val) +Optional<u32> user_atomic_fetch_add_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -73,7 +73,7 @@ Optional<u32> user_atomic_fetch_add_relaxed(volatile u32* var, u32 val) return Kernel::safe_atomic_fetch_add_relaxed(var, val); } -Optional<u32> user_atomic_exchange_relaxed(volatile u32* var, u32 val) +Optional<u32> user_atomic_exchange_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -84,7 +84,7 @@ Optional<u32> user_atomic_exchange_relaxed(volatile u32* var, u32 val) return Kernel::safe_atomic_exchange_relaxed(var, val); } -Optional<u32> user_atomic_load_relaxed(volatile u32* var) +Optional<u32> user_atomic_load_relaxed(u32 volatile* var) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -95,7 +95,7 @@ Optional<u32> user_atomic_load_relaxed(volatile u32* var) return Kernel::safe_atomic_load_relaxed(var); } -bool user_atomic_store_relaxed(volatile u32* var, u32 val) +bool user_atomic_store_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return false; // not aligned! @@ -106,7 +106,7 @@ bool user_atomic_store_relaxed(volatile u32* var, u32 val) return Kernel::safe_atomic_store_relaxed(var, val); } -Optional<bool> user_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) +Optional<bool> user_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -118,7 +118,7 @@ Optional<bool> user_atomic_compare_exchange_relaxed(volatile u32* var, u32& expe return Kernel::safe_atomic_compare_exchange_relaxed(var, expected, val); } -Optional<u32> user_atomic_fetch_and_relaxed(volatile u32* var, u32 val) +Optional<u32> user_atomic_fetch_and_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -129,7 +129,7 @@ Optional<u32> user_atomic_fetch_and_relaxed(volatile u32* var, u32 val) return Kernel::safe_atomic_fetch_and_relaxed(var, val); } -Optional<u32> user_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val) +Optional<u32> user_atomic_fetch_and_not_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -140,7 +140,7 @@ Optional<u32> user_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val) return Kernel::safe_atomic_fetch_and_not_relaxed(var, val); } -Optional<u32> user_atomic_fetch_or_relaxed(volatile u32* var, u32 val) +Optional<u32> user_atomic_fetch_or_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -151,7 +151,7 @@ Optional<u32> user_atomic_fetch_or_relaxed(volatile u32* var, u32 val) return Kernel::safe_atomic_fetch_or_relaxed(var, val); } -Optional<u32> user_atomic_fetch_xor_relaxed(volatile u32* var, u32 val) +Optional<u32> user_atomic_fetch_xor_relaxed(u32 volatile* var, u32 val) { if (FlatPtr(var) & 3) return {}; // not aligned! @@ -220,7 +220,7 @@ FlatPtr missing_got_workaround() extern "C" { -const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) +void const* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) { return AK::memmem(haystack, haystack_length, needle, needle_length); } diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h index c2a933d5fb..c54bd20b20 100644 --- a/Kernel/StdLib.h +++ b/Kernel/StdLib.h @@ -14,38 +14,38 @@ #include <Kernel/KString.h> #include <Kernel/UnixTypes.h> -ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<const char*>, size_t); +ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<char const*>, size_t); ErrorOr<Time> copy_time_from_user(timespec const*); ErrorOr<Time> copy_time_from_user(timeval const*); template<typename T> ErrorOr<Time> copy_time_from_user(Userspace<T*>); -[[nodiscard]] Optional<u32> user_atomic_fetch_add_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional<u32> user_atomic_exchange_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional<u32> user_atomic_load_relaxed(volatile u32* var); -[[nodiscard]] bool user_atomic_store_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional<bool> user_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val); -[[nodiscard]] Optional<u32> user_atomic_fetch_and_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional<u32> user_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional<u32> user_atomic_fetch_or_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional<u32> user_atomic_fetch_xor_relaxed(volatile u32* var, u32 val); - -ErrorOr<void> copy_to_user(void*, const void*, size_t); -ErrorOr<void> copy_from_user(void*, const void*, size_t); +[[nodiscard]] Optional<u32> user_atomic_fetch_add_relaxed(u32 volatile* var, u32 val); +[[nodiscard]] Optional<u32> user_atomic_exchange_relaxed(u32 volatile* var, u32 val); +[[nodiscard]] Optional<u32> user_atomic_load_relaxed(u32 volatile* var); +[[nodiscard]] bool user_atomic_store_relaxed(u32 volatile* var, u32 val); +[[nodiscard]] Optional<bool> user_atomic_compare_exchange_relaxed(u32 volatile* var, u32& expected, u32 val); +[[nodiscard]] Optional<u32> user_atomic_fetch_and_relaxed(u32 volatile* var, u32 val); +[[nodiscard]] Optional<u32> user_atomic_fetch_and_not_relaxed(u32 volatile* var, u32 val); +[[nodiscard]] Optional<u32> user_atomic_fetch_or_relaxed(u32 volatile* var, u32 val); +[[nodiscard]] Optional<u32> user_atomic_fetch_xor_relaxed(u32 volatile* var, u32 val); + +ErrorOr<void> copy_to_user(void*, void const*, size_t); +ErrorOr<void> copy_from_user(void*, void const*, size_t); ErrorOr<void> memset_user(void*, int, size_t); extern "C" { -void* memcpy(void*, const void*, size_t); -[[nodiscard]] int strncmp(const char* s1, const char* s2, size_t n); -[[nodiscard]] char* strstr(const char* haystack, const char* needle); -[[nodiscard]] int strcmp(char const*, const char*); -[[nodiscard]] size_t strlen(const char*); -[[nodiscard]] size_t strnlen(const char*, size_t); +void* memcpy(void*, void const*, size_t); +[[nodiscard]] int strncmp(char const* s1, char const* s2, size_t n); +[[nodiscard]] char* strstr(char const* haystack, char const* needle); +[[nodiscard]] int strcmp(char const*, char const*); +[[nodiscard]] size_t strlen(char const*); +[[nodiscard]] size_t strnlen(char const*, size_t); void* memset(void*, int, size_t); -[[nodiscard]] int memcmp(const void*, const void*, size_t); -void* memmove(void* dest, const void* src, size_t n); -const void* memmem(const void* haystack, size_t, const void* needle, size_t); +[[nodiscard]] int memcmp(void const*, void const*, size_t); +void* memmove(void* dest, void const* src, size_t n); +void const* memmem(void const* haystack, size_t, void const* needle, size_t); [[nodiscard]] inline u16 ntohs(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); } [[nodiscard]] inline u16 htons(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); } @@ -107,7 +107,7 @@ template<typename T> } template<typename T> -[[nodiscard]] inline ErrorOr<void> copy_to_user(Userspace<T*> dest, const void* src, size_t size) +[[nodiscard]] inline ErrorOr<void> copy_to_user(Userspace<T*> dest, void const* src, size_t size) { static_assert(IsTriviallyCopyable<T>); return copy_to_user(dest.unsafe_userspace_ptr(), src, size); diff --git a/Kernel/Storage/ATA/AHCI.h b/Kernel/Storage/ATA/AHCI.h index 9502208d3b..988994ea2a 100644 --- a/Kernel/Storage/ATA/AHCI.h +++ b/Kernel/Storage/ATA/AHCI.h @@ -130,13 +130,13 @@ namespace Kernel::AHCI { class MaskedBitField { public: - explicit MaskedBitField(volatile u32& bitfield_register) + explicit MaskedBitField(u32 volatile& bitfield_register) : m_bitfield(bitfield_register) , m_bit_mask(0xffffffff) { } - MaskedBitField(volatile u32& bitfield_register, u32 bit_mask) + MaskedBitField(u32 volatile& bitfield_register, u32 bit_mask) : m_bitfield(bitfield_register) , m_bit_mask(bit_mask) { @@ -180,14 +180,14 @@ public: u32 bit_mask() const { return m_bit_mask; }; // Disable default implementations that would use surprising integer promotion. - bool operator==(const MaskedBitField&) const = delete; - bool operator<=(const MaskedBitField&) const = delete; - bool operator>=(const MaskedBitField&) const = delete; - bool operator<(const MaskedBitField&) const = delete; - bool operator>(const MaskedBitField&) const = delete; + bool operator==(MaskedBitField const&) const = delete; + bool operator<=(MaskedBitField const&) const = delete; + bool operator>=(MaskedBitField const&) const = delete; + bool operator<(MaskedBitField const&) const = delete; + bool operator>(MaskedBitField const&) const = delete; private: - volatile u32& m_bitfield; + u32 volatile& m_bitfield; const u32 m_bit_mask; }; @@ -321,7 +321,7 @@ enum SErr : u32 { class PortInterruptStatusBitField { public: - explicit PortInterruptStatusBitField(volatile u32& bitfield_register) + explicit PortInterruptStatusBitField(u32 volatile& bitfield_register) : m_bitfield(bitfield_register) { } @@ -331,20 +331,20 @@ public: void clear() { m_bitfield = 0xffffffff; } // Disable default implementations that would use surprising integer promotion. - bool operator==(const MaskedBitField&) const = delete; - bool operator<=(const MaskedBitField&) const = delete; - bool operator>=(const MaskedBitField&) const = delete; - bool operator<(const MaskedBitField&) const = delete; - bool operator>(const MaskedBitField&) const = delete; + bool operator==(MaskedBitField const&) const = delete; + bool operator<=(MaskedBitField const&) const = delete; + bool operator>=(MaskedBitField const&) const = delete; + bool operator<(MaskedBitField const&) const = delete; + bool operator>(MaskedBitField const&) const = delete; private: - volatile u32& m_bitfield; + u32 volatile& m_bitfield; }; class PortInterruptEnableBitField { public: - explicit PortInterruptEnableBitField(volatile u32& bitfield_register) + explicit PortInterruptEnableBitField(u32 volatile& bitfield_register) : m_bitfield(bitfield_register) { } @@ -357,14 +357,14 @@ public: void set_all() { m_bitfield = 0xffffffff; } // Disable default implementations that would use surprising integer promotion. - bool operator==(const MaskedBitField&) const = delete; - bool operator<=(const MaskedBitField&) const = delete; - bool operator>=(const MaskedBitField&) const = delete; - bool operator<(const MaskedBitField&) const = delete; - bool operator>(const MaskedBitField&) const = delete; + bool operator==(MaskedBitField const&) const = delete; + bool operator<=(MaskedBitField const&) const = delete; + bool operator>=(MaskedBitField const&) const = delete; + bool operator<(MaskedBitField const&) const = delete; + bool operator>(MaskedBitField const&) const = delete; private: - volatile u32& m_bitfield; + u32 volatile& m_bitfield; }; struct [[gnu::packed]] PortRegisters { diff --git a/Kernel/Storage/ATA/AHCIController.cpp b/Kernel/Storage/ATA/AHCIController.cpp index b505f40f5b..4d18840018 100644 --- a/Kernel/Storage/ATA/AHCIController.cpp +++ b/Kernel/Storage/ATA/AHCIController.cpp @@ -51,7 +51,7 @@ size_t AHCIController::devices_count() const { size_t count = 0; for (auto& port_handler : m_handlers) { - port_handler.enumerate_ports([&](const AHCIPort& port) { + port_handler.enumerate_ports([&](AHCIPort const& port) { if (port.connected_device()) count++; }); @@ -59,7 +59,7 @@ size_t AHCIController::devices_count() const return count; } -void AHCIController::start_request(const ATADevice& device, AsyncBlockDeviceRequest& request) +void AHCIController::start_request(ATADevice const& device, AsyncBlockDeviceRequest& request) { // FIXME: For now we have one port handler, check all of them... VERIFY(m_handlers.size() > 0); @@ -154,7 +154,7 @@ void AHCIController::initialize_hba(PCI::DeviceIdentifier const& pci_device_iden PCI::enable_bus_mastering(pci_address()); enable_global_interrupts(); m_handlers.append(AHCIPortHandler::create(*this, pci_device_identifier.interrupt_line().value(), - AHCI::MaskedBitField((volatile u32&)(hba().control_regs.pi)))); + AHCI::MaskedBitField((u32 volatile&)(hba().control_regs.pi)))); } void AHCIController::disable_global_interrupts() const diff --git a/Kernel/Storage/ATA/AHCIController.h b/Kernel/Storage/ATA/AHCIController.h index f59603a1f1..687a61537b 100644 --- a/Kernel/Storage/ATA/AHCIController.h +++ b/Kernel/Storage/ATA/AHCIController.h @@ -32,7 +32,7 @@ public: virtual bool reset() override; virtual bool shutdown() override; virtual size_t devices_count() const override; - virtual void start_request(const ATADevice&, AsyncBlockDeviceRequest&) override; + virtual void start_request(ATADevice const&, AsyncBlockDeviceRequest&) override; virtual void complete_current_request(AsyncDeviceRequest::RequestResult) override; const AHCI::HBADefinedCapabilities& hba_capabilities() const { return m_capabilities; }; diff --git a/Kernel/Storage/ATA/AHCIPort.cpp b/Kernel/Storage/ATA/AHCIPort.cpp index c98b6fc8bb..24df2a7383 100644 --- a/Kernel/Storage/ATA/AHCIPort.cpp +++ b/Kernel/Storage/ATA/AHCIPort.cpp @@ -20,17 +20,17 @@ namespace Kernel { -NonnullRefPtr<AHCIPort> AHCIPort::create(const AHCIPortHandler& handler, volatile AHCI::PortRegisters& registers, u32 port_index) +NonnullRefPtr<AHCIPort> AHCIPort::create(AHCIPortHandler const& handler, volatile AHCI::PortRegisters& registers, u32 port_index) { return adopt_ref(*new AHCIPort(handler, registers, port_index)); } -AHCIPort::AHCIPort(const AHCIPortHandler& handler, volatile AHCI::PortRegisters& registers, u32 port_index) +AHCIPort::AHCIPort(AHCIPortHandler const& handler, volatile AHCI::PortRegisters& registers, u32 port_index) : m_port_index(port_index) , m_port_registers(registers) , m_parent_handler(handler) - , m_interrupt_status((volatile u32&)m_port_registers.is) - , m_interrupt_enable((volatile u32&)m_port_registers.ie) + , m_interrupt_status((u32 volatile&)m_port_registers.is) + , m_interrupt_enable((u32 volatile&)m_port_registers.ie) { if (is_interface_disabled()) { m_disabled_by_firmware = true; @@ -319,7 +319,7 @@ bool AHCIPort::initialize() return true; } -const char* AHCIPort::try_disambiguate_sata_status() +char const* AHCIPort::try_disambiguate_sata_status() { switch (m_port_registers.ssts & 0xf) { case 0: diff --git a/Kernel/Storage/ATA/AHCIPort.h b/Kernel/Storage/ATA/AHCIPort.h index 9e11051d24..6799a1d6ba 100644 --- a/Kernel/Storage/ATA/AHCIPort.h +++ b/Kernel/Storage/ATA/AHCIPort.h @@ -37,7 +37,7 @@ class AHCIPort friend class AHCIController; public: - UNMAP_AFTER_INIT static NonnullRefPtr<AHCIPort> create(const AHCIPortHandler&, volatile AHCI::PortRegisters&, u32 port_index); + UNMAP_AFTER_INIT static NonnullRefPtr<AHCIPort> create(AHCIPortHandler const&, volatile AHCI::PortRegisters&, u32 port_index); u32 port_index() const { return m_port_index; } u32 representative_port_index() const { return port_index() + 1; } @@ -54,13 +54,13 @@ private: bool is_phy_enabled() const { return (m_port_registers.ssts & 0xf) == 3; } bool initialize(); - UNMAP_AFTER_INIT AHCIPort(const AHCIPortHandler&, volatile AHCI::PortRegisters&, u32 port_index); + UNMAP_AFTER_INIT AHCIPort(AHCIPortHandler const&, volatile AHCI::PortRegisters&, u32 port_index); ALWAYS_INLINE void clear_sata_error_register() const; void eject(); - const char* try_disambiguate_sata_status(); + char const* try_disambiguate_sata_status(); void try_disambiguate_sata_error(); bool initiate_sata_reset(); diff --git a/Kernel/Storage/ATA/AHCIPortHandler.cpp b/Kernel/Storage/ATA/AHCIPortHandler.cpp index b009547767..93ca767302 100644 --- a/Kernel/Storage/ATA/AHCIPortHandler.cpp +++ b/Kernel/Storage/ATA/AHCIPortHandler.cpp @@ -46,7 +46,7 @@ AHCIPortHandler::AHCIPortHandler(AHCIController& controller, u8 irq, AHCI::Maske } } -void AHCIPortHandler::enumerate_ports(Function<void(const AHCIPort&)> callback) const +void AHCIPortHandler::enumerate_ports(Function<void(AHCIPort const&)> callback) const { for (auto& port : m_handled_ports) { callback(*port.value); @@ -70,7 +70,7 @@ PhysicalAddress AHCIPortHandler::get_identify_metadata_physical_region(u32 port_ AHCI::MaskedBitField AHCIPortHandler::create_pending_ports_interrupts_bitfield() const { - return AHCI::MaskedBitField((volatile u32&)m_parent_controller->hba().control_regs.is, m_taken_ports.bit_mask()); + return AHCI::MaskedBitField((u32 volatile&)m_parent_controller->hba().control_regs.is, m_taken_ports.bit_mask()); } AHCI::HBADefinedCapabilities AHCIPortHandler::hba_capabilities() const @@ -80,7 +80,7 @@ AHCI::HBADefinedCapabilities AHCIPortHandler::hba_capabilities() const AHCIPortHandler::~AHCIPortHandler() = default; -bool AHCIPortHandler::handle_irq(const RegisterState&) +bool AHCIPortHandler::handle_irq(RegisterState const&) { dbgln_if(AHCI_DEBUG, "AHCI Port Handler: IRQ received"); if (m_pending_ports_interrupts.is_zeroed()) diff --git a/Kernel/Storage/ATA/AHCIPortHandler.h b/Kernel/Storage/ATA/AHCIPortHandler.h index f44c992605..235b5b4162 100644 --- a/Kernel/Storage/ATA/AHCIPortHandler.h +++ b/Kernel/Storage/ATA/AHCIPortHandler.h @@ -47,7 +47,7 @@ private: UNMAP_AFTER_INIT AHCIPortHandler(AHCIController&, u8 irq, AHCI::MaskedBitField taken_ports); //^ IRQHandler - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; enum class Direction : u8 { Read, @@ -59,7 +59,7 @@ private: void start_request(AsyncBlockDeviceRequest&, bool, bool, u16); void complete_current_request(AsyncDeviceRequest::RequestResult); - void enumerate_ports(Function<void(const AHCIPort&)> callback) const; + void enumerate_ports(Function<void(AHCIPort const&)> callback) const; RefPtr<AHCIPort> port_at_index(u32 port_index) const; // Data members diff --git a/Kernel/Storage/ATA/ATAController.h b/Kernel/Storage/ATA/ATAController.h index de0643f12e..02885d77a2 100644 --- a/Kernel/Storage/ATA/ATAController.h +++ b/Kernel/Storage/ATA/ATAController.h @@ -21,7 +21,7 @@ class ATAController : public StorageController , public Weakable<ATAController> { public: - virtual void start_request(const ATADevice&, AsyncBlockDeviceRequest&) = 0; + virtual void start_request(ATADevice const&, AsyncBlockDeviceRequest&) = 0; protected: ATAController() = default; diff --git a/Kernel/Storage/ATA/ATADevice.cpp b/Kernel/Storage/ATA/ATADevice.cpp index d4591affe1..b7c14f1d74 100644 --- a/Kernel/Storage/ATA/ATADevice.cpp +++ b/Kernel/Storage/ATA/ATADevice.cpp @@ -13,7 +13,7 @@ namespace Kernel { -ATADevice::ATADevice(const ATAController& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name) +ATADevice::ATADevice(ATAController const& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name) : StorageDevice(StorageManagement::storage_type_major_number(), minor_number, logical_sector_size, max_addressable_block, move(early_storage_name)) , m_controller(controller) , m_ata_address(ata_address) diff --git a/Kernel/Storage/ATA/ATADevice.h b/Kernel/Storage/ATA/ATADevice.h index e469dcfe8c..5700353dad 100644 --- a/Kernel/Storage/ATA/ATADevice.h +++ b/Kernel/Storage/ATA/ATADevice.h @@ -33,10 +33,10 @@ public: virtual void start_request(AsyncBlockDeviceRequest&) override; u16 ata_capabilites() const { return m_capabilities; } - const Address& ata_address() const { return m_ata_address; } + Address const& ata_address() const { return m_ata_address; } protected: - ATADevice(const ATAController&, Address, MinorNumber, u16, u16, u64, NonnullOwnPtr<KString>); + ATADevice(ATAController const&, Address, MinorNumber, u16, u16, u64, NonnullOwnPtr<KString>); WeakPtr<ATAController> m_controller; const Address m_ata_address; diff --git a/Kernel/Storage/ATA/ATADiskDevice.cpp b/Kernel/Storage/ATA/ATADiskDevice.cpp index 4d2687725f..d0229b7c6c 100644 --- a/Kernel/Storage/ATA/ATADiskDevice.cpp +++ b/Kernel/Storage/ATA/ATADiskDevice.cpp @@ -14,7 +14,7 @@ namespace Kernel { -NonnullRefPtr<ATADiskDevice> ATADiskDevice::create(const ATAController& controller, ATADevice::Address ata_address, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block) +NonnullRefPtr<ATADiskDevice> ATADiskDevice::create(ATAController const& controller, ATADevice::Address ata_address, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block) { auto minor_device_number = StorageManagement::generate_storage_minor_number(); @@ -26,7 +26,7 @@ NonnullRefPtr<ATADiskDevice> ATADiskDevice::create(const ATAController& controll return disk_device_or_error.release_value(); } -ATADiskDevice::ATADiskDevice(const ATAController& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name) +ATADiskDevice::ATADiskDevice(ATAController const& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name) : ATADevice(controller, ata_address, minor_number, capabilities, logical_sector_size, max_addressable_block, move(early_storage_name)) { } diff --git a/Kernel/Storage/ATA/ATADiskDevice.h b/Kernel/Storage/ATA/ATADiskDevice.h index c71672321e..4f08973ca8 100644 --- a/Kernel/Storage/ATA/ATADiskDevice.h +++ b/Kernel/Storage/ATA/ATADiskDevice.h @@ -19,14 +19,14 @@ class ATADiskDevice final : public ATADevice { friend class DeviceManagement; public: - static NonnullRefPtr<ATADiskDevice> create(const ATAController&, ATADevice::Address, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block); + static NonnullRefPtr<ATADiskDevice> create(ATAController const&, ATADevice::Address, u16 capabilities, u16 logical_sector_size, u64 max_addressable_block); virtual ~ATADiskDevice() override; // ^StorageDevice virtual CommandSet command_set() const override { return CommandSet::ATA; } private: - ATADiskDevice(const ATAController&, Address, MinorNumber, u16, u16, u64, NonnullOwnPtr<KString>); + ATADiskDevice(ATAController const&, Address, MinorNumber, u16, u16, u64, NonnullOwnPtr<KString>); // ^DiskDevice virtual StringView class_name() const override; diff --git a/Kernel/Storage/ATA/ATAPIDiscDevice.cpp b/Kernel/Storage/ATA/ATAPIDiscDevice.cpp index f7ea93f4b6..ac8ee20f94 100644 --- a/Kernel/Storage/ATA/ATAPIDiscDevice.cpp +++ b/Kernel/Storage/ATA/ATAPIDiscDevice.cpp @@ -14,7 +14,7 @@ namespace Kernel { -NonnullRefPtr<ATAPIDiscDevice> ATAPIDiscDevice::create(const ATAController& controller, ATADevice::Address ata_address, u16 capabilities, u64 max_addressable_block) +NonnullRefPtr<ATAPIDiscDevice> ATAPIDiscDevice::create(ATAController const& controller, ATADevice::Address ata_address, u16 capabilities, u64 max_addressable_block) { auto minor_device_number = StorageManagement::generate_storage_minor_number(); @@ -26,7 +26,7 @@ NonnullRefPtr<ATAPIDiscDevice> ATAPIDiscDevice::create(const ATAController& cont return disc_device_or_error.release_value(); } -ATAPIDiscDevice::ATAPIDiscDevice(const ATAController& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name) +ATAPIDiscDevice::ATAPIDiscDevice(ATAController const& controller, ATADevice::Address ata_address, MinorNumber minor_number, u16 capabilities, u64 max_addressable_block, NonnullOwnPtr<KString> early_storage_name) : ATADevice(controller, ata_address, minor_number, capabilities, 0, max_addressable_block, move(early_storage_name)) { } diff --git a/Kernel/Storage/ATA/ATAPIDiscDevice.h b/Kernel/Storage/ATA/ATAPIDiscDevice.h index 12a18bde33..bfb80befe9 100644 --- a/Kernel/Storage/ATA/ATAPIDiscDevice.h +++ b/Kernel/Storage/ATA/ATAPIDiscDevice.h @@ -19,14 +19,14 @@ class ATAPIDiscDevice final : public ATADevice { friend class DeviceManagement; public: - static NonnullRefPtr<ATAPIDiscDevice> create(const ATAController&, ATADevice::Address, u16 capabilities, u64 max_addressable_block); + static NonnullRefPtr<ATAPIDiscDevice> create(ATAController const&, ATADevice::Address, u16 capabilities, u64 max_addressable_block); virtual ~ATAPIDiscDevice() override; // ^StorageDevice virtual CommandSet command_set() const override { return CommandSet::SCSI; } private: - ATAPIDiscDevice(const ATAController&, Address, MinorNumber, u16, u64, NonnullOwnPtr<KString>); + ATAPIDiscDevice(ATAController const&, Address, MinorNumber, u16, u64, NonnullOwnPtr<KString>); // ^DiskDevice virtual StringView class_name() const override; diff --git a/Kernel/Storage/ATA/BMIDEChannel.cpp b/Kernel/Storage/ATA/BMIDEChannel.cpp index f46251f53b..2e6e40ce22 100644 --- a/Kernel/Storage/ATA/BMIDEChannel.cpp +++ b/Kernel/Storage/ATA/BMIDEChannel.cpp @@ -13,23 +13,23 @@ namespace Kernel { -UNMAP_AFTER_INIT NonnullRefPtr<BMIDEChannel> BMIDEChannel::create(const IDEController& ide_controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) +UNMAP_AFTER_INIT NonnullRefPtr<BMIDEChannel> BMIDEChannel::create(IDEController const& ide_controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) { return adopt_ref(*new BMIDEChannel(ide_controller, io_group, type)); } -UNMAP_AFTER_INIT NonnullRefPtr<BMIDEChannel> BMIDEChannel::create(const IDEController& ide_controller, u8 irq, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) +UNMAP_AFTER_INIT NonnullRefPtr<BMIDEChannel> BMIDEChannel::create(IDEController const& ide_controller, u8 irq, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) { return adopt_ref(*new BMIDEChannel(ide_controller, irq, io_group, type)); } -UNMAP_AFTER_INIT BMIDEChannel::BMIDEChannel(const IDEController& controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) +UNMAP_AFTER_INIT BMIDEChannel::BMIDEChannel(IDEController const& controller, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) : IDEChannel(controller, io_group, type) { initialize(); } -UNMAP_AFTER_INIT BMIDEChannel::BMIDEChannel(const IDEController& controller, u8 irq, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) +UNMAP_AFTER_INIT BMIDEChannel::BMIDEChannel(IDEController const& controller, u8 irq, IDEChannel::IOAddressGroup io_group, IDEChannel::ChannelType type) : IDEChannel(controller, irq, io_group, type) { initialize(); @@ -71,7 +71,7 @@ static void print_ide_status(u8 status) (status & ATA_SR_ERR) != 0); } -bool BMIDEChannel::handle_irq(const RegisterState&) +bool BMIDEChannel::handle_irq(RegisterState const&) { u8 status = m_io_group.io_base().offset(ATA_REG_STATUS).in<u8>(); diff --git a/Kernel/Storage/ATA/BMIDEChannel.h b/Kernel/Storage/ATA/BMIDEChannel.h index 5f948149e5..89d7f09090 100644 --- a/Kernel/Storage/ATA/BMIDEChannel.h +++ b/Kernel/Storage/ATA/BMIDEChannel.h @@ -25,21 +25,21 @@ class BMIDEChannel final : public IDEChannel { friend class PATADiskDevice; public: - static NonnullRefPtr<BMIDEChannel> create(const IDEController&, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); - static NonnullRefPtr<BMIDEChannel> create(const IDEController&, u8 irq, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); + static NonnullRefPtr<BMIDEChannel> create(IDEController const&, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); + static NonnullRefPtr<BMIDEChannel> create(IDEController const&, u8 irq, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); virtual ~BMIDEChannel() override {}; virtual bool is_dma_enabled() const override { return true; }; private: - BMIDEChannel(const IDEController&, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); - BMIDEChannel(const IDEController&, u8 irq, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); + BMIDEChannel(IDEController const&, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); + BMIDEChannel(IDEController const&, u8 irq, IDEChannel::IOAddressGroup, IDEChannel::ChannelType type); void initialize(); void complete_current_request(AsyncDeviceRequest::RequestResult); //^ IRQHandler - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; //* IDEChannel virtual void send_ata_io_command(LBAMode lba_mode, Direction direction) const override; diff --git a/Kernel/Storage/ATA/IDEChannel.cpp b/Kernel/Storage/ATA/IDEChannel.cpp index 0efb001fd2..d01dd5a65e 100644 --- a/Kernel/Storage/ATA/IDEChannel.cpp +++ b/Kernel/Storage/ATA/IDEChannel.cpp @@ -22,12 +22,12 @@ namespace Kernel { #define PATA_PRIMARY_IRQ 14 #define PATA_SECONDARY_IRQ 15 -UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(const IDEController& controller, IOAddressGroup io_group, ChannelType type) +UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(IDEController const& controller, IOAddressGroup io_group, ChannelType type) { return adopt_ref(*new IDEChannel(controller, io_group, type)); } -UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(const IDEController& controller, u8 irq, IOAddressGroup io_group, ChannelType type) +UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(IDEController const& controller, u8 irq, IOAddressGroup io_group, ChannelType type) { return adopt_ref(*new IDEChannel(controller, irq, io_group, type)); } @@ -77,7 +77,7 @@ UNMAP_AFTER_INIT void IDEChannel::initialize() clear_pending_interrupts(); } -UNMAP_AFTER_INIT IDEChannel::IDEChannel(const IDEController& controller, u8 irq, IOAddressGroup io_group, ChannelType type) +UNMAP_AFTER_INIT IDEChannel::IDEChannel(IDEController const& controller, u8 irq, IOAddressGroup io_group, ChannelType type) : IRQHandler(irq) , m_channel_type(type) , m_io_group(io_group) @@ -86,7 +86,7 @@ UNMAP_AFTER_INIT IDEChannel::IDEChannel(const IDEController& controller, u8 irq, initialize(); } -UNMAP_AFTER_INIT IDEChannel::IDEChannel(const IDEController& controller, IOAddressGroup io_group, ChannelType type) +UNMAP_AFTER_INIT IDEChannel::IDEChannel(IDEController const& controller, IOAddressGroup io_group, ChannelType type) : IRQHandler(type == ChannelType::Primary ? PATA_PRIMARY_IRQ : PATA_SECONDARY_IRQ) , m_channel_type(type) , m_io_group(io_group) @@ -188,7 +188,7 @@ void IDEChannel::try_disambiguate_error() } } -bool IDEChannel::handle_irq(const RegisterState&) +bool IDEChannel::handle_irq(RegisterState const&) { u8 status = m_io_group.io_base().offset(ATA_REG_STATUS).in<u8>(); @@ -394,7 +394,7 @@ UNMAP_AFTER_INIT void IDEChannel::detect_disks() for (u32 i = 93; i > 54 && bbuf[i] == ' '; --i) bbuf[i] = 0; - volatile ATAIdentifyBlock& identify_block = (volatile ATAIdentifyBlock&)(*wbuf.data()); + ATAIdentifyBlock volatile& identify_block = (ATAIdentifyBlock volatile&)(*wbuf.data()); u16 capabilities = identify_block.capabilities[0]; diff --git a/Kernel/Storage/ATA/IDEChannel.h b/Kernel/Storage/ATA/IDEChannel.h index bc1f3c1540..4c9aa03d3e 100644 --- a/Kernel/Storage/ATA/IDEChannel.h +++ b/Kernel/Storage/ATA/IDEChannel.h @@ -74,11 +74,11 @@ public: IOAddressGroup(IOAddressGroup const&) = default; // Disable default implementations that would use surprising integer promotion. - bool operator==(const IOAddressGroup&) const = delete; - bool operator<=(const IOAddressGroup&) const = delete; - bool operator>=(const IOAddressGroup&) const = delete; - bool operator<(const IOAddressGroup&) const = delete; - bool operator>(const IOAddressGroup&) const = delete; + bool operator==(IOAddressGroup const&) const = delete; + bool operator<=(IOAddressGroup const&) const = delete; + bool operator>=(IOAddressGroup const&) const = delete; + bool operator<(IOAddressGroup const&) const = delete; + bool operator>(IOAddressGroup const&) const = delete; IOAddress io_base() const { return m_io_base; }; IOAddress control_base() const { return m_control_base; } @@ -91,8 +91,8 @@ public: }; public: - static NonnullRefPtr<IDEChannel> create(const IDEController&, IOAddressGroup, ChannelType type); - static NonnullRefPtr<IDEChannel> create(const IDEController&, u8 irq, IOAddressGroup, ChannelType type); + static NonnullRefPtr<IDEChannel> create(IDEController const&, IOAddressGroup, ChannelType type); + static NonnullRefPtr<IDEChannel> create(IDEController const&, u8 irq, IOAddressGroup, ChannelType type); virtual ~IDEChannel() override; RefPtr<StorageDevice> master_device() const; @@ -119,10 +119,10 @@ protected: Write, }; - IDEChannel(const IDEController&, IOAddressGroup, ChannelType type); - IDEChannel(const IDEController&, u8 irq, IOAddressGroup, ChannelType type); + IDEChannel(IDEController const&, IOAddressGroup, ChannelType type); + IDEChannel(IDEController const&, u8 irq, IOAddressGroup, ChannelType type); //^ IRQHandler - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; virtual void send_ata_io_command(LBAMode lba_mode, Direction direction) const; diff --git a/Kernel/Storage/ATA/IDEController.cpp b/Kernel/Storage/ATA/IDEController.cpp index 52b71c4462..030591e71a 100644 --- a/Kernel/Storage/ATA/IDEController.cpp +++ b/Kernel/Storage/ATA/IDEController.cpp @@ -41,7 +41,7 @@ size_t IDEController::devices_count() const return count; } -void IDEController::start_request(const ATADevice& device, AsyncBlockDeviceRequest& request) +void IDEController::start_request(ATADevice const& device, AsyncBlockDeviceRequest& request) { auto& address = device.ata_address(); VERIFY(address.subport < 2); diff --git a/Kernel/Storage/ATA/IDEController.h b/Kernel/Storage/ATA/IDEController.h index 77319a8f20..4ca4f3f2bf 100644 --- a/Kernel/Storage/ATA/IDEController.h +++ b/Kernel/Storage/ATA/IDEController.h @@ -26,7 +26,7 @@ public: virtual bool reset() override final; virtual bool shutdown() override final; virtual size_t devices_count() const override final; - virtual void start_request(const ATADevice&, AsyncBlockDeviceRequest&) override final; + virtual void start_request(ATADevice const&, AsyncBlockDeviceRequest&) override final; virtual void complete_current_request(AsyncDeviceRequest::RequestResult) override final; protected: diff --git a/Kernel/Storage/ATA/PCIIDEController.cpp b/Kernel/Storage/ATA/PCIIDEController.cpp index cbf156b501..6e8b898185 100644 --- a/Kernel/Storage/ATA/PCIIDEController.cpp +++ b/Kernel/Storage/ATA/PCIIDEController.cpp @@ -53,7 +53,7 @@ bool PCIIDEController::is_bus_master_capable() const return m_prog_if.value() & (1 << 7); } -static const char* detect_controller_type(u8 programming_value) +static char const* detect_controller_type(u8 programming_value) { switch (programming_value) { case 0x00: diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp index e1ea8ac8b9..18b82b3420 100644 --- a/Kernel/Storage/NVMe/NVMeController.cpp +++ b/Kernel/Storage/NVMe/NVMeController.cpp @@ -21,7 +21,7 @@ namespace Kernel { Atomic<u8> NVMeController::controller_id {}; -UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NVMeController>> NVMeController::try_initialize(const Kernel::PCI::DeviceIdentifier& device_identifier, bool is_queue_polled) +UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NVMeController>> NVMeController::try_initialize(Kernel::PCI::DeviceIdentifier const& device_identifier, bool is_queue_polled) { auto controller = TRY(adopt_nonnull_ref_or_enomem(new NVMeController(device_identifier))); TRY(controller->initialize(is_queue_polled)); diff --git a/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp b/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp index 0cc00ccc08..95842165cb 100644 --- a/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp +++ b/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp @@ -18,7 +18,7 @@ UNMAP_AFTER_INIT NVMeInterruptQueue::NVMeInterruptQueue(NonnullOwnPtr<Memory::Re enable_irq(); } -bool NVMeInterruptQueue::handle_irq(const RegisterState&) +bool NVMeInterruptQueue::handle_irq(RegisterState const&) { SpinlockLocker lock(m_request_lock); return process_cq() ? true : false; diff --git a/Kernel/Storage/Partition/DiskPartition.cpp b/Kernel/Storage/Partition/DiskPartition.cpp index ba208e5980..4bf2a5eca1 100644 --- a/Kernel/Storage/Partition/DiskPartition.cpp +++ b/Kernel/Storage/Partition/DiskPartition.cpp @@ -28,7 +28,7 @@ DiskPartition::DiskPartition(BlockDevice& device, unsigned minor_number, DiskPar DiskPartition::~DiskPartition() = default; -const DiskPartitionMetadata& DiskPartition::metadata() const +DiskPartitionMetadata const& DiskPartition::metadata() const { return m_metadata; } @@ -52,21 +52,21 @@ ErrorOr<size_t> DiskPartition::read(OpenFileDescription& fd, u64 offset, UserOrK return m_device.strong_ref()->read(fd, offset + adjust, outbuf, len); } -bool DiskPartition::can_read(const OpenFileDescription& fd, u64 offset) const +bool DiskPartition::can_read(OpenFileDescription const& fd, u64 offset) const { u64 adjust = m_metadata.start_block() * block_size(); dbgln_if(OFFD_DEBUG, "DiskPartition::can_read offset={}, adjust={}", offset, adjust); return m_device.strong_ref()->can_read(fd, offset + adjust); } -ErrorOr<size_t> DiskPartition::write(OpenFileDescription& fd, u64 offset, const UserOrKernelBuffer& inbuf, size_t len) +ErrorOr<size_t> DiskPartition::write(OpenFileDescription& fd, u64 offset, UserOrKernelBuffer const& inbuf, size_t len) { u64 adjust = m_metadata.start_block() * block_size(); dbgln_if(OFFD_DEBUG, "DiskPartition::write offset={}, adjust={}, len={}", offset, adjust, len); return m_device.strong_ref()->write(fd, offset + adjust, inbuf, len); } -bool DiskPartition::can_write(const OpenFileDescription& fd, u64 offset) const +bool DiskPartition::can_write(OpenFileDescription const& fd, u64 offset) const { u64 adjust = m_metadata.start_block() * block_size(); dbgln_if(OFFD_DEBUG, "DiskPartition::can_write offset={}, adjust={}", offset, adjust); diff --git a/Kernel/Storage/Partition/DiskPartition.h b/Kernel/Storage/Partition/DiskPartition.h index 79bdb64fc1..a6a17797a9 100644 --- a/Kernel/Storage/Partition/DiskPartition.h +++ b/Kernel/Storage/Partition/DiskPartition.h @@ -24,11 +24,11 @@ public: // ^BlockDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override; - const DiskPartitionMetadata& metadata() const; + DiskPartitionMetadata const& metadata() const; private: DiskPartition(BlockDevice&, unsigned, DiskPartitionMetadata); diff --git a/Kernel/Storage/Partition/DiskPartitionMetadata.cpp b/Kernel/Storage/Partition/DiskPartitionMetadata.cpp index 7565cc460a..903f713efd 100644 --- a/Kernel/Storage/Partition/DiskPartitionMetadata.cpp +++ b/Kernel/Storage/Partition/DiskPartitionMetadata.cpp @@ -34,7 +34,7 @@ bool DiskPartitionMetadata::PartitionType::is_uuid() const } bool DiskPartitionMetadata::PartitionType::is_valid() const { - return !all_of(m_partition_type, [](const auto octet) { return octet == 0; }); + return !all_of(m_partition_type, [](auto const octet) { return octet == 0; }); } DiskPartitionMetadata::DiskPartitionMetadata(u64 start_block, u64 end_block, u8 partition_type) @@ -86,7 +86,7 @@ Optional<u64> DiskPartitionMetadata::special_attributes() const return m_attributes; } -const DiskPartitionMetadata::PartitionType& DiskPartitionMetadata::type() const +DiskPartitionMetadata::PartitionType const& DiskPartitionMetadata::type() const { return m_type; } diff --git a/Kernel/Storage/Partition/DiskPartitionMetadata.h b/Kernel/Storage/Partition/DiskPartitionMetadata.h index 2b1ff22ab1..2511b127c0 100644 --- a/Kernel/Storage/Partition/DiskPartitionMetadata.h +++ b/Kernel/Storage/Partition/DiskPartitionMetadata.h @@ -40,7 +40,7 @@ public: DiskPartitionMetadata offset(u64 blocks_count) const; Optional<u64> special_attributes() const; - const PartitionType& type() const; + PartitionType const& type() const; const UUID& unique_guid() const; private: diff --git a/Kernel/Storage/Partition/EBRPartitionTable.cpp b/Kernel/Storage/Partition/EBRPartitionTable.cpp index 8d2eefbcec..d3889093a9 100644 --- a/Kernel/Storage/Partition/EBRPartitionTable.cpp +++ b/Kernel/Storage/Partition/EBRPartitionTable.cpp @@ -9,7 +9,7 @@ namespace Kernel { -Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> EBRPartitionTable::try_to_initialize(const StorageDevice& device) +Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> EBRPartitionTable::try_to_initialize(StorageDevice const& device) { auto table = adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); if (table->is_protective_mbr()) @@ -19,7 +19,7 @@ Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> EBRPartitionTabl return table; } -void EBRPartitionTable::search_extended_partition(const StorageDevice& device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) +void EBRPartitionTable::search_extended_partition(StorageDevice const& device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) { if (limit == 0) return; @@ -39,7 +39,7 @@ void EBRPartitionTable::search_extended_partition(const StorageDevice& device, M search_extended_partition(device, *next_ebr, current_block_offset, (limit - 1)); } -EBRPartitionTable::EBRPartitionTable(const StorageDevice& device) +EBRPartitionTable::EBRPartitionTable(StorageDevice const& device) : MBRPartitionTable(device) { if (!is_header_valid()) diff --git a/Kernel/Storage/Partition/EBRPartitionTable.h b/Kernel/Storage/Partition/EBRPartitionTable.h index 11ec42c548..bff3c70a53 100644 --- a/Kernel/Storage/Partition/EBRPartitionTable.h +++ b/Kernel/Storage/Partition/EBRPartitionTable.h @@ -20,12 +20,12 @@ class EBRPartitionTable : public MBRPartitionTable { public: ~EBRPartitionTable(); - static Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> try_to_initialize(const StorageDevice&); - explicit EBRPartitionTable(const StorageDevice&); + static Result<NonnullOwnPtr<EBRPartitionTable>, PartitionTable::Error> try_to_initialize(StorageDevice const&); + explicit EBRPartitionTable(StorageDevice const&); virtual bool is_valid() const override { return m_valid; }; private: - void search_extended_partition(const StorageDevice&, MBRPartitionTable&, u64, size_t limit); + void search_extended_partition(StorageDevice const&, MBRPartitionTable&, u64, size_t limit); bool m_valid { false }; }; diff --git a/Kernel/Storage/Partition/GUIDPartitionTable.cpp b/Kernel/Storage/Partition/GUIDPartitionTable.cpp index ebb393415f..7605a20b2e 100644 --- a/Kernel/Storage/Partition/GUIDPartitionTable.cpp +++ b/Kernel/Storage/Partition/GUIDPartitionTable.cpp @@ -47,7 +47,7 @@ struct [[gnu::packed]] GUIDPartitionHeader { u32 crc32_entries_array; }; -Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTable::try_to_initialize(const StorageDevice& device) +Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTable::try_to_initialize(StorageDevice const& device) { auto table = adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); if (!table->is_valid()) @@ -55,7 +55,7 @@ Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> GUIDPartitionTa return table; } -GUIDPartitionTable::GUIDPartitionTable(const StorageDevice& device) +GUIDPartitionTable::GUIDPartitionTable(StorageDevice const& device) : MBRPartitionTable(device) { // FIXME: Handle OOM failure here. @@ -65,9 +65,9 @@ GUIDPartitionTable::GUIDPartitionTable(const StorageDevice& device) m_valid = false; } -const GUIDPartitionHeader& GUIDPartitionTable::header() const +GUIDPartitionHeader const& GUIDPartitionTable::header() const { - return *(const GUIDPartitionHeader*)m_cached_header.data(); + return *(GUIDPartitionHeader const*)m_cached_header.data(); } bool GUIDPartitionTable::initialize() @@ -101,7 +101,7 @@ bool GUIDPartitionTable::initialize() if (!m_device->read_block((raw_byte_index / m_device->block_size()), raw_entries_buffer)) { return false; } - auto* entries = (const GPTPartitionEntry*)entries_buffer.data(); + auto* entries = (GPTPartitionEntry const*)entries_buffer.data(); auto& entry = entries[entry_index % (m_device->block_size() / (size_t)header().partition_entry_size)]; Array<u8, 16> partition_type {}; partition_type.span().overwrite(0, entry.partition_guid, partition_type.size()); @@ -123,7 +123,7 @@ bool GUIDPartitionTable::initialize() bool GUIDPartitionTable::is_unused_entry(Array<u8, 16> partition_type) const { - return all_of(partition_type, [](const auto octet) { return octet == 0; }); + return all_of(partition_type, [](auto const octet) { return octet == 0; }); } } diff --git a/Kernel/Storage/Partition/GUIDPartitionTable.h b/Kernel/Storage/Partition/GUIDPartitionTable.h index 64e3cf1506..da90eb7454 100644 --- a/Kernel/Storage/Partition/GUIDPartitionTable.h +++ b/Kernel/Storage/Partition/GUIDPartitionTable.h @@ -20,14 +20,14 @@ public: virtual ~GUIDPartitionTable() = default; ; - static Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> try_to_initialize(const StorageDevice&); - explicit GUIDPartitionTable(const StorageDevice&); + static Result<NonnullOwnPtr<GUIDPartitionTable>, PartitionTable::Error> try_to_initialize(StorageDevice const&); + explicit GUIDPartitionTable(StorageDevice const&); virtual bool is_valid() const override { return m_valid; }; private: bool is_unused_entry(Array<u8, 16>) const; - const GUIDPartitionHeader& header() const; + GUIDPartitionHeader const& header() const; bool initialize(); bool m_valid { true }; diff --git a/Kernel/Storage/Partition/MBRPartitionTable.cpp b/Kernel/Storage/Partition/MBRPartitionTable.cpp index d5931e7c56..6d81b5a5de 100644 --- a/Kernel/Storage/Partition/MBRPartitionTable.cpp +++ b/Kernel/Storage/Partition/MBRPartitionTable.cpp @@ -15,7 +15,7 @@ namespace Kernel { #define EBR_CHS_CONTAINER 0x05 #define EBR_LBA_CONTAINER 0x0F -Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTable::try_to_initialize(const StorageDevice& device) +Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTable::try_to_initialize(StorageDevice const& device) { auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); if (table->contains_ebr()) @@ -27,7 +27,7 @@ Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTabl return table; } -OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(const StorageDevice& device, u32 start_lba) +OwnPtr<MBRPartitionTable> MBRPartitionTable::try_to_initialize(StorageDevice const& device, u32 start_lba) { auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device, start_lba)).release_value_but_fixme_should_propagate_errors(); if (!table->is_valid()) @@ -44,7 +44,7 @@ bool MBRPartitionTable::read_boot_record() return m_header_valid; } -MBRPartitionTable::MBRPartitionTable(const StorageDevice& device, u32 start_lba) +MBRPartitionTable::MBRPartitionTable(StorageDevice const& device, u32 start_lba) : PartitionTable(device) , m_start_lba(start_lba) , m_cached_header(ByteBuffer::create_zeroed(m_device->block_size()).release_value_but_fixme_should_propagate_errors()) // FIXME: Do something sensible if this fails because of OOM. @@ -65,7 +65,7 @@ MBRPartitionTable::MBRPartitionTable(const StorageDevice& device, u32 start_lba) m_valid = true; } -MBRPartitionTable::MBRPartitionTable(const StorageDevice& device) +MBRPartitionTable::MBRPartitionTable(StorageDevice const& device) : PartitionTable(device) , m_start_lba(0) , m_cached_header(ByteBuffer::create_zeroed(m_device->block_size()).release_value_but_fixme_should_propagate_errors()) // FIXME: Do something sensible if this fails because of OOM. @@ -86,9 +86,9 @@ MBRPartitionTable::MBRPartitionTable(const StorageDevice& device) MBRPartitionTable::~MBRPartitionTable() = default; -const MBRPartitionTable::Header& MBRPartitionTable::header() const +MBRPartitionTable::Header const& MBRPartitionTable::header() const { - return *(const MBRPartitionTable::Header*)m_cached_header.data(); + return *(MBRPartitionTable::Header const*)m_cached_header.data(); } bool MBRPartitionTable::initialize() diff --git a/Kernel/Storage/Partition/MBRPartitionTable.h b/Kernel/Storage/Partition/MBRPartitionTable.h index 00f50c09e5..dc10676b55 100644 --- a/Kernel/Storage/Partition/MBRPartitionTable.h +++ b/Kernel/Storage/Partition/MBRPartitionTable.h @@ -41,17 +41,17 @@ public: public: ~MBRPartitionTable(); - static Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> try_to_initialize(const StorageDevice&); - static OwnPtr<MBRPartitionTable> try_to_initialize(const StorageDevice&, u32 start_lba); - explicit MBRPartitionTable(const StorageDevice&); - MBRPartitionTable(const StorageDevice&, u32 start_lba); + static Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> try_to_initialize(StorageDevice const&); + static OwnPtr<MBRPartitionTable> try_to_initialize(StorageDevice const&, u32 start_lba); + explicit MBRPartitionTable(StorageDevice const&); + MBRPartitionTable(StorageDevice const&, u32 start_lba); bool is_protective_mbr() const; bool contains_ebr() const; virtual bool is_valid() const override { return m_valid; }; protected: - const Header& header() const; + Header const& header() const; bool is_header_valid() const { return m_header_valid; }; private: diff --git a/Kernel/Storage/Partition/PartitionTable.cpp b/Kernel/Storage/Partition/PartitionTable.cpp index b870abdb19..1731ef63b4 100644 --- a/Kernel/Storage/Partition/PartitionTable.cpp +++ b/Kernel/Storage/Partition/PartitionTable.cpp @@ -7,7 +7,7 @@ #include <Kernel/Storage/Partition/PartitionTable.h> namespace Kernel { -PartitionTable::PartitionTable(const StorageDevice& device) +PartitionTable::PartitionTable(StorageDevice const& device) : m_device(device) { } diff --git a/Kernel/Storage/Partition/PartitionTable.h b/Kernel/Storage/Partition/PartitionTable.h index 89935e3c69..34d955bd10 100644 --- a/Kernel/Storage/Partition/PartitionTable.h +++ b/Kernel/Storage/Partition/PartitionTable.h @@ -31,7 +31,7 @@ public: Vector<DiskPartitionMetadata> partitions() const { return m_partitions; } protected: - explicit PartitionTable(const StorageDevice&); + explicit PartitionTable(StorageDevice const&); NonnullRefPtr<StorageDevice> m_device; Vector<DiskPartitionMetadata> m_partitions; diff --git a/Kernel/Storage/Ramdisk/Device.cpp b/Kernel/Storage/Ramdisk/Device.cpp index 9062926819..5d4689a359 100644 --- a/Kernel/Storage/Ramdisk/Device.cpp +++ b/Kernel/Storage/Ramdisk/Device.cpp @@ -13,7 +13,7 @@ namespace Kernel { -NonnullRefPtr<RamdiskDevice> RamdiskDevice::create(const RamdiskController& controller, NonnullOwnPtr<Memory::Region>&& region, int major, int minor) +NonnullRefPtr<RamdiskDevice> RamdiskDevice::create(RamdiskController const& controller, NonnullOwnPtr<Memory::Region>&& region, int major, int minor) { // FIXME: Try to not hardcode a maximum of 16 partitions per drive! size_t drive_index = minor / 16; @@ -25,7 +25,7 @@ NonnullRefPtr<RamdiskDevice> RamdiskDevice::create(const RamdiskController& cont return device_or_error.release_value(); } -RamdiskDevice::RamdiskDevice(const RamdiskController&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor, NonnullOwnPtr<KString> device_name) +RamdiskDevice::RamdiskDevice(RamdiskController const&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor, NonnullOwnPtr<KString> device_name) : StorageDevice(major, minor, 512, region->size() / 512, move(device_name)) , m_region(move(region)) { diff --git a/Kernel/Storage/Ramdisk/Device.h b/Kernel/Storage/Ramdisk/Device.h index 7d611cfdc9..1747bd4eae 100644 --- a/Kernel/Storage/Ramdisk/Device.h +++ b/Kernel/Storage/Ramdisk/Device.h @@ -18,14 +18,14 @@ class RamdiskDevice final : public StorageDevice { friend class DeviceManagement; public: - static NonnullRefPtr<RamdiskDevice> create(const RamdiskController&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor); + static NonnullRefPtr<RamdiskDevice> create(RamdiskController const&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor); virtual ~RamdiskDevice() override; // ^DiskDevice virtual StringView class_name() const override; private: - RamdiskDevice(const RamdiskController&, NonnullOwnPtr<Memory::Region>&&, int major, int minor, NonnullOwnPtr<KString> device_name); + RamdiskDevice(RamdiskController const&, NonnullOwnPtr<Memory::Region>&&, int major, int minor, NonnullOwnPtr<KString> device_name); // ^BlockDevice virtual void start_request(AsyncBlockDeviceRequest&) override; diff --git a/Kernel/Storage/StorageDevice.cpp b/Kernel/Storage/StorageDevice.cpp index a94619b6a7..339b61cb31 100644 --- a/Kernel/Storage/StorageDevice.cpp +++ b/Kernel/Storage/StorageDevice.cpp @@ -88,12 +88,12 @@ ErrorOr<size_t> StorageDevice::read(OpenFileDescription&, u64 offset, UserOrKern return pos + remaining; } -bool StorageDevice::can_read(const OpenFileDescription&, u64 offset) const +bool StorageDevice::can_read(OpenFileDescription const&, u64 offset) const { return offset < (max_addressable_block() * block_size()); } -ErrorOr<size_t> StorageDevice::write(OpenFileDescription&, u64 offset, const UserOrKernelBuffer& inbuf, size_t len) +ErrorOr<size_t> StorageDevice::write(OpenFileDescription&, u64 offset, UserOrKernelBuffer const& inbuf, size_t len) { u64 index = offset >> block_size_log(); off_t offset_within_block = 0; @@ -188,7 +188,7 @@ StringView StorageDevice::early_storage_name() const return m_early_storage_device_name->view(); } -bool StorageDevice::can_write(const OpenFileDescription&, u64 offset) const +bool StorageDevice::can_write(OpenFileDescription const&, u64 offset) const { return offset < (max_addressable_block() * block_size()); } diff --git a/Kernel/Storage/StorageDevice.h b/Kernel/Storage/StorageDevice.h index b852653a67..2b178bc744 100644 --- a/Kernel/Storage/StorageDevice.h +++ b/Kernel/Storage/StorageDevice.h @@ -38,9 +38,9 @@ public: // ^BlockDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_read(const OpenFileDescription&, u64) const override; - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override; + virtual bool can_write(OpenFileDescription const&, u64) const override; virtual void prepare_for_unplug() { m_partitions.clear(); } // FIXME: Remove this method after figuring out another scheme for naming. diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp index 42bb90713a..4aa35875c1 100644 --- a/Kernel/Storage/StorageManagement.cpp +++ b/Kernel/Storage/StorageManagement.cpp @@ -129,7 +129,7 @@ UNMAP_AFTER_INIT void StorageManagement::dump_storage_devices_and_partitions() c } } -UNMAP_AFTER_INIT OwnPtr<PartitionTable> StorageManagement::try_to_initialize_partition_table(const StorageDevice& device) const +UNMAP_AFTER_INIT OwnPtr<PartitionTable> StorageManagement::try_to_initialize_partition_table(StorageDevice const& device) const { auto mbr_table_or_result = MBRPartitionTable::try_to_initialize(device); if (!mbr_table_or_result.is_error()) diff --git a/Kernel/Storage/StorageManagement.h b/Kernel/Storage/StorageManagement.h index 8d578de5ee..d37122fcc6 100644 --- a/Kernel/Storage/StorageManagement.h +++ b/Kernel/Storage/StorageManagement.h @@ -45,7 +45,7 @@ private: void dump_storage_devices_and_partitions() const; - OwnPtr<PartitionTable> try_to_initialize_partition_table(const StorageDevice&) const; + OwnPtr<PartitionTable> try_to_initialize_partition_table(StorageDevice const&) const; RefPtr<BlockDevice> boot_block_device() const; diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 807908000e..cd1d46c3c2 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -90,8 +90,8 @@ UNMAP_AFTER_INIT void initialize() register_user_callable_interrupt_handler(syscall_vector, syscall_asm_entry); } -using Handler = auto (Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> ErrorOr<FlatPtr>; -using HandlerWithRegisterState = auto (Process::*)(RegisterState&) -> ErrorOr<FlatPtr>; +using Handler = auto(Process::*)(FlatPtr, FlatPtr, FlatPtr, FlatPtr) -> ErrorOr<FlatPtr>; +using HandlerWithRegisterState = auto(Process::*)(RegisterState&) -> ErrorOr<FlatPtr>; struct HandlerMetadata { Handler handler; @@ -118,14 +118,14 @@ ErrorOr<FlatPtr> handle(RegisterState& regs, FlatPtr function, FlatPtr arg1, Fla return ENOSYS; } - const auto syscall_metadata = s_syscall_table[function]; + auto const syscall_metadata = s_syscall_table[function]; if (syscall_metadata.handler == nullptr) { dbgln("Null syscall {} requested, you probably need to rebuild this program!", function); return ENOSYS; } MutexLocker mutex_locker; - const auto needs_big_lock = syscall_metadata.needs_lock == NeedsBigProcessLock::Yes; + auto const needs_big_lock = syscall_metadata.needs_lock == NeedsBigProcessLock::Yes; if (needs_big_lock) { mutex_locker.attach_and_lock(process.big_lock()); }; diff --git a/Kernel/Syscalls/access.cpp b/Kernel/Syscalls/access.cpp index 96537207f6..08177de6c1 100644 --- a/Kernel/Syscalls/access.cpp +++ b/Kernel/Syscalls/access.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$access(Userspace<const char*> user_path, size_t path_length, int mode) +ErrorOr<FlatPtr> Process::sys$access(Userspace<char const*> user_path, size_t path_length, int mode) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/chdir.cpp b/Kernel/Syscalls/chdir.cpp index 9aac499f2d..001aa661c2 100644 --- a/Kernel/Syscalls/chdir.cpp +++ b/Kernel/Syscalls/chdir.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$chdir(Userspace<const char*> user_path, size_t path_length) +ErrorOr<FlatPtr> Process::sys$chdir(Userspace<char const*> user_path, size_t path_length) { VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/chown.cpp b/Kernel/Syscalls/chown.cpp index 00b4755567..797804da87 100644 --- a/Kernel/Syscalls/chown.cpp +++ b/Kernel/Syscalls/chown.cpp @@ -20,7 +20,7 @@ ErrorOr<FlatPtr> Process::sys$fchown(int fd, UserID uid, GroupID gid) return 0; } -ErrorOr<FlatPtr> Process::sys$chown(Userspace<const Syscall::SC_chown_params*> user_params) +ErrorOr<FlatPtr> Process::sys$chown(Userspace<Syscall::SC_chown_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); TRY(require_promise(Pledge::chown)); diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp index 323c3566aa..b6668b989b 100644 --- a/Kernel/Syscalls/clock.cpp +++ b/Kernel/Syscalls/clock.cpp @@ -34,7 +34,7 @@ ErrorOr<FlatPtr> Process::sys$clock_gettime(clockid_t clock_id, Userspace<timesp return 0; } -ErrorOr<FlatPtr> Process::sys$clock_settime(clockid_t clock_id, Userspace<const timespec*> user_ts) +ErrorOr<FlatPtr> Process::sys$clock_settime(clockid_t clock_id, Userspace<timespec const*> user_ts) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); TRY(require_promise(Pledge::settime)); @@ -54,7 +54,7 @@ ErrorOr<FlatPtr> Process::sys$clock_settime(clockid_t clock_id, Userspace<const return 0; } -ErrorOr<FlatPtr> Process::sys$clock_nanosleep(Userspace<const Syscall::SC_clock_nanosleep_params*> user_params) +ErrorOr<FlatPtr> Process::sys$clock_nanosleep(Userspace<Syscall::SC_clock_nanosleep_params const*> user_params) { VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::stdio)); @@ -92,7 +92,7 @@ ErrorOr<FlatPtr> Process::sys$clock_nanosleep(Userspace<const Syscall::SC_clock_ return 0; } -ErrorOr<FlatPtr> Process::sys$adjtime(Userspace<const timeval*> user_delta, Userspace<timeval*> user_old_delta) +ErrorOr<FlatPtr> Process::sys$adjtime(Userspace<timeval const*> user_delta, Userspace<timeval*> user_old_delta) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); if (user_old_delta) { diff --git a/Kernel/Syscalls/debug.cpp b/Kernel/Syscalls/debug.cpp index dc0e066828..ec3737327e 100644 --- a/Kernel/Syscalls/debug.cpp +++ b/Kernel/Syscalls/debug.cpp @@ -18,7 +18,7 @@ ErrorOr<FlatPtr> Process::sys$dump_backtrace() return 0; } -ErrorOr<FlatPtr> Process::sys$dbgputstr(Userspace<const char*> characters, size_t size) +ErrorOr<FlatPtr> Process::sys$dbgputstr(Userspace<char const*> characters, size_t size) { VERIFY_NO_PROCESS_BIG_LOCK(this); if (size == 0) diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 376be0fb73..aff41423bf 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -180,7 +180,7 @@ static ErrorOr<RequiredLoadRange> get_required_load_range(OpenFileDescription& p } RequiredLoadRange range {}; - elf_image.for_each_program_header([&range](const auto& pheader) { + elf_image.for_each_program_header([&range](auto const& pheader) { if (pheader.type() != PT_LOAD) return; @@ -833,7 +833,7 @@ ErrorOr<void> Process::exec(NonnullOwnPtr<KString> path, NonnullOwnPtrVector<KSt return do_exec(move(description), move(arguments), move(environment), move(interpreter_description), new_main_thread, prev_flags, *main_program_header); } -ErrorOr<FlatPtr> Process::sys$execve(Userspace<const Syscall::SC_execve_params*> user_params) +ErrorOr<FlatPtr> Process::sys$execve(Userspace<Syscall::SC_execve_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); TRY(require_promise(Pledge::exec)); @@ -858,7 +858,7 @@ ErrorOr<FlatPtr> Process::sys$execve(Userspace<const Syscall::SC_execve_params*> auto path = TRY(get_syscall_path_argument(params.path)); - auto copy_user_strings = [](const auto& list, auto& output) -> ErrorOr<void> { + auto copy_user_strings = [](auto const& list, auto& output) -> ErrorOr<void> { if (!list.length) return {}; Checked<size_t> size = sizeof(*list.strings); diff --git a/Kernel/Syscalls/fcntl.cpp b/Kernel/Syscalls/fcntl.cpp index 7a9e039dff..80c0f39373 100644 --- a/Kernel/Syscalls/fcntl.cpp +++ b/Kernel/Syscalls/fcntl.cpp @@ -45,7 +45,7 @@ ErrorOr<FlatPtr> Process::sys$fcntl(int fd, int cmd, u32 arg) TRY(description->get_flock(Userspace<flock*>(arg))); return 0; case F_SETLK: - TRY(description->apply_flock(Process::current(), Userspace<const flock*>(arg))); + TRY(description->apply_flock(Process::current(), Userspace<flock const*>(arg))); return 0; default: return EINVAL; diff --git a/Kernel/Syscalls/futex.cpp b/Kernel/Syscalls/futex.cpp index 0769d4953b..b7ca4c4a58 100644 --- a/Kernel/Syscalls/futex.cpp +++ b/Kernel/Syscalls/futex.cpp @@ -22,7 +22,7 @@ void Process::clear_futex_queues_on_exec() m_futex_queues.clear(); } -ErrorOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*> user_params) +ErrorOr<FlatPtr> Process::sys$futex(Userspace<Syscall::SC_futex_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); auto params = TRY(copy_typed_from_user(user_params)); diff --git a/Kernel/Syscalls/hostname.cpp b/Kernel/Syscalls/hostname.cpp index 8c96a39a44..3733ee438b 100644 --- a/Kernel/Syscalls/hostname.cpp +++ b/Kernel/Syscalls/hostname.cpp @@ -14,7 +14,7 @@ ErrorOr<FlatPtr> Process::sys$gethostname(Userspace<char*> buffer, size_t size) TRY(require_promise(Pledge::stdio)); if (size > NumericLimits<ssize_t>::max()) return EINVAL; - return hostname().with_shared([&](const auto& name) -> ErrorOr<FlatPtr> { + return hostname().with_shared([&](auto const& name) -> ErrorOr<FlatPtr> { if (size < (name->length() + 1)) return ENAMETOOLONG; TRY(copy_to_user(buffer, name->characters(), name->length() + 1)); @@ -22,7 +22,7 @@ ErrorOr<FlatPtr> Process::sys$gethostname(Userspace<char*> buffer, size_t size) }); } -ErrorOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> buffer, size_t length) +ErrorOr<FlatPtr> Process::sys$sethostname(Userspace<char const*> buffer, size_t length) { VERIFY_NO_PROCESS_BIG_LOCK(this) TRY(require_no_promises()); diff --git a/Kernel/Syscalls/inode_watcher.cpp b/Kernel/Syscalls/inode_watcher.cpp index 2f7e574828..cff0a82b71 100644 --- a/Kernel/Syscalls/inode_watcher.cpp +++ b/Kernel/Syscalls/inode_watcher.cpp @@ -36,7 +36,7 @@ ErrorOr<FlatPtr> Process::sys$create_inode_watcher(u32 flags) }); } -ErrorOr<FlatPtr> Process::sys$inode_watcher_add_watch(Userspace<const Syscall::SC_inode_watcher_add_watch_params*> user_params) +ErrorOr<FlatPtr> Process::sys$inode_watcher_add_watch(Userspace<Syscall::SC_inode_watcher_add_watch_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/keymap.cpp b/Kernel/Syscalls/keymap.cpp index 37c8ab7a02..81e925b95b 100644 --- a/Kernel/Syscalls/keymap.cpp +++ b/Kernel/Syscalls/keymap.cpp @@ -11,7 +11,7 @@ namespace Kernel { constexpr size_t map_name_max_size = 50; -ErrorOr<FlatPtr> Process::sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*> user_params) +ErrorOr<FlatPtr> Process::sys$setkeymap(Userspace<Syscall::SC_setkeymap_params const*> user_params) { VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::setkeymap)); diff --git a/Kernel/Syscalls/link.cpp b/Kernel/Syscalls/link.cpp index 9cbb382d68..a2b23589d1 100644 --- a/Kernel/Syscalls/link.cpp +++ b/Kernel/Syscalls/link.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$link(Userspace<const Syscall::SC_link_params*> user_params) +ErrorOr<FlatPtr> Process::sys$link(Userspace<Syscall::SC_link_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::cpath)); @@ -21,7 +21,7 @@ ErrorOr<FlatPtr> Process::sys$link(Userspace<const Syscall::SC_link_params*> use return 0; } -ErrorOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_params*> user_params) +ErrorOr<FlatPtr> Process::sys$symlink(Userspace<Syscall::SC_symlink_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::cpath)); diff --git a/Kernel/Syscalls/mkdir.cpp b/Kernel/Syscalls/mkdir.cpp index cd193bf778..aa61a4cf58 100644 --- a/Kernel/Syscalls/mkdir.cpp +++ b/Kernel/Syscalls/mkdir.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$mkdir(Userspace<const char*> user_path, size_t path_length, mode_t mode) +ErrorOr<FlatPtr> Process::sys$mkdir(Userspace<char const*> user_path, size_t path_length, mode_t mode) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::cpath)); diff --git a/Kernel/Syscalls/mknod.cpp b/Kernel/Syscalls/mknod.cpp index 41d2603731..fed155c4df 100644 --- a/Kernel/Syscalls/mknod.cpp +++ b/Kernel/Syscalls/mknod.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$mknod(Userspace<const Syscall::SC_mknod_params*> user_params) +ErrorOr<FlatPtr> Process::sys$mknod(Userspace<Syscall::SC_mknod_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::dpath)); diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index 689ef83d44..3a77238396 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -103,7 +103,7 @@ ErrorOr<void> Process::validate_mmap_prot(int prot, bool map_stack, bool map_ano return {}; } -ErrorOr<void> Process::validate_inode_mmap_prot(int prot, const Inode& inode, bool map_shared) const +ErrorOr<void> Process::validate_inode_mmap_prot(int prot, Inode const& inode, bool map_shared) const { auto metadata = inode.metadata(); if ((prot & PROT_READ) && !metadata.may_read(*this)) @@ -125,7 +125,7 @@ ErrorOr<void> Process::validate_inode_mmap_prot(int prot, const Inode& inode, bo return {}; } -ErrorOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> user_params) +ErrorOr<FlatPtr> Process::sys$mmap(Userspace<Syscall::SC_mmap_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); @@ -322,10 +322,10 @@ ErrorOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int p return 0; } - if (const auto& regions = TRY(address_space().find_regions_intersecting(range_to_mprotect)); regions.size()) { + if (auto const& regions = TRY(address_space().find_regions_intersecting(range_to_mprotect)); regions.size()) { size_t full_size_found = 0; // Check that all intersecting regions are compatible. - for (const auto* region : regions) { + for (auto const* region : regions) { if (!region->is_mmap()) return EPERM; TRY(validate_mmap_prot(prot, region->is_stack(), region->vmobject().is_anonymous(), region)); @@ -343,7 +343,7 @@ ErrorOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int p if (old_region->access() == Memory::prot_to_region_access_flags(prot)) continue; - const auto intersection_to_mprotect = range_to_mprotect.intersect(old_region->range()); + auto const intersection_to_mprotect = range_to_mprotect.intersect(old_region->range()); // If the region is completely covered by range, simply update the access flags if (intersection_to_mprotect == old_region->range()) { old_region->set_readable(prot & PROT_READ); @@ -419,7 +419,7 @@ ErrorOr<FlatPtr> Process::sys$madvise(Userspace<void*> address, size_t size, int return EINVAL; } -ErrorOr<FlatPtr> Process::sys$set_mmap_name(Userspace<const Syscall::SC_set_mmap_name_params*> user_params) +ErrorOr<FlatPtr> Process::sys$set_mmap_name(Userspace<Syscall::SC_set_mmap_name_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); @@ -451,7 +451,7 @@ ErrorOr<FlatPtr> Process::sys$munmap(Userspace<void*> addr, size_t size) return 0; } -ErrorOr<FlatPtr> Process::sys$mremap(Userspace<const Syscall::SC_mremap_params*> user_params) +ErrorOr<FlatPtr> Process::sys$mremap(Userspace<Syscall::SC_mremap_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); @@ -488,7 +488,7 @@ ErrorOr<FlatPtr> Process::sys$mremap(Userspace<const Syscall::SC_mremap_params*> return ENOTIMPL; } -ErrorOr<FlatPtr> Process::sys$allocate_tls(Userspace<const char*> initial_data, size_t size) +ErrorOr<FlatPtr> Process::sys$allocate_tls(Userspace<char const*> initial_data, size_t size) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); diff --git a/Kernel/Syscalls/mount.cpp b/Kernel/Syscalls/mount.cpp index c78c3076a8..6311852dec 100644 --- a/Kernel/Syscalls/mount.cpp +++ b/Kernel/Syscalls/mount.cpp @@ -18,7 +18,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*> user_params) +ErrorOr<FlatPtr> Process::sys$mount(Userspace<Syscall::SC_mount_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_no_promises()); @@ -114,7 +114,7 @@ ErrorOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*> u return 0; } -ErrorOr<FlatPtr> Process::sys$umount(Userspace<const char*> user_mountpoint, size_t mountpoint_length) +ErrorOr<FlatPtr> Process::sys$umount(Userspace<char const*> user_mountpoint, size_t mountpoint_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) if (!is_superuser()) diff --git a/Kernel/Syscalls/open.cpp b/Kernel/Syscalls/open.cpp index 34b1754d3b..46f654753c 100644 --- a/Kernel/Syscalls/open.cpp +++ b/Kernel/Syscalls/open.cpp @@ -12,7 +12,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$open(Userspace<const Syscall::SC_open_params*> user_params) +ErrorOr<FlatPtr> Process::sys$open(Userspace<Syscall::SC_open_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); diff --git a/Kernel/Syscalls/pledge.cpp b/Kernel/Syscalls/pledge.cpp index 9db4490264..6759801c16 100644 --- a/Kernel/Syscalls/pledge.cpp +++ b/Kernel/Syscalls/pledge.cpp @@ -9,7 +9,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$pledge(Userspace<const Syscall::SC_pledge_params*> user_params) +ErrorOr<FlatPtr> Process::sys$pledge(Userspace<Syscall::SC_pledge_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); diff --git a/Kernel/Syscalls/poll.cpp b/Kernel/Syscalls/poll.cpp index 1ea55e2dad..a647ce6a43 100644 --- a/Kernel/Syscalls/poll.cpp +++ b/Kernel/Syscalls/poll.cpp @@ -14,7 +14,7 @@ namespace Kernel { using BlockFlags = Thread::FileBlocker::BlockFlags; -ErrorOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_params) +ErrorOr<FlatPtr> Process::sys$poll(Userspace<Syscall::SC_poll_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); diff --git a/Kernel/Syscalls/process.cpp b/Kernel/Syscalls/process.cpp index 036bf1df4d..8ef8fed952 100644 --- a/Kernel/Syscalls/process.cpp +++ b/Kernel/Syscalls/process.cpp @@ -34,7 +34,7 @@ ErrorOr<FlatPtr> Process::sys$get_process_name(Userspace<char*> buffer, size_t b return 0; } -ErrorOr<FlatPtr> Process::sys$set_process_name(Userspace<const char*> user_name, size_t user_name_length) +ErrorOr<FlatPtr> Process::sys$set_process_name(Userspace<char const*> user_name, size_t user_name_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::proc)); @@ -48,7 +48,7 @@ ErrorOr<FlatPtr> Process::sys$set_process_name(Userspace<const char*> user_name, return 0; } -ErrorOr<FlatPtr> Process::sys$set_coredump_metadata(Userspace<const Syscall::SC_set_coredump_metadata_params*> user_params) +ErrorOr<FlatPtr> Process::sys$set_coredump_metadata(Userspace<Syscall::SC_set_coredump_metadata_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); diff --git a/Kernel/Syscalls/profiling.cpp b/Kernel/Syscalls/profiling.cpp index 3c154f148b..1671f185ff 100644 --- a/Kernel/Syscalls/profiling.cpp +++ b/Kernel/Syscalls/profiling.cpp @@ -23,7 +23,7 @@ ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, Userspace<u64 const*> VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_no_promises()); - const auto event_mask = TRY(copy_typed_from_user(userspace_event_mask)); + auto const event_mask = TRY(copy_typed_from_user(userspace_event_mask)); if (pid == -1) { if (!is_superuser()) diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp index 26d5d92e71..bca30d428a 100644 --- a/Kernel/Syscalls/ptrace.cpp +++ b/Kernel/Syscalls/ptrace.cpp @@ -16,7 +16,7 @@ namespace Kernel { -static ErrorOr<FlatPtr> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& params, Process& caller) +static ErrorOr<FlatPtr> handle_ptrace(Kernel::Syscall::SC_ptrace_params const& params, Process& caller) { SpinlockLocker scheduler_lock(g_scheduler_lock); if (params.request == PT_TRACE_ME) { @@ -101,7 +101,7 @@ static ErrorOr<FlatPtr> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& p return EINVAL; PtraceRegisters regs {}; - TRY(copy_from_user(®s, (const PtraceRegisters*)params.addr)); + TRY(copy_from_user(®s, (PtraceRegisters const*)params.addr)); auto& peer_saved_registers = peer->get_register_dump_from_stack(); // Verify that the saved registers are in usermode context @@ -114,7 +114,7 @@ static ErrorOr<FlatPtr> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& p } case PT_PEEK: { - auto data = TRY(peer->process().peek_user_data(Userspace<const FlatPtr*> { (FlatPtr)params.addr })); + auto data = TRY(peer->process().peek_user_data(Userspace<FlatPtr const*> { (FlatPtr)params.addr })); TRY(copy_to_user((FlatPtr*)params.data, &data)); break; } @@ -132,7 +132,7 @@ static ErrorOr<FlatPtr> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& p FlatPtr tracee_ptr = (FlatPtr)params.addr; while (buf_params.buf.size > 0) { size_t copy_this_iteration = min(buf.size(), buf_params.buf.size); - TRY(peer->process().peek_user_data(buf.span().slice(0, copy_this_iteration), Userspace<const u8*> { tracee_ptr })); + TRY(peer->process().peek_user_data(buf.span().slice(0, copy_this_iteration), Userspace<u8 const*> { tracee_ptr })); TRY(copy_to_user((void*)buf_params.buf.data, buf.data(), copy_this_iteration)); tracee_ptr += copy_this_iteration; buf_params.buf.data += copy_this_iteration; @@ -156,7 +156,7 @@ static ErrorOr<FlatPtr> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& p return 0; } -ErrorOr<FlatPtr> Process::sys$ptrace(Userspace<const Syscall::SC_ptrace_params*> user_params) +ErrorOr<FlatPtr> Process::sys$ptrace(Userspace<Syscall::SC_ptrace_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::ptrace)); @@ -175,7 +175,7 @@ bool Process::has_tracee_thread(ProcessID tracer_pid) return false; } -ErrorOr<FlatPtr> Process::peek_user_data(Userspace<const FlatPtr*> address) +ErrorOr<FlatPtr> Process::peek_user_data(Userspace<FlatPtr const*> address) { // This function can be called from the context of another // process that called PT_PEEK @@ -183,7 +183,7 @@ ErrorOr<FlatPtr> Process::peek_user_data(Userspace<const FlatPtr*> address) return TRY(copy_typed_from_user(address)); } -ErrorOr<void> Process::peek_user_data(Span<u8> destination, Userspace<const u8*> address) +ErrorOr<void> Process::peek_user_data(Span<u8> destination, Userspace<u8 const*> address) { // This function can be called from the context of another // process that called PT_PEEKBUF @@ -207,7 +207,7 @@ ErrorOr<void> Process::poke_user_data(Userspace<FlatPtr*> address, FlatPtr data) region->set_vmobject(move(vmobject)); region->set_shared(false); } - const bool was_writable = region->is_writable(); + bool const was_writable = region->is_writable(); if (!was_writable) { region->set_writable(true); region->remap(); diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp index 3e8e7e094f..1e51933e7c 100644 --- a/Kernel/Syscalls/read.cpp +++ b/Kernel/Syscalls/read.cpp @@ -74,8 +74,8 @@ ErrorOr<FlatPtr> Process::sys$readv(int fd, Userspace<const struct iovec*> iov, ErrorOr<FlatPtr> Process::sys$read(int fd, Userspace<u8*> buffer, size_t size) { - const auto start_timestamp = TimeManagement::the().uptime_ms(); - const auto result = read_impl(fd, buffer, size); + auto const start_timestamp = TimeManagement::the().uptime_ms(); + auto const result = read_impl(fd, buffer, size); if (Thread::current()->is_profiling_suppressed()) return result; diff --git a/Kernel/Syscalls/readlink.cpp b/Kernel/Syscalls/readlink.cpp index 375bc9c5e6..540073ea9a 100644 --- a/Kernel/Syscalls/readlink.cpp +++ b/Kernel/Syscalls/readlink.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_params) +ErrorOr<FlatPtr> Process::sys$readlink(Userspace<Syscall::SC_readlink_params const*> user_params) { VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/realpath.cpp b/Kernel/Syscalls/realpath.cpp index bda04d2e8a..1412761310 100644 --- a/Kernel/Syscalls/realpath.cpp +++ b/Kernel/Syscalls/realpath.cpp @@ -11,7 +11,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$realpath(Userspace<const Syscall::SC_realpath_params*> user_params) +ErrorOr<FlatPtr> Process::sys$realpath(Userspace<Syscall::SC_realpath_params const*> user_params) { VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/rename.cpp b/Kernel/Syscalls/rename.cpp index 39ebb9bef4..edbf69160e 100644 --- a/Kernel/Syscalls/rename.cpp +++ b/Kernel/Syscalls/rename.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$rename(Userspace<const Syscall::SC_rename_params*> user_params) +ErrorOr<FlatPtr> Process::sys$rename(Userspace<Syscall::SC_rename_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::cpath)); diff --git a/Kernel/Syscalls/rmdir.cpp b/Kernel/Syscalls/rmdir.cpp index 0371c267fa..7002115c28 100644 --- a/Kernel/Syscalls/rmdir.cpp +++ b/Kernel/Syscalls/rmdir.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$rmdir(Userspace<const char*> user_path, size_t path_length) +ErrorOr<FlatPtr> Process::sys$rmdir(Userspace<char const*> user_path, size_t path_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::cpath)); diff --git a/Kernel/Syscalls/setuid.cpp b/Kernel/Syscalls/setuid.cpp index 992ca2879d..38dadfeaf5 100644 --- a/Kernel/Syscalls/setuid.cpp +++ b/Kernel/Syscalls/setuid.cpp @@ -167,7 +167,7 @@ ErrorOr<FlatPtr> Process::sys$setresgid(GroupID new_rgid, GroupID new_egid, Grou return 0; } -ErrorOr<FlatPtr> Process::sys$setgroups(size_t count, Userspace<const gid_t*> user_gids) +ErrorOr<FlatPtr> Process::sys$setgroups(size_t count, Userspace<gid_t const*> user_gids) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::id)); diff --git a/Kernel/Syscalls/sigaction.cpp b/Kernel/Syscalls/sigaction.cpp index 31a355e0ec..888be45529 100644 --- a/Kernel/Syscalls/sigaction.cpp +++ b/Kernel/Syscalls/sigaction.cpp @@ -11,7 +11,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$sigprocmask(int how, Userspace<const sigset_t*> set, Userspace<sigset_t*> old_set) +ErrorOr<FlatPtr> Process::sys$sigprocmask(int how, Userspace<sigset_t const*> set, Userspace<sigset_t*> old_set) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::sigaction)); @@ -50,7 +50,7 @@ ErrorOr<FlatPtr> Process::sys$sigpending(Userspace<sigset_t*> set) return 0; } -ErrorOr<FlatPtr> Process::sys$sigaction(int signum, Userspace<const sigaction*> user_act, Userspace<sigaction*> user_old_act) +ErrorOr<FlatPtr> Process::sys$sigaction(int signum, Userspace<sigaction const*> user_act, Userspace<sigaction*> user_old_act) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::sigaction)); @@ -184,10 +184,10 @@ ErrorOr<void> Process::remap_range_as_stack(FlatPtr address, size_t size) return {}; } - if (const auto& regions = TRY(address_space().find_regions_intersecting(range_to_remap)); regions.size()) { + if (auto const& regions = TRY(address_space().find_regions_intersecting(range_to_remap)); regions.size()) { size_t full_size_found = 0; // Check that all intersecting regions are compatible. - for (const auto* region : regions) { + for (auto const* region : regions) { if (!region->is_mmap()) return EPERM; if (!region->vmobject().is_anonymous() || region->is_shared()) @@ -201,7 +201,7 @@ ErrorOr<void> Process::remap_range_as_stack(FlatPtr address, size_t size) // Finally, iterate over each region, either updating its access flags if the range covers it wholly, // or carving out a new subregion with the appropriate access flags set. for (auto* old_region : regions) { - const auto intersection_to_remap = range_to_remap.intersect(old_region->range()); + auto const intersection_to_remap = range_to_remap.intersect(old_region->range()); // If the region is completely covered by range, simply update the access flags if (intersection_to_remap == old_region->range()) { old_region->unsafe_clear_access(); @@ -250,7 +250,7 @@ ErrorOr<void> Process::remap_range_as_stack(FlatPtr address, size_t size) return EINVAL; } -ErrorOr<FlatPtr> Process::sys$sigaltstack(Userspace<const stack_t*> user_ss, Userspace<stack_t*> user_old_ss) +ErrorOr<FlatPtr> Process::sys$sigaltstack(Userspace<stack_t const*> user_ss, Userspace<stack_t*> user_old_ss) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::sigaction)); @@ -299,7 +299,7 @@ ErrorOr<FlatPtr> Process::sys$sigaltstack(Userspace<const stack_t*> user_ss, Use } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html -ErrorOr<FlatPtr> Process::sys$sigtimedwait(Userspace<const sigset_t*> set, Userspace<siginfo_t*> info, Userspace<const timespec*> timeout) +ErrorOr<FlatPtr> Process::sys$sigtimedwait(Userspace<sigset_t const*> set, Userspace<siginfo_t*> info, Userspace<timespec const*> timeout) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::sigaction)); diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp index b522513d48..8811c37571 100644 --- a/Kernel/Syscalls/socket.cpp +++ b/Kernel/Syscalls/socket.cpp @@ -48,7 +48,7 @@ ErrorOr<FlatPtr> Process::sys$socket(int domain, int type, int protocol) }); } -ErrorOr<FlatPtr> Process::sys$bind(int sockfd, Userspace<const sockaddr*> address, socklen_t address_length) +ErrorOr<FlatPtr> Process::sys$bind(int sockfd, Userspace<sockaddr const*> address, socklen_t address_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) return m_fds.with_exclusive([&](auto& fds) -> ErrorOr<FlatPtr> { @@ -80,7 +80,7 @@ ErrorOr<FlatPtr> Process::sys$listen(int sockfd, int backlog) }); } -ErrorOr<FlatPtr> Process::sys$accept4(Userspace<const Syscall::SC_accept4_params*> user_params) +ErrorOr<FlatPtr> Process::sys$accept4(Userspace<Syscall::SC_accept4_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::accept)); @@ -93,7 +93,7 @@ ErrorOr<FlatPtr> Process::sys$accept4(Userspace<const Syscall::SC_accept4_params socklen_t address_size = 0; if (user_address) { - TRY(copy_from_user(&address_size, static_ptr_cast<const socklen_t*>(user_address_size))); + TRY(copy_from_user(&address_size, static_ptr_cast<socklen_t const*>(user_address_size))); } ScopedDescriptionAllocation fd_allocation; @@ -148,7 +148,7 @@ ErrorOr<FlatPtr> Process::sys$accept4(Userspace<const Syscall::SC_accept4_params return fd_allocation.fd; } -ErrorOr<FlatPtr> Process::sys$connect(int sockfd, Userspace<const sockaddr*> user_address, socklen_t user_address_size) +ErrorOr<FlatPtr> Process::sys$connect(int sockfd, Userspace<sockaddr const*> user_address, socklen_t user_address_size) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) @@ -190,7 +190,7 @@ ErrorOr<FlatPtr> Process::sys$sendmsg(int sockfd, Userspace<const struct msghdr* if (iovs[0].iov_len > NumericLimits<ssize_t>::max()) return EINVAL; - Userspace<const sockaddr*> user_addr((FlatPtr)msg.msg_name); + Userspace<sockaddr const*> user_addr((FlatPtr)msg.msg_name); socklen_t addr_length = msg.msg_namelen; auto description = TRY(open_file_description(sockfd)); @@ -286,7 +286,7 @@ ErrorOr<FlatPtr> Process::sys$recvmsg(int sockfd, Userspace<struct msghdr*> user } template<bool sockname, typename Params> -ErrorOr<void> Process::get_sock_or_peer_name(const Params& params) +ErrorOr<void> Process::get_sock_or_peer_name(Params const& params) { socklen_t addrlen_value; TRY(copy_from_user(&addrlen_value, params.addrlen, sizeof(socklen_t))); @@ -311,7 +311,7 @@ ErrorOr<void> Process::get_sock_or_peer_name(const Params& params) return copy_to_user(params.addrlen, &addrlen_value); } -ErrorOr<FlatPtr> Process::sys$getsockname(Userspace<const Syscall::SC_getsockname_params*> user_params) +ErrorOr<FlatPtr> Process::sys$getsockname(Userspace<Syscall::SC_getsockname_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); @@ -319,7 +319,7 @@ ErrorOr<FlatPtr> Process::sys$getsockname(Userspace<const Syscall::SC_getsocknam return 0; } -ErrorOr<FlatPtr> Process::sys$getpeername(Userspace<const Syscall::SC_getpeername_params*> user_params) +ErrorOr<FlatPtr> Process::sys$getpeername(Userspace<Syscall::SC_getpeername_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); @@ -327,7 +327,7 @@ ErrorOr<FlatPtr> Process::sys$getpeername(Userspace<const Syscall::SC_getpeernam return 0; } -ErrorOr<FlatPtr> Process::sys$getsockopt(Userspace<const Syscall::SC_getsockopt_params*> user_params) +ErrorOr<FlatPtr> Process::sys$getsockopt(Userspace<Syscall::SC_getsockopt_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); @@ -350,12 +350,12 @@ ErrorOr<FlatPtr> Process::sys$getsockopt(Userspace<const Syscall::SC_getsockopt_ return 0; } -ErrorOr<FlatPtr> Process::sys$setsockopt(Userspace<const Syscall::SC_setsockopt_params*> user_params) +ErrorOr<FlatPtr> Process::sys$setsockopt(Userspace<Syscall::SC_setsockopt_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); - Userspace<const void*> user_value((FlatPtr)params.value); + Userspace<void const*> user_value((FlatPtr)params.value); auto description = TRY(open_file_description(params.sockfd)); if (!description->is_socket()) return ENOTSOCK; @@ -365,7 +365,7 @@ ErrorOr<FlatPtr> Process::sys$setsockopt(Userspace<const Syscall::SC_setsockopt_ return 0; } -ErrorOr<FlatPtr> Process::sys$socketpair(Userspace<const Syscall::SC_socketpair_params*> user_params) +ErrorOr<FlatPtr> Process::sys$socketpair(Userspace<Syscall::SC_socketpair_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); diff --git a/Kernel/Syscalls/stat.cpp b/Kernel/Syscalls/stat.cpp index 8c9a191916..bff2b782a4 100644 --- a/Kernel/Syscalls/stat.cpp +++ b/Kernel/Syscalls/stat.cpp @@ -21,7 +21,7 @@ ErrorOr<FlatPtr> Process::sys$fstat(int fd, Userspace<stat*> user_statbuf) return 0; } -ErrorOr<FlatPtr> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> user_params) +ErrorOr<FlatPtr> Process::sys$stat(Userspace<Syscall::SC_stat_params const*> user_params) { VERIFY_NO_PROCESS_BIG_LOCK(this); TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/statvfs.cpp b/Kernel/Syscalls/statvfs.cpp index a34866a1d7..3b3d26d83a 100644 --- a/Kernel/Syscalls/statvfs.cpp +++ b/Kernel/Syscalls/statvfs.cpp @@ -37,7 +37,7 @@ ErrorOr<FlatPtr> Process::do_statvfs(FileSystem const& fs, Custody const* custod return 0; } -ErrorOr<FlatPtr> Process::sys$statvfs(Userspace<const Syscall::SC_statvfs_params*> user_params) +ErrorOr<FlatPtr> Process::sys$statvfs(Userspace<Syscall::SC_statvfs_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::rpath)); diff --git a/Kernel/Syscalls/thread.cpp b/Kernel/Syscalls/thread.cpp index f34f9541c8..7a4d3620d4 100644 --- a/Kernel/Syscalls/thread.cpp +++ b/Kernel/Syscalls/thread.cpp @@ -12,7 +12,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$create_thread(void* (*entry)(void*), Userspace<const Syscall::SC_create_thread_params*> user_params) +ErrorOr<FlatPtr> Process::sys$create_thread(void* (*entry)(void*), Userspace<Syscall::SC_create_thread_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::thread)); @@ -169,7 +169,7 @@ ErrorOr<FlatPtr> Process::sys$kill_thread(pid_t tid, int signal) return 0; } -ErrorOr<FlatPtr> Process::sys$set_thread_name(pid_t tid, Userspace<const char*> user_name, size_t user_name_length) +ErrorOr<FlatPtr> Process::sys$set_thread_name(pid_t tid, Userspace<char const*> user_name, size_t user_name_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); diff --git a/Kernel/Syscalls/uname.cpp b/Kernel/Syscalls/uname.cpp index ea8128d660..09922a9624 100644 --- a/Kernel/Syscalls/uname.cpp +++ b/Kernel/Syscalls/uname.cpp @@ -23,7 +23,7 @@ ErrorOr<FlatPtr> Process::sys$uname(Userspace<utsname*> user_buf) memcpy(buf.machine, "x86_64", 7); #endif - hostname().with_shared([&](const auto& name) { + hostname().with_shared([&](auto const& name) { auto length = min(name->length(), UTSNAME_ENTRY_LEN - 1); memcpy(buf.nodename, name->characters(), length); buf.nodename[length] = '\0'; diff --git a/Kernel/Syscalls/unlink.cpp b/Kernel/Syscalls/unlink.cpp index 98526ed9f9..8d39f9ed6a 100644 --- a/Kernel/Syscalls/unlink.cpp +++ b/Kernel/Syscalls/unlink.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$unlink(Userspace<const char*> user_path, size_t path_length) +ErrorOr<FlatPtr> Process::sys$unlink(Userspace<char const*> user_path, size_t path_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::cpath)); diff --git a/Kernel/Syscalls/unveil.cpp b/Kernel/Syscalls/unveil.cpp index b968653c40..3db49b3a87 100644 --- a/Kernel/Syscalls/unveil.cpp +++ b/Kernel/Syscalls/unveil.cpp @@ -24,7 +24,7 @@ static void update_intermediate_node_permissions(UnveilNode& root_node, UnveilAc } } -ErrorOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> user_params) +ErrorOr<FlatPtr> Process::sys$unveil(Userspace<Syscall::SC_unveil_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) auto params = TRY(copy_typed_from_user(user_params)); @@ -52,7 +52,7 @@ ErrorOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> // Let's work out permissions first... unsigned new_permissions = 0; - for (const char permission : permissions->view()) { + for (char const permission : permissions->view()) { switch (permission) { case 'r': new_permissions |= UnveilAccess::Read; diff --git a/Kernel/Syscalls/utime.cpp b/Kernel/Syscalls/utime.cpp index b72599ab04..ad5918aaff 100644 --- a/Kernel/Syscalls/utime.cpp +++ b/Kernel/Syscalls/utime.cpp @@ -10,7 +10,7 @@ namespace Kernel { -ErrorOr<FlatPtr> Process::sys$utime(Userspace<const char*> user_path, size_t path_length, Userspace<const struct utimbuf*> user_buf) +ErrorOr<FlatPtr> Process::sys$utime(Userspace<char const*> user_path, size_t path_length, Userspace<const struct utimbuf*> user_buf) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::fattr)); diff --git a/Kernel/Syscalls/waitid.cpp b/Kernel/Syscalls/waitid.cpp index 7ac7ff4ee8..d204e82e73 100644 --- a/Kernel/Syscalls/waitid.cpp +++ b/Kernel/Syscalls/waitid.cpp @@ -19,7 +19,7 @@ ErrorOr<siginfo_t> Process::do_waitid(Variant<Empty, NonnullRefPtr<Process>, Non return result; } -ErrorOr<FlatPtr> Process::sys$waitid(Userspace<const Syscall::SC_waitid_params*> user_params) +ErrorOr<FlatPtr> Process::sys$waitid(Userspace<Syscall::SC_waitid_params const*> user_params) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::proc)); diff --git a/Kernel/Syscalls/write.cpp b/Kernel/Syscalls/write.cpp index bc7903cf69..c51e949a3d 100644 --- a/Kernel/Syscalls/write.cpp +++ b/Kernel/Syscalls/write.cpp @@ -51,7 +51,7 @@ ErrorOr<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> iov, return nwritten; } -ErrorOr<FlatPtr> Process::do_write(OpenFileDescription& description, const UserOrKernelBuffer& data, size_t data_size) +ErrorOr<FlatPtr> Process::do_write(OpenFileDescription& description, UserOrKernelBuffer const& data, size_t data_size) { size_t total_nwritten = 0; @@ -87,7 +87,7 @@ ErrorOr<FlatPtr> Process::do_write(OpenFileDescription& description, const UserO return total_nwritten; } -ErrorOr<FlatPtr> Process::sys$write(int fd, Userspace<const u8*> data, size_t size) +ErrorOr<FlatPtr> Process::sys$write(int fd, Userspace<u8 const*> data, size_t size) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) TRY(require_promise(Pledge::stdio)); diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index b0217bde42..6c27d348ee 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -55,7 +55,7 @@ ErrorOr<size_t> MasterPTY::read(OpenFileDescription&, u64, UserOrKernelBuffer& b return m_buffer->read(buffer, size); } -ErrorOr<size_t> MasterPTY::write(OpenFileDescription&, u64, const UserOrKernelBuffer& buffer, size_t size) +ErrorOr<size_t> MasterPTY::write(OpenFileDescription&, u64, UserOrKernelBuffer const& buffer, size_t size) { if (!m_slave) return EIO; @@ -63,14 +63,14 @@ ErrorOr<size_t> MasterPTY::write(OpenFileDescription&, u64, const UserOrKernelBu return size; } -bool MasterPTY::can_read(const OpenFileDescription&, u64) const +bool MasterPTY::can_read(OpenFileDescription const&, u64) const { if (!m_slave) return true; return !m_buffer->is_empty(); } -bool MasterPTY::can_write(const OpenFileDescription&, u64) const +bool MasterPTY::can_write(OpenFileDescription const&, u64) const { return true; } @@ -84,7 +84,7 @@ void MasterPTY::notify_slave_closed(Badge<SlavePTY>) m_slave = nullptr; } -ErrorOr<size_t> MasterPTY::on_slave_write(const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> MasterPTY::on_slave_write(UserOrKernelBuffer const& data, size_t size) { if (m_closed) return EIO; @@ -129,7 +129,7 @@ ErrorOr<void> MasterPTY::ioctl(OpenFileDescription& description, unsigned reques } } -ErrorOr<NonnullOwnPtr<KString>> MasterPTY::pseudo_path(const OpenFileDescription&) const +ErrorOr<NonnullOwnPtr<KString>> MasterPTY::pseudo_path(OpenFileDescription const&) const { return KString::formatted("ptm:{}", m_index); } diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h index e6e4eea17c..45528fb5c3 100644 --- a/Kernel/TTY/MasterPTY.h +++ b/Kernel/TTY/MasterPTY.h @@ -20,20 +20,20 @@ public: virtual ~MasterPTY() override; unsigned index() const { return m_index; } - ErrorOr<size_t> on_slave_write(const UserOrKernelBuffer&, size_t); + ErrorOr<size_t> on_slave_write(UserOrKernelBuffer const&, size_t); bool can_write_from_slave() const; void notify_slave_closed(Badge<SlavePTY>); bool is_closed() const { return m_closed; } - virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const override; + virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override; private: explicit MasterPTY(unsigned index, NonnullOwnPtr<DoubleBuffer> buffer); // ^CharacterDevice virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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; + virtual ErrorOr<size_t> 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; virtual ErrorOr<void> close() override; virtual bool is_master_pty() const override { return true; } virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index 9c0a546cf2..7ae972a601 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -24,9 +24,9 @@ public: // ^CharacterDevice virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override; virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return 0; } - virtual ErrorOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return 0; } - virtual bool can_read(const OpenFileDescription&, u64) const override { return true; } - virtual bool can_write(const OpenFileDescription&, u64) const override { return true; } + virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return 0; } + virtual bool can_read(OpenFileDescription const&, u64) const override { return true; } + virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } void notify_master_destroyed(Badge<MasterPTY>, unsigned index); diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index f916a330f3..f04cf1bc2d 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -67,7 +67,7 @@ void SlavePTY::echo(u8 ch) } } -void SlavePTY::on_master_write(const UserOrKernelBuffer& buffer, size_t size) +void SlavePTY::on_master_write(UserOrKernelBuffer const& buffer, size_t size) { auto result = buffer.read_buffered<128>(size, [&](ReadonlyBytes data) { for (const auto& byte : data) @@ -78,18 +78,18 @@ void SlavePTY::on_master_write(const UserOrKernelBuffer& buffer, size_t size) evaluate_block_conditions(); } -ErrorOr<size_t> SlavePTY::on_tty_write(const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> SlavePTY::on_tty_write(UserOrKernelBuffer const& data, size_t size) { m_time_of_last_write = kgettimeofday().to_truncated_seconds(); return m_master->on_slave_write(data, size); } -bool SlavePTY::can_write(const OpenFileDescription&, u64) const +bool SlavePTY::can_write(OpenFileDescription const&, u64) const { return m_master->can_write_from_slave(); } -bool SlavePTY::can_read(const OpenFileDescription& description, u64 offset) const +bool SlavePTY::can_read(OpenFileDescription const& description, u64 offset) const { if (m_master->is_closed()) return true; diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index 0c688c73a8..0901034ec6 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -18,7 +18,7 @@ public: virtual bool unref() const override; virtual ~SlavePTY() override; - void on_master_write(const UserOrKernelBuffer&, size_t); + void on_master_write(UserOrKernelBuffer const&, size_t); unsigned index() const { return m_index; } time_t time_of_last_write() const { return m_time_of_last_write; } @@ -28,13 +28,13 @@ public: private: // ^TTY virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_name() const override; - virtual ErrorOr<size_t> on_tty_write(const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> on_tty_write(UserOrKernelBuffer const&, size_t) override; virtual void echo(u8) override; // ^CharacterDevice - virtual bool can_read(const OpenFileDescription&, u64) const override; + virtual bool can_read(OpenFileDescription const&, u64) const override; virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual bool can_write(const OpenFileDescription&, u64) const override; + virtual bool can_write(OpenFileDescription const&, u64) const override; virtual StringView class_name() const override { return "SlavePTY"sv; } virtual ErrorOr<void> close() override; diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp index aff9b326d1..841e73720f 100644 --- a/Kernel/TTY/TTY.cpp +++ b/Kernel/TTY/TTY.cpp @@ -79,7 +79,7 @@ ErrorOr<size_t> TTY::read(OpenFileDescription&, u64, UserOrKernelBuffer& buffer, return result; } -ErrorOr<size_t> TTY::write(OpenFileDescription&, u64, const UserOrKernelBuffer& buffer, size_t size) +ErrorOr<size_t> TTY::write(OpenFileDescription&, u64, UserOrKernelBuffer const& buffer, size_t size) { if (m_termios.c_lflag & TOSTOP && Process::current().pgid() != pgid()) { [[maybe_unused]] auto rc = Process::current().send_signal(SIGTTOU, nullptr); @@ -138,7 +138,7 @@ void TTY::process_output(u8 ch, Functor put_char) } } -bool TTY::can_read(const OpenFileDescription&, u64) const +bool TTY::can_read(OpenFileDescription const&, u64) const { if (in_canonical_mode()) { return m_available_lines > 0; @@ -146,7 +146,7 @@ bool TTY::can_read(const OpenFileDescription&, u64) const return !m_input_buffer.is_empty(); } -bool TTY::can_write(const OpenFileDescription&, u64) const +bool TTY::can_write(OpenFileDescription const&, u64) const { return true; } @@ -313,8 +313,8 @@ void TTY::do_backspace() void TTY::erase_word() { - //Note: if we have leading whitespace before the word - //we want to delete we have to also delete that. + // Note: if we have leading whitespace before the word + // we want to delete we have to also delete that. bool first_char = false; bool did_dequeue = false; while (can_do_backspace()) { @@ -373,7 +373,7 @@ void TTY::flush_input() evaluate_block_conditions(); } -ErrorOr<void> TTY::set_termios(const termios& t) +ErrorOr<void> TTY::set_termios(termios const& t) { ErrorOr<void> rc; m_termios = t; diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h index a093120b6e..881fe90523 100644 --- a/Kernel/TTY/TTY.h +++ b/Kernel/TTY/TTY.h @@ -22,9 +22,9 @@ public: virtual ~TTY() override; virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual ErrorOr<size_t> 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; + virtual ErrorOr<size_t> 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; virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override final; unsigned short rows() const { return m_rows; } @@ -37,7 +37,7 @@ public: return 0; } - ErrorOr<void> set_termios(const termios&); + ErrorOr<void> set_termios(termios const&); bool should_generate_signals() const { return (m_termios.c_lflag & ISIG) == ISIG; } bool should_flush_on_signal() const { return (m_termios.c_lflag & NOFLSH) != NOFLSH; } bool should_echo_input() const { return (m_termios.c_lflag & ECHO) == ECHO; } @@ -49,7 +49,7 @@ public: virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_name() const = 0; protected: - virtual ErrorOr<size_t> on_tty_write(const UserOrKernelBuffer&, size_t) = 0; + virtual ErrorOr<size_t> on_tty_write(UserOrKernelBuffer const&, size_t) = 0; void set_size(unsigned short columns, unsigned short rows); TTY(MajorNumber major, MinorNumber minor); diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index 9a143918c2..87e1b003e5 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -115,7 +115,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<VirtualConsole> VirtualConsole::create(size_t ind return virtual_console_or_error.release_value(); } -UNMAP_AFTER_INIT NonnullRefPtr<VirtualConsole> VirtualConsole::create_with_preset_log(size_t index, const CircularQueue<char, 16384>& log) +UNMAP_AFTER_INIT NonnullRefPtr<VirtualConsole> VirtualConsole::create_with_preset_log(size_t index, CircularQueue<char, 16384> const& log) { auto virtual_console = VirtualConsole::create(index); // HACK: We have to go through the TTY layer for correct newline handling. @@ -179,7 +179,7 @@ void VirtualConsole::refresh_after_resolution_change() flush_dirty_lines(); } -UNMAP_AFTER_INIT VirtualConsole::VirtualConsole(const unsigned index) +UNMAP_AFTER_INIT VirtualConsole::VirtualConsole(unsigned const index) : TTY(4, index) , m_index(index) , m_console_impl(*this) @@ -258,7 +258,7 @@ void VirtualConsole::on_key_pressed(KeyEvent event) }); } -ErrorOr<size_t> VirtualConsole::on_tty_write(const UserOrKernelBuffer& data, size_t size) +ErrorOr<size_t> VirtualConsole::on_tty_write(UserOrKernelBuffer const& data, size_t size) { SpinlockLocker global_lock(ConsoleManagement::the().tty_write_lock()); auto result = data.read_buffered<512>(size, [&](ReadonlyBytes buffer) { @@ -352,7 +352,7 @@ void VirtualConsole::terminal_history_changed(int) // Do nothing, I guess? } -void VirtualConsole::emit(const u8* data, size_t size) +void VirtualConsole::emit(u8 const* data, size_t size) { for (size_t i = 0; i < size; i++) TTY::emit(data[i], true); diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index e3a9a22ea1..615ad4cf16 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -70,7 +70,7 @@ public: public: static NonnullRefPtr<VirtualConsole> create(size_t index); - static NonnullRefPtr<VirtualConsole> create_with_preset_log(size_t index, const CircularQueue<char, 16384>&); + static NonnullRefPtr<VirtualConsole> create_with_preset_log(size_t index, CircularQueue<char, 16384> const&); virtual ~VirtualConsole() override; @@ -84,13 +84,13 @@ public: void emit_char(char); private: - explicit VirtualConsole(const unsigned index); + explicit VirtualConsole(unsigned const index); // ^KeyboardClient virtual void on_key_pressed(KeyEvent) override; // ^TTY virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_name() const override; - virtual ErrorOr<size_t> on_tty_write(const UserOrKernelBuffer&, size_t) override; + virtual ErrorOr<size_t> on_tty_write(UserOrKernelBuffer const&, size_t) override; virtual void echo(u8) override; // ^TerminalClient @@ -99,7 +99,7 @@ private: virtual void set_window_progress(int, int) override; virtual void terminal_did_resize(u16 columns, u16 rows) override; virtual void terminal_history_changed(int) override; - virtual void emit(const u8*, size_t) override; + virtual void emit(u8 const*, size_t) override; virtual void set_cursor_style(VT::CursorStyle) override; // ^CharacterDevice diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 8b59d957f8..c23c9fd4a2 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -537,14 +537,14 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore) } // NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block<SleepBlocker> which is not const -auto Thread::sleep(clockid_t clock_id, const Time& duration, Time* remaining_time) -> BlockResult +auto Thread::sleep(clockid_t clock_id, Time const& duration, Time* remaining_time) -> BlockResult { VERIFY(state() == Thread::State::Running); return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time); } // NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block<SleepBlocker> which is not const -auto Thread::sleep_until(clockid_t clock_id, const Time& deadline) -> BlockResult +auto Thread::sleep_until(clockid_t clock_id, Time const& deadline) -> BlockResult { VERIFY(state() == Thread::State::Running); return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(true, &deadline, nullptr, clock_id)); @@ -588,7 +588,7 @@ void Thread::finalize() dbgln("Thread {} leaking {} Locks!", *this, lock_count()); SpinlockLocker list_lock(m_holding_locks_lock); for (auto& info : m_holding_locks_list) { - const auto& location = info.lock_location; + auto const& location = info.lock_location; dbgln(" - Mutex: \"{}\" @ {} locked in function \"{}\" at \"{}:{}\" with a count of: {}", info.lock->name(), info.lock, location.function_name(), location.filename(), location.line_number(), info.count); } VERIFY_NOT_REACHED(); @@ -1346,7 +1346,7 @@ void Thread::set_state(State new_state, u8 stop_signal) struct RecognizedSymbol { FlatPtr address; - const KernelSymbol* symbol { nullptr }; + KernelSymbol const* symbol { nullptr }; }; static ErrorOr<bool> symbolicate(RecognizedSymbol const& symbol, Process& process, StringBuilder& builder) diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 38227f8135..5ba85da85b 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -177,7 +177,7 @@ public: } Process& process() { return m_process; } - const Process& process() const { return m_process; } + Process const& process() const { return m_process; } // NOTE: This returns a null-terminated string. StringView name() const @@ -252,10 +252,10 @@ public: : m_infinite(true) { } - explicit BlockTimeout(bool is_absolute, const Time* time, const Time* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE); + explicit BlockTimeout(bool is_absolute, Time const* time, Time const* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE); - const Time& absolute_time() const { return m_time; } - const Time* start_time() const { return !m_infinite ? &m_start_time : nullptr; } + Time const& absolute_time() const { return m_time; } + Time const* start_time() const { return !m_infinite ? &m_start_time : nullptr; } clockid_t clock_id() const { return m_clock_id; } bool is_infinite() const { return m_infinite; } @@ -288,7 +288,7 @@ public: virtual ~Blocker(); virtual StringView state_string() const = 0; virtual Type blocker_type() const = 0; - virtual const BlockTimeout& override_timeout(const BlockTimeout& timeout) { return timeout; } + virtual BlockTimeout const& override_timeout(BlockTimeout const& timeout) { return timeout; } virtual bool can_be_interrupted() const { return true; } virtual bool setup_blocker(); virtual void finalize(); @@ -600,7 +600,7 @@ public: class OpenFileDescriptionBlocker : public FileBlocker { public: - const OpenFileDescription& blocked_description() const; + OpenFileDescription const& blocked_description() const; virtual bool unblock_if_conditions_are_met(bool, void*) override; virtual void will_unblock_immediately_without_blocking(UnblockImmediatelyReason) override; @@ -632,7 +632,7 @@ public: public: explicit WriteBlocker(OpenFileDescription&, BlockFlags&); virtual StringView state_string() const override { return "Writing"sv; } - virtual const BlockTimeout& override_timeout(const BlockTimeout&) override; + virtual BlockTimeout const& override_timeout(BlockTimeout const&) override; private: BlockTimeout m_timeout; @@ -642,7 +642,7 @@ public: public: explicit ReadBlocker(OpenFileDescription&, BlockFlags&); virtual StringView state_string() const override { return "Reading"sv; } - virtual const BlockTimeout& override_timeout(const BlockTimeout&) override; + virtual BlockTimeout const& override_timeout(BlockTimeout const&) override; private: BlockTimeout m_timeout; @@ -650,10 +650,10 @@ public: class SleepBlocker final : public Blocker { public: - explicit SleepBlocker(const BlockTimeout&, Time* = nullptr); + explicit SleepBlocker(BlockTimeout const&, Time* = nullptr); virtual StringView state_string() const override { return "Sleeping"sv; } virtual Type blocker_type() const override { return Type::Sleep; } - virtual const BlockTimeout& override_timeout(const BlockTimeout&) override; + virtual BlockTimeout const& override_timeout(BlockTimeout const&) override; virtual void will_unblock_immediately_without_blocking(UnblockImmediatelyReason) override; virtual void was_unblocked(bool) override; virtual Thread::BlockResult block_result() override; @@ -747,9 +747,9 @@ public: private: void do_was_disowned(); - void do_set_result(const siginfo_t&); + void do_set_result(siginfo_t const&); - const int m_wait_options; + int const m_wait_options; ErrorOr<siginfo_t>& m_result; Variant<Empty, NonnullRefPtr<Process>, NonnullRefPtr<ProcessGroup>> m_waitee; bool m_did_unblock { false }; @@ -823,10 +823,10 @@ public: void set_affinity(u32 affinity) { m_cpu_affinity = affinity; } RegisterState& get_register_dump_from_stack(); - const RegisterState& get_register_dump_from_stack() const { return const_cast<Thread*>(this)->get_register_dump_from_stack(); } + RegisterState const& get_register_dump_from_stack() const { return const_cast<Thread*>(this)->get_register_dump_from_stack(); } DebugRegisterState& debug_register_state() { return m_debug_register_state; } - const DebugRegisterState& debug_register_state() const { return m_debug_register_state; } + DebugRegisterState const& debug_register_state() const { return m_debug_register_state; } ThreadRegisters& regs() { return m_regs; } ThreadRegisters const& regs() const { return m_regs; } @@ -869,19 +869,19 @@ public: void unblock(u8 signal = 0); template<class... Args> - Thread::BlockResult wait_on(WaitQueue& wait_queue, const Thread::BlockTimeout& timeout, Args&&... args) + Thread::BlockResult wait_on(WaitQueue& wait_queue, Thread::BlockTimeout const& timeout, Args&&... args) { VERIFY(this == Thread::current()); return block<Thread::WaitQueueBlocker>(timeout, wait_queue, forward<Args>(args)...); } - BlockResult sleep(clockid_t, const Time&, Time* = nullptr); - BlockResult sleep(const Time& duration, Time* remaining_time = nullptr) + BlockResult sleep(clockid_t, Time const&, Time* = nullptr); + BlockResult sleep(Time const& duration, Time* remaining_time = nullptr) { return sleep(CLOCK_MONOTONIC_COARSE, duration, remaining_time); } - BlockResult sleep_until(clockid_t, const Time&); - BlockResult sleep_until(const Time& duration) + BlockResult sleep_until(clockid_t, Time const&); + BlockResult sleep_until(Time const& duration) { return sleep_until(CLOCK_MONOTONIC_COARSE, duration); } diff --git a/Kernel/ThreadBlockers.cpp b/Kernel/ThreadBlockers.cpp index c24d0aae9f..e05a94fed1 100644 --- a/Kernel/ThreadBlockers.cpp +++ b/Kernel/ThreadBlockers.cpp @@ -14,7 +14,7 @@ namespace Kernel { -Thread::BlockTimeout::BlockTimeout(bool is_absolute, const Time* time, const Time* start_time, clockid_t clock_id) +Thread::BlockTimeout::BlockTimeout(bool is_absolute, Time const* time, Time const* start_time, clockid_t clock_id) : m_clock_id(clock_id) , m_infinite(!time) { @@ -245,7 +245,7 @@ void Thread::OpenFileDescriptionBlocker::will_unblock_immediately_without_blocki unblock_if_conditions_are_met(false, nullptr); } -const OpenFileDescription& Thread::OpenFileDescriptionBlocker::blocked_description() const +OpenFileDescription const& Thread::OpenFileDescriptionBlocker::blocked_description() const { return m_blocked_description; } @@ -265,7 +265,7 @@ Thread::WriteBlocker::WriteBlocker(OpenFileDescription& description, BlockFlags& { } -auto Thread::WriteBlocker::override_timeout(const BlockTimeout& timeout) -> const BlockTimeout& +auto Thread::WriteBlocker::override_timeout(BlockTimeout const& timeout) -> BlockTimeout const& { auto const& description = blocked_description(); if (description.is_socket()) { @@ -285,7 +285,7 @@ Thread::ReadBlocker::ReadBlocker(OpenFileDescription& description, BlockFlags& u { } -auto Thread::ReadBlocker::override_timeout(const BlockTimeout& timeout) -> const BlockTimeout& +auto Thread::ReadBlocker::override_timeout(BlockTimeout const& timeout) -> BlockTimeout const& { auto const& description = blocked_description(); if (description.is_socket()) { @@ -300,13 +300,13 @@ auto Thread::ReadBlocker::override_timeout(const BlockTimeout& timeout) -> const return timeout; } -Thread::SleepBlocker::SleepBlocker(const BlockTimeout& deadline, Time* remaining) +Thread::SleepBlocker::SleepBlocker(BlockTimeout const& deadline, Time* remaining) : m_deadline(deadline) , m_remaining(remaining) { } -auto Thread::SleepBlocker::override_timeout(const BlockTimeout& timeout) -> const BlockTimeout& +auto Thread::SleepBlocker::override_timeout(BlockTimeout const& timeout) -> BlockTimeout const& { VERIFY(timeout.is_infinite()); // A timeout should not be provided // To simplify things only use the sleep deadline. @@ -688,7 +688,7 @@ void Thread::WaitBlocker::do_was_disowned() m_result = ECHILD; } -void Thread::WaitBlocker::do_set_result(const siginfo_t& result) +void Thread::WaitBlocker::do_set_result(siginfo_t const& result) { VERIFY(!m_did_unblock); m_did_unblock = true; diff --git a/Kernel/ThreadTracer.cpp b/Kernel/ThreadTracer.cpp index 359e60e31a..97d811bf47 100644 --- a/Kernel/ThreadTracer.cpp +++ b/Kernel/ThreadTracer.cpp @@ -14,7 +14,7 @@ ThreadTracer::ThreadTracer(ProcessID tracer_pid) { } -void ThreadTracer::set_regs(const RegisterState& regs) +void ThreadTracer::set_regs(RegisterState const& regs) { PtraceRegisters r {}; copy_kernel_registers_into_ptrace_registers(r, regs); diff --git a/Kernel/ThreadTracer.h b/Kernel/ThreadTracer.h index 589e0a7d27..29b1ef1e60 100644 --- a/Kernel/ThreadTracer.h +++ b/Kernel/ThreadTracer.h @@ -26,10 +26,10 @@ public: bool is_tracing_syscalls() const { return m_trace_syscalls; } void set_trace_syscalls(bool val) { m_trace_syscalls = val; } - void set_regs(const RegisterState& regs); - void set_regs(const PtraceRegisters& regs) { m_regs = regs; } + void set_regs(RegisterState const& regs); + void set_regs(PtraceRegisters const& regs) { m_regs = regs; } bool has_regs() const { return m_regs.has_value(); } - const PtraceRegisters& regs() const + PtraceRegisters const& regs() const { VERIFY(m_regs.has_value()); return m_regs.value(); diff --git a/Kernel/Time/APICTimer.cpp b/Kernel/Time/APICTimer.cpp index 273cb08b28..4131627d24 100644 --- a/Kernel/Time/APICTimer.cpp +++ b/Kernel/Time/APICTimer.cpp @@ -24,7 +24,7 @@ UNMAP_AFTER_INIT APICTimer* APICTimer::initialize(u8 interrupt_number, HardwareT return &timer.leak_ref(); } -UNMAP_AFTER_INIT APICTimer::APICTimer(u8 interrupt_number, Function<void(const RegisterState&)> callback) +UNMAP_AFTER_INIT APICTimer::APICTimer(u8 interrupt_number, Function<void(RegisterState const&)> callback) : HardwareTimer<GenericInterruptHandler>(interrupt_number, move(callback)) { disable_remap(); @@ -50,7 +50,7 @@ UNMAP_AFTER_INIT bool APICTimer::calibrate(HardwareTimerBase& calibration_source volatile u64 start_reference = 0, end_reference = 0; volatile u32 start_apic_count = 0, end_apic_count = 0; bool query_reference = calibration_source.can_query_raw(); - auto original_source_callback = calibration_source.set_callback([&](const RegisterState&) { + auto original_source_callback = calibration_source.set_callback([&](RegisterState const&) { u32 current_timer_count = apic.get_timer_current_count(); #ifdef APIC_TIMER_MEASURE_CPU_CLOCK u64 current_tsc = supports_tsc ? read_tsc() : 0; @@ -77,7 +77,7 @@ UNMAP_AFTER_INIT bool APICTimer::calibrate(HardwareTimerBase& calibration_source // We don't want the APIC timer to actually fire. We do however want the // calbibration_source timer to fire so that we can read the current // tick count from the APIC timer - auto original_callback = set_callback([&](const RegisterState&) { + auto original_callback = set_callback([&](RegisterState const&) { // TODO: How should we handle this? PANIC("APICTimer: Timer fired during calibration!"); }); diff --git a/Kernel/Time/APICTimer.h b/Kernel/Time/APICTimer.h index 400adb79be..88d51c6e90 100644 --- a/Kernel/Time/APICTimer.h +++ b/Kernel/Time/APICTimer.h @@ -35,7 +35,7 @@ public: void disable_local_timer(); private: - explicit APICTimer(u8, Function<void(const RegisterState&)>); + explicit APICTimer(u8, Function<void(RegisterState const&)>); bool calibrate(HardwareTimerBase&); diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index 708dd2500f..231ce1065c 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -90,7 +90,7 @@ static_assert(__builtin_offsetof(HPETRegistersBlock, timers[1]) == 0x120); // MMIO space has to be 1280 bytes and not 1024 bytes. static_assert(AssertSize<HPETRegistersBlock, 0x500>()); -static u64 read_register_safe64(const HPETRegister& reg) +static u64 read_register_safe64(HPETRegister const& reg) { #if ARCH(X86_64) return reg.full; @@ -238,7 +238,7 @@ void HPET::update_periodic_comparator_value() global_enable(); } -void HPET::update_non_periodic_comparator_value(const HPETComparator& comparator) +void HPET::update_non_periodic_comparator_value(HPETComparator const& comparator) { VERIFY_INTERRUPTS_DISABLED(); VERIFY(!comparator.is_periodic()); @@ -306,7 +306,7 @@ u64 HPET::read_main_counter() const return ((u64)wraps << 32) | (u64)current_value; } -void HPET::enable_periodic_interrupt(const HPETComparator& comparator) +void HPET::enable_periodic_interrupt(HPETComparator const& comparator) { dbgln_if(HPET_DEBUG, "HPET: Set comparator {} to be periodic.", comparator.comparator_number()); disable(comparator); @@ -318,7 +318,7 @@ void HPET::enable_periodic_interrupt(const HPETComparator& comparator) if (comparator.is_enabled()) enable(comparator); } -void HPET::disable_periodic_interrupt(const HPETComparator& comparator) +void HPET::disable_periodic_interrupt(HPETComparator const& comparator) { dbgln_if(HPET_DEBUG, "HPET: Disable periodic interrupt in comparator {}", comparator.comparator_number()); disable(comparator); @@ -331,14 +331,14 @@ void HPET::disable_periodic_interrupt(const HPETComparator& comparator) enable(comparator); } -void HPET::disable(const HPETComparator& comparator) +void HPET::disable(HPETComparator const& comparator) { dbgln_if(HPET_DEBUG, "HPET: Disable comparator {}", comparator.comparator_number()); VERIFY(comparator.comparator_number() <= m_comparators.size()); auto& timer = registers().timers[comparator.comparator_number()]; timer.capabilities = timer.capabilities & ~(u32)HPETFlags::TimerConfiguration::InterruptEnable; } -void HPET::enable(const HPETComparator& comparator) +void HPET::enable(HPETComparator const& comparator) { dbgln_if(HPET_DEBUG, "HPET: Enable comparator {}", comparator.comparator_number()); VERIFY(comparator.comparator_number() <= m_comparators.size()); @@ -346,7 +346,7 @@ void HPET::enable(const HPETComparator& comparator) timer.capabilities = timer.capabilities | (u32)HPETFlags::TimerConfiguration::InterruptEnable; } -Vector<unsigned> HPET::capable_interrupt_numbers(const HPETComparator& comparator) +Vector<unsigned> HPET::capable_interrupt_numbers(HPETComparator const& comparator) { VERIFY(comparator.comparator_number() <= m_comparators.size()); Vector<unsigned> capable_interrupts; @@ -408,9 +408,9 @@ PhysicalAddress HPET::find_acpi_hpet_registers_block() return PhysicalAddress(sdt->event_timer_block.address); } -const HPETRegistersBlock& HPET::registers() const +HPETRegistersBlock const& HPET::registers() const { - return *(const HPETRegistersBlock*)m_hpet_mmio_region->vaddr().offset(m_physical_acpi_hpet_registers.offset_in_page()).as_ptr(); + return *(HPETRegistersBlock const*)m_hpet_mmio_region->vaddr().offset(m_physical_acpi_hpet_registers.offset_in_page()).as_ptr(); } HPETRegistersBlock& HPET::registers() diff --git a/Kernel/Time/HPET.h b/Kernel/Time/HPET.h index 620219ec98..799c3439d9 100644 --- a/Kernel/Time/HPET.h +++ b/Kernel/Time/HPET.h @@ -29,27 +29,27 @@ public: u64 raw_counter_ticks_to_ns(u64) const; u64 ns_to_raw_counter_ticks(u64) const; - const NonnullRefPtrVector<HPETComparator>& comparators() const { return m_comparators; } - void disable(const HPETComparator&); - void enable(const HPETComparator&); + NonnullRefPtrVector<HPETComparator> const& comparators() const { return m_comparators; } + void disable(HPETComparator const&); + void enable(HPETComparator const&); void update_periodic_comparator_value(); - void update_non_periodic_comparator_value(const HPETComparator& comparator); + void update_non_periodic_comparator_value(HPETComparator const& comparator); void set_comparator_irq_vector(u8 comparator_number, u8 irq_vector); - void enable_periodic_interrupt(const HPETComparator& comparator); - void disable_periodic_interrupt(const HPETComparator& comparator); + void enable_periodic_interrupt(HPETComparator const& comparator); + void disable_periodic_interrupt(HPETComparator const& comparator); u64 update_time(u64& seconds_since_boot, u32& ticks_this_second, bool query_only); u64 read_main_counter_unsafe() const; u64 read_main_counter() const; Vector<unsigned> capable_interrupt_numbers(u8 comparator_number); - Vector<unsigned> capable_interrupt_numbers(const HPETComparator&); + Vector<unsigned> capable_interrupt_numbers(HPETComparator const&); private: - const HPETRegistersBlock& registers() const; + HPETRegistersBlock const& registers() const; HPETRegistersBlock& registers(); void global_disable(); diff --git a/Kernel/Time/HPETComparator.cpp b/Kernel/Time/HPETComparator.cpp index 55718053da..ce95a93fbf 100644 --- a/Kernel/Time/HPETComparator.cpp +++ b/Kernel/Time/HPETComparator.cpp @@ -53,7 +53,7 @@ void HPETComparator::set_non_periodic() HPET::the().disable_periodic_interrupt(*this); } -bool HPETComparator::handle_irq(const RegisterState& regs) +bool HPETComparator::handle_irq(RegisterState const& regs) { auto result = HardwareTimer::handle_irq(regs); if (!is_periodic()) diff --git a/Kernel/Time/HPETComparator.h b/Kernel/Time/HPETComparator.h index a09408ce0d..584c0499be 100644 --- a/Kernel/Time/HPETComparator.h +++ b/Kernel/Time/HPETComparator.h @@ -43,7 +43,7 @@ public: private: void set_new_countdown(); - virtual bool handle_irq(const RegisterState&) override; + virtual bool handle_irq(RegisterState const&) override; HPETComparator(u8 number, u8 irq, bool periodic_capable, bool is_64bit_capable); bool m_periodic : 1; bool m_periodic_capable : 1; diff --git a/Kernel/Time/HardwareTimer.h b/Kernel/Time/HardwareTimer.h index 2f637db3f4..96643e820b 100644 --- a/Kernel/Time/HardwareTimer.h +++ b/Kernel/Time/HardwareTimer.h @@ -36,7 +36,7 @@ public: virtual StringView model() const = 0; virtual HardwareTimerType timer_type() const = 0; - virtual Function<void(const RegisterState&)> set_callback(Function<void(const RegisterState&)>) = 0; + virtual Function<void(RegisterState const&)> set_callback(Function<void(RegisterState const&)>) = 0; virtual bool is_periodic() const = 0; virtual bool is_periodic_capable() const = 0; @@ -73,7 +73,7 @@ public: return model(); } - virtual Function<void(const RegisterState&)> set_callback(Function<void(const RegisterState&)> callback) override + virtual Function<void(RegisterState const&)> set_callback(Function<void(RegisterState const&)> callback) override { disable_irq(); auto previous_callback = move(m_callback); @@ -85,13 +85,13 @@ public: virtual u32 frequency() const override { return (u32)m_frequency; } protected: - HardwareTimer(u8 irq_number, Function<void(const RegisterState&)> callback = nullptr) + HardwareTimer(u8 irq_number, Function<void(RegisterState const&)> callback = nullptr) : IRQHandler(irq_number) , m_callback(move(callback)) { } - virtual bool handle_irq(const RegisterState& regs) override + virtual bool handle_irq(RegisterState const& regs) override { // Note: if we have an IRQ on this line, it's going to be the timer always if (m_callback) { @@ -104,7 +104,7 @@ protected: u64 m_frequency { OPTIMAL_TICKS_PER_SECOND_RATE }; private: - Function<void(const RegisterState&)> m_callback; + Function<void(RegisterState const&)> m_callback; }; template<> @@ -122,7 +122,7 @@ public: return model(); } - virtual Function<void(const RegisterState&)> set_callback(Function<void(const RegisterState&)> callback) override + virtual Function<void(RegisterState const&)> set_callback(Function<void(RegisterState const&)> callback) override { auto previous_callback = move(m_callback); m_callback = move(callback); @@ -139,13 +139,13 @@ public: virtual u32 frequency() const override { return (u32)m_frequency; } protected: - HardwareTimer(u8 irq_number, Function<void(const RegisterState&)> callback = nullptr) + HardwareTimer(u8 irq_number, Function<void(RegisterState const&)> callback = nullptr) : GenericInterruptHandler(irq_number) , m_callback(move(callback)) { } - virtual bool handle_interrupt(const RegisterState& regs) override + virtual bool handle_interrupt(RegisterState const& regs) override { // Note: if we have an IRQ on this line, it's going to be the timer always if (m_callback) { @@ -158,7 +158,7 @@ protected: u64 m_frequency { OPTIMAL_TICKS_PER_SECOND_RATE }; private: - Function<void(const RegisterState&)> m_callback; + Function<void(RegisterState const&)> m_callback; }; } diff --git a/Kernel/Time/PIT.cpp b/Kernel/Time/PIT.cpp index 642b5b4686..455a77240e 100644 --- a/Kernel/Time/PIT.cpp +++ b/Kernel/Time/PIT.cpp @@ -16,7 +16,7 @@ #define IRQ_TIMER 0 namespace Kernel { -UNMAP_AFTER_INIT NonnullRefPtr<PIT> PIT::initialize(Function<void(const RegisterState&)> callback) +UNMAP_AFTER_INIT NonnullRefPtr<PIT> PIT::initialize(Function<void(RegisterState const&)> callback) { return adopt_ref(*new PIT(move(callback))); } @@ -28,7 +28,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<PIT> PIT::initialize(Function<void(const Register IO::out8(TIMER0_CTL, MSB(timer_reload)); } -PIT::PIT(Function<void(const RegisterState&)> callback) +PIT::PIT(Function<void(RegisterState const&)> callback) : HardwareTimer(IRQ_TIMER, move(callback)) , m_periodic(true) { diff --git a/Kernel/Time/PIT.h b/Kernel/Time/PIT.h index 3840693005..081ecb9523 100644 --- a/Kernel/Time/PIT.h +++ b/Kernel/Time/PIT.h @@ -34,7 +34,7 @@ namespace Kernel { class PIT final : public HardwareTimer<IRQHandler> { public: - static NonnullRefPtr<PIT> initialize(Function<void(const RegisterState&)>); + static NonnullRefPtr<PIT> initialize(Function<void(RegisterState const&)>); virtual HardwareTimerType timer_type() const override { return HardwareTimerType::i8253; } virtual StringView model() const override { return "i8254"sv; } virtual size_t ticks_per_second() const override; @@ -51,7 +51,7 @@ public: virtual size_t calculate_nearest_possible_frequency(size_t frequency) const override; private: - explicit PIT(Function<void(const RegisterState&)>); + explicit PIT(Function<void(RegisterState const&)>); bool m_periodic { true }; }; } diff --git a/Kernel/Time/RTC.cpp b/Kernel/Time/RTC.cpp index 34b928644f..86c2d38842 100644 --- a/Kernel/Time/RTC.cpp +++ b/Kernel/Time/RTC.cpp @@ -14,11 +14,11 @@ namespace Kernel { #define IRQ_TIMER 8 #define MAX_FREQUENCY 8000 -NonnullRefPtr<RealTimeClock> RealTimeClock::create(Function<void(const RegisterState&)> callback) +NonnullRefPtr<RealTimeClock> RealTimeClock::create(Function<void(RegisterState const&)> callback) { return adopt_ref(*new RealTimeClock(move(callback))); } -RealTimeClock::RealTimeClock(Function<void(const RegisterState&)> callback) +RealTimeClock::RealTimeClock(Function<void(RegisterState const&)> callback) : HardwareTimer(IRQ_TIMER, move(callback)) { InterruptDisabler disabler; @@ -27,7 +27,7 @@ RealTimeClock::RealTimeClock(Function<void(const RegisterState&)> callback) CMOS::write(0x8B, CMOS::read(0xB) | 0x40); reset_to_default_ticks_per_second(); } -bool RealTimeClock::handle_irq(const RegisterState& regs) +bool RealTimeClock::handle_irq(RegisterState const& regs) { auto result = HardwareTimer::handle_irq(regs); CMOS::read(0x8C); diff --git a/Kernel/Time/RTC.h b/Kernel/Time/RTC.h index c745194a11..c0b3ab4c7b 100644 --- a/Kernel/Time/RTC.h +++ b/Kernel/Time/RTC.h @@ -13,7 +13,7 @@ namespace Kernel { class RealTimeClock final : public HardwareTimer<IRQHandler> { public: - static NonnullRefPtr<RealTimeClock> create(Function<void(const RegisterState&)> callback); + static NonnullRefPtr<RealTimeClock> create(Function<void(RegisterState const&)> callback); virtual HardwareTimerType timer_type() const override { return HardwareTimerType::RTC; } virtual StringView model() const override { return "Real Time Clock"sv; } virtual size_t ticks_per_second() const override; @@ -30,7 +30,7 @@ public: virtual size_t calculate_nearest_possible_frequency(size_t frequency) const override; private: - explicit RealTimeClock(Function<void(const RegisterState&)> callback); - virtual bool handle_irq(const RegisterState&) override; + explicit RealTimeClock(Function<void(RegisterState const&)> callback); + virtual bool handle_irq(RegisterState const&) override; }; } diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp index 2b6abbb2fa..811cd7a4ef 100644 --- a/Kernel/Time/TimeManagement.cpp +++ b/Kernel/Time/TimeManagement.cpp @@ -70,7 +70,7 @@ Time TimeManagement::current_time(clockid_t clock_id) const } } -bool TimeManagement::is_system_timer(const HardwareTimerBase& timer) const +bool TimeManagement::is_system_timer(HardwareTimerBase const& timer) const { return &timer == m_system_timer.ptr(); } @@ -282,7 +282,7 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_non_legacy_hardware_timers() taken_non_periodic_timers_count += 1; } - m_system_timer->set_callback([this](const RegisterState& regs) { + m_system_timer->set_callback([this](RegisterState const& regs) { // Update the time. We don't really care too much about the // frequency of the interrupt because we'll query the main // counter to get an accurate time. @@ -343,7 +343,7 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_legacy_hardware_timers() return true; } -void TimeManagement::update_time(const RegisterState&) +void TimeManagement::update_time(RegisterState const&) { TimeManagement::the().increment_time_since_boot(); } @@ -406,7 +406,7 @@ void TimeManagement::increment_time_since_boot() update_time_page(); } -void TimeManagement::system_timer_tick(const RegisterState& regs) +void TimeManagement::system_timer_tick(RegisterState const& regs) { if (Processor::current_in_irq() <= 1) { // Don't expire timers while handling IRQs diff --git a/Kernel/Time/TimeManagement.h b/Kernel/Time/TimeManagement.h index 6c72279457..76b38ecf92 100644 --- a/Kernel/Time/TimeManagement.h +++ b/Kernel/Time/TimeManagement.h @@ -49,10 +49,10 @@ public: time_t ticks_per_second() const; time_t boot_time() const; - bool is_system_timer(const HardwareTimerBase&) const; + bool is_system_timer(HardwareTimerBase const&) const; - static void update_time(const RegisterState&); - static void update_time_hpet(const RegisterState&); + static void update_time(RegisterState const&); + static void update_time_hpet(RegisterState const&); void increment_time_since_boot_hpet(); void increment_time_since_boot(); @@ -69,7 +69,7 @@ public: timespec remaining_epoch_time_adjustment() const { return m_remaining_epoch_time_adjustment; } // FIXME: Should use AK::Time internally // FIXME: Also, most likely broken, because it does not check m_update[12] for in-progress updates. - void set_remaining_epoch_time_adjustment(const timespec& adjustment) { m_remaining_epoch_time_adjustment = adjustment; } + void set_remaining_epoch_time_adjustment(timespec const& adjustment) { m_remaining_epoch_time_adjustment = adjustment; } bool can_query_precise_time() const { return m_can_query_precise_time; } @@ -85,7 +85,7 @@ private: Vector<HardwareTimerBase*> scan_for_non_periodic_timers(); NonnullRefPtrVector<HardwareTimerBase> m_hardware_timers; void set_system_timer(HardwareTimerBase&); - static void system_timer_tick(const RegisterState&); + static void system_timer_tick(RegisterState const&); static u64 scheduling_current_time(bool); diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp index 8bf69f302e..cd2d774438 100644 --- a/Kernel/TimerQueue.cpp +++ b/Kernel/TimerQueue.cpp @@ -55,7 +55,7 @@ UNMAP_AFTER_INIT TimerQueue::TimerQueue() m_ticks_per_second = TimeManagement::the().ticks_per_second(); } -bool TimerQueue::add_timer_without_id(NonnullRefPtr<Timer> timer, clockid_t clock_id, const Time& deadline, Function<void()>&& callback) +bool TimerQueue::add_timer_without_id(NonnullRefPtr<Timer> timer, clockid_t clock_id, Time const& deadline, Function<void()>&& callback) { if (deadline <= TimeManagement::the().current_time(clock_id)) return false; diff --git a/Kernel/TimerQueue.h b/Kernel/TimerQueue.h index e795db7b48..a9e59bd774 100644 --- a/Kernel/TimerQueue.h +++ b/Kernel/TimerQueue.h @@ -47,15 +47,15 @@ private: Atomic<bool> m_callback_finished { false }; Atomic<bool> m_in_use { false }; - bool operator<(const Timer& rhs) const + bool operator<(Timer const& rhs) const { return m_expires < rhs.m_expires; } - bool operator>(const Timer& rhs) const + bool operator>(Timer const& rhs) const { return m_expires > rhs.m_expires; } - bool operator==(const Timer& rhs) const + bool operator==(Timer const& rhs) const { return m_id == rhs.m_id; } @@ -88,7 +88,7 @@ public: static TimerQueue& the(); TimerId add_timer(NonnullRefPtr<Timer>&&); - bool add_timer_without_id(NonnullRefPtr<Timer>, clockid_t, const Time&, Function<void()>&&); + bool add_timer_without_id(NonnullRefPtr<Timer>, clockid_t, Time const&, Function<void()>&&); bool cancel_timer(Timer& timer, bool* was_in_use = nullptr); void fire(); diff --git a/Kernel/UBSanitizer.cpp b/Kernel/UBSanitizer.cpp index 3edccc960e..3cc6292723 100644 --- a/Kernel/UBSanitizer.cpp +++ b/Kernel/UBSanitizer.cpp @@ -16,7 +16,7 @@ Atomic<bool> AK::UBSanitizer::g_ubsan_is_deadly { true }; extern "C" { -static void print_location(const SourceLocation& location) +static void print_location(SourceLocation const& location) { if (!location.filename()) critical_dmesgln("KUBSAN: in unknown file"); @@ -29,102 +29,102 @@ static void print_location(const SourceLocation& location) } } -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) { critical_dmesgln("KUBSAN: load-invalid-value: {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: null pointer passed as argument {}, which is declared to never be null", data.argument_index); 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) { critical_dmesgln("KUBSAN: null pointer passed as argument {}, which is declared to never be null", data.argument_index); 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) { critical_dmesgln("KUBSAN: null pointer return from function declared to never return null"); 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) { critical_dmesgln("KUBSAN: null pointer return from function declared to never return null"); 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) { critical_dmesgln("KUBSAN: VLA bound not positive {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: addition overflow, {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: subtraction overflow, {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: negation overflow, {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: multiplication overflow, {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: shift out of bounds, {} ({}-bit) shifted by {} ({}-bit)", data.lhs_type.name(), data.lhs_type.bit_width(), data.rhs_type.name(), data.rhs_type.bit_width()); 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) { critical_dmesgln("KUBSAN: divrem overflow, {} ({}-bit)", data.type.name(), data.type.bit_width()); 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) { critical_dmesgln("KUBSAN: out of bounds access into array of {} ({}-bit), index type {} ({}-bit)", data.array_type.name(), data.array_type.bit_width(), data.index_type.name(), data.index_type.bit_width()); 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 ptr) +void __ubsan_handle_type_mismatch_v1(TypeMismatchData const&, ValueHandle) __attribute__((used)); +void __ubsan_handle_type_mismatch_v1(TypeMismatchData const& data, ValueHandle ptr) { constexpr StringView kinds[] = { "load of", @@ -154,8 +154,8 @@ void __ubsan_handle_type_mismatch_v1(const TypeMismatchData& data, ValueHandle p 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 pointer, ValueHandle alignment, ValueHandle offset) +void __ubsan_handle_alignment_assumption(AlignmentAssumptionData const&, ValueHandle, ValueHandle, ValueHandle) __attribute__((used)); +void __ubsan_handle_alignment_assumption(AlignmentAssumptionData const& data, ValueHandle pointer, ValueHandle alignment, ValueHandle offset) { if (offset) critical_dmesgln("KUBSAN: assumption of {:p} byte alignment (with offset of {:p} byte) for pointer {:p} of type {} failed", alignment, offset, pointer, data.type.name()); @@ -165,25 +165,25 @@ void __ubsan_handle_alignment_assumption(const AlignmentAssumptionData& data, Va 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) { critical_dmesgln("KUBSAN: execution reached an unreachable program point"); 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) { critical_dmesgln("KUBSAN: execution reached the end of a value-returning function without returning a value"); 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) { - const char* src_signed = data.from_type.is_signed() ? "" : "un"; - const char* dst_signed = data.to_type.is_signed() ? "" : "un"; + char const* src_signed = data.from_type.is_signed() ? "" : "un"; + char const* dst_signed = data.to_type.is_signed() ? "" : "un"; critical_dmesgln("KUBSAN: implicit conversion from type {} ({}-bit, {}signed) to type {} ({}-bit, {}signed)", data.from_type.name(), data.from_type.bit_width(), src_signed, data.to_type.name(), data.to_type.bit_width(), dst_signed); print_location(data.location); } @@ -195,8 +195,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 base, ValueHandle result) +void __ubsan_handle_pointer_overflow(PointerOverflowData const&, ValueHandle, ValueHandle) __attribute__((used)); +void __ubsan_handle_pointer_overflow(PointerOverflowData const& data, ValueHandle base, ValueHandle result) { if (base == 0 && result == 0) critical_dmesgln("KUBSAN: applied zero offset to nullptr"); diff --git a/Kernel/UserOrKernelBuffer.h b/Kernel/UserOrKernelBuffer.h index 4b9e47c767..7e6f8600bf 100644 --- a/Kernel/UserOrKernelBuffer.h +++ b/Kernel/UserOrKernelBuffer.h @@ -38,11 +38,11 @@ public: { if (!Memory::is_user_range(VirtualAddress(userspace.unsafe_userspace_ptr()), size)) return Error::from_errno(EFAULT); - return UserOrKernelBuffer(const_cast<u8*>((const u8*)userspace.unsafe_userspace_ptr())); + return UserOrKernelBuffer(const_cast<u8*>((u8 const*)userspace.unsafe_userspace_ptr())); } [[nodiscard]] bool is_kernel_buffer() const; - [[nodiscard]] const void* user_or_kernel_ptr() const { return m_buffer; } + [[nodiscard]] void const* user_or_kernel_ptr() const { return m_buffer; } [[nodiscard]] UserOrKernelBuffer offset(size_t offset) const { @@ -55,8 +55,8 @@ public: } ErrorOr<NonnullOwnPtr<KString>> try_copy_into_kstring(size_t) const; - ErrorOr<void> write(const void* src, size_t offset, size_t len); - ErrorOr<void> write(const void* src, size_t len) + ErrorOr<void> write(void const* src, size_t offset, size_t len); + ErrorOr<void> write(void const* src, size_t len) { return write(src, 0, len); } diff --git a/Kernel/VirtualAddress.h b/Kernel/VirtualAddress.h index 28febf6097..82ba5a88ef 100644 --- a/Kernel/VirtualAddress.h +++ b/Kernel/VirtualAddress.h @@ -17,7 +17,7 @@ public: { } - explicit VirtualAddress(const void* address) + explicit VirtualAddress(void const* address) : m_address((FlatPtr)address) { } @@ -30,16 +30,16 @@ public: void set(FlatPtr address) { m_address = address; } void mask(FlatPtr m) { m_address &= m; } - bool operator<=(const VirtualAddress& other) const { return m_address <= other.m_address; } - bool operator>=(const VirtualAddress& other) const { return m_address >= other.m_address; } - bool operator>(const VirtualAddress& other) const { return m_address > other.m_address; } - bool operator<(const VirtualAddress& other) const { return m_address < other.m_address; } - bool operator==(const VirtualAddress& other) const { return m_address == other.m_address; } - bool operator!=(const VirtualAddress& other) const { return m_address != other.m_address; } + bool operator<=(VirtualAddress const& other) const { return m_address <= other.m_address; } + bool operator>=(VirtualAddress const& other) const { return m_address >= other.m_address; } + bool operator>(VirtualAddress const& other) const { return m_address > other.m_address; } + bool operator<(VirtualAddress const& other) const { return m_address < other.m_address; } + bool operator==(VirtualAddress const& other) const { return m_address == other.m_address; } + bool operator!=(VirtualAddress const& other) const { return m_address != other.m_address; } // NOLINTNEXTLINE(readability-make-member-function-const) const VirtualAddress shouldn't be allowed to modify the underlying memory [[nodiscard]] u8* as_ptr() { return reinterpret_cast<u8*>(m_address); } - [[nodiscard]] const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); } + [[nodiscard]] u8 const* as_ptr() const { return reinterpret_cast<u8 const*>(m_address); } [[nodiscard]] VirtualAddress page_base() const { return VirtualAddress(m_address & ~(FlatPtr)0xfffu); } @@ -47,14 +47,14 @@ private: FlatPtr m_address { 0 }; }; -inline VirtualAddress operator-(const VirtualAddress& a, const VirtualAddress& b) +inline VirtualAddress operator-(VirtualAddress const& a, VirtualAddress const& b) { return VirtualAddress(a.get() - b.get()); } template<> struct AK::Formatter<VirtualAddress> : AK::Formatter<FormatString> { - ErrorOr<void> format(FormatBuilder& builder, const VirtualAddress& value) + ErrorOr<void> format(FormatBuilder& builder, VirtualAddress const& value) { return AK::Formatter<FormatString>::format(builder, "V{}", value.as_ptr()); } diff --git a/Kernel/WaitQueue.h b/Kernel/WaitQueue.h index 9c8ca5c83e..d5f4145e76 100644 --- a/Kernel/WaitQueue.h +++ b/Kernel/WaitQueue.h @@ -19,7 +19,7 @@ public: u32 wake_all(); template<class... Args> - Thread::BlockResult wait_on(const Thread::BlockTimeout& timeout, Args&&... args) + Thread::BlockResult wait_on(Thread::BlockTimeout const& timeout, Args&&... args) { return Thread::current()->block<Thread::WaitQueueBlocker>(timeout, *this, forward<Args>(args)...); } diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 42d1b2a4db..3ac16761e6 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -131,7 +131,7 @@ READONLY_AFTER_INIT PhysicalAddress boot_pdpt; READONLY_AFTER_INIT PhysicalAddress boot_pd0; READONLY_AFTER_INIT PhysicalAddress boot_pd_kernel; READONLY_AFTER_INIT PageTableEntry* boot_pd_kernel_pt1023; -READONLY_AFTER_INIT const char* kernel_cmdline; +READONLY_AFTER_INIT char const* kernel_cmdline; READONLY_AFTER_INIT u32 multiboot_flags; READONLY_AFTER_INIT multiboot_memory_map_t* multiboot_memory_map; READONLY_AFTER_INIT size_t multiboot_memory_map_count; @@ -395,7 +395,7 @@ void init_stage2(void*) if (boot_profiling) { dbgln("Starting full system boot profiling"); MutexLocker mutex_locker(Process::current().big_lock()); - const auto enable_all = ~(u64)0; + auto const enable_all = ~(u64)0; auto result = Process::current().sys$profiling_enable(-1, reinterpret_cast<FlatPtr>(&enable_all)); VERIFY(!result.is_error()); } diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index 3a8d343a79..0b8f7360e9 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -111,9 +111,9 @@ static void buffer_putch(char*& bufptr, char ch) // Declare it, so that the symbol is exported, because libstdc++ uses it. // However, *only* libstdc++ uses it, and none of the rest of the Kernel. -extern "C" int sprintf(char* buffer, const char* fmt, ...); +extern "C" int sprintf(char* buffer, char const* fmt, ...); -int sprintf(char* buffer, const char* fmt, ...) +int sprintf(char* buffer, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -123,7 +123,7 @@ int sprintf(char* buffer, const char* fmt, ...) return ret; } -int snprintf(char* buffer, size_t size, const char* fmt, ...) +int snprintf(char* buffer, size_t size, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -156,7 +156,7 @@ static inline void internal_dbgputch(char ch) IO::out8(IO::BOCHS_DEBUG_PORT, ch); } -extern "C" void dbgputstr(const char* characters, size_t length) +extern "C" void dbgputstr(char const* characters, size_t length) { if (!characters) return; @@ -170,7 +170,7 @@ void dbgputstr(StringView view) ::dbgputstr(view.characters_without_null_termination(), view.length()); } -extern "C" void kernelputstr(const char* characters, size_t length) +extern "C" void kernelputstr(char const* characters, size_t length) { if (!characters) return; @@ -179,7 +179,7 @@ extern "C" void kernelputstr(const char* characters, size_t length) console_out(characters[i]); } -extern "C" void kernelcriticalputstr(const char* characters, size_t length) +extern "C" void kernelcriticalputstr(char const* characters, size_t length) { if (!characters) return; @@ -188,7 +188,7 @@ extern "C" void kernelcriticalputstr(const char* characters, size_t length) critical_console_out(characters[i]); } -extern "C" void kernelearlyputstr(const char* characters, size_t length) +extern "C" void kernelearlyputstr(char const* characters, size_t length) { if (!characters) return; diff --git a/Kernel/kstdio.h b/Kernel/kstdio.h index 111debc58c..d560b4b8c0 100644 --- a/Kernel/kstdio.h +++ b/Kernel/kstdio.h @@ -10,11 +10,11 @@ #include <AK/Types.h> extern "C" { -void dbgputstr(const char*, size_t); -void kernelputstr(const char*, size_t); -void kernelcriticalputstr(const char*, size_t); -void kernelearlyputstr(const char*, size_t); -int snprintf(char* buf, size_t, const char* fmt, ...) __attribute__((format(printf, 3, 4))); +void dbgputstr(char const*, size_t); +void kernelputstr(char const*, size_t); +void kernelcriticalputstr(char const*, size_t); +void kernelearlyputstr(char const*, size_t); +int snprintf(char* buf, size_t, char const* fmt, ...) __attribute__((format(printf, 3, 4))); void set_serial_debug(bool on_or_off); int get_serial_debug(); } diff --git a/Meta/Lagom/Fuzzers/EntryShim.cpp b/Meta/Lagom/Fuzzers/EntryShim.cpp index 0b45509a3f..0f9bdc3002 100644 --- a/Meta/Lagom/Fuzzers/EntryShim.cpp +++ b/Meta/Lagom/Fuzzers/EntryShim.cpp @@ -12,9 +12,9 @@ #include <sys/stat.h> #include <unistd.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size); -int fuzz_from_file(const char* filename) +int fuzz_from_file(char const* filename) { struct stat file_stats; diff --git a/Meta/Lagom/Fuzzers/FuzzASN1.cpp b/Meta/Lagom/Fuzzers/FuzzASN1.cpp index e1dddca082..e232f73a53 100644 --- a/Meta/Lagom/Fuzzers/FuzzASN1.cpp +++ b/Meta/Lagom/Fuzzers/FuzzASN1.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { (void)TLS::Certificate::parse_asn1({ data, size }); diff --git a/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp b/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp index f27a2707d5..f581351d14 100644 --- a/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp @@ -7,7 +7,7 @@ #include <LibGfx/BMPLoader.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::BMPImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp b/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp index 3ac4a172e0..e5160bde57 100644 --- a/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp +++ b/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp @@ -9,7 +9,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto* decoder = TextCodec::decoder_for("windows-1251"); VERIFY(decoder); diff --git a/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp b/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp index 4b8f4a49c4..8e21aa96be 100644 --- a/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp +++ b/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp @@ -7,7 +7,7 @@ #include <LibCompress/Deflate.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto result = Compress::DeflateCompressor::compress_all(ReadonlyBytes { data, size }); return result.has_value(); diff --git a/Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp b/Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp index 0d689989fc..b1167f2527 100644 --- a/Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp +++ b/Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp @@ -7,7 +7,7 @@ #include <LibCompress/Deflate.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto result = Compress::DeflateDecompressor::decompress_all(ReadonlyBytes { data, size }); return result.has_value(); diff --git a/Meta/Lagom/Fuzzers/FuzzELF.cpp b/Meta/Lagom/Fuzzers/FuzzELF.cpp index 41ae8428ff..a8e0eee0e0 100644 --- a/Meta/Lagom/Fuzzers/FuzzELF.cpp +++ b/Meta/Lagom/Fuzzers/FuzzELF.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { ELF::Image elf(data, size, /*verbose_logging=*/false); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp b/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp index 7c32717c47..1364d9efd2 100644 --- a/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto flac_data = ByteBuffer::copy(data, size).release_value(); auto flac = make<Audio::FlacLoaderPlugin>(flac_data); diff --git a/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp b/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp index 948214c8f2..f066f445ae 100644 --- a/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp @@ -11,7 +11,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::GIFImageDecoderPlugin gif_decoder(data, size); auto bitmap_or_error = gif_decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzGemini.cpp b/Meta/Lagom/Fuzzers/FuzzGemini.cpp index 0b7ad874df..183a383ddd 100644 --- a/Meta/Lagom/Fuzzers/FuzzGemini.cpp +++ b/Meta/Lagom/Fuzzers/FuzzGemini.cpp @@ -10,9 +10,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto gemini = StringView(static_cast<const unsigned char*>(data), size); + auto gemini = StringView(static_cast<unsigned char const*>(data), size); (void)Gemini::Document::parse(gemini, {}); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp b/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp index 239fed7175..db2f23078a 100644 --- a/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp +++ b/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp @@ -7,7 +7,7 @@ #include <LibCompress/Gzip.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto result = Compress::GzipCompressor::compress_all(ReadonlyBytes { data, size }); return result.has_value(); diff --git a/Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp b/Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp index 13cb1c44e2..00cf7a8b35 100644 --- a/Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp +++ b/Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp @@ -7,7 +7,7 @@ #include <LibCompress/Gzip.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto result = Compress::GzipDecompressor::decompress_all(ReadonlyBytes { data, size }); return result.has_value(); diff --git a/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp b/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp index de7fe03562..162dfd6a7c 100644 --- a/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp +++ b/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp @@ -9,7 +9,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto* decoder = TextCodec::decoder_for("windows-1255"); VERIFY(decoder); diff --git a/Meta/Lagom/Fuzzers/FuzzHttpRequest.cpp b/Meta/Lagom/Fuzzers/FuzzHttpRequest.cpp index e0e95fa39e..a16f5170c1 100644 --- a/Meta/Lagom/Fuzzers/FuzzHttpRequest.cpp +++ b/Meta/Lagom/Fuzzers/FuzzHttpRequest.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto request_wrapper = HTTP::HttpRequest::from_raw_request(ReadonlyBytes { data, size }); if (!request_wrapper.has_value()) diff --git a/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp b/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp index b691415ee6..56db322b1b 100644 --- a/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::ICOImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzIMAPParser.cpp b/Meta/Lagom/Fuzzers/FuzzIMAPParser.cpp index 32e5a1e420..a5d31df0fa 100644 --- a/Meta/Lagom/Fuzzers/FuzzIMAPParser.cpp +++ b/Meta/Lagom/Fuzzers/FuzzIMAPParser.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto parser = IMAP::Parser(); parser.parse(ByteBuffer::copy(data, size).release_value(), true); diff --git a/Meta/Lagom/Fuzzers/FuzzJPGLoader.cpp b/Meta/Lagom/Fuzzers/FuzzJPGLoader.cpp index 4d3c97aed0..54d54bcdc1 100644 --- a/Meta/Lagom/Fuzzers/FuzzJPGLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzJPGLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::JPGImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzJs.cpp b/Meta/Lagom/Fuzzers/FuzzJs.cpp index b10b03a54a..602a9d52f8 100644 --- a/Meta/Lagom/Fuzzers/FuzzJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzJs.cpp @@ -12,9 +12,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto js = StringView(static_cast<const unsigned char*>(data), size); + auto js = StringView(static_cast<unsigned char const*>(data), size); auto vm = JS::VM::create(); auto interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm); auto parse_result = JS::Script::parse(js, interpreter->realm()); diff --git a/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp b/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp index bf8a04f384..fefe5d341d 100644 --- a/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp +++ b/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp @@ -9,7 +9,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto* decoder = TextCodec::decoder_for("windows-1252"); VERIFY(decoder); diff --git a/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp b/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp index 1a031f158d..5bdf6c7af0 100644 --- a/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp +++ b/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp @@ -9,7 +9,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto* decoder = TextCodec::decoder_for("iso-8859-2"); VERIFY(decoder); diff --git a/Meta/Lagom/Fuzzers/FuzzMD5.cpp b/Meta/Lagom/Fuzzers/FuzzMD5.cpp index e33f37d835..9ed0aad2ad 100644 --- a/Meta/Lagom/Fuzzers/FuzzMD5.cpp +++ b/Meta/Lagom/Fuzzers/FuzzMD5.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Crypto::Hash::MD5::hash(data, size); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp b/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp index fd8cecc810..b53fc37731 100644 --- a/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto flac_data = ByteBuffer::copy(data, size).release_value(); auto mp3 = make<Audio::MP3LoaderPlugin>(flac_data); diff --git a/Meta/Lagom/Fuzzers/FuzzMarkdown.cpp b/Meta/Lagom/Fuzzers/FuzzMarkdown.cpp index 9e1f0c6f4a..eb18526073 100644 --- a/Meta/Lagom/Fuzzers/FuzzMarkdown.cpp +++ b/Meta/Lagom/Fuzzers/FuzzMarkdown.cpp @@ -10,9 +10,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto markdown = StringView(static_cast<const unsigned char*>(data), size); + auto markdown = StringView(static_cast<unsigned char const*>(data), size); (void)Markdown::Document::parse(markdown); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp index 24464bbae1..d5244a6ee1 100644 --- a/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::PBMImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzPDF.cpp b/Meta/Lagom/Fuzzers/FuzzPDF.cpp index b2eb5e701f..7877c677ff 100644 --- a/Meta/Lagom/Fuzzers/FuzzPDF.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPDF.cpp @@ -7,7 +7,7 @@ #include <LibPDF/Document.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { ReadonlyBytes bytes { data, size }; diff --git a/Meta/Lagom/Fuzzers/FuzzPEM.cpp b/Meta/Lagom/Fuzzers/FuzzPEM.cpp index cf950ebda0..8e488fe9ad 100644 --- a/Meta/Lagom/Fuzzers/FuzzPEM.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPEM.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { (void)Crypto::decode_pem({ data, size }); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp index 4ec226d962..3db44ec53d 100644 --- a/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::PGMImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp index 848ce18562..54a1b832f0 100644 --- a/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::PNGImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp index 9b99627b88..30f53592e6 100644 --- a/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Gfx::PPMImageDecoderPlugin decoder(data, size); (void)decoder.frame(0); diff --git a/Meta/Lagom/Fuzzers/FuzzRSAKeyParsing.cpp b/Meta/Lagom/Fuzzers/FuzzRSAKeyParsing.cpp index 69e19cfea1..b5f7ef4fac 100644 --- a/Meta/Lagom/Fuzzers/FuzzRSAKeyParsing.cpp +++ b/Meta/Lagom/Fuzzers/FuzzRSAKeyParsing.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Crypto::PK::RSA::parse_rsa_key({ data, size }); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzRegexECMA262.cpp b/Meta/Lagom/Fuzzers/FuzzRegexECMA262.cpp index 202faf685f..a254b60901 100644 --- a/Meta/Lagom/Fuzzers/FuzzRegexECMA262.cpp +++ b/Meta/Lagom/Fuzzers/FuzzRegexECMA262.cpp @@ -9,9 +9,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto pattern = StringView(static_cast<const unsigned char*>(data), size); + auto pattern = StringView(static_cast<unsigned char const*>(data), size); [[maybe_unused]] auto re = Regex<ECMA262>(pattern); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzRegexPosixBasic.cpp b/Meta/Lagom/Fuzzers/FuzzRegexPosixBasic.cpp index f66da056b6..83046fdc02 100644 --- a/Meta/Lagom/Fuzzers/FuzzRegexPosixBasic.cpp +++ b/Meta/Lagom/Fuzzers/FuzzRegexPosixBasic.cpp @@ -9,9 +9,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto pattern = StringView(static_cast<const unsigned char*>(data), size); + auto pattern = StringView(static_cast<unsigned char const*>(data), size); [[maybe_unused]] auto re = Regex<PosixBasic>(pattern); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzRegexPosixExtended.cpp b/Meta/Lagom/Fuzzers/FuzzRegexPosixExtended.cpp index 41a15ce779..13fbc09a1d 100644 --- a/Meta/Lagom/Fuzzers/FuzzRegexPosixExtended.cpp +++ b/Meta/Lagom/Fuzzers/FuzzRegexPosixExtended.cpp @@ -9,9 +9,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto pattern = StringView(static_cast<const unsigned char*>(data), size); + auto pattern = StringView(static_cast<unsigned char const*>(data), size); [[maybe_unused]] auto re = Regex<PosixExtended>(pattern); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzSHA1.cpp b/Meta/Lagom/Fuzzers/FuzzSHA1.cpp index 08f944edf0..235e117bc6 100644 --- a/Meta/Lagom/Fuzzers/FuzzSHA1.cpp +++ b/Meta/Lagom/Fuzzers/FuzzSHA1.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Crypto::Hash::SHA1::hash(data, size); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzSHA256.cpp b/Meta/Lagom/Fuzzers/FuzzSHA256.cpp index 7af6117229..ffa6d07ce1 100644 --- a/Meta/Lagom/Fuzzers/FuzzSHA256.cpp +++ b/Meta/Lagom/Fuzzers/FuzzSHA256.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Crypto::Hash::SHA256::hash(data, size); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzSHA384.cpp b/Meta/Lagom/Fuzzers/FuzzSHA384.cpp index 2343860dec..7d46b1b112 100644 --- a/Meta/Lagom/Fuzzers/FuzzSHA384.cpp +++ b/Meta/Lagom/Fuzzers/FuzzSHA384.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Crypto::Hash::SHA384::hash(data, size); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzSHA512.cpp b/Meta/Lagom/Fuzzers/FuzzSHA512.cpp index e34980974d..bb07df7d6a 100644 --- a/Meta/Lagom/Fuzzers/FuzzSHA512.cpp +++ b/Meta/Lagom/Fuzzers/FuzzSHA512.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { Crypto::Hash::SHA512::hash(data, size); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzSQLParser.cpp b/Meta/Lagom/Fuzzers/FuzzSQLParser.cpp index b60df45fff..9d332b9c6f 100644 --- a/Meta/Lagom/Fuzzers/FuzzSQLParser.cpp +++ b/Meta/Lagom/Fuzzers/FuzzSQLParser.cpp @@ -8,7 +8,7 @@ #include <LibSQL/AST/Parser.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto parser = SQL::AST::Parser(SQL::AST::Lexer({ data, size })); [[maybe_unused]] auto statement = parser.next_statement(); diff --git a/Meta/Lagom/Fuzzers/FuzzShell.cpp b/Meta/Lagom/Fuzzers/FuzzShell.cpp index 24b1bbcc6c..9869283e25 100644 --- a/Meta/Lagom/Fuzzers/FuzzShell.cpp +++ b/Meta/Lagom/Fuzzers/FuzzShell.cpp @@ -9,9 +9,9 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { - auto source = StringView(static_cast<const unsigned char*>(data), size); + auto source = StringView(static_cast<unsigned char const*>(data), size); Shell::Parser parser(source); (void)parser.parse(); return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzURL.cpp b/Meta/Lagom/Fuzzers/FuzzURL.cpp index 4c006bd340..9037954eb0 100644 --- a/Meta/Lagom/Fuzzers/FuzzURL.cpp +++ b/Meta/Lagom/Fuzzers/FuzzURL.cpp @@ -6,7 +6,7 @@ #include <AK/URL.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto string_view = StringView(data, size); auto url = URL(string_view); diff --git a/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp b/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp index 5947b2d7fb..d1e3cf43d5 100644 --- a/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp +++ b/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp @@ -9,7 +9,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto* decoder = TextCodec::decoder_for("utf-16be"); VERIFY(decoder); diff --git a/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp b/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp index 92a183f4b2..f2a767d957 100644 --- a/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { if (!data) return 0; diff --git a/Meta/Lagom/Fuzzers/FuzzWasmParser.cpp b/Meta/Lagom/Fuzzers/FuzzWasmParser.cpp index 7bdfe4b6bd..d5c5acbe17 100644 --- a/Meta/Lagom/Fuzzers/FuzzWasmParser.cpp +++ b/Meta/Lagom/Fuzzers/FuzzWasmParser.cpp @@ -10,7 +10,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { ReadonlyBytes bytes { data, size }; InputMemoryStream stream { bytes }; diff --git a/Meta/Lagom/Fuzzers/FuzzZip.cpp b/Meta/Lagom/Fuzzers/FuzzZip.cpp index fe9b62dadf..9d2d669c0a 100644 --- a/Meta/Lagom/Fuzzers/FuzzZip.cpp +++ b/Meta/Lagom/Fuzzers/FuzzZip.cpp @@ -8,7 +8,7 @@ #include <stddef.h> #include <stdint.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto zip_file = Archive::Zip::try_create({ data, size }); if (!zip_file.has_value()) diff --git a/Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp b/Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp index 72cbc7399a..19a535931a 100644 --- a/Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp +++ b/Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp @@ -7,7 +7,7 @@ #include <LibCompress/Zlib.h> #include <stdio.h> -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto result = Compress::Zlib::decompress_all(ReadonlyBytes { data, size }); return result.has_value(); diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp index d96353bb6b..b0a8b221a9 100644 --- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp @@ -73,7 +73,7 @@ extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t* start, uint32_t* s __edges_stop = stop; // Map the shared memory region - const char* shm_key = getenv("SHM_ID"); + char const* shm_key = getenv("SHM_ID"); if (!shm_key) { puts("[COV] no shared memory bitmap available, skipping"); __shmem = (struct shmem_data*)malloc(SHM_SIZE); @@ -205,7 +205,7 @@ int main(int, char**) int result = 0; - auto js = StringView(static_cast<const unsigned char*>(data_buffer.data()), script_size); + auto js = StringView(static_cast<unsigned char const*>(data_buffer.data()), script_size); auto parse_result = JS::Script::parse(js, interpreter->realm()); if (parse_result.is_error()) { diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp index b93e9f9919..36680fbf86 100644 --- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp @@ -282,7 +282,7 @@ String constructor_for_message(String const& name, Vector<Parameter> const& para return builder.to_string(); } -void do_message(SourceGenerator message_generator, const String& name, const Vector<Parameter>& parameters, const String& response_type = {}) +void do_message(SourceGenerator message_generator, String const& name, Vector<Parameter> const& parameters, String const& response_type = {}) { auto pascal_name = pascal_case(name); message_generator.set("message.name", name); @@ -598,7 +598,7 @@ public: switch (message_id) {)~~~"); for (auto const& message : endpoint.messages) { - auto do_decode_message = [&](const String& name) { + auto do_decode_message = [&](String const& name) { auto message_generator = generator.fork(); message_generator.set("message.name", name); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp b/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp index 7aee4e4ab6..528d03a2c9 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp @@ -125,7 +125,7 @@ static ErrorOr<HashMap<String, PnpIdData>> parse_pnp_ids_database(Core::File& pn HashMap<String, PnpIdData> pnp_id_data; for (size_t row_content_offset = 0;;) { - static const auto row_start_tag = "<tr class=\""sv; + static auto const row_start_tag = "<tr class=\""sv; auto row_start = pnp_ids_file_contents.find(row_start_tag, row_content_offset); if (!row_start.has_value()) break; @@ -134,7 +134,7 @@ static ErrorOr<HashMap<String, PnpIdData>> parse_pnp_ids_database(Core::File& pn if (!row_start_tag_end.has_value()) return Error::from_string_literal("Incomplete row start tag"sv); - static const auto row_end_tag = "</tr>"sv; + static auto const row_end_tag = "</tr>"sv; auto row_end = pnp_ids_file_contents.find(row_end_tag, row_start.value()); if (!row_end.has_value()) return Error::from_string_literal("No matching row end tag found"sv); @@ -145,12 +145,12 @@ static ErrorOr<HashMap<String, PnpIdData>> parse_pnp_ids_database(Core::File& pn auto row_string = pnp_ids_file_contents.substring_view(row_start_tag_end.value() + 1, row_end.value() - row_start_tag_end.value() - 1); Vector<String, (size_t)PnpIdColumns::ColumnCount> columns; for (size_t column_row_offset = 0;;) { - static const auto column_start_tag = "<td>"sv; + static auto const column_start_tag = "<td>"sv; auto column_start = row_string.find(column_start_tag, column_row_offset); if (!column_start.has_value()) break; - static const auto column_end_tag = "</td>"sv; + static auto const column_end_tag = "</td>"sv; auto column_end = row_string.find(column_end_tag, column_start.value() + column_start_tag.length()); if (!column_end.has_value()) return Error::from_string_literal("No matching column end tag found"sv); diff --git a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp index 2c506fbb36..6651764d0e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp @@ -211,12 +211,12 @@ parse_state_machine(StringView input) return state_machine; } -void output_header(const StateMachine&, SourceGenerator&); +void output_header(StateMachine const&, SourceGenerator&); int main(int argc, char** argv) { Core::ArgsParser args_parser; - const char* path = nullptr; + char const* path = nullptr; args_parser.add_positional_argument(path, "Path to parser description", "input", Core::ArgsParser::Required::Yes); args_parser.parse(argc, argv); @@ -235,11 +235,11 @@ int main(int argc, char** argv) return 0; } -HashTable<String> actions(const StateMachine& machine) +HashTable<String> actions(StateMachine const& machine) { HashTable<String> table; - auto do_state = [&](const State& state) { + auto do_state = [&](State const& state) { if (state.entry_action.has_value()) table.set(state.entry_action.value()); if (state.exit_action.has_value()) @@ -257,13 +257,13 @@ HashTable<String> actions(const StateMachine& machine) return table; } -void generate_lookup_table(const StateMachine& machine, SourceGenerator& generator) +void generate_lookup_table(StateMachine const& machine, SourceGenerator& generator) { generator.append(R"~~~( static constexpr StateTransition STATE_TRANSITION_TABLE[][256] = { )~~~"); - auto generate_for_state = [&](const State& s) { + auto generate_for_state = [&](State const& s) { auto table_generator = generator.fork(); table_generator.set("active_state", s.name); table_generator.append("/* @active_state@ */ { "); @@ -295,7 +295,7 @@ void generate_lookup_table(const StateMachine& machine, SourceGenerator& generat )~~~"); } -void output_header(const StateMachine& machine, SourceGenerator& generator) +void output_header(StateMachine const& machine, SourceGenerator& generator) { generator.set("class_name", machine.name); generator.set("initial_state", machine.initial_state); diff --git a/Tests/AK/TestArray.cpp b/Tests/AK/TestArray.cpp index a1eab1e1f0..03038a9958 100644 --- a/Tests/AK/TestArray.cpp +++ b/Tests/AK/TestArray.cpp @@ -8,7 +8,7 @@ #include <AK/Array.h> -static constexpr int constexpr_sum(const Span<const int> span) +static constexpr int constexpr_sum(Span<int const> const span) { int sum = 0; for (auto value : span) diff --git a/Tests/AK/TestBase64.cpp b/Tests/AK/TestBase64.cpp index 25c1c6ada7..ce0ccffe84 100644 --- a/Tests/AK/TestBase64.cpp +++ b/Tests/AK/TestBase64.cpp @@ -12,7 +12,7 @@ TEST_CASE(test_decode) { - auto decode_equal = [&](const char* input, const char* expected) { + auto decode_equal = [&](char const* input, char const* expected) { auto decoded_option = decode_base64(StringView(input)); EXPECT(!decoded_option.is_error()); auto decoded = decoded_option.release_value(); @@ -41,7 +41,7 @@ TEST_CASE(test_decode_invalid) TEST_CASE(test_encode) { - auto encode_equal = [&](const char* input, const char* expected) { + auto encode_equal = [&](char const* input, char const* expected) { auto encoded = encode_base64({ input, strlen(input) }); EXPECT(encoded == String(expected)); EXPECT_EQ(StringView(expected).length(), calculate_base64_encoded_length(StringView(input).bytes())); diff --git a/Tests/AK/TestBinarySearch.cpp b/Tests/AK/TestBinarySearch.cpp index bf7cdb76ae..f5a63eac33 100644 --- a/Tests/AK/TestBinarySearch.cpp +++ b/Tests/AK/TestBinarySearch.cpp @@ -54,7 +54,7 @@ TEST_CASE(vector_strings) strings.append("cat"); strings.append("dog"); - auto string_compare = [](const String& a, const String& b) -> int { + auto string_compare = [](String const& a, String const& b) -> int { return strcmp(a.characters(), b.characters()); }; auto test1 = *binary_search(strings, String("bat"), nullptr, string_compare); @@ -108,7 +108,7 @@ TEST_CASE(constexpr_array_search) TEST_CASE(unsigned_to_signed_regression) { - const Array<u32, 5> input { 0, 1, 2, 3, 4 }; + Array<u32, 5> const input { 0, 1, 2, 3, 4 }; // The algorithm computes 1 - input[2] = -1, and if this is (incorrectly) cast // to an unsigned then it will look in the wrong direction and miss the 1. diff --git a/Tests/AK/TestBitmap.cpp b/Tests/AK/TestBitmap.cpp index 8eac72aa16..56fba7fd79 100644 --- a/Tests/AK/TestBitmap.cpp +++ b/Tests/AK/TestBitmap.cpp @@ -216,7 +216,7 @@ TEST_CASE(count_in_range) bitmap.set(i, true); } - auto count_bits_slow = [](const Bitmap& b, size_t start, size_t len, bool value) -> size_t { + auto count_bits_slow = [](Bitmap const& b, size_t start, size_t len, bool value) -> size_t { size_t count = 0; for (size_t i = start; i < start + len; i++) { if (b.get(i) == value) diff --git a/Tests/AK/TestDoublyLinkedList.cpp b/Tests/AK/TestDoublyLinkedList.cpp index 407484e443..480b0c585d 100644 --- a/Tests/AK/TestDoublyLinkedList.cpp +++ b/Tests/AK/TestDoublyLinkedList.cpp @@ -35,7 +35,7 @@ TEST_CASE(should_find_mutable) TEST_CASE(should_find_const) { - const auto sut = make_list(); + auto const sut = make_list(); EXPECT_EQ(4, *sut.find(4)); diff --git a/Tests/AK/TestFormat.cpp b/Tests/AK/TestFormat.cpp index 61923da842..29c922316d 100644 --- a/Tests/AK/TestFormat.cpp +++ b/Tests/AK/TestFormat.cpp @@ -14,7 +14,7 @@ TEST_CASE(is_integral_works_properly) { - EXPECT(!IsIntegral<const char*>); + EXPECT(!IsIntegral<char const*>); EXPECT(IsIntegral<unsigned long>); } @@ -186,7 +186,7 @@ TEST_CASE(ensure_that_format_works) TEST_CASE(format_string_literal_as_pointer) { - const char* literal = "abc"; + char const* literal = "abc"; EXPECT_EQ(String::formatted("{:p}", literal), String::formatted("{:p}", reinterpret_cast<FlatPtr>(literal))); } @@ -228,7 +228,7 @@ TEST_CASE(file_descriptor) rewind(file); Array<u8, 256> buffer; - const auto nread = fread(buffer.data(), 1, buffer.size(), file); + auto const nread = fread(buffer.data(), 1, buffer.size(), file); EXPECT_EQ("Hello, World!\nfoobar\n"sv, StringView { buffer.span().trim(nread) }); diff --git a/Tests/AK/TestHashFunctions.cpp b/Tests/AK/TestHashFunctions.cpp index 6fbb0ab6f7..f5750c887e 100644 --- a/Tests/AK/TestHashFunctions.cpp +++ b/Tests/AK/TestHashFunctions.cpp @@ -42,14 +42,14 @@ TEST_CASE(ptr_hash) EXPECT_EQ(ptr_hash(FlatPtr(42)), 2824066580u); EXPECT_EQ(ptr_hash(FlatPtr(0)), 954888656u); - EXPECT_EQ(ptr_hash(reinterpret_cast<const void*>(42)), 2824066580u); - EXPECT_EQ(ptr_hash(reinterpret_cast<const void*>(0)), 954888656u); + EXPECT_EQ(ptr_hash(reinterpret_cast<void const*>(42)), 2824066580u); + EXPECT_EQ(ptr_hash(reinterpret_cast<void const*>(0)), 954888656u); } else { EXPECT_EQ(ptr_hash(FlatPtr(42)), 3564735745u); EXPECT_EQ(ptr_hash(FlatPtr(0)), 1177991625u); - EXPECT_EQ(ptr_hash(reinterpret_cast<const void*>(42)), 3564735745u); - EXPECT_EQ(ptr_hash(reinterpret_cast<const void*>(0)), 1177991625u); + EXPECT_EQ(ptr_hash(reinterpret_cast<void const*>(42)), 3564735745u); + EXPECT_EQ(ptr_hash(reinterpret_cast<void const*>(0)), 1177991625u); } } diff --git a/Tests/AK/TestHashMap.cpp b/Tests/AK/TestHashMap.cpp index 25e248b7a6..b7a284a8cd 100644 --- a/Tests/AK/TestHashMap.cpp +++ b/Tests/AK/TestHashMap.cpp @@ -111,7 +111,7 @@ TEST_CASE(case_insensitive) TEST_CASE(hashmap_of_nonnullownptr_get) { struct Object { - Object(const String& s) + Object(String const& s) : string(s) { } diff --git a/Tests/AK/TestHashTable.cpp b/Tests/AK/TestHashTable.cpp index 4f5aa422b5..02c94c6b62 100644 --- a/Tests/AK/TestHashTable.cpp +++ b/Tests/AK/TestHashTable.cpp @@ -136,7 +136,7 @@ TEST_CASE(many_strings) TEST_CASE(many_collisions) { struct StringCollisionTraits : public GenericTraits<String> { - static unsigned hash(const String&) { return 0; } + static unsigned hash(String const&) { return 0; } }; HashTable<String, StringCollisionTraits> strings; @@ -158,7 +158,7 @@ TEST_CASE(many_collisions) TEST_CASE(space_reuse) { struct StringCollisionTraits : public GenericTraits<String> { - static unsigned hash(const String&) { return 0; } + static unsigned hash(String const&) { return 0; } }; HashTable<String, StringCollisionTraits> strings; diff --git a/Tests/AK/TestIPv4Address.cpp b/Tests/AK/TestIPv4Address.cpp index b8f07d1e3c..4f3055ebd4 100644 --- a/Tests/AK/TestIPv4Address.cpp +++ b/Tests/AK/TestIPv4Address.cpp @@ -66,7 +66,7 @@ TEST_CASE(should_convert_to_string) TEST_CASE(should_make_ipv4_address_from_string) { - const auto addr = IPv4Address::from_string("192.168.0.1"); + auto const addr = IPv4Address::from_string("192.168.0.1"); EXPECT(addr.has_value()); EXPECT_EQ(192, addr.value()[0]); @@ -77,21 +77,21 @@ TEST_CASE(should_make_ipv4_address_from_string) TEST_CASE(should_make_empty_optional_from_bad_string) { - const auto addr = IPv4Address::from_string("bad string"); + auto const addr = IPv4Address::from_string("bad string"); EXPECT(!addr.has_value()); } TEST_CASE(should_make_empty_optional_from_out_of_range_values) { - const auto addr = IPv4Address::from_string("192.168.0.500"); + auto const addr = IPv4Address::from_string("192.168.0.500"); EXPECT(!addr.has_value()); } TEST_CASE(should_fill_d_octet_from_1_part) { - const auto addr = IPv4Address::from_string("1"); + auto const addr = IPv4Address::from_string("1"); EXPECT(addr.has_value()); EXPECT_EQ(0, addr.value()[0]); @@ -102,7 +102,7 @@ TEST_CASE(should_fill_d_octet_from_1_part) TEST_CASE(should_fill_a_and_d_octets_from_2_parts) { - const auto addr = IPv4Address::from_string("192.1"); + auto const addr = IPv4Address::from_string("192.1"); EXPECT(addr.has_value()); EXPECT_EQ(192, addr.value()[0]); @@ -113,7 +113,7 @@ TEST_CASE(should_fill_a_and_d_octets_from_2_parts) TEST_CASE(should_fill_a_b_d_octets_from_3_parts) { - const auto addr = IPv4Address::from_string("192.168.1"); + auto const addr = IPv4Address::from_string("192.168.1"); EXPECT(addr.has_value()); EXPECT_EQ(192, addr.value()[0]); diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index 0627b110c1..36f0b8cebc 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -46,7 +46,7 @@ TEST_CASE(load_form) auto widgets = form_json.as_object().get("widgets").as_array(); - widgets.for_each([&](const JsonValue& widget_value) { + widgets.for_each([&](JsonValue const& widget_value) { auto& widget_object = widget_value.as_object(); auto widget_class = widget_object.get("class").as_string(); widget_object.for_each_member([&]([[maybe_unused]] auto& property_name, [[maybe_unused]] const JsonValue& property_value) { @@ -87,7 +87,7 @@ TEST_CASE(json_utf8_multibyte) { auto json_or_error = JsonValue::from_string("\"š\""); EXPECT_EQ(json_or_error.is_error(), false); - + auto& json = json_or_error.value(); EXPECT_EQ(json.type(), JsonValue::Type::String); EXPECT_EQ(json.as_string().is_null(), false); diff --git a/Tests/AK/TestMACAddress.cpp b/Tests/AK/TestMACAddress.cpp index 258f1ac0e0..55767f8551 100644 --- a/Tests/AK/TestMACAddress.cpp +++ b/Tests/AK/TestMACAddress.cpp @@ -85,7 +85,7 @@ TEST_CASE(should_string_format) TEST_CASE(should_make_mac_address_from_string_numbers) { - const auto sut = MACAddress::from_string("01:02:03:04:05:06"); + auto const sut = MACAddress::from_string("01:02:03:04:05:06"); EXPECT(sut.has_value()); EXPECT_EQ(1, sut.value()[0]); @@ -98,7 +98,7 @@ TEST_CASE(should_make_mac_address_from_string_numbers) TEST_CASE(should_make_mac_address_from_string_letters) { - const auto sut = MACAddress::from_string("de:ad:be:ee:ee:ef"); + auto const sut = MACAddress::from_string("de:ad:be:ee:ee:ef"); EXPECT(sut.has_value()); EXPECT_EQ(u8 { 0xDE }, sut.value()[0]); @@ -111,14 +111,14 @@ TEST_CASE(should_make_mac_address_from_string_letters) TEST_CASE(should_make_empty_optional_from_bad_string) { - const auto sut = MACAddress::from_string("bad string"); + auto const sut = MACAddress::from_string("bad string"); EXPECT(!sut.has_value()); } TEST_CASE(should_make_empty_optional_from_out_of_range_values) { - const auto sut = MACAddress::from_string("de:ad:be:ee:ee:fz"); + auto const sut = MACAddress::from_string("de:ad:be:ee:ee:fz"); EXPECT(!sut.has_value()); } diff --git a/Tests/AK/TestMemoryStream.cpp b/Tests/AK/TestMemoryStream.cpp index 90512fe456..3c774c70b3 100644 --- a/Tests/AK/TestMemoryStream.cpp +++ b/Tests/AK/TestMemoryStream.cpp @@ -63,7 +63,7 @@ TEST_CASE(recoverable_error) TEST_CASE(chain_stream_operator) { - const Array<u8, 4> expected { 0, 1, 2, 3 }; + Array<u8, 4> const expected { 0, 1, 2, 3 }; Array<u8, 4> actual; InputMemoryStream stream { expected }; @@ -76,10 +76,10 @@ TEST_CASE(chain_stream_operator) TEST_CASE(seeking_slicing_offset) { - const Array<u8, 8> input { 0, 1, 2, 3, 4, 5, 6, 7 }; - const Array<u8, 4> expected0 { 0, 1, 2, 3 }; - const Array<u8, 4> expected1 { 4, 5, 6, 7 }; - const Array<u8, 4> expected2 { 1, 2, 3, 4 }; + Array<u8, 8> const input { 0, 1, 2, 3, 4, 5, 6, 7 }; + Array<u8, 4> const expected0 { 0, 1, 2, 3 }; + Array<u8, 4> const expected1 { 4, 5, 6, 7 }; + Array<u8, 4> const expected2 { 1, 2, 3, 4 }; Array<u8, 4> actual0 {}, actual1 {}, actual2 {}; @@ -140,7 +140,7 @@ TEST_CASE(duplex_large_buffer) TEST_CASE(read_endian_values) { - const Array<u8, 8> input { 0, 1, 2, 3, 4, 5, 6, 7 }; + Array<u8, 8> const input { 0, 1, 2, 3, 4, 5, 6, 7 }; InputMemoryStream stream { input }; LittleEndian<u32> value1; @@ -153,7 +153,7 @@ TEST_CASE(read_endian_values) TEST_CASE(write_endian_values) { - const Array<u8, 8> expected { 4, 3, 2, 1, 1, 2, 3, 4 }; + Array<u8, 8> const expected { 4, 3, 2, 1, 1, 2, 3, 4 }; DuplexMemoryStream stream; stream << LittleEndian<u32> { 0x01020304 } << BigEndian<u32> { 0x01020304 }; diff --git a/Tests/AK/TestNeverDestroyed.cpp b/Tests/AK/TestNeverDestroyed.cpp index 329eaa8ebd..43ea3e65f6 100644 --- a/Tests/AK/TestNeverDestroyed.cpp +++ b/Tests/AK/TestNeverDestroyed.cpp @@ -14,7 +14,7 @@ struct Counter { ~Counter() { ++num_destroys; } - Counter(const Counter&) + Counter(Counter const&) { ++num_copies; } diff --git a/Tests/AK/TestOptional.cpp b/Tests/AK/TestOptional.cpp index 2e71ce7f32..e96c12a23c 100644 --- a/Tests/AK/TestOptional.cpp +++ b/Tests/AK/TestOptional.cpp @@ -159,7 +159,7 @@ TEST_CASE(test_copy_ctor_and_dtor_called) { } - CopyChecker(const CopyChecker& other) + CopyChecker(CopyChecker const& other) : m_was_copy_constructed(other.m_was_copy_constructed) { m_was_copy_constructed = true; @@ -182,7 +182,7 @@ TEST_CASE(test_copy_ctor_and_dtor_called) { } - MoveChecker(const MoveChecker& other) + MoveChecker(MoveChecker const& other) : m_was_move_constructed(other.m_was_move_constructed) { EXPECT(false); diff --git a/Tests/AK/TestQuickSort.cpp b/Tests/AK/TestQuickSort.cpp index 12cbf18c7f..fbbd72326e 100644 --- a/Tests/AK/TestQuickSort.cpp +++ b/Tests/AK/TestQuickSort.cpp @@ -50,7 +50,7 @@ TEST_CASE(sorts_without_copy) // So it provides no strong guarantees about the properties of quick_sort. TEST_CASE(maximum_stack_depth) { - const int size = 256; + int const size = 256; int* data = new int[size]; for (int i = 0; i < size; i++) { @@ -72,7 +72,7 @@ TEST_CASE(maximum_stack_depth) : max_depth(max_depth) { } - DepthMeasurer(const DepthMeasurer& obj) + DepthMeasurer(DepthMeasurer const& obj) : max_depth(obj.max_depth) { depth = obj.depth + 1; diff --git a/Tests/AK/TestSinglyLinkedList.cpp b/Tests/AK/TestSinglyLinkedList.cpp index 750940f74e..308e59f15a 100644 --- a/Tests/AK/TestSinglyLinkedList.cpp +++ b/Tests/AK/TestSinglyLinkedList.cpp @@ -37,14 +37,14 @@ TEST_CASE(should_find_mutable_with_predicate) { auto sut = make_list(); - EXPECT_EQ(4, *sut.find_if([](const auto v) { return v == 4; })); + EXPECT_EQ(4, *sut.find_if([](auto const v) { return v == 4; })); - EXPECT_EQ(sut.end(), sut.find_if([](const auto v) { return v == 42; })); + EXPECT_EQ(sut.end(), sut.find_if([](auto const v) { return v == 42; })); } TEST_CASE(should_find_const) { - const auto sut = make_list(); + auto const sut = make_list(); EXPECT_EQ(4, *sut.find(4)); @@ -53,11 +53,11 @@ TEST_CASE(should_find_const) TEST_CASE(should_find_const_with_predicate) { - const auto sut = make_list(); + auto const sut = make_list(); - EXPECT_EQ(4, *sut.find_if([](const auto v) { return v == 4; })); + EXPECT_EQ(4, *sut.find_if([](auto const v) { return v == 4; })); - EXPECT_EQ(sut.end(), sut.find_if([](const auto v) { return v == 42; })); + EXPECT_EQ(sut.end(), sut.find_if([](auto const v) { return v == 42; })); } TEST_CASE(removal_during_iteration) diff --git a/Tests/AK/TestSourceLocation.cpp b/Tests/AK/TestSourceLocation.cpp index 8fc7f97426..1f8e6b2359 100644 --- a/Tests/AK/TestSourceLocation.cpp +++ b/Tests/AK/TestSourceLocation.cpp @@ -18,7 +18,7 @@ TEST_CASE(basic_scenario) EXPECT_EQ(StringView(__FILE__), location.filename()); } -static StringView test_default_arg(const SourceLocation& loc = SourceLocation::current()) +static StringView test_default_arg(SourceLocation const& loc = SourceLocation::current()) { return loc.function_name(); } diff --git a/Tests/AK/TestSpan.cpp b/Tests/AK/TestSpan.cpp index c34e02b4bb..7cac637cc9 100644 --- a/Tests/AK/TestSpan.cpp +++ b/Tests/AK/TestSpan.cpp @@ -115,23 +115,23 @@ TEST_CASE(span_from_void_pointer) { int value = 0; [[maybe_unused]] Bytes bytes0 { reinterpret_cast<void*>(value), 4 }; - [[maybe_unused]] ReadonlyBytes bytes1 { reinterpret_cast<const void*>(value), 4 }; + [[maybe_unused]] ReadonlyBytes bytes1 { reinterpret_cast<void const*>(value), 4 }; } TEST_CASE(span_from_c_string) { - const char* str = "Serenity"; + char const* str = "Serenity"; [[maybe_unused]] ReadonlyBytes bytes { str, strlen(str) }; } TEST_CASE(starts_with) { - const char* str = "HeyFriends!"; + char const* str = "HeyFriends!"; ReadonlyBytes bytes { str, strlen(str) }; - const char* str_hey = "Hey"; + char const* str_hey = "Hey"; ReadonlyBytes hey_bytes { str_hey, strlen(str_hey) }; EXPECT(bytes.starts_with(hey_bytes)); - const char* str_nah = "Nah"; + char const* str_nah = "Nah"; ReadonlyBytes nah_bytes { str_nah, strlen(str_nah) }; EXPECT(!bytes.starts_with(nah_bytes)); diff --git a/Tests/AK/TestStringView.cpp b/Tests/AK/TestStringView.cpp index c2c81aa5e6..6623081c3c 100644 --- a/Tests/AK/TestStringView.cpp +++ b/Tests/AK/TestStringView.cpp @@ -19,7 +19,7 @@ TEST_CASE(construct_empty) TEST_CASE(view_literal) { - const char* truth = "cats rule dogs drool"; + char const* truth = "cats rule dogs drool"; StringView view(truth); EXPECT_EQ(view.is_null(), false); EXPECT_EQ(view.characters_without_null_termination(), truth); diff --git a/Tests/AK/TestTuple.cpp b/Tests/AK/TestTuple.cpp index 6084819ade..9e7f82b724 100644 --- a/Tests/AK/TestTuple.cpp +++ b/Tests/AK/TestTuple.cpp @@ -97,8 +97,8 @@ TEST_CASE(apply) // With const reference, taken from a const tuple { bool was_called = false; - const auto& args_ref = args; - args_ref.apply_as_args([&](const int& a, const int& b, const String& c) { + auto const& args_ref = args; + args_ref.apply_as_args([&](int const& a, int const& b, String const& c) { was_called = true; EXPECT_EQ(a, 1); EXPECT_EQ(b, 2); diff --git a/Tests/AK/TestTypeTraits.cpp b/Tests/AK/TestTypeTraits.cpp index 59df08e38e..b1c464c90c 100644 --- a/Tests/AK/TestTypeTraits.cpp +++ b/Tests/AK/TestTypeTraits.cpp @@ -220,7 +220,7 @@ TEST_CASE(IsConstructible) }; EXPECT_VARIADIC_TRAIT_TRUE(IsConstructible, D, int); EXPECT_VARIADIC_TRAIT_TRUE(IsConstructible, D, char); - EXPECT_VARIADIC_TRAIT_FALSE(IsConstructible, D, const char*); + EXPECT_VARIADIC_TRAIT_FALSE(IsConstructible, D, char const*); EXPECT_VARIADIC_TRAIT_FALSE(IsConstructible, D, void); } diff --git a/Tests/AK/TestTypedTransfer.cpp b/Tests/AK/TestTypedTransfer.cpp index 5a0c347092..392d6a6600 100644 --- a/Tests/AK/TestTypedTransfer.cpp +++ b/Tests/AK/TestTypedTransfer.cpp @@ -20,7 +20,7 @@ struct NonPrimitiveIntWrapper { TEST_CASE(overlapping_source_and_destination_1) { - const Array<NonPrimitiveIntWrapper, 6> expected { 3, 4, 5, 6, 5, 6 }; + Array<NonPrimitiveIntWrapper, 6> const expected { 3, 4, 5, 6, 5, 6 }; Array<NonPrimitiveIntWrapper, 6> actual { 1, 2, 3, 4, 5, 6 }; AK::TypedTransfer<NonPrimitiveIntWrapper>::copy(actual.data(), actual.data() + 2, 4); @@ -31,7 +31,7 @@ TEST_CASE(overlapping_source_and_destination_1) TEST_CASE(overlapping_source_and_destination_2) { - const Array<NonPrimitiveIntWrapper, 6> expected { 1, 2, 1, 2, 3, 4 }; + Array<NonPrimitiveIntWrapper, 6> const expected { 1, 2, 1, 2, 3, 4 }; Array<NonPrimitiveIntWrapper, 6> actual { 1, 2, 3, 4, 5, 6 }; AK::TypedTransfer<NonPrimitiveIntWrapper>::copy(actual.data() + 2, actual.data(), 4); diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cpp index 74038f3788..3216c24a3c 100644 --- a/Tests/AK/TestVector.cpp +++ b/Tests/AK/TestVector.cpp @@ -43,14 +43,14 @@ TEST_CASE(strings) strings.append("DEF"); int loop_counter = 0; - for (const String& string : strings) { + for (String const& string : strings) { EXPECT(!string.is_null()); EXPECT(!string.is_empty()); ++loop_counter; } loop_counter = 0; - for (auto& string : (const_cast<const Vector<String>&>(strings))) { + for (auto& string : (const_cast<Vector<String> const&>(strings))) { EXPECT(!string.is_null()); EXPECT(!string.is_empty()); ++loop_counter; @@ -402,7 +402,7 @@ TEST_CASE(should_find_value) { Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 }; - const auto expected = v.begin() + 4; + auto const expected = v.begin() + 4; EXPECT_EQ(expected, v.find(0)); } @@ -411,9 +411,9 @@ TEST_CASE(should_find_predicate) { Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 }; - const auto expected = v.begin() + 4; + auto const expected = v.begin() + 4; - EXPECT_EQ(expected, v.find_if([](const auto v) { return v == 0; })); + EXPECT_EQ(expected, v.find_if([](auto const v) { return v == 0; })); } TEST_CASE(should_find_index) @@ -548,8 +548,8 @@ TEST_CASE(rend) { Vector<int> v { 1, 2, 3, 4, 5, 6, 7, 8, 0 }; - const auto expected = v.end() - 5; - const auto expected_in_reverse = v.rend() - 5; + auto const expected = v.end() - 5; + auto const expected_in_reverse = v.rend() - 5; EXPECT_EQ(*expected, *expected_in_reverse); } diff --git a/Tests/Kernel/TestKernelPledge.cpp b/Tests/Kernel/TestKernelPledge.cpp index 3a90450c2e..88bd5beac7 100644 --- a/Tests/Kernel/TestKernelPledge.cpp +++ b/Tests/Kernel/TestKernelPledge.cpp @@ -18,7 +18,7 @@ TEST_CASE(test_nonexistent_pledge) TEST_CASE(test_pledge_argument_validation) { - const auto long_argument = String::repeated('a', 2048); + auto const long_argument = String::repeated('a', 2048); auto res = pledge(long_argument.characters(), "stdio"); EXPECT_EQ(res, -1); diff --git a/Tests/Kernel/bind-local-socket-to-symlink.cpp b/Tests/Kernel/bind-local-socket-to-symlink.cpp index fed92a90a9..78f8f3994a 100644 --- a/Tests/Kernel/bind-local-socket-to-symlink.cpp +++ b/Tests/Kernel/bind-local-socket-to-symlink.cpp @@ -13,7 +13,7 @@ int main(int, char**) { - constexpr const char* path = "/tmp/foo"; + constexpr char const* path = "/tmp/foo"; int rc = symlink("bar", path); if (rc < 0) { perror("symlink"); diff --git a/Tests/Kernel/elf-execve-mmap-race.cpp b/Tests/Kernel/elf-execve-mmap-race.cpp index 5254fac3e5..931551e69a 100644 --- a/Tests/Kernel/elf-execve-mmap-race.cpp +++ b/Tests/Kernel/elf-execve-mmap-race.cpp @@ -16,7 +16,7 @@ #include <sys/wait.h> #include <unistd.h> -volatile bool hax = false; +bool volatile hax = false; int main() { diff --git a/Tests/Kernel/fuzz-syscalls.cpp b/Tests/Kernel/fuzz-syscalls.cpp index 3b7a812c41..ba06429a0c 100644 --- a/Tests/Kernel/fuzz-syscalls.cpp +++ b/Tests/Kernel/fuzz-syscalls.cpp @@ -32,7 +32,7 @@ static bool is_nosys_syscall(int fn) return fn == SC_futex || fn == SC_emuctl; } -static bool is_bad_idea(int fn, const size_t* direct_sc_args, const size_t* fake_sc_params, const char* some_string) +static bool is_bad_idea(int fn, size_t const* direct_sc_args, size_t const* fake_sc_params, char const* some_string) { switch (fn) { case SC_mprotect: @@ -78,7 +78,7 @@ static void do_systematic_tests() VERIFY(rc == -ENOSYS); } -static void randomize_from(size_t* buffer, size_t len, const Vector<size_t>& values) +static void randomize_from(size_t* buffer, size_t len, Vector<size_t> const& values) { for (size_t i = 0; i < len; ++i) { buffer[i] = values[get_random_uniform(values.size())]; @@ -122,7 +122,7 @@ static void do_random_tests() size_t direct_sc_args[3] = { 0 }; // Isolate to a separate region to make corruption less likely, because we will write to it: auto* fake_sc_params = reinterpret_cast<size_t*>(mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_RANDOMIZED, 0, 0)); - const char* some_string = "Hello, world!"; + char const* some_string = "Hello, world!"; Vector<size_t> interesting_values = { 0, 1, @@ -134,7 +134,7 @@ static void do_random_tests() 0xffffffff, }; dbgln("Doing a few random syscalls with:"); - for (const auto& interesting_value : interesting_values) { + for (auto const& interesting_value : interesting_values) { dbgln(" {0} ({0:p})", interesting_value); } for (size_t i = 0; i < fuzz_syscall_count; ++i) { diff --git a/Tests/Kernel/kill-pidtid-confusion.cpp b/Tests/Kernel/kill-pidtid-confusion.cpp index f75add2f02..be50df5797 100644 --- a/Tests/Kernel/kill-pidtid-confusion.cpp +++ b/Tests/Kernel/kill-pidtid-confusion.cpp @@ -55,7 +55,7 @@ static void fork_into(void(fn)()) static void thread_into(void* (*fn)(void*)) { pthread_t tid; - const int rc = pthread_create(&tid, nullptr, fn, nullptr); + int const rc = pthread_create(&tid, nullptr, fn, nullptr); if (rc < 0) { perror("pthread_create"); exit(1); @@ -64,7 +64,7 @@ static void thread_into(void* (*fn)(void*)) static void sleep_steps(useconds_t steps) { - const int rc = usleep(steps * STEP_SIZE); + int const rc = usleep(steps * STEP_SIZE); if (rc < 0) { perror("usleep"); VERIFY_NOT_REACHED(); diff --git a/Tests/Kernel/mprotect-multi-region-mprotect.cpp b/Tests/Kernel/mprotect-multi-region-mprotect.cpp index 6e36859338..07e278a3de 100644 --- a/Tests/Kernel/mprotect-multi-region-mprotect.cpp +++ b/Tests/Kernel/mprotect-multi-region-mprotect.cpp @@ -67,7 +67,7 @@ int main() return 1; } - //cleanup + // cleanup munmap(map1, 6 * PAGE_SIZE); outln("PASS"); diff --git a/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp b/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp index e598b22083..a86da20130 100644 --- a/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp +++ b/Tests/Kernel/nanosleep-race-outbuf-munmap.cpp @@ -19,7 +19,7 @@ static void signal_printer(int) typedef struct yank_shared_t { timespec* remaining_sleep; // TODO: Be nice and use thread ID - //pthread_t sleeper_thread; + // pthread_t sleeper_thread; } yank_shared_t; static void* yanker_fn(void* shared_) diff --git a/Tests/Kernel/pthread-cond-timedwait-example.cpp b/Tests/Kernel/pthread-cond-timedwait-example.cpp index 799b0fa6b3..c2bd2b62c5 100644 --- a/Tests/Kernel/pthread-cond-timedwait-example.cpp +++ b/Tests/Kernel/pthread-cond-timedwait-example.cpp @@ -14,7 +14,7 @@ #include <unistd.h> struct worker_t { - const char* name; + char const* name; int count; pthread_t thread; pthread_mutex_t lock; @@ -45,7 +45,7 @@ static void* run_worker(void* args) return nullptr; } -static void init_worker(worker_t* worker, const char* name, long int wait_time) +static void init_worker(worker_t* worker, char const* name, long int wait_time) { worker->name = name; worker->wait_time = wait_time; diff --git a/Tests/Kernel/setpgid-across-sessions-without-leader.cpp b/Tests/Kernel/setpgid-across-sessions-without-leader.cpp index e22c041880..0626c4b458 100644 --- a/Tests/Kernel/setpgid-across-sessions-without-leader.cpp +++ b/Tests/Kernel/setpgid-across-sessions-without-leader.cpp @@ -57,7 +57,7 @@ static void fork_into(void (*fn)(void*), void* arg) exit(1); } if (rc > 0) { - const int disown_rc = disown(rc); + int const disown_rc = disown(rc); if (disown_rc < 0) { perror("disown"); dbgln("This might cause PA1 to remain in the Zombie state, " @@ -73,7 +73,7 @@ static void fork_into(void (*fn)(void*), void* arg) static void sleep_steps(useconds_t steps) { - const int rc = usleep(steps * STEP_SIZE); + int const rc = usleep(steps * STEP_SIZE); if (rc < 0) { perror("usleep"); VERIFY_NOT_REACHED(); diff --git a/Tests/Kernel/siginfo-example.cpp b/Tests/Kernel/siginfo-example.cpp index 75cf4745f9..6495570eca 100644 --- a/Tests/Kernel/siginfo-example.cpp +++ b/Tests/Kernel/siginfo-example.cpp @@ -17,7 +17,7 @@ volatile ucontext_t saved_ucontext; siginfo_t* sig_info_addr; ucontext_t* ucontext_addr; void* stack_ptr; -volatile bool signal_was_delivered = false; +bool volatile signal_was_delivered = false; static void signal_handler(int sig, siginfo_t* sig_info, void* u_context) { diff --git a/Tests/Kernel/stress-truncate.cpp b/Tests/Kernel/stress-truncate.cpp index 8c683477bd..7164bb05b2 100644 --- a/Tests/Kernel/stress-truncate.cpp +++ b/Tests/Kernel/stress-truncate.cpp @@ -13,7 +13,7 @@ int main(int argc, char** argv) { - const char* target = nullptr; + char const* target = nullptr; int max_file_size = 1024 * 1024; int count = 1024; diff --git a/Tests/Kernel/stress-writeread.cpp b/Tests/Kernel/stress-writeread.cpp index 6ae5bf5c46..07666b5ed6 100644 --- a/Tests/Kernel/stress-writeread.cpp +++ b/Tests/Kernel/stress-writeread.cpp @@ -60,7 +60,7 @@ bool write_block(int fd, int seed, off_t block, AK::ByteBuffer& buffer) int main(int argc, char** argv) { - const char* target = nullptr; + char const* target = nullptr; int min_block_offset = 0; int block_length = 2048; int block_size = 512; diff --git a/Tests/LibC/TestIo.cpp b/Tests/LibC/TestIo.cpp index bd47d7d6c8..b8c833ecca 100644 --- a/Tests/LibC/TestIo.cpp +++ b/Tests/LibC/TestIo.cpp @@ -348,9 +348,9 @@ TEST_CASE(writev) EXPECT(rc == 0); iovec iov[2]; - iov[0].iov_base = const_cast<void*>((const void*)"Hello"); + iov[0].iov_base = const_cast<void*>((void const*)"Hello"); iov[0].iov_len = 5; - iov[1].iov_base = const_cast<void*>((const void*)"Friends"); + iov[1].iov_base = const_cast<void*>((void const*)"Friends"); iov[1].iov_len = 7; int nwritten = writev(pipefds[1], iov, 2); EXPECT_EQ(nwritten, 12); diff --git a/Tests/LibC/TestLibCMkTemp.cpp b/Tests/LibC/TestLibCMkTemp.cpp index 03d377642b..80f279adaa 100644 --- a/Tests/LibC/TestLibCMkTemp.cpp +++ b/Tests/LibC/TestLibCMkTemp.cpp @@ -33,7 +33,7 @@ TEST_CASE(test_mktemp_unique_filename) } else { wait(NULL); - auto path1 = String::formatted("{}", reinterpret_cast<const char*>(ptr)); + auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr)); char path[] = "/tmp/test.mktemp.XXXXXX"; auto path2 = String::formatted("{}", mktemp(path)); @@ -63,7 +63,7 @@ TEST_CASE(test_mkdtemp_unique_filename) } else { wait(NULL); - auto path1 = String::formatted("{}", reinterpret_cast<const char*>(ptr)); + auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr)); char path[] = "/tmp/test.mkdtemp.XXXXXX"; auto path2 = String::formatted("{}", mkdtemp(path)); @@ -101,7 +101,7 @@ TEST_CASE(test_mkstemp_unique_filename) } else { wait(NULL); - auto path1 = String::formatted("{}", reinterpret_cast<const char*>(ptr)); + auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr)); char path[] = "/tmp/test.mkstemp.XXXXXX"; auto fd = mkstemp(path); diff --git a/Tests/LibC/TestLibCSetjmp.cpp b/Tests/LibC/TestLibCSetjmp.cpp index 8e4facddd9..1519f5d743 100644 --- a/Tests/LibC/TestLibCSetjmp.cpp +++ b/Tests/LibC/TestLibCSetjmp.cpp @@ -12,7 +12,7 @@ TEST_CASE(setjmp) { jmp_buf env; - volatile int set = 1; + int volatile set = 1; if (setjmp(env)) { EXPECT_EQ(set, 0); @@ -29,7 +29,7 @@ TEST_CASE(setjmp) TEST_CASE(setjmp_zero) { jmp_buf env; - volatile int set = 1; + int volatile set = 1; switch (setjmp(env)) { case 0: @@ -50,7 +50,7 @@ TEST_CASE(setjmp_zero) TEST_CASE(setjmp_value) { jmp_buf env; - volatile int set = 1; + int volatile set = 1; switch (setjmp(env)) { case 0: @@ -71,7 +71,7 @@ TEST_CASE(setjmp_value) TEST_CASE(sigsetjmp) { sigjmp_buf env; - volatile int set = 1; + int volatile set = 1; if (sigsetjmp(env, 0)) { EXPECT_EQ(set, 0); @@ -88,7 +88,7 @@ TEST_CASE(sigsetjmp) TEST_CASE(sigsetjmp_zero) { sigjmp_buf env; - volatile int set = 1; + int volatile set = 1; switch (sigsetjmp(env, 0)) { case 0: @@ -109,7 +109,7 @@ TEST_CASE(sigsetjmp_zero) TEST_CASE(sigsetjmp_value) { sigjmp_buf env; - volatile int set = 1; + int volatile set = 1; switch (sigsetjmp(env, 0)) { case 0: diff --git a/Tests/LibC/TestLibCTime.cpp b/Tests/LibC/TestLibCTime.cpp index 72e0777b2c..6534e9e0c1 100644 --- a/Tests/LibC/TestLibCTime.cpp +++ b/Tests/LibC/TestLibCTime.cpp @@ -8,7 +8,7 @@ #include <LibTest/TestCase.h> #include <time.h> -const auto expected_epoch = "Thu Jan 1 00:00:00 1970\n"sv; +auto const expected_epoch = "Thu Jan 1 00:00:00 1970\n"sv; class TimeZoneGuard { public: diff --git a/Tests/LibC/TestMemmem.cpp b/Tests/LibC/TestMemmem.cpp index f266b53dad..a6aefe388e 100644 --- a/Tests/LibC/TestMemmem.cpp +++ b/Tests/LibC/TestMemmem.cpp @@ -10,19 +10,19 @@ #include <string.h> struct TestCase { - const u8* haystack; + u8 const* haystack; size_t haystack_length; - const u8* needle; + u8 const* needle; size_t needle_length; ssize_t matching_offset { -1 }; }; const static TestCase g_test_cases[] = { - { (const u8*) {}, 0u, (const u8*) {}, 0u, 0 }, + { (u8 const*) {}, 0u, (u8 const*) {}, 0u, 0 }, { (const u8[]) { 1, 2, 3 }, 3u, (const u8[]) { 1, 2, 3 }, 3u, 0 }, { (const u8[]) { 1, 2, 4 }, 3u, (const u8[]) { 1, 2, 3 }, 3u, -1 }, - { (const u8*)"abcdef", 6u, (const u8[]) {}, 0u, 0 }, - { (const u8*)"abcdef", 6u, (const u8*)"de", 2u, 3 }, + { (u8 const*)"abcdef", 6u, (const u8[]) {}, 0u, 0 }, + { (u8 const*)"abcdef", 6u, (u8 const*)"de", 2u, 3 }, { (const u8[]) { 0, 1, 2, 5, 2, 5 }, 6u, (const u8[]) { 1 }, 1u, 1 }, { (const u8[]) { 0, 1, 2, 5, 2, 5 }, 6u, (const u8[]) { 1, 2 }, 2u, 1 }, { (const u8[]) { 0, 1, 1, 2 }, 4u, (const u8[]) { 1, 5 }, 2u, -1 }, @@ -33,7 +33,7 @@ const static TestCase g_test_cases[] = { TEST_CASE(memmem_search) { size_t i = 0; - for (const auto& test_case : g_test_cases) { + for (auto const& test_case : g_test_cases) { auto expected = test_case.matching_offset >= 0 ? test_case.haystack + test_case.matching_offset : nullptr; auto result = memmem(test_case.haystack, test_case.haystack_length, test_case.needle, test_case.needle_length); if (result != expected) { diff --git a/Tests/LibC/TestQsort.cpp b/Tests/LibC/TestQsort.cpp index 5a194d6b24..12df7b644f 100644 --- a/Tests/LibC/TestQsort.cpp +++ b/Tests/LibC/TestQsort.cpp @@ -19,10 +19,10 @@ struct SortableObject { int m_payload; }; -static int compare_sortable_object(const void* a, const void* b) +static int compare_sortable_object(void const* a, void const* b) { - const int key1 = static_cast<const SortableObject*>(a)->m_key; - const int key2 = static_cast<const SortableObject*>(b)->m_key; + int const key1 = static_cast<SortableObject const*>(a)->m_key; + int const key2 = static_cast<SortableObject const*>(b)->m_key; if (key1 < key2) { return -1; } else if (key1 == key2) { @@ -60,16 +60,16 @@ TEST_CASE(quick_sort) qsort(test_objects.data(), test_objects.size(), sizeof(SortableObject), compare_sortable_object); // Check that the objects are sorted by key for (auto i = 0u; i + 1 < test_objects.size(); ++i) { - const auto& key1 = test_objects[i].m_key; - const auto& key2 = test_objects[i + 1].m_key; + auto const& key1 = test_objects[i].m_key; + auto const& key2 = test_objects[i + 1].m_key; if (key1 > key2) { FAIL(String::formatted("saw key {} before key {}\n", key1, key2)); } } // Check that the object's payloads have not been corrupted for (auto i = 0u; i < test_objects.size(); ++i) { - const auto expected = calc_payload_for_pos(i); - const auto payload = test_objects[i].m_payload; + auto const expected = calc_payload_for_pos(i); + auto const payload = test_objects[i].m_payload; if (payload != expected) { FAIL(String::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload)); } diff --git a/Tests/LibC/TestRealpath.cpp b/Tests/LibC/TestRealpath.cpp index c0fb283890..21a1d527f8 100644 --- a/Tests/LibC/TestRealpath.cpp +++ b/Tests/LibC/TestRealpath.cpp @@ -21,7 +21,7 @@ static constexpr char PATH_LOREM_250[] = "This-is-an-annoyingly-long-name-that-s static constexpr size_t ITERATION_DEPTH = 17; -static void check_result(const char* what, const String& expected, const char* actual) +static void check_result(char const* what, String const& expected, char const* actual) { if (expected != actual) FAIL(String::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0)); diff --git a/Tests/LibC/TestScanf.cpp b/Tests/LibC/TestScanf.cpp index 5209088400..5c1a1c934a 100644 --- a/Tests/LibC/TestScanf.cpp +++ b/Tests/LibC/TestScanf.cpp @@ -65,7 +65,7 @@ constexpr static Array<unsigned char, 32> to_value_t(T x) } template<size_t N> -constexpr static Array<unsigned char, 32> str_to_value_t(const char (&x)[N]) +constexpr static Array<unsigned char, 32> str_to_value_t(char const (&x)[N]) { Array<unsigned char, 32> value { 0 }; for (size_t i = 0; i < N; ++i) @@ -78,7 +78,7 @@ struct Argument { void* data; }; -static Array<u8, 32> arg_to_value_t(const Argument& arg) +static Array<u8, 32> arg_to_value_t(Argument const& arg) { if (arg.size == 1) return to_value_t(*(u8*)arg.data); @@ -140,8 +140,8 @@ Argument charstararg1 { sizeof(charstar), &_charstararg1[0] }; Argument charstararg2 { sizeof(charstar), &_charstararg2[0] }; struct TestSuite { - const char* format; - const char* input; + char const* format; + char const* input; int expected_return_value; size_t argument_count; Argument arguments[8]; @@ -184,7 +184,7 @@ const TestSuite test_suites[] { bool g_any_failed = false; -static bool check_value_conformance(const TestSuite& test) +static bool check_value_conformance(TestSuite const& test) { bool fail = false; for (size_t i = 0; i < test.argument_count; ++i) { @@ -192,8 +192,8 @@ static bool check_value_conformance(const TestSuite& test) auto arg_value = arg_to_value_t(arg); auto& value = test.expected_values[i]; if (arg_value != value) { - auto arg_ptr = (const u32*)arg_value.data(); - auto value_ptr = (const u32*)value.data(); + auto arg_ptr = (u32 const*)arg_value.data(); + auto value_ptr = (u32 const*)value.data(); printf(" value %zu FAIL,\n", i); printf(" expected %08x%08x%08x%08x%08x%08x%08x%08x\n", value_ptr[0], value_ptr[1], value_ptr[2], value_ptr[3], @@ -210,7 +210,7 @@ static bool check_value_conformance(const TestSuite& test) return !fail; } -static void do_one_test(const TestSuite& test) +static void do_one_test(TestSuite const& test) { printf("Testing '%s' against '%s'...\n", test.input, test.format); diff --git a/Tests/LibC/TestSearch.cpp b/Tests/LibC/TestSearch.cpp index 892295d42c..1b30076580 100644 --- a/Tests/LibC/TestSearch.cpp +++ b/Tests/LibC/TestSearch.cpp @@ -13,11 +13,11 @@ #define NODE(node) static_cast<struct search_tree_node*>(node) #define ROOTP(root) reinterpret_cast<void**>(root) -#define COMP(func) reinterpret_cast<int (*)(const void*, const void*)>(func) +#define COMP(func) reinterpret_cast<int (*)(void const*, void const*)>(func) #define U8(value) static_cast<u8>(value) struct twalk_test_entry { - const void* node; + void const* node; VISIT order; int depth; }; @@ -30,7 +30,7 @@ TEST_CASE(tsearch) { struct search_tree_node* root = nullptr; void* ret; - const char* key; + char const* key; char* search; // Try a nullptr rootp. @@ -150,8 +150,8 @@ TEST_CASE(tfind) delete_node_recursive(root); } -void twalk_action(const void* node, VISIT order, int depth); -void twalk_action(const void* node, VISIT order, int depth) +void twalk_action(void const* node, VISIT order, int depth); +void twalk_action(void const* node, VISIT order, int depth) { static int count = 0; static const struct twalk_test_entry* tests = nullptr; diff --git a/Tests/LibC/TestSnprintf.cpp b/Tests/LibC/TestSnprintf.cpp index 125f045c6b..0ab31f79d1 100644 --- a/Tests/LibC/TestSnprintf.cpp +++ b/Tests/LibC/TestSnprintf.cpp @@ -18,16 +18,16 @@ template<typename TArg> struct Testcase { - const char* dest; + char const* dest; size_t dest_n; - const char* fmt; + char const* fmt; const TArg arg; int expected_return; - const char* dest_expected; + char const* dest_expected; size_t dest_expected_n; // == dest_n }; -static String show(const ByteBuffer& buf) +static String show(ByteBuffer const& buf) { StringBuilder builder; for (size_t i = 0; i < buf.size(); ++i) { @@ -46,7 +46,7 @@ static String show(const ByteBuffer& buf) } template<typename TArg> -static bool test_single(const Testcase<TArg>& testcase) +static bool test_single(Testcase<TArg> const& testcase) { constexpr size_t SANDBOX_CANARY_SIZE = 8; @@ -109,41 +109,41 @@ static bool test_single(const Testcase<TArg>& testcase) // Drop the NUL terminator added by the C++ compiler. #define LITERAL(x) x, (sizeof(x) - 1) -static const char* const POISON = (const char*)1; +static char const* const POISON = (char const*)1; TEST_CASE(golden_path) { - EXPECT(test_single<const char*>({ LITERAL("Hello World!\0\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0\0") })); - EXPECT(test_single<const char*>({ LITERAL("Hello World!\0\0\0"), "Hello %s!", "Friend", 13, LITERAL("Hello Friend!\0\0") })); - EXPECT(test_single<const char*>({ LITERAL("aaaaaaaaaa"), "whf", POISON, 3, LITERAL("whf\0aaaaaa") })); - EXPECT(test_single<const char*>({ LITERAL("aaaaaaaaaa"), "w%sf", "h", 3, LITERAL("whf\0aaaaaa") })); + EXPECT(test_single<char const*>({ LITERAL("Hello World!\0\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0\0") })); + EXPECT(test_single<char const*>({ LITERAL("Hello World!\0\0\0"), "Hello %s!", "Friend", 13, LITERAL("Hello Friend!\0\0") })); + EXPECT(test_single<char const*>({ LITERAL("aaaaaaaaaa"), "whf", POISON, 3, LITERAL("whf\0aaaaaa") })); + EXPECT(test_single<char const*>({ LITERAL("aaaaaaaaaa"), "w%sf", "h", 3, LITERAL("whf\0aaaaaa") })); } TEST_CASE(border_cases) { - EXPECT(test_single<const char*>({ LITERAL("Hello World!\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0") })); - EXPECT(test_single<const char*>({ LITERAL("AAAA"), "whf", POISON, 3, LITERAL("whf\0") })); - EXPECT(test_single<const char*>({ LITERAL("AAAA"), "%s", "whf", 3, LITERAL("whf\0") })); + EXPECT(test_single<char const*>({ LITERAL("Hello World!\0\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend!\0") })); + EXPECT(test_single<char const*>({ LITERAL("AAAA"), "whf", POISON, 3, LITERAL("whf\0") })); + EXPECT(test_single<char const*>({ LITERAL("AAAA"), "%s", "whf", 3, LITERAL("whf\0") })); } TEST_CASE(too_long) { - EXPECT(test_single<const char*>({ LITERAL("Hello World!\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend\0") })); - EXPECT(test_single<const char*>({ LITERAL("Hello World!\0"), "This source is %s too long!", "just *way*", 35, LITERAL("This source \0") })); - EXPECT(test_single<const char*>({ LITERAL("x"), "This source is %s too long!", "just *way*", 35, LITERAL("\0") })); + EXPECT(test_single<char const*>({ LITERAL("Hello World!\0"), "Hello Friend!", POISON, 13, LITERAL("Hello Friend\0") })); + EXPECT(test_single<char const*>({ LITERAL("Hello World!\0"), "This source is %s too long!", "just *way*", 35, LITERAL("This source \0") })); + EXPECT(test_single<char const*>({ LITERAL("x"), "This source is %s too long!", "just *way*", 35, LITERAL("\0") })); } TEST_CASE(special_cases) { - EXPECT(test_single<const char*>({ LITERAL(""), "Hello Friend!", POISON, 13, LITERAL("") })); + EXPECT(test_single<char const*>({ LITERAL(""), "Hello Friend!", POISON, 13, LITERAL("") })); EXPECT_EQ(snprintf(nullptr, 0, "Hello, friend!"), 14); - EXPECT(test_single<const char*>({ LITERAL(""), "", POISON, 0, LITERAL("") })); - EXPECT(test_single<const char*>({ LITERAL("x"), "", POISON, 0, LITERAL("\0") })); - EXPECT(test_single<const char*>({ LITERAL("xx"), "", POISON, 0, LITERAL("\0x") })); - EXPECT(test_single<const char*>({ LITERAL("xxx"), "", POISON, 0, LITERAL("\0xx") })); - EXPECT(test_single<const char*>({ LITERAL(""), "whf", POISON, 3, LITERAL("") })); - EXPECT(test_single<const char*>({ LITERAL("x"), "whf", POISON, 3, LITERAL("\0") })); - EXPECT(test_single<const char*>({ LITERAL("xx"), "whf", POISON, 3, LITERAL("w\0") })); + EXPECT(test_single<char const*>({ LITERAL(""), "", POISON, 0, LITERAL("") })); + EXPECT(test_single<char const*>({ LITERAL("x"), "", POISON, 0, LITERAL("\0") })); + EXPECT(test_single<char const*>({ LITERAL("xx"), "", POISON, 0, LITERAL("\0x") })); + EXPECT(test_single<char const*>({ LITERAL("xxx"), "", POISON, 0, LITERAL("\0xx") })); + EXPECT(test_single<char const*>({ LITERAL(""), "whf", POISON, 3, LITERAL("") })); + EXPECT(test_single<char const*>({ LITERAL("x"), "whf", POISON, 3, LITERAL("\0") })); + EXPECT(test_single<char const*>({ LITERAL("xx"), "whf", POISON, 3, LITERAL("w\0") })); } TEST_CASE(octal_values) diff --git a/Tests/LibC/TestStrlcpy.cpp b/Tests/LibC/TestStrlcpy.cpp index 9458710600..407c307e2f 100644 --- a/Tests/LibC/TestStrlcpy.cpp +++ b/Tests/LibC/TestStrlcpy.cpp @@ -14,15 +14,15 @@ #include <string.h> struct Testcase { - const char* dest; + char const* dest; size_t dest_n; - const char* src; + char const* src; size_t src_n; - const char* dest_expected; + char const* dest_expected; size_t dest_expected_n; // == dest_n }; -static String show(const ByteBuffer& buf) +static String show(ByteBuffer const& buf) { StringBuilder builder; for (size_t i = 0; i < buf.size(); ++i) { @@ -40,7 +40,7 @@ static String show(const ByteBuffer& buf) return builder.build(); } -static bool test_single(const Testcase& testcase) +static bool test_single(Testcase const& testcase) { constexpr size_t SANDBOX_CANARY_SIZE = 8; diff --git a/Tests/LibC/TestStrtodAccuracy.cpp b/Tests/LibC/TestStrtodAccuracy.cpp index 5f57769299..f251b441ad 100644 --- a/Tests/LibC/TestStrtodAccuracy.cpp +++ b/Tests/LibC/TestStrtodAccuracy.cpp @@ -18,10 +18,10 @@ static constexpr char TEXT_RESET[] = "\x1b[0m"; static constexpr long long LENIENCY = 8; struct Testcase { - const char* test_name; + char const* test_name; int should_consume; - const char* hex; - const char* test_string; + char const* hex; + char const* test_string; }; static Testcase TESTCASES[] = { @@ -231,7 +231,7 @@ static Testcase TESTCASES[] = { constexpr size_t NUM_TESTCASES = sizeof(TESTCASES) / sizeof(TESTCASES[0]); -typedef double (*strtod_fn_t)(const char* str, char** endptr); +typedef double (*strtod_fn_t)(char const* str, char** endptr); static long long cast_ll(double d) { @@ -250,7 +250,7 @@ static long long cast_ll(double d) return readable.as_ll; } -static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, const char* expect_hex, int expect_consume, long long expect_ll) +static bool is_strtod_close(strtod_fn_t strtod_fn, char const* test_string, char const* expect_hex, int expect_consume, long long expect_ll) { union readable_t { double as_double; @@ -277,7 +277,7 @@ static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, cons if (endptr < test_string) { actual_consume = 999; } else { - const char* max_endptr = test_string + strlen(test_string); + char const* max_endptr = test_string + strlen(test_string); actual_consume_possible = endptr <= max_endptr; actual_consume = endptr - test_string; } @@ -303,7 +303,7 @@ static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, cons return !(wrong_hex || error_cns || wrong_cns); } -static long long hex_to_ll(const char* hex) +static long long hex_to_ll(char const* hex) { long long result = 0; for (int i = 0; i < 16; ++i) { diff --git a/Tests/LibC/TestWchar.cpp b/Tests/LibC/TestWchar.cpp index 05c4f24bb6..d8b7c0c236 100644 --- a/Tests/LibC/TestWchar.cpp +++ b/Tests/LibC/TestWchar.cpp @@ -13,7 +13,7 @@ TEST_CASE(wcspbrk) { - const wchar_t* input; + wchar_t const* input; wchar_t* ret; // Test empty haystack. @@ -40,7 +40,7 @@ TEST_CASE(wcspbrk) TEST_CASE(wcsstr) { - const wchar_t* input = L"abcde"; + wchar_t const* input = L"abcde"; wchar_t* ret; // Empty needle should return haystack. @@ -70,7 +70,7 @@ TEST_CASE(wcsstr) TEST_CASE(wmemchr) { - const wchar_t* input = L"abcde"; + wchar_t const* input = L"abcde"; wchar_t* ret; // Empty haystack returns nothing. @@ -102,7 +102,7 @@ TEST_CASE(wmemchr) TEST_CASE(wmemcpy) { - const wchar_t* input = L"abc\0def"; + wchar_t const* input = L"abc\0def"; auto buf = static_cast<wchar_t*>(malloc(8 * sizeof(wchar_t))); if (!buf) { @@ -142,7 +142,7 @@ TEST_CASE(wmemset) TEST_CASE(wmemmove) { wchar_t* ret; - const wchar_t* string = L"abc\0def"; + wchar_t const* string = L"abc\0def"; auto buf = static_cast<wchar_t*>(calloc(32, sizeof(wchar_t))); if (!buf) { @@ -324,7 +324,7 @@ TEST_CASE(wcsrtombs) char buf[MB_LEN_MAX * 4]; const wchar_t good_chars[] = { L'\U0001F41E', L'\U0001F41E', L'\0' }; const wchar_t bad_chars[] = { L'\U0001F41E', static_cast<wchar_t>(0x1111F41E), L'\0' }; - const wchar_t* src; + wchar_t const* src; size_t ret = 0; // Convert normal and valid wchar_t values. @@ -369,7 +369,7 @@ TEST_CASE(wcsnrtombs) { mbstate_t state = {}; const wchar_t good_chars[] = { L'\U0001F41E', L'\U0001F41E', L'\0' }; - const wchar_t* src; + wchar_t const* src; size_t ret = 0; // Convert nothing. @@ -395,9 +395,9 @@ TEST_CASE(mbsrtowcs) { mbstate_t state = {}; wchar_t buf[4]; - const char good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e"; - const char bad_chars[] = "\xf0\x9f\x90\x9e\xf0\xff\x90\x9e"; - const char* src; + char const good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e"; + char const bad_chars[] = "\xf0\x9f\x90\x9e\xf0\xff\x90\x9e"; + char const* src; size_t ret = 0; // Convert normal and valid multibyte sequences. @@ -445,8 +445,8 @@ TEST_CASE(mbsrtowcs) TEST_CASE(mbsnrtowcs) { mbstate_t state = {}; - const char good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e"; - const char* src; + char const good_chars[] = "\xf0\x9f\x90\x9e\xf0\x9f\x90\x9e"; + char const* src; size_t ret = 0; // Convert nothing. diff --git a/Tests/LibCompress/TestDeflate.cpp b/Tests/LibCompress/TestDeflate.cpp index b325ffa3db..d2bc4e82c6 100644 --- a/Tests/LibCompress/TestDeflate.cpp +++ b/Tests/LibCompress/TestDeflate.cpp @@ -14,19 +14,19 @@ TEST_CASE(canonical_code_simple) { - const Array<u8, 32> code { + Array<u8, 32> const code { 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 }; - const Array<u8, 6> input { + Array<u8, 6> const input { 0x00, 0x42, 0x84, 0xa9, 0xb0, 0x15 }; - const Array<u32, 9> output { + Array<u32, 9> const output { 0x00, 0x01, 0x01, 0x02, 0x03, 0x05, 0x08, 0x0d, 0x15 }; - const auto huffman = Compress::CanonicalCode::from_bytes(code).value(); + auto const huffman = Compress::CanonicalCode::from_bytes(code).value(); auto memory_stream = InputMemoryStream { input }; auto bit_stream = InputBitStream { memory_stream }; @@ -36,17 +36,17 @@ TEST_CASE(canonical_code_simple) TEST_CASE(canonical_code_complex) { - const Array<u8, 6> code { + Array<u8, 6> const code { 0x03, 0x02, 0x03, 0x03, 0x02, 0x03 }; - const Array<u8, 4> input { + Array<u8, 4> const input { 0xa1, 0xf3, 0xa1, 0xf3 }; - const Array<u32, 12> output { + Array<u32, 12> const output { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; - const auto huffman = Compress::CanonicalCode::from_bytes(code).value(); + auto const huffman = Compress::CanonicalCode::from_bytes(code).value(); auto memory_stream = InputMemoryStream { input }; auto bit_stream = InputBitStream { memory_stream }; @@ -56,7 +56,7 @@ TEST_CASE(canonical_code_complex) TEST_CASE(deflate_decompress_compressed_block) { - const Array<u8, 28> compressed { + Array<u8, 28> const compressed { 0x0B, 0xC9, 0xC8, 0x2C, 0x56, 0x00, 0xA2, 0x44, 0x85, 0xE2, 0xCC, 0xDC, 0x82, 0x9C, 0x54, 0x85, 0x92, 0xD4, 0x8A, 0x12, 0x85, 0xB4, 0x4C, 0x20, 0xCB, 0x4A, 0x13, 0x00 @@ -64,26 +64,26 @@ TEST_CASE(deflate_decompress_compressed_block) const u8 uncompressed[] = "This is a simple text file :)"; - const auto decompressed = Compress::DeflateDecompressor::decompress_all(compressed); + auto const decompressed = Compress::DeflateDecompressor::decompress_all(compressed); EXPECT(decompressed.value().bytes() == ReadonlyBytes({ uncompressed, sizeof(uncompressed) - 1 })); } TEST_CASE(deflate_decompress_uncompressed_block) { - const Array<u8, 18> compressed { + Array<u8, 18> const compressed { 0x01, 0x0d, 0x00, 0xf2, 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21 }; const u8 uncompressed[] = "Hello, World!"; - const auto decompressed = Compress::DeflateDecompressor::decompress_all(compressed); + auto const decompressed = Compress::DeflateDecompressor::decompress_all(compressed); EXPECT(decompressed.value().bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 })); } TEST_CASE(deflate_decompress_multiple_blocks) { - const Array<u8, 84> compressed { + Array<u8, 84> const compressed { 0x00, 0x1f, 0x00, 0xe0, 0xff, 0x54, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x69, 0x73, 0x20, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, @@ -94,20 +94,20 @@ TEST_CASE(deflate_decompress_multiple_blocks) const u8 uncompressed[] = "The first block is uncompressed and the second block is compressed."; - const auto decompressed = Compress::DeflateDecompressor::decompress_all(compressed); + auto const decompressed = Compress::DeflateDecompressor::decompress_all(compressed); EXPECT(decompressed.value().bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 })); } TEST_CASE(deflate_decompress_zeroes) { - const Array<u8, 20> compressed { + Array<u8, 20> const compressed { 0xed, 0xc1, 0x01, 0x0d, 0x00, 0x00, 0x00, 0xc2, 0xa0, 0xf7, 0x4f, 0x6d, 0x0f, 0x07, 0x14, 0x00, 0x00, 0x00, 0xf0, 0x6e }; - const Array<u8, 4096> uncompressed { 0 }; + Array<u8, 4096> const uncompressed { 0 }; - const auto decompressed = Compress::DeflateDecompressor::decompress_all(compressed); + auto const decompressed = Compress::DeflateDecompressor::decompress_all(compressed); EXPECT(uncompressed == decompressed.value().bytes()); } diff --git a/Tests/LibCompress/TestGzip.cpp b/Tests/LibCompress/TestGzip.cpp index ca1d043aa0..7ec312874c 100644 --- a/Tests/LibCompress/TestGzip.cpp +++ b/Tests/LibCompress/TestGzip.cpp @@ -12,7 +12,7 @@ TEST_CASE(gzip_decompress_simple) { - const Array<u8, 33> compressed { + Array<u8, 33> const compressed { 0x1f, 0x8b, 0x08, 0x00, 0x77, 0xff, 0x47, 0x5f, 0x02, 0xff, 0x2b, 0xcf, 0x2f, 0x4a, 0x31, 0x54, 0x48, 0x4c, 0x4a, 0x56, 0x28, 0x07, 0xb2, 0x8c, 0x00, 0xc2, 0x1d, 0x22, 0x15, 0x0f, 0x00, 0x00, 0x00 @@ -20,13 +20,13 @@ TEST_CASE(gzip_decompress_simple) const u8 uncompressed[] = "word1 abc word2"; - const auto decompressed = Compress::GzipDecompressor::decompress_all(compressed); + auto const decompressed = Compress::GzipDecompressor::decompress_all(compressed); EXPECT(decompressed.value().bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 })); } TEST_CASE(gzip_decompress_multiple_members) { - const Array<u8, 52> compressed { + Array<u8, 52> const compressed { 0x1f, 0x8b, 0x08, 0x00, 0xe0, 0x03, 0x48, 0x5f, 0x02, 0xff, 0x4b, 0x4c, 0x4a, 0x4e, 0x4c, 0x4a, 0x06, 0x00, 0x4c, 0x99, 0x6e, 0x72, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x00, 0xe0, 0x03, 0x48, 0x5f, 0x02, 0xff, @@ -36,13 +36,13 @@ TEST_CASE(gzip_decompress_multiple_members) const u8 uncompressed[] = "abcabcabcabc"; - const auto decompressed = Compress::GzipDecompressor::decompress_all(compressed); + auto const decompressed = Compress::GzipDecompressor::decompress_all(compressed); EXPECT(decompressed.value().bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 })); } TEST_CASE(gzip_decompress_zeroes) { - const Array<u8, 161> compressed { + Array<u8, 161> const compressed { 0x1f, 0x8b, 0x08, 0x00, 0x6e, 0x7a, 0x4b, 0x5f, 0x02, 0xff, 0xed, 0xc1, 0x31, 0x01, 0x00, 0x00, 0x00, 0xc2, 0xa0, 0xf5, 0x4f, 0xed, 0x61, 0x0d, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -59,15 +59,15 @@ TEST_CASE(gzip_decompress_zeroes) 0x7e, 0x00, 0x00, 0x02, 0x00 }; - const Array<u8, 128 * 1024> uncompressed = { 0 }; + Array<u8, 128 * 1024> const uncompressed = { 0 }; - const auto decompressed = Compress::GzipDecompressor::decompress_all(compressed); + auto const decompressed = Compress::GzipDecompressor::decompress_all(compressed); EXPECT(uncompressed == decompressed.value().bytes()); } TEST_CASE(gzip_decompress_repeat_around_buffer) { - const Array<u8, 70> compressed { + Array<u8, 70> const compressed { 0x1f, 0x8b, 0x08, 0x00, 0xc6, 0x74, 0x53, 0x5f, 0x02, 0xff, 0xed, 0xc1, 0x01, 0x0d, 0x00, 0x00, 0x0c, 0x02, 0xa0, 0xdb, 0xbf, 0xf4, 0x37, 0x6b, 0x08, 0x24, 0xdb, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -81,7 +81,7 @@ TEST_CASE(gzip_decompress_repeat_around_buffer) uncompressed.span().slice(0x0100, 0x7e00).fill(0); uncompressed.span().slice(0x7f00, 0x0100).fill(1); - const auto decompressed = Compress::GzipDecompressor::decompress_all(compressed); + auto const decompressed = Compress::GzipDecompressor::decompress_all(compressed); EXPECT(uncompressed == decompressed.value().bytes()); } diff --git a/Tests/LibCompress/TestZlib.cpp b/Tests/LibCompress/TestZlib.cpp index 8ab5b81a95..4565bdd6f8 100644 --- a/Tests/LibCompress/TestZlib.cpp +++ b/Tests/LibCompress/TestZlib.cpp @@ -11,7 +11,7 @@ TEST_CASE(zlib_decompress_simple) { - const Array<u8, 40> compressed { + Array<u8, 40> const compressed { 0x78, 0x01, 0x01, 0x1D, 0x00, 0xE2, 0xFF, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6D, 0x70, 0x6C, 0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x3A, 0x29, @@ -20,6 +20,6 @@ TEST_CASE(zlib_decompress_simple) const u8 uncompressed[] = "This is a simple text file :)"; - const auto decompressed = Compress::Zlib::decompress_all(compressed); + auto const decompressed = Compress::Zlib::decompress_all(compressed); EXPECT(decompressed.value().bytes() == (ReadonlyBytes { uncompressed, sizeof(uncompressed) - 1 })); } diff --git a/Tests/LibCpp/test-cpp-parser.cpp b/Tests/LibCpp/test-cpp-parser.cpp index 4f0f6ae7da..18eb0dcff1 100644 --- a/Tests/LibCpp/test-cpp-parser.cpp +++ b/Tests/LibCpp/test-cpp-parser.cpp @@ -72,7 +72,7 @@ TEST_CASE(test_regression) fclose(input_stream); - String content { reinterpret_cast<const char*>(buffer.data()), buffer.size() }; + String content { reinterpret_cast<char const*>(buffer.data()), buffer.size() }; auto equal = content == target_ast; EXPECT(equal); diff --git a/Tests/LibCrypto/TestAES.cpp b/Tests/LibCrypto/TestAES.cpp index bfcd1626e1..c20ab686ed 100644 --- a/Tests/LibCrypto/TestAES.cpp +++ b/Tests/LibCrypto/TestAES.cpp @@ -10,7 +10,7 @@ #include <LibTest/TestCase.h> #include <cstring> -static ReadonlyBytes operator""_b(const char* string, size_t length) +static ReadonlyBytes operator""_b(char const* string, size_t length) { return ReadonlyBytes(string, length); } diff --git a/Tests/LibCrypto/TestRSA.cpp b/Tests/LibCrypto/TestRSA.cpp index 307ed609c7..04c72f8f42 100644 --- a/Tests/LibCrypto/TestRSA.cpp +++ b/Tests/LibCrypto/TestRSA.cpp @@ -10,7 +10,7 @@ #include <LibTest/TestCase.h> #include <cstring> -static ByteBuffer operator""_b(const char* string, size_t length) +static ByteBuffer operator""_b(char const* string, size_t length) { return ByteBuffer::copy(string, length).release_value(); } diff --git a/Tests/LibGfx/BenchmarkGfxPainter.cpp b/Tests/LibGfx/BenchmarkGfxPainter.cpp index a9c8707c3d..000de1cfd7 100644 --- a/Tests/LibGfx/BenchmarkGfxPainter.cpp +++ b/Tests/LibGfx/BenchmarkGfxPainter.cpp @@ -22,8 +22,8 @@ static struct FontDatabaseSpoofer { BENCHMARK_CASE(diagonal_lines) { - const int run_count = 50; - const int bitmap_size = 2000; + int const run_count = 50; + int const bitmap_size = 2000; auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }).release_value_but_fixme_should_propagate_errors(); Gfx::Painter painter(bitmap); @@ -38,8 +38,8 @@ BENCHMARK_CASE(diagonal_lines) BENCHMARK_CASE(fill) { - const int run_count = 1000; - const int bitmap_size = 2000; + int const run_count = 1000; + int const bitmap_size = 2000; auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }).release_value_but_fixme_should_propagate_errors(); Gfx::Painter painter(bitmap); @@ -51,8 +51,8 @@ BENCHMARK_CASE(fill) BENCHMARK_CASE(fill_with_gradient) { - const int run_count = 50; - const int bitmap_size = 2000; + int const run_count = 50; + int const bitmap_size = 2000; auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }).release_value_but_fixme_should_propagate_errors(); Gfx::Painter painter(bitmap); diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp index 5dad37a112..19b8b927aa 100644 --- a/Tests/LibGfx/TestFontHandling.cpp +++ b/Tests/LibGfx/TestFontHandling.cpp @@ -14,7 +14,7 @@ TEST_CASE(test_fontdatabase_get_by_name) { - const char* name = "Liza 10 400 0"; + char const* name = "Liza 10 400 0"; auto& font_database = Gfx::FontDatabase::the(); EXPECT(!font_database.get_by_name(name)->name().is_null()); } @@ -28,7 +28,7 @@ TEST_CASE(test_fontdatabase_get) TEST_CASE(test_fontdatabase_for_each_font) { auto& font_database = Gfx::FontDatabase::the(); - font_database.for_each_font([&](const Gfx::Font& font) { + font_database.for_each_font([&](Gfx::Font const& font) { EXPECT(!font.name().is_null()); EXPECT(!font.qualified_name().is_null()); EXPECT(!font.family().is_null()); @@ -55,7 +55,7 @@ TEST_CASE(test_set_name) u8 glyph_width = 1; auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); - const char* name = "my newly created font"; + char const* name = "my newly created font"; font->set_name(name); EXPECT(!font->name().is_null()); @@ -68,7 +68,7 @@ TEST_CASE(test_set_family) u8 glyph_width = 1; auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); - const char* family = "my newly created font family"; + char const* family = "my newly created font family"; font->set_family(family); EXPECT(!font->family().is_null()); diff --git a/Tests/LibIMAP/TestQuotedPrintable.cpp b/Tests/LibIMAP/TestQuotedPrintable.cpp index e89c5b06f3..92171bd376 100644 --- a/Tests/LibIMAP/TestQuotedPrintable.cpp +++ b/Tests/LibIMAP/TestQuotedPrintable.cpp @@ -10,12 +10,12 @@ TEST_CASE(test_decode) { - auto decode_equal = [](const char* input, const char* expected) { + auto decode_equal = [](char const* input, char const* expected) { auto decoded = IMAP::decode_quoted_printable(StringView(input)); EXPECT(String::copy(decoded) == String(expected)); }; - auto decode_equal_byte_buffer = [](const char* input, const char* expected, size_t expected_length) { + auto decode_equal_byte_buffer = [](char const* input, char const* expected, size_t expected_length) { auto decoded = IMAP::decode_quoted_printable(StringView(input)); EXPECT(decoded == ByteBuffer::copy(expected, expected_length).value()); }; diff --git a/Tests/LibM/test-math.cpp b/Tests/LibM/test-math.cpp index fcd37d9063..422e7347d5 100644 --- a/Tests/LibM/test-math.cpp +++ b/Tests/LibM/test-math.cpp @@ -120,7 +120,7 @@ union Extractor { }; double d; - bool operator==(const Extractor& other) const + bool operator==(Extractor const& other) const { return other.sign == sign && other.exponent == exponent && other.mantissa == mantissa; } @@ -227,7 +227,7 @@ TEST_CASE(gamma) EXPECT(isnan(tgamma(-5))); // TODO: investigate Stirling approximation implementation of gamma function - //EXPECT_APPROXIMATE(tgamma(0.5), sqrt(M_PI)); + // EXPECT_APPROXIMATE(tgamma(0.5), sqrt(M_PI)); EXPECT_EQ(tgammal(21.0l), 2'432'902'008'176'640'000.0l); EXPECT_EQ(tgamma(19.0), 6'402'373'705'728'000.0); EXPECT_EQ(tgammaf(11.0f), 3628800.0f); diff --git a/Tests/LibRegex/RegexLibC.cpp b/Tests/LibRegex/RegexLibC.cpp index 2b212c23d9..05bc755613 100644 --- a/Tests/LibRegex/RegexLibC.cpp +++ b/Tests/LibRegex/RegexLibC.cpp @@ -407,7 +407,7 @@ TEST_CASE(parens_qualifier_questionmark) regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -437,7 +437,7 @@ TEST_CASE(parens_qualifier_asterisk) regex_t regex; static constexpr int num_matches { 6 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -483,7 +483,7 @@ TEST_CASE(parens_qualifier_asterisk_2) regex_t regex; static constexpr int num_matches { 6 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -527,7 +527,7 @@ TEST_CASE(mulit_parens_qualifier_too_less_result_values) regex_t regex; static constexpr int num_matches { 4 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; matches[3] = { -2, -2, 100 }; @@ -591,7 +591,7 @@ TEST_CASE(multi_parens_qualifier_questionmark) regex_t regex; static constexpr int num_matches { 8 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -682,7 +682,7 @@ TEST_CASE(alternative_match_groups) regex_t regex; static constexpr int num_matches { 8 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -788,7 +788,7 @@ TEST_CASE(parens_qualifier_exact) regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -835,7 +835,7 @@ TEST_CASE(parens_qualifier_minimum) regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -893,7 +893,7 @@ TEST_CASE(parens_qualifier_maximum) regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; - const char* match_str; + char const* match_str; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); diff --git a/Tests/LibSQL/TestSqlStatementExecution.cpp b/Tests/LibSQL/TestSqlStatementExecution.cpp index d3a5d145be..a5ca80aae2 100644 --- a/Tests/LibSQL/TestSqlStatementExecution.cpp +++ b/Tests/LibSQL/TestSqlStatementExecution.cpp @@ -19,7 +19,7 @@ namespace { -constexpr const char* db_name = "/tmp/test.db"; +constexpr char const* db_name = "/tmp/test.db"; SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, String const& sql) { diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index c9bd3845a8..a02a668884 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -11,12 +11,12 @@ #include <LibTLS/TLSv12.h> #include <LibTest/TestCase.h> -static const char* ca_certs_file = "./ca_certs.ini"; +static char const* ca_certs_file = "./ca_certs.ini"; static int port = 443; -constexpr const char* DEFAULT_SERVER { "www.google.com" }; +constexpr char const* DEFAULT_SERVER { "www.google.com" }; -static ByteBuffer operator""_b(const char* string, size_t length) +static ByteBuffer operator""_b(char const* string, size_t length) { return ByteBuffer::copy(string, length).release_value(); } diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index f6e14a7d9e..2e7254abac 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -170,10 +170,10 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export) return JS::Value(static_cast<unsigned long>(ptr->value())); if (auto v = value.get_pointer<Wasm::GlobalAddress>()) { return m_machine.store().get(*v)->value().value().visit( - [&](const auto& value) -> JS::Value { return JS::Value(static_cast<double>(value)); }, + [&](auto const& value) -> JS::Value { return JS::Value(static_cast<double>(value)); }, [&](i32 value) { return JS::Value(static_cast<double>(value)); }, [&](i64 value) -> JS::Value { return JS::js_bigint(vm, Crypto::SignedBigInteger::create_from(value)); }, - [&](const Wasm::Reference& reference) -> JS::Value { + [&](Wasm::Reference const& reference) -> JS::Value { return reference.ref().visit( [&](const Wasm::Reference::Null&) -> JS::Value { return JS::js_null(); }, [&](const auto& ref) -> JS::Value { return JS::Value(static_cast<double>(ref.address.value())); }); @@ -193,7 +193,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke) if (!function_instance) return vm.throw_completion<JS::TypeError>(global_object, "Invalid function address"); - const Wasm::FunctionType* type { nullptr }; + Wasm::FunctionType const* type { nullptr }; function_instance->visit([&](auto& value) { type = &value.type(); }); if (!type) return vm.throw_completion<JS::TypeError>(global_object, "Invalid function found at given address"); @@ -249,10 +249,10 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke) JS::Value return_value; result.values().first().value().visit( - [&](const auto& value) { return_value = JS::Value(static_cast<double>(value)); }, + [&](auto const& value) { return_value = JS::Value(static_cast<double>(value)); }, [&](i32 value) { return_value = JS::Value(static_cast<double>(value)); }, [&](i64 value) { return_value = JS::Value(JS::js_bigint(vm, Crypto::SignedBigInteger::create_from(value))); }, - [&](const Wasm::Reference& reference) { + [&](Wasm::Reference const& reference) { reference.ref().visit( [&](const Wasm::Reference::Null&) { return_value = JS::js_null(); }, [&](const auto& ref) { return_value = JS::Value(static_cast<double>(ref.address.value())); }); diff --git a/Tests/UserspaceEmulator/ue-write-oob.cpp b/Tests/UserspaceEmulator/ue-write-oob.cpp index 811d7199ec..70663a24f8 100644 --- a/Tests/UserspaceEmulator/ue-write-oob.cpp +++ b/Tests/UserspaceEmulator/ue-write-oob.cpp @@ -11,10 +11,10 @@ #include <stdlib.h> #include <sys/mman.h> -static void write8(void* ptr) { *(volatile uint8_t*)ptr = 1; } -static void write16(void* ptr) { *(volatile uint16_t*)ptr = 1; } -static void write32(void* ptr) { *(volatile uint32_t*)ptr = 1; } -static void write64(void* ptr) { *(volatile double*)ptr = 1.0; } +static void write8(void* ptr) { *(uint8_t volatile*)ptr = 1; } +static void write16(void* ptr) { *(uint16_t volatile*)ptr = 1; } +static void write32(void* ptr) { *(uint32_t volatile*)ptr = 1; } +static void write64(void* ptr) { *(double volatile*)ptr = 1.0; } // A u64 write might be translated by the compiler as a 32-then-32-bit write: // static void write64_bad(void* ptr) { *(volatile uint64_t*)ptr = 1.0; } // Let's hope this won't be translated like that. diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp index 57d2211511..40f90c18b5 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp @@ -37,7 +37,7 @@ String ClipboardHistoryModel::column_name(int column) const } } -static const char* bpp_for_format_resilient(String format) +static char const* bpp_for_format_resilient(String format) { unsigned format_uint = format.to_uint().value_or(static_cast<unsigned>(Gfx::BitmapFormat::Invalid)); // Cannot use Gfx::Bitmap::bpp_for_format here, as we have to accept invalid enum values. diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h index ec3de5f4d2..64bed85ad2 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h @@ -35,7 +35,7 @@ public: virtual ~ClipboardHistoryModel() override = default; - const ClipboardItem& item_at(int index) const { return m_history_items[index]; } + ClipboardItem const& item_at(int index) const { return m_history_items[index]; } void remove_item(int index); // ^GUI::Model @@ -54,7 +54,7 @@ private: virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; } // ^GUI::Clipboard::ClipboardClient - virtual void clipboard_content_did_change(const String&) override { add_item(GUI::Clipboard::the().fetch_data_and_type()); } + virtual void clipboard_content_did_change(String const&) override { add_item(GUI::Clipboard::the().fetch_data_and_type()); } Vector<ClipboardItem> m_history_items; size_t m_history_limit; diff --git a/Userland/Applets/Keymap/KeymapStatusWindow.cpp b/Userland/Applets/Keymap/KeymapStatusWindow.cpp index 95428d2a1c..e2b2d9e317 100644 --- a/Userland/Applets/Keymap/KeymapStatusWindow.cpp +++ b/Userland/Applets/Keymap/KeymapStatusWindow.cpp @@ -40,7 +40,7 @@ void KeymapStatusWindow::wm_event(GUI::WMEvent& event) } } -void KeymapStatusWindow::set_keymap_text(const String& keymap) +void KeymapStatusWindow::set_keymap_text(String const& keymap) { GUI::Painter painter(*m_status_widget); painter.clear_rect(m_status_widget->rect(), Color::from_argb(0)); diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp index 35fcbf6695..f0e5d77bcd 100644 --- a/Userland/Applets/Network/main.cpp +++ b/Userland/Applets/Network/main.cpp @@ -51,7 +51,7 @@ private: return; pid_t child_pid; - const char* argv[] = { "SystemMonitor", "-t", "network", nullptr }; + char const* argv[] = { "SystemMonitor", "-t", "network", nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/SystemMonitor", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); @@ -179,7 +179,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil(nullptr, nullptr)); bool display_notifications = false; - const char* name = nullptr; + char const* name = nullptr; Core::ArgsParser args_parser; args_parser.add_option(display_notifications, "Display notifications", "display-notifications", 'd'); args_parser.add_option(name, "Applet name used by WindowServer.ini to set the applet order", "name", 'n', "name"); diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp index 3da6bc2841..8a8a13c6e8 100644 --- a/Userland/Applets/ResourceGraph/main.cpp +++ b/Userland/Applets/ResourceGraph/main.cpp @@ -110,7 +110,7 @@ private: if (event.button() != GUI::MouseButton::Primary) return; pid_t child_pid; - const char* argv[] = { "SystemMonitor", "-t", "graphs", nullptr }; + char const* argv[] = { "SystemMonitor", "-t", "graphs", nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/SystemMonitor", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); } else { @@ -197,8 +197,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd proc exec rpath")); - const char* cpu = nullptr; - const char* memory = nullptr; + char const* cpu = nullptr; + char const* memory = nullptr; Core::ArgsParser args_parser; args_parser.add_option(cpu, "Create CPU graph", "cpu", 'C', "cpu"); args_parser.add_option(memory, "Create memory graph", "memory", 'M', "memory"); diff --git a/Userland/Applications/3DFileViewer/Mesh.cpp b/Userland/Applications/3DFileViewer/Mesh.cpp index a3cdbb1824..d4fc13c9b5 100644 --- a/Userland/Applications/3DFileViewer/Mesh.cpp +++ b/Userland/Applications/3DFileViewer/Mesh.cpp @@ -34,7 +34,7 @@ Mesh::Mesh(Vector<Vertex> vertices, Vector<TexCoord> tex_coords, Vector<Vertex> void Mesh::draw(float uv_scale) { for (u32 i = 0; i < m_triangle_list.size(); i++) { - const auto& triangle = m_triangle_list[i]; + auto const& triangle = m_triangle_list[i]; const FloatVector3 vertex_a( m_vertex_list.at(triangle.a).x, diff --git a/Userland/Applications/Assistant/FuzzyMatch.cpp b/Userland/Applications/Assistant/FuzzyMatch.cpp index f16c767c90..b931537b0b 100644 --- a/Userland/Applications/Assistant/FuzzyMatch.cpp +++ b/Userland/Applications/Assistant/FuzzyMatch.cpp @@ -10,17 +10,17 @@ namespace Assistant { -static constexpr const int RECURSION_LIMIT = 10; -static constexpr const int MAX_MATCHES = 256; +static constexpr int const RECURSION_LIMIT = 10; +static constexpr int const MAX_MATCHES = 256; // Bonuses and penalties are used to build up a final score for the match. -static constexpr const int SEQUENTIAL_BONUS = 15; // bonus for adjacent matches (needle: 'ca', haystack: 'cat') -static constexpr const int SEPARATOR_BONUS = 30; // bonus if match occurs after a separator ('_' or ' ') -static constexpr const int CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower (needle: 'myF' haystack: '/path/to/myFile.txt') -static constexpr const int FIRST_LETTER_BONUS = 20; // bonus if the first letter is matched (needle: 'c' haystack: 'cat') -static constexpr const int LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match -static constexpr const int MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters -static constexpr const int UNMATCHED_LETTER_PENALTY = -1; // penalty for every letter that doesn't matter +static constexpr int const SEQUENTIAL_BONUS = 15; // bonus for adjacent matches (needle: 'ca', haystack: 'cat') +static constexpr int const SEPARATOR_BONUS = 30; // bonus if match occurs after a separator ('_' or ' ') +static constexpr int const CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower (needle: 'myF' haystack: '/path/to/myFile.txt') +static constexpr int const FIRST_LETTER_BONUS = 20; // bonus if the first letter is matched (needle: 'c' haystack: 'cat') +static constexpr int const LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match +static constexpr int const MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters +static constexpr int const UNMATCHED_LETTER_PENALTY = -1; // penalty for every letter that doesn't matter static int calculate_score(String const& string, u8* index_points, size_t index_points_size) { diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 767432a56a..0a24463638 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -123,7 +123,7 @@ FileProvider::FileProvider() build_filesystem_cache(); } -void FileProvider::query(const String& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) +void FileProvider::query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) { build_filesystem_cache(); diff --git a/Userland/Applications/Assistant/Providers.h b/Userland/Applications/Assistant/Providers.h index 2469e912bc..b240e18e53 100644 --- a/Userland/Applications/Assistant/Providers.h +++ b/Userland/Applications/Assistant/Providers.h @@ -132,7 +132,7 @@ class Provider : public RefCounted<Provider> { public: virtual ~Provider() = default; - virtual void query(const String&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0; + virtual void query(String const&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0; }; class AppProvider final : public Provider { diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index 92a00b70f8..7fb28b5e58 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -100,7 +100,7 @@ BookmarksBarWidget& BookmarksBarWidget::the() return *s_the; } -BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enabled) +BookmarksBarWidget::BookmarksBarWidget(String const& bookmarks_file, bool enabled) { s_the = this; set_layout<GUI::HorizontalBoxLayout>(); @@ -255,7 +255,7 @@ void BookmarksBarWidget::update_content_size() } } -bool BookmarksBarWidget::contains_bookmark(const String& url) +bool BookmarksBarWidget::contains_bookmark(String const& url) { for (int item_index = 0; item_index < model()->row_count(); ++item_index) { @@ -268,7 +268,7 @@ bool BookmarksBarWidget::contains_bookmark(const String& url) return false; } -bool BookmarksBarWidget::remove_bookmark(const String& url) +bool BookmarksBarWidget::remove_bookmark(String const& url) { for (int item_index = 0; item_index < model()->row_count(); ++item_index) { @@ -277,7 +277,7 @@ bool BookmarksBarWidget::remove_bookmark(const String& url) if (item_url == url) { auto& json_model = *static_cast<GUI::JsonArrayModel*>(model()); - const auto item_removed = json_model.remove(item_index); + auto const item_removed = json_model.remove(item_index); if (item_removed) json_model.store(); @@ -288,7 +288,7 @@ bool BookmarksBarWidget::remove_bookmark(const String& url) return false; } -bool BookmarksBarWidget::add_bookmark(const String& url, const String& title) +bool BookmarksBarWidget::add_bookmark(String const& url, String const& title) { Vector<JsonValue> values; values.append(title); @@ -302,7 +302,7 @@ bool BookmarksBarWidget::add_bookmark(const String& url, const String& title) return false; } -bool BookmarksBarWidget::edit_bookmark(const String& url) +bool BookmarksBarWidget::edit_bookmark(String const& url) { for (int item_index = 0; item_index < model()->row_count(); ++item_index) { auto item_title = model()->index(item_index, 0).data().to_string(); diff --git a/Userland/Applications/Browser/BookmarksBarWidget.h b/Userland/Applications/Browser/BookmarksBarWidget.h index dfcef0a7a4..1110c60b30 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.h +++ b/Userland/Applications/Browser/BookmarksBarWidget.h @@ -26,16 +26,16 @@ public: GUI::Model* model() { return m_model.ptr(); } const GUI::Model* model() const { return m_model.ptr(); } - Function<void(const String& url, unsigned modifiers)> on_bookmark_click; - Function<void(const String&, const String&)> on_bookmark_hover; + Function<void(String const& url, unsigned modifiers)> on_bookmark_click; + Function<void(String const&, String const&)> on_bookmark_hover; - bool contains_bookmark(const String& url); - bool remove_bookmark(const String& url); - bool add_bookmark(const String& url, const String& title); - bool edit_bookmark(const String& url); + bool contains_bookmark(String const& url); + bool remove_bookmark(String const& url); + bool add_bookmark(String const& url, String const& title); + bool edit_bookmark(String const& url); private: - BookmarksBarWidget(const String&, bool enabled); + BookmarksBarWidget(String const&, bool enabled); // ^GUI::ModelClient virtual void model_did_update(unsigned) override; diff --git a/Userland/Applications/Browser/ConsoleWidget.cpp b/Userland/Applications/Browser/ConsoleWidget.cpp index 53e3f1d9fc..33511a38cb 100644 --- a/Userland/Applications/Browser/ConsoleWidget.cpp +++ b/Userland/Applications/Browser/ConsoleWidget.cpp @@ -93,7 +93,7 @@ void ConsoleWidget::notify_about_new_console_message(i32 message_index) request_console_messages(); } -void ConsoleWidget::handle_console_messages(i32 start_index, const Vector<String>& message_types, const Vector<String>& messages) +void ConsoleWidget::handle_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages) { i32 end_index = start_index + message_types.size() - 1; if (end_index <= m_highest_received_message_index) { diff --git a/Userland/Applications/Browser/ConsoleWidget.h b/Userland/Applications/Browser/ConsoleWidget.h index 4683a84e2e..aaa7a5d5c0 100644 --- a/Userland/Applications/Browser/ConsoleWidget.h +++ b/Userland/Applications/Browser/ConsoleWidget.h @@ -26,7 +26,7 @@ public: void print_html(StringView); void reset(); - Function<void(const String&)> on_js_input; + Function<void(String const&)> on_js_input; Function<void(i32)> on_request_messages; private: diff --git a/Userland/Applications/Browser/CookieJar.cpp b/Userland/Applications/Browser/CookieJar.cpp index 119dc9e1ab..d8be5e30e6 100644 --- a/Userland/Applications/Browser/CookieJar.cpp +++ b/Userland/Applications/Browser/CookieJar.cpp @@ -26,7 +26,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source) auto cookie_list = get_matching_cookies(url, domain.value(), source); StringBuilder builder; - for (const auto& cookie : cookie_list) { + for (auto const& cookie : cookie_list) { // If there is an unprocessed cookie in the cookie-list, output the characters %x3B and %x20 ("; ") if (!builder.is_empty()) builder.append("; "); @@ -38,7 +38,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source) return builder.build(); } -void CookieJar::set_cookie(const URL& url, const Web::Cookie::ParsedCookie& parsed_cookie, Web::Cookie::Source source) +void CookieJar::set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source) { auto domain = canonicalize_domain(url); if (!domain.has_value()) @@ -57,7 +57,7 @@ void CookieJar::dump_cookies() const StringBuilder builder; builder.appendff("{} cookies stored\n", m_cookies.size()); - for (const auto& cookie : m_cookies) { + for (auto const& cookie : m_cookies) { builder.appendff("{}{}{} - ", key_color, cookie.key.name, no_color); builder.appendff("{}{}{} - ", key_color, cookie.key.domain, no_color); builder.appendff("{}{}{}\n", key_color, cookie.key.path, no_color); @@ -96,7 +96,7 @@ Optional<String> CookieJar::canonicalize_domain(const URL& url) return url.host().to_lowercase(); } -bool CookieJar::domain_matches(const String& string, const String& domain_string) +bool CookieJar::domain_matches(String const& string, String const& domain_string) { // https://tools.ietf.org/html/rfc6265#section-5.1.3 @@ -120,7 +120,7 @@ bool CookieJar::domain_matches(const String& string, const String& domain_string return true; } -bool CookieJar::path_matches(const String& request_path, const String& cookie_path) +bool CookieJar::path_matches(String const& request_path, String const& cookie_path) { // https://tools.ietf.org/html/rfc6265#section-5.1.4 @@ -165,7 +165,7 @@ String CookieJar::default_path(const URL& url) return uri_path.substring(0, last_separator); } -void CookieJar::store_cookie(const Web::Cookie::ParsedCookie& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source) +void CookieJar::store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source) { // https://tools.ietf.org/html/rfc6265#section-5.3 @@ -251,7 +251,7 @@ void CookieJar::store_cookie(const Web::Cookie::ParsedCookie& parsed_cookie, con m_cookies.set(key, move(cookie)); } -Vector<Web::Cookie::Cookie&> CookieJar::get_matching_cookies(const URL& url, const String& canonicalized_domain, Web::Cookie::Source source) +Vector<Web::Cookie::Cookie&> CookieJar::get_matching_cookies(const URL& url, String const& canonicalized_domain, Web::Cookie::Source source) { // https://tools.ietf.org/html/rfc6265#section-5.4 @@ -305,12 +305,12 @@ void CookieJar::purge_expired_cookies() time_t now = Core::DateTime::now().timestamp(); Vector<CookieStorageKey> keys_to_evict; - for (const auto& cookie : m_cookies) { + for (auto const& cookie : m_cookies) { if (cookie.value.expiry_time.timestamp() < now) keys_to_evict.append(cookie.key); } - for (const auto& key : keys_to_evict) + for (auto const& key : keys_to_evict) m_cookies.remove(key); } diff --git a/Userland/Applications/Browser/CookieJar.h b/Userland/Applications/Browser/CookieJar.h index 1fde67f462..3aedeceef4 100644 --- a/Userland/Applications/Browser/CookieJar.h +++ b/Userland/Applications/Browser/CookieJar.h @@ -17,7 +17,7 @@ namespace Browser { struct CookieStorageKey { - bool operator==(const CookieStorageKey&) const = default; + bool operator==(CookieStorageKey const&) const = default; String name; String domain; @@ -27,18 +27,18 @@ struct CookieStorageKey { class CookieJar { public: String get_cookie(const URL& url, Web::Cookie::Source source); - void set_cookie(const URL& url, const Web::Cookie::ParsedCookie& parsed_cookie, Web::Cookie::Source source); + void set_cookie(const URL& url, Web::Cookie::ParsedCookie const& parsed_cookie, Web::Cookie::Source source); void dump_cookies() const; Vector<Web::Cookie::Cookie> get_all_cookies() const; private: static Optional<String> canonicalize_domain(const URL& url); - static bool domain_matches(const String& string, const String& domain_string); - static bool path_matches(const String& request_path, const String& cookie_path); + static bool domain_matches(String const& string, String const& domain_string); + static bool path_matches(String const& request_path, String const& cookie_path); static String default_path(const URL& url); - void store_cookie(const Web::Cookie::ParsedCookie& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source); - Vector<Web::Cookie::Cookie&> get_matching_cookies(const URL& url, const String& canonicalized_domain, Web::Cookie::Source source); + void store_cookie(Web::Cookie::ParsedCookie const& parsed_cookie, const URL& url, String canonicalized_domain, Web::Cookie::Source source); + Vector<Web::Cookie::Cookie&> get_matching_cookies(const URL& url, String const& canonicalized_domain, Web::Cookie::Source source); void purge_expired_cookies(); HashMap<CookieStorageKey, Web::Cookie::Cookie> m_cookies; @@ -50,7 +50,7 @@ namespace AK { template<> struct Traits<Browser::CookieStorageKey> : public GenericTraits<Browser::CookieStorageKey> { - static unsigned hash(const Browser::CookieStorageKey& key) + static unsigned hash(Browser::CookieStorageKey const& key) { unsigned hash = 0; hash = pair_int_hash(hash, string_hash(key.name.characters(), key.name.length())); diff --git a/Userland/Applications/Browser/CookiesModel.cpp b/Userland/Applications/Browser/CookiesModel.cpp index aa2b7abf07..6daecfac33 100644 --- a/Userland/Applications/Browser/CookiesModel.cpp +++ b/Userland/Applications/Browser/CookiesModel.cpp @@ -58,7 +58,7 @@ GUI::Variant CookiesModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol if (role != GUI::ModelRole::Display) return {}; - const auto& cookie = m_cookies[index.row()]; + auto const& cookie = m_cookies[index.row()]; switch (index.column()) { case Column::Domain: diff --git a/Userland/Applications/Browser/History.cpp b/Userland/Applications/Browser/History.cpp index 20dfd3b117..7732c6f5d7 100644 --- a/Userland/Applications/Browser/History.cpp +++ b/Userland/Applications/Browser/History.cpp @@ -18,7 +18,7 @@ void History::dump() const } } -void History::push(const URL& url, const String& title) +void History::push(const URL& url, String const& title) { if (!m_items.is_empty() && m_items[m_current].url == url) return; @@ -55,12 +55,12 @@ void History::clear() m_current = -1; } -void History::update_title(const String& title) +void History::update_title(String const& title) { m_items[m_current].title = title; } -const Vector<StringView> History::get_back_title_history() +Vector<StringView> const History::get_back_title_history() { Vector<StringView> back_title_history; for (int i = m_current - 1; i >= 0; i--) { @@ -69,7 +69,7 @@ const Vector<StringView> History::get_back_title_history() return back_title_history; } -const Vector<StringView> History::get_forward_title_history() +Vector<StringView> const History::get_forward_title_history() { Vector<StringView> forward_title_history; for (int i = m_current + 1; i < static_cast<int>(m_items.size()); i++) { diff --git a/Userland/Applications/Browser/History.h b/Userland/Applications/Browser/History.h index e7891b29a1..05afcd8532 100644 --- a/Userland/Applications/Browser/History.h +++ b/Userland/Applications/Browser/History.h @@ -19,12 +19,12 @@ public: }; void dump() const; - void push(const URL& url, const String& title); - void update_title(const String& title); + void push(const URL& url, String const& title); + void update_title(String const& title); URLTitlePair current() const; - const Vector<StringView> get_back_title_history(); - const Vector<StringView> get_forward_title_history(); + Vector<StringView> const get_back_title_history(); + Vector<StringView> const get_forward_title_history(); void go_back(int steps = 1); void go_forward(int steps = 1); diff --git a/Userland/Applications/Browser/InspectorWidget.cpp b/Userland/Applications/Browser/InspectorWidget.cpp index d923fe17dd..7b04ca5691 100644 --- a/Userland/Applications/Browser/InspectorWidget.cpp +++ b/Userland/Applications/Browser/InspectorWidget.cpp @@ -183,7 +183,7 @@ void InspectorWidget::update_node_box_model(Optional<String> node_box_sizing_jso return; } auto json_value = json_or_error.release_value(); - const auto& json_object = json_value.as_object(); + auto const& json_object = json_value.as_object(); m_node_box_sizing.margin.top = json_object.get("margin_top").to_float(); m_node_box_sizing.margin.right = json_object.get("margin_right").to_float(); diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index e8445e7343..7fa98ec1fb 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -66,7 +66,7 @@ void Tab::start_download(const URL& url) window->show(); } -void Tab::view_source(const URL& url, const String& source) +void Tab::view_source(const URL& url, String const& source) { auto window = GUI::Window::construct(&this->window()); auto& editor = window->set_main_widget<GUI::TextEditor>(); @@ -282,7 +282,7 @@ Tab::Tab(BrowserWindow& window) m_image_context_menu->add_separator(); m_image_context_menu->add_action(window.inspect_dom_node_action()); - hooks().on_image_context_menu_request = [this](auto& image_url, auto& screen_position, const Gfx::ShareableBitmap& shareable_bitmap) { + hooks().on_image_context_menu_request = [this](auto& image_url, auto& screen_position, Gfx::ShareableBitmap const& shareable_bitmap) { m_image_context_menu_url = image_url; m_image_context_menu_bitmap = shareable_bitmap; m_image_context_menu->popup(screen_position); @@ -469,7 +469,7 @@ void Tab::bookmark_current_url() update_bookmark_button(url); } -void Tab::update_bookmark_button(const String& url) +void Tab::update_bookmark_button(String const& url) { if (BookmarksBarWidget::the().contains_bookmark(url)) { m_bookmark_button->set_icon(g_icon_bag.bookmark_filled); @@ -503,7 +503,7 @@ void Tab::did_become_active() update_actions(); } -void Tab::context_menu_requested(const Gfx::IntPoint& screen_position) +void Tab::context_menu_requested(Gfx::IntPoint const& screen_position) { m_tab_context_menu->popup(screen_position); } diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h index 7e01c61765..3b060ac586 100644 --- a/Userland/Applications/Browser/Tab.h +++ b/Userland/Applications/Browser/Tab.h @@ -50,19 +50,19 @@ public: void go_forward(int steps = 1); void did_become_active(); - void context_menu_requested(const Gfx::IntPoint& screen_position); + void context_menu_requested(Gfx::IntPoint const& screen_position); void content_filters_changed(); void action_entered(GUI::Action&); void action_left(GUI::Action&); - Function<void(const String&)> on_title_change; + Function<void(String const&)> on_title_change; Function<void(const URL&)> on_tab_open_request; Function<void(Tab&)> on_tab_close_request; Function<void(Tab&)> on_tab_close_other_request; - Function<void(const Gfx::Bitmap&)> on_favicon_change; + Function<void(Gfx::Bitmap const&)> on_favicon_change; Function<String(const URL&, Web::Cookie::Source source)> on_get_cookie; - Function<void(const URL&, const Web::Cookie::ParsedCookie& cookie, Web::Cookie::Source source)> on_set_cookie; + Function<void(const URL&, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)> on_set_cookie; Function<void()> on_dump_cookies; Function<Vector<Web::Cookie::Cookie>()> on_want_cookies; @@ -75,8 +75,8 @@ public: void show_console_window(); void show_storage_inspector(); - const String& title() const { return m_title; } - const Gfx::Bitmap* icon() const { return m_icon; } + String const& title() const { return m_title; } + Gfx::Bitmap const* icon() const { return m_icon; } GUI::AbstractScrollableWidget& view(); @@ -89,9 +89,9 @@ private: Web::WebViewHooks& hooks(); void update_actions(); void bookmark_current_url(); - void update_bookmark_button(const String& url); + void update_bookmark_button(String const& url); void start_download(const URL& url); - void view_source(const URL& url, const String& source); + void view_source(const URL& url, String const& source); void update_status(Optional<String> text_override = {}, i32 count_waiting = 0); enum class MayAppendTLD { @@ -134,6 +134,6 @@ private: bool m_is_history_navigation { false }; }; -URL url_from_user_input(const String& input); +URL url_from_user_input(String const& input); } diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index f60edeb295..1842e32f1c 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd unix cpath rpath wpath proc exec")); - const char* specified_url = nullptr; + char const* specified_url = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No); diff --git a/Userland/Applications/Calculator/KeypadValue.cpp b/Userland/Applications/Calculator/KeypadValue.cpp index 63f38212f4..144e447ff6 100644 --- a/Userland/Applications/Calculator/KeypadValue.cpp +++ b/Userland/Applications/Calculator/KeypadValue.cpp @@ -22,7 +22,7 @@ KeypadValue::KeypadValue(i64 value) KeypadValue::KeypadValue(StringView sv) { - String str = sv.to_string(); //TODO: Once we have a StringView equivalent for this C API, we won't need to create a copy for this anymore. + String str = sv.to_string(); // TODO: Once we have a StringView equivalent for this C API, we won't need to create a copy for this anymore. size_t first_index = 0; char* dot_ptr; i64 int_part = strtoll(&str[first_index], &dot_ptr, 10); diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index ac3766c5c2..61e0842432 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -136,7 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); - const char* coredump_path = nullptr; + char const* coredump_path = nullptr; bool unlink_on_exit = false; Core::ArgsParser args_parser; diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp index d62a39a2df..65e9bdeba3 100644 --- a/Userland/Applications/Debugger/main.cpp +++ b/Userland/Applications/Debugger/main.cpp @@ -37,7 +37,7 @@ static void handle_sigint(int) g_debug_session = nullptr; } -static void handle_print_registers(const PtraceRegisters& regs) +static void handle_print_registers(PtraceRegisters const& regs) { #if ARCH(I386) outln("eax={:p} ebx={:p} ecx={:p} edx={:p}", regs.eax, regs.ebx, regs.ecx, regs.edx); @@ -52,7 +52,7 @@ static void handle_print_registers(const PtraceRegisters& regs) #endif } -static bool handle_disassemble_command(const String& command, FlatPtr first_instruction) +static bool handle_disassemble_command(String const& command, FlatPtr first_instruction) { auto parts = command.split(' '); size_t number_of_instructions_to_disassemble = 5; @@ -90,7 +90,7 @@ static bool handle_disassemble_command(const String& command, FlatPtr first_inst return true; } -static bool handle_backtrace_command(const PtraceRegisters& regs) +static bool handle_backtrace_command(PtraceRegisters const& regs) { #if ARCH(I386) auto ebp_val = regs.ebp; @@ -122,7 +122,7 @@ static bool insert_breakpoint_at_address(FlatPtr address) return g_debug_session->insert_breakpoint(address); } -static bool insert_breakpoint_at_source_position(const String& file, size_t line) +static bool insert_breakpoint_at_source_position(String const& file, size_t line) { auto result = g_debug_session->insert_breakpoint(file, line); if (!result.has_value()) { @@ -133,7 +133,7 @@ static bool insert_breakpoint_at_source_position(const String& file, size_t line return true; } -static bool insert_breakpoint_at_symbol(const String& symbol) +static bool insert_breakpoint_at_symbol(String const& symbol) { auto result = g_debug_session->insert_breakpoint(symbol); if (!result.has_value()) { @@ -144,7 +144,7 @@ static bool insert_breakpoint_at_symbol(const String& symbol) return true; } -static bool handle_breakpoint_command(const String& command) +static bool handle_breakpoint_command(String const& command) { auto parts = command.split(' '); if (parts.size() != 2) @@ -171,7 +171,7 @@ static bool handle_breakpoint_command(const String& command) return insert_breakpoint_at_symbol(argument); } -static bool handle_examine_command(const String& command) +static bool handle_examine_command(String const& command) { auto parts = command.split(' '); if (parts.size() != 2) @@ -214,7 +214,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio proc ptrace exec rpath tty sigaction cpath unix", nullptr)); - const char* command = nullptr; + char const* command = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(command, "The program to be debugged, along with its arguments", diff --git a/Userland/Applications/Help/ManualModel.cpp b/Userland/Applications/Help/ManualModel.cpp index f5a99c702c..7f35f565d5 100644 --- a/Userland/Applications/Help/ManualModel.cpp +++ b/Userland/Applications/Help/ManualModel.cpp @@ -34,10 +34,10 @@ Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const auto parent_index = index(section, 0); for (int row = 0; row < row_count(parent_index); ++row) { auto child_index = index(row, 0, parent_index); - auto* node = static_cast<const ManualNode*>(child_index.internal_data()); + auto* node = static_cast<ManualNode const*>(child_index.internal_data()); if (!node->is_page()) continue; - auto* page = static_cast<const ManualPageNode*>(node); + auto* page = static_cast<ManualPageNode const*>(node); if (page->path() != path) continue; return child_index; @@ -50,10 +50,10 @@ String ManualModel::page_name(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* node = static_cast<const ManualNode*>(index.internal_data()); + auto* node = static_cast<ManualNode const*>(index.internal_data()); if (!node->is_page()) return {}; - auto* page = static_cast<const ManualPageNode*>(node); + auto* page = static_cast<ManualPageNode const*>(node); return page->name(); } @@ -61,10 +61,10 @@ String ManualModel::page_path(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* node = static_cast<const ManualNode*>(index.internal_data()); + auto* node = static_cast<ManualNode const*>(index.internal_data()); if (!node->is_page()) return {}; - auto* page = static_cast<const ManualPageNode*>(node); + auto* page = static_cast<ManualPageNode const*>(node); return page->path(); } @@ -91,11 +91,11 @@ String ManualModel::page_and_section(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* node = static_cast<const ManualNode*>(index.internal_data()); + auto* node = static_cast<ManualNode const*>(index.internal_data()); if (!node->is_page()) return {}; - auto* page = static_cast<const ManualPageNode*>(node); - auto* section = static_cast<const ManualSectionNode*>(page->parent()); + auto* page = static_cast<ManualPageNode const*>(node); + auto* section = static_cast<ManualSectionNode const*>(page->parent()); return String::formatted("{}({})", page->name(), section->section_name()); } @@ -103,7 +103,7 @@ GUI::ModelIndex ManualModel::index(int row, int column, const GUI::ModelIndex& p { if (!parent_index.is_valid()) return create_index(row, column, &s_sections[row]); - auto* parent = static_cast<const ManualNode*>(parent_index.internal_data()); + auto* parent = static_cast<ManualNode const*>(parent_index.internal_data()); auto* child = &parent->children()[row]; return create_index(row, column, child); } @@ -112,7 +112,7 @@ GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* child = static_cast<const ManualNode*>(index.internal_data()); + auto* child = static_cast<ManualNode const*>(index.internal_data()); auto* parent = child->parent(); if (parent == nullptr) return {}; @@ -135,7 +135,7 @@ int ManualModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return sizeof(s_sections) / sizeof(s_sections[0]); - auto* node = static_cast<const ManualNode*>(index.internal_data()); + auto* node = static_cast<ManualNode const*>(index.internal_data()); return node->children().size(); } @@ -146,7 +146,7 @@ int ManualModel::column_count(const GUI::ModelIndex&) const GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* node = static_cast<const ManualNode*>(index.internal_data()); + auto* node = static_cast<ManualNode const*>(index.internal_data()); switch (role) { case GUI::ModelRole::Search: if (!node->is_page()) @@ -165,7 +165,7 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role } } -void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, const bool open) +void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, bool const open) { auto* node = static_cast<ManualSectionNode*>(index.internal_data()); node->set_open(open); diff --git a/Userland/Applications/Help/ManualModel.h b/Userland/Applications/Help/ManualModel.h index 262464ee8a..9995836636 100644 --- a/Userland/Applications/Help/ManualModel.h +++ b/Userland/Applications/Help/ManualModel.h @@ -28,7 +28,7 @@ public: String page_and_section(const GUI::ModelIndex&) const; ErrorOr<StringView> page_view(String const& path) const; - void update_section_node_on_toggle(const GUI::ModelIndex&, const bool); + void update_section_node_on_toggle(const GUI::ModelIndex&, bool const); virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; diff --git a/Userland/Applications/Help/ManualNode.h b/Userland/Applications/Help/ManualNode.h index 34971e234d..6fb5957eda 100644 --- a/Userland/Applications/Help/ManualNode.h +++ b/Userland/Applications/Help/ManualNode.h @@ -15,7 +15,7 @@ public: virtual ~ManualNode() = default; virtual NonnullOwnPtrVector<ManualNode>& children() const = 0; - virtual const ManualNode* parent() const = 0; + virtual ManualNode const* parent() const = 0; virtual String name() const = 0; virtual bool is_page() const { return false; } virtual bool is_open() const { return false; } diff --git a/Userland/Applications/Help/ManualPageNode.cpp b/Userland/Applications/Help/ManualPageNode.cpp index dc28cb4c08..e906e34c37 100644 --- a/Userland/Applications/Help/ManualPageNode.cpp +++ b/Userland/Applications/Help/ManualPageNode.cpp @@ -8,7 +8,7 @@ #include "ManualPageNode.h" #include "ManualSectionNode.h" -const ManualNode* ManualPageNode::parent() const +ManualNode const* ManualPageNode::parent() const { return &m_section; } diff --git a/Userland/Applications/Help/ManualPageNode.h b/Userland/Applications/Help/ManualPageNode.h index 0f60dd6569..c01349f2de 100644 --- a/Userland/Applications/Help/ManualPageNode.h +++ b/Userland/Applications/Help/ManualPageNode.h @@ -14,20 +14,20 @@ class ManualPageNode : public ManualNode { public: virtual ~ManualPageNode() override = default; - ManualPageNode(const ManualSectionNode& section, StringView page) + ManualPageNode(ManualSectionNode const& section, StringView page) : m_section(section) , m_page(page) { } virtual NonnullOwnPtrVector<ManualNode>& children() const override; - virtual const ManualNode* parent() const override; + virtual ManualNode const* parent() const override; virtual String name() const override { return m_page; }; virtual bool is_page() const override { return true; } String path() const; private: - const ManualSectionNode& m_section; + ManualSectionNode const& m_section; String m_page; }; diff --git a/Userland/Applications/Help/ManualSectionNode.h b/Userland/Applications/Help/ManualSectionNode.h index 468137066c..173e3475bf 100644 --- a/Userland/Applications/Help/ManualSectionNode.h +++ b/Userland/Applications/Help/ManualSectionNode.h @@ -25,12 +25,12 @@ public: return m_children; } - virtual const ManualNode* parent() const override { return nullptr; } + virtual ManualNode const* parent() const override { return nullptr; } virtual String name() const override { return m_full_name; } virtual bool is_open() const override { return m_open; } void set_open(bool open); - const String& section_name() const { return m_section; } + String const& section_name() const { return m_section; } String path() const; private: diff --git a/Userland/Applications/HexEditor/HexDocument.h b/Userland/Applications/HexEditor/HexDocument.h index bc943a2aa2..5566fade95 100644 --- a/Userland/Applications/HexEditor/HexDocument.h +++ b/Userland/Applications/HexEditor/HexDocument.h @@ -54,7 +54,7 @@ public: explicit HexDocumentFile(NonnullRefPtr<Core::File> file); virtual ~HexDocumentFile() = default; - HexDocumentFile(const HexDocumentFile&) = delete; + HexDocumentFile(HexDocumentFile const&) = delete; void set_file(NonnullRefPtr<Core::File> file); NonnullRefPtr<Core::File> file() const; diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index fe82bec33a..bb2b2faaee 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -570,11 +570,11 @@ void HexEditor::paint_event(GUI::PaintEvent& event) if (byte_position >= m_document->size()) return; - const bool edited_flag = m_document->get(byte_position).modified; + bool const edited_flag = m_document->get(byte_position).modified; - const bool selection_inbetween_start_end = byte_position >= m_selection_start && byte_position < m_selection_end; - const bool selection_inbetween_end_start = byte_position >= m_selection_end && byte_position < m_selection_start; - const bool highlight_flag = selection_inbetween_start_end || selection_inbetween_end_start; + bool const selection_inbetween_start_end = byte_position >= m_selection_start && byte_position < m_selection_end; + bool const selection_inbetween_end_start = byte_position >= m_selection_end && byte_position < m_selection_start; + bool const highlight_flag = selection_inbetween_start_end || selection_inbetween_end_start; Gfx::IntRect hex_display_rect { frame_thickness() + offset_margin_width() + static_cast<int>(j) * cell_width() + 2 * m_padding, diff --git a/Userland/Applications/HexEditor/SearchResultsModel.h b/Userland/Applications/HexEditor/SearchResultsModel.h index dff620df99..99ba4329f5 100644 --- a/Userland/Applications/HexEditor/SearchResultsModel.h +++ b/Userland/Applications/HexEditor/SearchResultsModel.h @@ -25,7 +25,7 @@ public: Value }; - explicit SearchResultsModel(const Vector<Match>&& matches) + explicit SearchResultsModel(Vector<Match> const&& matches) : m_matches(move(matches)) { } diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 0bde797a59..0a1dfc7c4e 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -75,7 +75,7 @@ bool ViewWidget::is_previous_available() const return false; } -Vector<String> ViewWidget::load_files_from_directory(const String& path) const +Vector<String> ViewWidget::load_files_from_directory(String const& path) const { Vector<String> files_in_directory; @@ -90,7 +90,7 @@ Vector<String> ViewWidget::load_files_from_directory(const String& path) const return files_in_directory; } -void ViewWidget::set_path(const String& path) +void ViewWidget::set_path(String const& path) { m_path = path; m_files_in_same_dir = load_files_from_directory(path); @@ -151,7 +151,7 @@ void ViewWidget::mouseup_event(GUI::MouseEvent& event) GUI::AbstractZoomPanWidget::mouseup_event(event); } -void ViewWidget::load_from_file(const String& path) +void ViewWidget::load_from_file(String const& path) { auto show_error = [&] { GUI::MessageBox::show(window(), String::formatted("Failed to open {}", path), "Cannot open image", GUI::MessageBox::Type::Error); @@ -186,7 +186,7 @@ void ViewWidget::load_from_file(const String& path) on_image_change(m_bitmap); if (m_decoded_image->is_animated && m_decoded_image->frames.size() > 1) { - const auto& first_frame = m_decoded_image->frames[0]; + auto const& first_frame = m_decoded_image->frames[0]; m_timer->set_interval(first_frame.duration); m_timer->on_timeout = [this] { animate(); }; m_timer->start(); @@ -229,7 +229,7 @@ void ViewWidget::resize_window() window()->resize(new_size); } -void ViewWidget::set_bitmap(const Gfx::Bitmap* bitmap) +void ViewWidget::set_bitmap(Gfx::Bitmap const* bitmap) { if (m_bitmap == bitmap) return; @@ -246,7 +246,7 @@ void ViewWidget::animate() m_current_frame_index = (m_current_frame_index + 1) % m_decoded_image->frames.size(); - const auto& current_frame = m_decoded_image->frames[m_current_frame_index]; + auto const& current_frame = m_decoded_image->frames[m_current_frame_index]; set_bitmap(current_frame.bitmap); if ((int)current_frame.duration != m_timer->interval()) { diff --git a/Userland/Applications/ImageViewer/ViewWidget.h b/Userland/Applications/ImageViewer/ViewWidget.h index b016cd80e7..8aab232c92 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.h +++ b/Userland/Applications/ImageViewer/ViewWidget.h @@ -29,13 +29,13 @@ public: virtual ~ViewWidget() override = default; - const Gfx::Bitmap* bitmap() const { return m_bitmap.ptr(); } - const String& path() const { return m_path; } + Gfx::Bitmap const* bitmap() const { return m_bitmap.ptr(); } + String const& path() const { return m_path; } void set_toolbar_height(int height) { m_toolbar_height = height; } int toolbar_height() { return m_toolbar_height; } bool scaled_for_first_image() { return m_scaled_for_first_image; } void set_scaled_for_first_image(bool val) { m_scaled_for_first_image = val; } - void set_path(const String& path); + void set_path(String const& path); void resize_window(); void set_scaling_mode(Gfx::Painter::ScalingMode); @@ -46,11 +46,11 @@ public: void flip(Gfx::Orientation); void rotate(Gfx::RotationDirection); void navigate(Directions); - void load_from_file(const String&); + void load_from_file(String const&); Function<void()> on_doubleclick; Function<void(const GUI::DropEvent&)> on_drop; - Function<void(const Gfx::Bitmap*)> on_image_change; + Function<void(Gfx::Bitmap const*)> on_image_change; private: ViewWidget(); @@ -60,9 +60,9 @@ private: virtual void mouseup_event(GUI::MouseEvent&) override; virtual void drop_event(GUI::DropEvent&) override; - void set_bitmap(const Gfx::Bitmap* bitmap); + void set_bitmap(Gfx::Bitmap const* bitmap); void animate(); - Vector<String> load_files_from_directory(const String& path) const; + Vector<String> load_files_from_directory(String const& path) const; String m_path; RefPtr<Gfx::Bitmap> m_bitmap; diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index 10d73fa6eb..6a5bcf99aa 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -45,7 +45,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app_icon = GUI::Icon::default_icon("filetype-image"); - const char* path = nullptr; + char const* path = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); @@ -244,7 +244,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) widget->set_scaling_mode(Gfx::Painter::ScalingMode::BilinearBlend); }); - widget->on_image_change = [&](const Gfx::Bitmap* bitmap) { + widget->on_image_change = [&](Gfx::Bitmap const* bitmap) { bool should_enable_image_actions = (bitmap != nullptr); bool should_enable_forward_actions = (widget->is_next_available() && should_enable_image_actions); bool should_enable_backward_actions = (widget->is_previous_available() && should_enable_image_actions); diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 4271223d75..62598ff9c7 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -127,7 +127,7 @@ u32* KeyboardMapperWidget::map_from_name(const StringView map_name) return map; } -ErrorOr<void> KeyboardMapperWidget::load_map_from_file(const String& filename) +ErrorOr<void> KeyboardMapperWidget::load_map_from_file(String const& filename) { auto character_map = TRY(Keyboard::CharacterMapFile::load_from_file(filename)); diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h index f63c98d389..ca51cd18b2 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h @@ -18,7 +18,7 @@ public: virtual ~KeyboardMapperWidget() override = default; void create_frame(); - ErrorOr<void> load_map_from_file(const String&); + ErrorOr<void> load_map_from_file(String const&); ErrorOr<void> load_map_from_system(); ErrorOr<void> save(); ErrorOr<void> save_to_file(StringView); diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp index 7c482eb0de..36c89f7ca7 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp @@ -268,7 +268,7 @@ void KeyboardSettingsWidget::set_keymaps(Vector<String> const& keymaps, String c pid_t child_pid; auto keymaps_string = String::join(',', keymaps); - const char* argv[] = { "/bin/keymap", "-s", keymaps_string.characters(), "-m", active_keymap.characters(), nullptr }; + char const* argv[] = { "/bin/keymap", "-s", keymaps_string.characters(), "-m", active_keymap.characters(), nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); exit(1); diff --git a/Userland/Applications/PDFViewer/OutlineModel.cpp b/Userland/Applications/PDFViewer/OutlineModel.cpp index ad4d770416..65f86f7a68 100644 --- a/Userland/Applications/PDFViewer/OutlineModel.cpp +++ b/Userland/Applications/PDFViewer/OutlineModel.cpp @@ -7,12 +7,12 @@ #include "OutlineModel.h" #include <LibGfx/FontDatabase.h> -NonnullRefPtr<OutlineModel> OutlineModel::create(const NonnullRefPtr<PDF::OutlineDict>& outline) +NonnullRefPtr<OutlineModel> OutlineModel::create(NonnullRefPtr<PDF::OutlineDict> const& outline) { return adopt_ref(*new OutlineModel(outline)); } -OutlineModel::OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline) +OutlineModel::OutlineModel(NonnullRefPtr<PDF::OutlineDict> const& outline) : m_outline(outline) { m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors()); diff --git a/Userland/Applications/PDFViewer/OutlineModel.h b/Userland/Applications/PDFViewer/OutlineModel.h index e97fcb3574..50cf406966 100644 --- a/Userland/Applications/PDFViewer/OutlineModel.h +++ b/Userland/Applications/PDFViewer/OutlineModel.h @@ -12,7 +12,7 @@ class OutlineModel final : public GUI::Model { public: - static NonnullRefPtr<OutlineModel> create(const NonnullRefPtr<PDF::OutlineDict>& outline); + static NonnullRefPtr<OutlineModel> create(NonnullRefPtr<PDF::OutlineDict> const& outline); void set_index_open_state(const GUI::ModelIndex& index, bool is_open); @@ -23,7 +23,7 @@ public: virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override; private: - OutlineModel(const NonnullRefPtr<PDF::OutlineDict>& outline); + OutlineModel(NonnullRefPtr<PDF::OutlineDict> const& outline); GUI::Icon m_closed_item_icon; GUI::Icon m_open_item_icon; diff --git a/Userland/Applications/PDFViewer/PDFViewer.h b/Userland/Applications/PDFViewer/PDFViewer.h index 12f4a17cb2..5f53958087 100644 --- a/Userland/Applications/PDFViewer/PDFViewer.h +++ b/Userland/Applications/PDFViewer/PDFViewer.h @@ -23,7 +23,7 @@ public: ALWAYS_INLINE u32 current_page() const { return m_current_page_index; } ALWAYS_INLINE void set_current_page(u32 current_page) { m_current_page_index = current_page; } - ALWAYS_INLINE const RefPtr<PDF::Document>& document() const { return m_document; } + ALWAYS_INLINE RefPtr<PDF::Document> const& document() const { return m_document; } void set_document(RefPtr<PDF::Document>); Function<void(u32 new_page)> on_page_change; diff --git a/Userland/Applications/PDFViewer/main.cpp b/Userland/Applications/PDFViewer/main.cpp index 31be4ed46d..831c5b78b5 100644 --- a/Userland/Applications/PDFViewer/main.cpp +++ b/Userland/Applications/PDFViewer/main.cpp @@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { - const char* file_path = nullptr; + char const* file_path = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(file_path, "PDF file to open", "path", Core::ArgsParser::Required::No); args_parser.parse(arguments); diff --git a/Userland/Applications/Piano/KeysWidget.cpp b/Userland/Applications/Piano/KeysWidget.cpp index 5d128b4523..21f7d2a6af 100644 --- a/Userland/Applications/Piano/KeysWidget.cpp +++ b/Userland/Applications/Piano/KeysWidget.cpp @@ -235,7 +235,7 @@ static inline int note_from_white_keys(int white_keys) return note; } -int KeysWidget::note_for_event_position(const Gfx::IntPoint& a_point) const +int KeysWidget::note_for_event_position(Gfx::IntPoint const& a_point) const { if (!frame_inner_rect().contains(a_point)) return -1; diff --git a/Userland/Applications/Piano/KeysWidget.h b/Userland/Applications/Piano/KeysWidget.h index daf6048837..d21aba7fa0 100644 --- a/Userland/Applications/Piano/KeysWidget.h +++ b/Userland/Applications/Piano/KeysWidget.h @@ -32,7 +32,7 @@ private: virtual void mouseup_event(GUI::MouseEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; - int note_for_event_position(const Gfx::IntPoint&) const; + int note_for_event_position(Gfx::IntPoint const&) const; TrackManager& m_track_manager; diff --git a/Userland/Applications/Piano/Music.h b/Userland/Applications/Piano/Music.h index 5af0825baa..6759142482 100644 --- a/Userland/Applications/Piano/Music.h +++ b/Userland/Applications/Piano/Music.h @@ -160,7 +160,7 @@ constexpr int beats_per_bar = 4; constexpr int notes_per_beat = 4; constexpr int roll_length = (sample_rate / (beats_per_minute / 60)) * beats_per_bar; -constexpr const char* note_names[] = { +constexpr char const* note_names[] = { "C", "C#", "D", diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index d2457051cb..84ba9ce64f 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -152,7 +152,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) } Gfx::IntRect note_name_rect(3, y, 1, note_height); - const char* note_name = note_names[note % notes_per_octave]; + char const* note_name = note_names[note % notes_per_octave]; painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft); note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0); diff --git a/Userland/Applications/Piano/RollWidget.h b/Userland/Applications/Piano/RollWidget.h index 3e4ca04e9f..76f7599bb0 100644 --- a/Userland/Applications/Piano/RollWidget.h +++ b/Userland/Applications/Piano/RollWidget.h @@ -22,8 +22,8 @@ class RollWidget final : public GUI::AbstractScrollableWidget { public: virtual ~RollWidget() override = default; - const KeysWidget* keys_widget() const { return m_keys_widget; } - void set_keys_widget(const KeysWidget* widget) { m_keys_widget = widget; } + KeysWidget const* keys_widget() const { return m_keys_widget; } + void set_keys_widget(KeysWidget const* widget) { m_keys_widget = widget; } private: explicit RollWidget(TrackManager&); @@ -36,7 +36,7 @@ private: bool viewport_changed() const; TrackManager& m_track_manager; - const KeysWidget* m_keys_widget; + KeysWidget const* m_keys_widget; int m_roll_width { 0 }; int m_num_notes { 0 }; diff --git a/Userland/Applications/Piano/Track.cpp b/Userland/Applications/Piano/Track.cpp index 7344a5c0d7..f2cd6494a3 100644 --- a/Userland/Applications/Piano/Track.cpp +++ b/Userland/Applications/Piano/Track.cpp @@ -16,7 +16,7 @@ #include <LibDSP/Music.h> #include <math.h> -Track::Track(const u32& time) +Track::Track(u32 const& time) : m_time(time) , m_temporary_transport(LibDSP::Transport::construct(120, 4)) , m_delay(make_ref_counted<LibDSP::Effects::Delay>(m_temporary_transport)) diff --git a/Userland/Applications/Piano/Track.h b/Userland/Applications/Piano/Track.h index 230b052231..bd785586a1 100644 --- a/Userland/Applications/Piano/Track.h +++ b/Userland/Applications/Piano/Track.h @@ -26,11 +26,11 @@ class Track { AK_MAKE_NONMOVABLE(Track); public: - explicit Track(const u32& time); + explicit Track(u32 const& time); ~Track() = default; - const Vector<Audio::Sample>& recorded_sample() const { return m_recorded_sample; } - const SinglyLinkedList<RollNote>& roll_notes(int note) const { return m_roll_notes[note]; } + Vector<Audio::Sample> const& recorded_sample() const { return m_recorded_sample; } + SinglyLinkedList<RollNote> const& roll_notes(int note) const { return m_roll_notes[note]; } int volume() const { return m_volume; } NonnullRefPtr<LibDSP::Synthesizers::Classic> synth() { return m_synth; } NonnullRefPtr<LibDSP::Effects::Delay> delay() { return m_delay; } @@ -51,7 +51,7 @@ private: int m_volume; - const u32& m_time; + u32 const& m_time; NonnullRefPtr<LibDSP::Transport> m_temporary_transport; NonnullRefPtr<LibDSP::Effects::Delay> m_delay; diff --git a/Userland/Applications/PixelPaint/EditGuideDialog.cpp b/Userland/Applications/PixelPaint/EditGuideDialog.cpp index e509d99d8f..b9c8f79950 100644 --- a/Userland/Applications/PixelPaint/EditGuideDialog.cpp +++ b/Userland/Applications/PixelPaint/EditGuideDialog.cpp @@ -76,7 +76,7 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, String const& offse }; } -Optional<float> EditGuideDialog::offset_as_pixel(const ImageEditor& editor) +Optional<float> EditGuideDialog::offset_as_pixel(ImageEditor const& editor) { float offset = 0; if (m_offset.ends_with('%')) { diff --git a/Userland/Applications/PixelPaint/FilterModel.cpp b/Userland/Applications/PixelPaint/FilterModel.cpp index 025be5b23b..eb0fd6d57a 100644 --- a/Userland/Applications/PixelPaint/FilterModel.cpp +++ b/Userland/Applications/PixelPaint/FilterModel.cpp @@ -64,7 +64,7 @@ GUI::ModelIndex FilterModel::index(int row, int column, const GUI::ModelIndex& p return {}; return create_index(row, column, &m_filters[row]); } - auto* parent = static_cast<const FilterInfo*>(parent_index.internal_data()); + auto* parent = static_cast<FilterInfo const*>(parent_index.internal_data()); if (static_cast<size_t>(row) >= parent->children.size()) return {}; auto* child = &parent->children[row]; @@ -76,7 +76,7 @@ GUI::ModelIndex FilterModel::parent_index(const GUI::ModelIndex& index) const if (!index.is_valid()) return {}; - auto* child = static_cast<const FilterInfo*>(index.internal_data()); + auto* child = static_cast<FilterInfo const*>(index.internal_data()); auto* parent = child->parent; if (parent == nullptr) return {}; @@ -99,13 +99,13 @@ int FilterModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_filters.size(); - auto* node = static_cast<const FilterInfo*>(index.internal_data()); + auto* node = static_cast<FilterInfo const*>(index.internal_data()); return node->children.size(); } GUI::Variant FilterModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* filter = static_cast<const FilterInfo*>(index.internal_data()); + auto* filter = static_cast<FilterInfo const*>(index.internal_data()); switch (role) { case GUI::ModelRole::Display: return filter->text; diff --git a/Userland/Applications/PixelPaint/FilterPreviewWidget.cpp b/Userland/Applications/PixelPaint/FilterPreviewWidget.cpp index f86fe42769..aff498e971 100644 --- a/Userland/Applications/PixelPaint/FilterPreviewWidget.cpp +++ b/Userland/Applications/PixelPaint/FilterPreviewWidget.cpp @@ -21,7 +21,7 @@ FilterPreviewWidget::~FilterPreviewWidget() { } -void FilterPreviewWidget::set_bitmap(const RefPtr<Gfx::Bitmap>& bitmap) +void FilterPreviewWidget::set_bitmap(RefPtr<Gfx::Bitmap> const& bitmap) { m_bitmap = bitmap; clear_filter(); diff --git a/Userland/Applications/PixelPaint/FilterPreviewWidget.h b/Userland/Applications/PixelPaint/FilterPreviewWidget.h index 451ff90569..4753c693ef 100644 --- a/Userland/Applications/PixelPaint/FilterPreviewWidget.h +++ b/Userland/Applications/PixelPaint/FilterPreviewWidget.h @@ -19,7 +19,7 @@ class FilterPreviewWidget final : public GUI::Frame { public: virtual ~FilterPreviewWidget() override; - void set_bitmap(const RefPtr<Gfx::Bitmap>& bitmap); + void set_bitmap(RefPtr<Gfx::Bitmap> const& bitmap); void set_filter(Filter* filter); void clear_filter(); diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index a14246b08e..f64edc2cad 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -126,7 +126,7 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const MUST(json.add("height", m_size.height())); { auto json_layers = MUST(json.add_array("layers")); - for (const auto& layer : m_layers) { + for (auto const& layer : m_layers) { Gfx::BMPWriter bmp_writer; auto json_layer = MUST(json_layers.add_object()); MUST(json_layer.add("width", layer.size().width())); @@ -147,7 +147,7 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const } } -ErrorOr<void> Image::write_to_file(const String& file_path) const +ErrorOr<void> Image::write_to_file(String const& file_path) const { StringBuilder builder; auto json = MUST(JsonObjectSerializer<>::try_create(builder)); @@ -228,7 +228,7 @@ void Image::add_layer(NonnullRefPtr<Layer> layer) ErrorOr<NonnullRefPtr<Image>> Image::take_snapshot() const { auto snapshot = TRY(try_create_with_size(m_size)); - for (const auto& layer : m_layers) { + for (auto const& layer : m_layers) { auto layer_snapshot = TRY(Layer::try_create_snapshot(*snapshot, layer)); snapshot->add_layer(move(layer_snapshot)); } diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 9718bfd3c6..490271105c 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -162,49 +162,49 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) m_selection.paint(painter); if (m_show_rulers) { - const auto ruler_bg_color = palette().color(Gfx::ColorRole::InactiveSelection); - const auto ruler_fg_color = palette().color(Gfx::ColorRole::Ruler); - const auto ruler_text_color = palette().color(Gfx::ColorRole::InactiveSelectionText); - const auto mouse_indicator_color = Color::White; + auto const ruler_bg_color = palette().color(Gfx::ColorRole::InactiveSelection); + auto const ruler_fg_color = palette().color(Gfx::ColorRole::Ruler); + auto const ruler_text_color = palette().color(Gfx::ColorRole::InactiveSelectionText); + auto const mouse_indicator_color = Color::White; // Ruler background painter.fill_rect({ { 0, 0 }, { m_ruler_thickness, rect().height() } }, ruler_bg_color); painter.fill_rect({ { 0, 0 }, { rect().width(), m_ruler_thickness } }, ruler_bg_color); - const auto ruler_step = calculate_ruler_step_size(); - const auto editor_origin_to_image = frame_to_content_position({ 0, 0 }); - const auto editor_max_to_image = frame_to_content_position({ width(), height() }); + auto const ruler_step = calculate_ruler_step_size(); + auto const editor_origin_to_image = frame_to_content_position({ 0, 0 }); + auto const editor_max_to_image = frame_to_content_position({ width(), height() }); // Horizontal ruler painter.draw_line({ 0, m_ruler_thickness }, { rect().width(), m_ruler_thickness }, ruler_fg_color); - const auto x_start = floor(editor_origin_to_image.x()) - ((int)floor(editor_origin_to_image.x()) % ruler_step) - ruler_step; + auto const x_start = floor(editor_origin_to_image.x()) - ((int)floor(editor_origin_to_image.x()) % ruler_step) - ruler_step; for (int x = x_start; x < editor_max_to_image.x(); x += ruler_step) { - const int num_sub_divisions = min(ruler_step, 10); + int const num_sub_divisions = min(ruler_step, 10); for (int x_sub = 0; x_sub < num_sub_divisions; ++x_sub) { - const int x_pos = x + (int)(ruler_step * x_sub / num_sub_divisions); - const int editor_x_sub = content_to_frame_position({ x_pos, 0 }).x(); - const int line_length = (x_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6; + int const x_pos = x + (int)(ruler_step * x_sub / num_sub_divisions); + int const editor_x_sub = content_to_frame_position({ x_pos, 0 }).x(); + int const line_length = (x_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6; painter.draw_line({ editor_x_sub, m_ruler_thickness - line_length }, { editor_x_sub, m_ruler_thickness }, ruler_fg_color); } - const int editor_x = content_to_frame_position({ x, 0 }).x(); + int const editor_x = content_to_frame_position({ x, 0 }).x(); painter.draw_line({ editor_x, 0 }, { editor_x, m_ruler_thickness }, ruler_fg_color); painter.draw_text({ { editor_x + 2, 0 }, { m_ruler_thickness, m_ruler_thickness - 2 } }, String::formatted("{}", x), painter.font(), Gfx::TextAlignment::CenterLeft, ruler_text_color); } // Vertical ruler painter.draw_line({ m_ruler_thickness, 0 }, { m_ruler_thickness, rect().height() }, ruler_fg_color); - const auto y_start = floor(editor_origin_to_image.y()) - ((int)floor(editor_origin_to_image.y()) % ruler_step) - ruler_step; + auto const y_start = floor(editor_origin_to_image.y()) - ((int)floor(editor_origin_to_image.y()) % ruler_step) - ruler_step; for (int y = y_start; y < editor_max_to_image.y(); y += ruler_step) { - const int num_sub_divisions = min(ruler_step, 10); + int const num_sub_divisions = min(ruler_step, 10); for (int y_sub = 0; y_sub < num_sub_divisions; ++y_sub) { - const int y_pos = y + (int)(ruler_step * y_sub / num_sub_divisions); - const int editor_y_sub = content_to_frame_position({ 0, y_pos }).y(); - const int line_length = (y_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6; + int const y_pos = y + (int)(ruler_step * y_sub / num_sub_divisions); + int const editor_y_sub = content_to_frame_position({ 0, y_pos }).y(); + int const line_length = (y_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6; painter.draw_line({ m_ruler_thickness - line_length, editor_y_sub }, { m_ruler_thickness, editor_y_sub }, ruler_fg_color); } - const int editor_y = content_to_frame_position({ 0, y }).y(); + int const editor_y = content_to_frame_position({ 0, y }).y(); painter.draw_line({ 0, editor_y }, { m_ruler_thickness, editor_y }, ruler_fg_color); painter.draw_text({ { 0, editor_y - m_ruler_thickness }, { m_ruler_thickness, m_ruler_thickness } }, String::formatted("{}", y), painter.font(), Gfx::TextAlignment::BottomRight, ruler_text_color); } @@ -222,8 +222,8 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) int ImageEditor::calculate_ruler_step_size() const { - const auto step_target = 80 / scale(); - const auto max_factor = 5; + auto const step_target = 80 / scale(); + auto const max_factor = 5; for (int factor = 0; factor < max_factor; ++factor) { int ten_to_factor = AK::pow<int>(10, factor); if (step_target <= 1 * ten_to_factor) @@ -619,7 +619,7 @@ Result<void, String> ImageEditor::save_project_to_file(Core::File& file) const auto json = MUST(JsonObjectSerializer<>::try_create(builder)); m_image->serialize_as_json(json); auto json_guides = MUST(json.add_array("guides")); - for (const auto& guide : m_guides) { + for (auto const& guide : m_guides) { auto json_guide = MUST(json_guides.add_object()); MUST(json_guide.add("offset"sv, (double)guide.offset())); if (guide.orientation() == Guide::Orientation::Vertical) diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index abb28a1377..eb00abeebf 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -101,7 +101,7 @@ MainWidget::MainWidget() } // Note: Update these together! v -static const Vector<String> s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" }; +static Vector<String> const s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" }; static constexpr int s_zoom_level_fit_width = 8; static constexpr int s_zoom_level_fit_height = 9; static constexpr int s_zoom_level_fit_image = 10; diff --git a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp index aa809795d1..866be15713 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp @@ -36,7 +36,7 @@ void BrushTool::on_mousedown(Layer* layer, MouseEvent& event) return; } - const int first_draw_opacity = 10; + int const first_draw_opacity = 10; for (int i = 0; i < first_draw_opacity; ++i) draw_point(layer->currently_edited_bitmap(), color_for(layer_event), layer_event.position()); diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp index 1203fe7285..bbe4efeb70 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp @@ -16,7 +16,7 @@ namespace PixelPaint { -RefPtr<Guide> GuideTool::closest_guide(const Gfx::IntPoint& point) +RefPtr<Guide> GuideTool::closest_guide(Gfx::IntPoint const& point) { auto guides = editor()->guides(); Guide* closest_guide = nullptr; diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp index 9f7de2d0d8..0d2d7daea1 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp @@ -157,7 +157,7 @@ GUI::Widget* RectangleSelectTool::get_properties_widget() feather_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); feather_label.set_fixed_size(80, 20); - const int feather_slider_max = 100; + int const feather_slider_max = 100; auto& feather_slider = feather_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); feather_slider.set_range(0, feather_slider_max); feather_slider.set_value((int)floorf(m_edge_feathering * (float)feather_slider_max)); diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp index 529798cddf..b1b2521ca7 100644 --- a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp @@ -43,13 +43,13 @@ void SprayTool::paint_it() auto& bitmap = layer->currently_edited_bitmap(); GUI::Painter painter(bitmap); VERIFY(bitmap.bpp() == 32); - const double minimal_radius = 2; - const double base_radius = minimal_radius * m_thickness; + double const minimal_radius = 2; + double const base_radius = minimal_radius * m_thickness; for (int i = 0; i < M_PI * base_radius * base_radius * (m_density / 100.0); i++) { double radius = base_radius * nrand(); double angle = 2 * M_PI * nrand(); - const int xpos = m_last_pos.x() + radius * AK::cos(angle); - const int ypos = m_last_pos.y() - radius * AK::sin(angle); + int const xpos = m_last_pos.x() + radius * AK::cos(angle); + int const ypos = m_last_pos.y() - radius * AK::sin(angle); if (xpos < 0 || xpos >= bitmap.width()) continue; if (ypos < 0 || ypos >= bitmap.height()) diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp index e2cebb31b9..71ba88cf13 100644 --- a/Userland/Applications/PixelPaint/main.cpp +++ b/Userland/Applications/PixelPaint/main.cpp @@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = GUI::Application::construct(arguments); Config::pledge_domain("PixelPaint"); - const char* image_file = nullptr; + char const* image_file = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(image_file, "Image file to open", "path", Core::ArgsParser::Required::No); args_parser.parse(arguments); diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index 6e680936c4..6dcc87dd48 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -107,11 +107,11 @@ void RunWindow::do_run() show(); } -bool RunWindow::run_as_command(const String& run_input) +bool RunWindow::run_as_command(String const& run_input) { pid_t child_pid; - const char* shell_executable = "/bin/Shell"; // TODO query and use the user's preferred shell. - const char* argv[] = { shell_executable, "-c", run_input.characters(), nullptr }; + char const* shell_executable = "/bin/Shell"; // TODO query and use the user's preferred shell. + char const* argv[] = { shell_executable, "-c", run_input.characters(), nullptr }; if ((errno = posix_spawn(&child_pid, shell_executable, nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); @@ -136,7 +136,7 @@ bool RunWindow::run_as_command(const String& run_input) return true; } -bool RunWindow::run_via_launch(const String& run_input) +bool RunWindow::run_via_launch(String const& run_input) { auto url = URL::create_with_url_or_path(run_input); diff --git a/Userland/Applications/Run/RunWindow.h b/Userland/Applications/Run/RunWindow.h index c05bccf2ef..ca19e41350 100644 --- a/Userland/Applications/Run/RunWindow.h +++ b/Userland/Applications/Run/RunWindow.h @@ -24,8 +24,8 @@ private: RunWindow(); void do_run(); - bool run_as_command(const String& run_input); - bool run_via_launch(const String& run_input); + bool run_as_command(String const& run_input); + bool run_via_launch(String const& run_input); String history_file_path(); void load_history(); diff --git a/Userland/Applications/SoundPlayer/M3UParser.cpp b/Userland/Applications/SoundPlayer/M3UParser.cpp index 5b32bff491..8454d03781 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.cpp +++ b/Userland/Applications/SoundPlayer/M3UParser.cpp @@ -24,7 +24,7 @@ NonnullOwnPtr<M3UParser> M3UParser::from_file(const String path) return from_memory(String { contents, NoChomp }, use_utf8); } -NonnullOwnPtr<M3UParser> M3UParser::from_memory(const String& m3u_contents, bool utf8) +NonnullOwnPtr<M3UParser> M3UParser::from_memory(String const& m3u_contents, bool utf8) { auto parser = make<M3UParser>(); VERIFY(!m3u_contents.is_null() && !m3u_contents.is_empty() && !m3u_contents.is_whitespace()); @@ -38,7 +38,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info) auto vec = make<Vector<M3UEntry>>(); if (m_use_utf8) { - //TODO: Implement M3U8 parsing + // TODO: Implement M3U8 parsing TODO(); return vec; } @@ -75,7 +75,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info) auto display_name = ext_inf.value().substring_view(seconds.length() + 1); VERIFY(!display_name.is_empty() && !display_name.is_null() && !display_name.is_empty()); metadata_for_next_file.track_display_title = display_name; - //TODO: support the alternative, non-standard #EXTINF value of a key=value dictionary + // TODO: support the alternative, non-standard #EXTINF value of a key=value dictionary continue; } if (auto playlist = tag("#PLAYLIST:"); playlist.has_value()) @@ -88,7 +88,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info) metadata_for_next_file.album_artist = move(ext_art.value()); else if (auto ext_genre = tag("#EXTGENRE:"); ext_genre.has_value()) metadata_for_next_file.album_genre = move(ext_genre.value()); - //TODO: Support M3A files (M3U files with embedded mp3 files) + // TODO: Support M3A files (M3U files with embedded mp3 files) } return vec; diff --git a/Userland/Applications/SoundPlayer/M3UParser.h b/Userland/Applications/SoundPlayer/M3UParser.h index d87b07ed95..31d3a7d71e 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.h +++ b/Userland/Applications/SoundPlayer/M3UParser.h @@ -33,7 +33,7 @@ struct M3UEntry { class M3UParser { public: static NonnullOwnPtr<M3UParser> from_file(String path); - static NonnullOwnPtr<M3UParser> from_memory(const String& m3u_contents, bool utf8); + static NonnullOwnPtr<M3UParser> from_memory(String const& m3u_contents, bool utf8); NonnullOwnPtr<Vector<M3UEntry>> parse(bool include_extended_info); diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp index bbaf720a34..fad0b1a7b1 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp +++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp @@ -66,7 +66,7 @@ void PlaybackManager::loop(bool loop) m_loop = loop; } -void PlaybackManager::seek(const int position) +void PlaybackManager::seek(int const position) { if (!m_loader) return; diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.h b/Userland/Applications/SoundPlayer/PlaybackManager.h index 2959855fa9..e4fa03eef6 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.h +++ b/Userland/Applications/SoundPlayer/PlaybackManager.h @@ -22,7 +22,7 @@ public: void play(); void stop(); void pause(); - void seek(const int position); + void seek(int const position); void loop(bool); bool toggle_pause(); void set_loader(NonnullRefPtr<Audio::Loader>&&); diff --git a/Userland/Applications/SoundPlayer/Playlist.cpp b/Userland/Applications/SoundPlayer/Playlist.cpp index 96f09f8001..69db139f07 100644 --- a/Userland/Applications/SoundPlayer/Playlist.cpp +++ b/Userland/Applications/SoundPlayer/Playlist.cpp @@ -51,12 +51,12 @@ void Playlist::try_fill_missing_info(Vector<M3UEntry>& entries, StringView path) entry.extended_info->track_display_title = LexicalPath::title(entry.path); if (!entry.extended_info->track_length_in_seconds.has_value()) { - //TODO: Implement embedded metadata extractor for other audio formats + // TODO: Implement embedded metadata extractor for other audio formats if (auto reader = Audio::Loader::create(entry.path); !reader.is_error()) entry.extended_info->track_length_in_seconds = reader.value()->total_samples() / reader.value()->sample_rate(); } - //TODO: Implement a metadata parser for the uncomfortably numerous popular embedded metadata formats + // TODO: Implement a metadata parser for the uncomfortably numerous popular embedded metadata formats } for (auto& entry : to_delete) diff --git a/Userland/Applications/SoundPlayer/PlaylistWidget.cpp b/Userland/Applications/SoundPlayer/PlaylistWidget.cpp index f954c93489..b5881d7bd7 100644 --- a/Userland/Applications/SoundPlayer/PlaylistWidget.cpp +++ b/Userland/Applications/SoundPlayer/PlaylistWidget.cpp @@ -19,7 +19,7 @@ PlaylistWidget::PlaylistWidget() m_table_view->set_selection_mode(GUI::AbstractView::SelectionMode::SingleSelection); m_table_view->set_selection_behavior(GUI::AbstractView::SelectionBehavior::SelectRows); m_table_view->set_highlight_selected_rows(true); - m_table_view->on_doubleclick = [&](const Gfx::Point<int>& point) { + m_table_view->on_doubleclick = [&](Gfx::Point<int> const& point) { auto player = dynamic_cast<Player*>(window()->main_widget()); auto index = m_table_view->index_at_event_position(point); if (!index.is_valid()) @@ -50,7 +50,7 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro } if (role == GUI::ModelRole::Sort) return data(index, GUI::ModelRole::Display); - if (role == static_cast<GUI::ModelRole>(PlaylistModelCustomRole::FilePath)) //path + if (role == static_cast<GUI::ModelRole>(PlaylistModelCustomRole::FilePath)) // path return m_playlist_items[index.row()].path; return {}; diff --git a/Userland/Applications/SoundPlayer/PlaylistWidget.h b/Userland/Applications/SoundPlayer/PlaylistWidget.h index d4c10360ad..e1260fd20e 100644 --- a/Userland/Applications/SoundPlayer/PlaylistWidget.h +++ b/Userland/Applications/SoundPlayer/PlaylistWidget.h @@ -39,7 +39,7 @@ class PlaylistTableView : public GUI::TableView { public: void doubleclick_event(GUI::MouseEvent& event) override; - Function<void(const Gfx::Point<int>&)> on_doubleclick; + Function<void(Gfx::Point<int> const&)> on_doubleclick; private: PlaylistTableView(); diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp index d9a8160ed7..8261504313 100644 --- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp +++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp @@ -35,17 +35,17 @@ static float get_normalized_aspect_ratio(float a, float b) } } -static bool node_is_leaf(const TreeMapNode& node) +static bool node_is_leaf(TreeMapNode const& node) { return node.num_children() == 0; } -bool TreeMapWidget::rect_can_contain_label(const Gfx::IntRect& rect) const +bool TreeMapWidget::rect_can_contain_label(Gfx::IntRect const& rect) const { return rect.height() >= font().presentation_size() && rect.width() > 20; } -void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& node, const Gfx::IntRect& cell_rect, const Gfx::IntRect& inner_rect, int depth, HasLabel has_label) const +void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, TreeMapNode const& node, Gfx::IntRect const& cell_rect, Gfx::IntRect const& inner_rect, int depth, HasLabel has_label) const { if (cell_rect.width() <= 2 || cell_rect.height() <= 2) { painter.fill_rect(cell_rect, Color::Black); @@ -101,7 +101,7 @@ void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& n } template<typename Function> -void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect& rect, int depth, Function callback) +void TreeMapWidget::lay_out_children(TreeMapNode const& node, Gfx::IntRect const& rect, int depth, Function callback) { if (node.num_children() == 0) { return; @@ -179,7 +179,7 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect inner_rect = cell_rect; inner_rect.shrink(4, 4); // border and shading if (rect_can_contain_label(inner_rect)) { - const int margin = 5; + int const margin = 5; has_label = HasLabel::Yes; inner_rect.set_y(inner_rect.y() + font().presentation_size() + margin); inner_rect.set_height(inner_rect.height() - (font().presentation_size() + margin * 2)); @@ -214,11 +214,11 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect } } -const TreeMapNode* TreeMapWidget::path_node(size_t n) const +TreeMapNode const* TreeMapWidget::path_node(size_t n) const { if (!m_tree.ptr()) return nullptr; - const TreeMapNode* iter = &m_tree->root(); + TreeMapNode const* iter = &m_tree->root(); size_t path_index = 0; while (iter && path_index < m_path.size() && path_index < n) { size_t child_index = m_path[path_index]; @@ -238,13 +238,13 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event) m_selected_node_cache = path_node(m_path.size()); - const TreeMapNode* node = path_node(m_viewpoint); + TreeMapNode const* node = path_node(m_viewpoint); if (!node) { painter.fill_rect(frame_inner_rect(), Color::MidGray); } else if (node_is_leaf(*node)) { paint_cell_frame(painter, *node, frame_inner_rect(), Gfx::IntRect(), m_viewpoint - 1, HasLabel::Yes); } else { - lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](const TreeMapNode& node, int, const Gfx::IntRect& rect, const Gfx::IntRect& inner_rect, int depth, HasLabel has_label, IsRemainder remainder) { + lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeMapNode const& node, int, Gfx::IntRect const& rect, Gfx::IntRect const& inner_rect, int depth, HasLabel has_label, IsRemainder remainder) { if (remainder == IsRemainder::No) { paint_cell_frame(painter, node, rect, inner_rect, depth, has_label); } else { @@ -258,14 +258,14 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event) } } -Vector<int> TreeMapWidget::path_to_position(const Gfx::IntPoint& position) +Vector<int> TreeMapWidget::path_to_position(Gfx::IntPoint const& position) { - const TreeMapNode* node = path_node(m_viewpoint); + TreeMapNode const* node = path_node(m_viewpoint); if (!node) { return {}; } Vector<int> path; - lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](const TreeMapNode&, int index, const Gfx::IntRect& rect, const Gfx::IntRect&, int, HasLabel, IsRemainder is_remainder) { + lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeMapNode const&, int index, Gfx::IntRect const& rect, Gfx::IntRect const&, int, HasLabel, IsRemainder is_remainder) { if (is_remainder == IsRemainder::No && rect.contains(position)) { path.append(index); } @@ -275,7 +275,7 @@ Vector<int> TreeMapWidget::path_to_position(const Gfx::IntPoint& position) void TreeMapWidget::mousedown_event(GUI::MouseEvent& event) { - const TreeMapNode* node = path_node(m_viewpoint); + TreeMapNode const* node = path_node(m_viewpoint); if (node && !node_is_leaf(*node)) { Vector<int> path = path_to_position(event.position()); if (!path.is_empty()) { @@ -293,7 +293,7 @@ void TreeMapWidget::doubleclick_event(GUI::MouseEvent& event) { if (event.button() != GUI::MouseButton::Primary) return; - const TreeMapNode* node = path_node(m_viewpoint); + TreeMapNode const* node = path_node(m_viewpoint); if (node && !node_is_leaf(*node)) { Vector<int> path = path_to_position(event.position()); m_path.shrink(m_viewpoint); diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h index 9c0ef8382d..14636e7f90 100644 --- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h +++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h @@ -15,7 +15,7 @@ struct TreeMapNode { virtual String name() const = 0; virtual i64 area() const = 0; virtual size_t num_children() const = 0; - virtual const TreeMapNode& child_at(size_t i) const = 0; + virtual TreeMapNode const& child_at(size_t i) const = 0; virtual void sort_children_by_area() const = 0; protected: @@ -24,7 +24,7 @@ protected: struct TreeMap : public RefCounted<TreeMap> { virtual ~TreeMap() = default; - virtual const TreeMapNode& root() const = 0; + virtual TreeMapNode const& root() const = 0; }; class TreeMapWidget final : public GUI::Frame { @@ -35,7 +35,7 @@ public: Function<void()> on_path_change; Function<void(GUI::ContextMenuEvent&)> on_context_menu_request; size_t path_size() const; - const TreeMapNode* path_node(size_t n) const; + TreeMapNode const* path_node(size_t n) const; size_t viewpoint() const; void set_viewpoint(size_t); void set_tree(RefPtr<TreeMap> tree); @@ -49,8 +49,8 @@ private: virtual void context_menu_event(GUI::ContextMenuEvent&) override; virtual void keydown_event(GUI::KeyEvent&) override; - bool rect_can_contain_children(const Gfx::IntRect& rect) const; - bool rect_can_contain_label(const Gfx::IntRect& rect) const; + bool rect_can_contain_children(Gfx::IntRect const& rect) const; + bool rect_can_contain_label(Gfx::IntRect const& rect) const; enum class HasLabel { Yes, @@ -62,14 +62,14 @@ private: }; template<typename Function> - void lay_out_children(const TreeMapNode&, const Gfx::IntRect&, int depth, Function); - void paint_cell_frame(GUI::Painter&, const TreeMapNode&, const Gfx::IntRect&, const Gfx::IntRect&, int depth, HasLabel has_label) const; - Vector<int> path_to_position(const Gfx::IntPoint&); + void lay_out_children(TreeMapNode const&, Gfx::IntRect const&, int depth, Function); + void paint_cell_frame(GUI::Painter&, TreeMapNode const&, Gfx::IntRect const&, Gfx::IntRect const&, int depth, HasLabel has_label) const; + Vector<int> path_to_position(Gfx::IntPoint const&); RefPtr<TreeMap> m_tree; Vector<int> m_path; size_t m_viewpoint { 0 }; - const void* m_selected_node_cache; + void const* m_selected_node_cache; }; } diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index b53b67be15..560c7d9e4e 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -46,7 +46,7 @@ struct TreeNode : public SpaceAnalyzer::TreeMapNode { } return 0; } - virtual const TreeNode& child_at(size_t i) const override { return m_children->at(i); } + virtual TreeNode const& child_at(size_t i) const override { return m_children->at(i); } virtual void sort_children_by_area() const override { if (m_children) { @@ -65,7 +65,7 @@ struct Tree : public SpaceAnalyzer::TreeMap { : m_root(move(root_name)) {}; virtual ~Tree() {}; TreeNode m_root; - virtual const SpaceAnalyzer::TreeMapNode& root() const override + virtual SpaceAnalyzer::TreeMapNode const& root() const override { return m_root; }; @@ -278,7 +278,7 @@ static void analyze(RefPtr<Tree> tree, SpaceAnalyzer::TreeMapWidget& treemapwidg treemapwidget.set_tree(tree); } -static bool is_removable(const String& absolute_path) +static bool is_removable(String const& absolute_path) { VERIFY(!absolute_path.is_empty()); int access_result = access(LexicalPath::dirname(absolute_path).characters(), W_OK); @@ -287,14 +287,14 @@ static bool is_removable(const String& absolute_path) return access_result == 0; } -static String get_absolute_path_to_selected_node(const SpaceAnalyzer::TreeMapWidget& treemapwidget, bool include_last_node = true) +static String get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMapWidget const& treemapwidget, bool include_last_node = true) { StringBuilder path_builder; for (size_t k = 0; k < treemapwidget.path_size() - (include_last_node ? 0 : 1); k++) { if (k != 0) { path_builder.append('/'); } - const SpaceAnalyzer::TreeMapNode* node = treemapwidget.path_node(k); + SpaceAnalyzer::TreeMapNode const* node = treemapwidget.path_node(k); path_builder.append(node->name()); } return path_builder.build(); diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp index dd111615c1..e9c41fdf61 100644 --- a/Userland/Applications/Spreadsheet/Cell.cpp +++ b/Userland/Applications/Spreadsheet/Cell.cpp @@ -47,7 +47,7 @@ void Cell::set_data(JS::Value new_data) m_evaluated_data = move(new_data); } -void Cell::set_type(const CellType* type) +void Cell::set_type(CellType const* type) { m_type = type; } @@ -67,7 +67,7 @@ void Cell::set_type_metadata(CellTypeMetadata&& metadata) m_type_metadata = move(metadata); } -const CellType& Cell::type() const +CellType const& Cell::type() const { if (m_type) return *m_type; @@ -171,13 +171,13 @@ void Cell::reference_from(Cell* other) if (!other || other == this) return; - if (!m_referencing_cells.find_if([other](const auto& ptr) { return ptr.ptr() == other; }).is_end()) + if (!m_referencing_cells.find_if([other](auto const& ptr) { return ptr.ptr() == other; }).is_end()) return; m_referencing_cells.append(other->make_weak_ptr()); } -void Cell::copy_from(const Cell& other) +void Cell::copy_from(Cell const& other) { m_dirty = true; m_evaluated_externally = other.m_evaluated_externally; diff --git a/Userland/Applications/Spreadsheet/Cell.h b/Userland/Applications/Spreadsheet/Cell.h index f38b0a7092..6159b9ec2d 100644 --- a/Userland/Applications/Spreadsheet/Cell.h +++ b/Userland/Applications/Spreadsheet/Cell.h @@ -58,16 +58,16 @@ struct Cell : public Weakable<Cell> { return m_thrown_value; } - const String& data() const { return m_data; } + String const& data() const { return m_data; } const JS::Value& evaluated_data() const { return m_evaluated_data; } Kind kind() const { return m_kind; } - const Vector<WeakPtr<Cell>>& referencing_cells() const { return m_referencing_cells; } + Vector<WeakPtr<Cell>> const& referencing_cells() const { return m_referencing_cells; } void set_type(StringView name); - void set_type(const CellType*); + void set_type(CellType const*); void set_type_metadata(CellTypeMetadata&&); - const Position& position() const { return m_position; } + Position const& position() const { return m_position; } void set_position(Position position, Badge<Sheet>) { if (position != m_position) { @@ -76,9 +76,9 @@ struct Cell : public Weakable<Cell> { } } - const Format& evaluated_formats() const { return m_evaluated_formats; } + Format const& evaluated_formats() const { return m_evaluated_formats; } Format& evaluated_formats() { return m_evaluated_formats; } - const Vector<ConditionalFormat>& conditional_formats() const { return m_conditional_formats; } + Vector<ConditionalFormat> const& conditional_formats() const { return m_conditional_formats; } void set_conditional_formats(Vector<ConditionalFormat>&& fmts) { m_dirty = true; @@ -88,8 +88,8 @@ struct Cell : public Weakable<Cell> { JS::ThrowCompletionOr<String> typed_display() const; JS::ThrowCompletionOr<JS::Value> typed_js_data() const; - const CellType& type() const; - const CellTypeMetadata& type_metadata() const { return m_type_metadata; } + CellType const& type() const; + CellTypeMetadata const& type_metadata() const { return m_type_metadata; } CellTypeMetadata& type_metadata() { return m_type_metadata; } String source() const; @@ -99,10 +99,10 @@ struct Cell : public Weakable<Cell> { void update(); void update_data(Badge<Sheet>); - const Sheet& sheet() const { return *m_sheet; } + Sheet const& sheet() const { return *m_sheet; } Sheet& sheet() { return *m_sheet; } - void copy_from(const Cell&); + void copy_from(Cell const&); private: bool m_dirty { false }; @@ -113,7 +113,7 @@ private: Kind m_kind { LiteralString }; WeakPtr<Sheet> m_sheet; Vector<WeakPtr<Cell>> m_referencing_cells; - const CellType* m_type { nullptr }; + CellType const* m_type { nullptr }; CellTypeMetadata m_type_metadata; Position m_position; diff --git a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp index e9c43180f8..4fdc12b110 100644 --- a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp +++ b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp @@ -11,7 +11,7 @@ namespace Spreadsheet { -void CellSyntaxHighlighter::rehighlight(const Palette& palette) +void CellSyntaxHighlighter::rehighlight(Palette const& palette) { auto text = m_client->get_text(); m_client->spans().clear(); diff --git a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.h b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.h index 0a19d3f715..265c28efbe 100644 --- a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.h +++ b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.h @@ -16,11 +16,11 @@ public: CellSyntaxHighlighter() = default; virtual ~CellSyntaxHighlighter() override = default; - virtual void rehighlight(const Palette&) override; - void set_cell(const Cell* cell) { m_cell = cell; } + virtual void rehighlight(Palette const&) override; + void set_cell(Cell const* cell) { m_cell = cell; } private: - const Cell* m_cell { nullptr }; + Cell const* m_cell { nullptr }; }; } diff --git a/Userland/Applications/Spreadsheet/CellType/Date.cpp b/Userland/Applications/Spreadsheet/CellType/Date.cpp index 3bc12c55af..9810f162d9 100644 --- a/Userland/Applications/Spreadsheet/CellType/Date.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Date.cpp @@ -17,7 +17,7 @@ DateCell::DateCell() { } -JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, const CellTypeMetadata& metadata) const +JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const { return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> { auto timestamp = TRY(js_value(cell, metadata)); @@ -30,7 +30,7 @@ JS::ThrowCompletionOr<String> DateCell::display(Cell& cell, const CellTypeMetada }); } -JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, const CellTypeMetadata&) const +JS::ThrowCompletionOr<JS::Value> DateCell::js_value(Cell& cell, CellTypeMetadata const&) const { auto js_data = cell.js_data(); auto value = TRY(js_data.to_double(cell.sheet().global_object())); diff --git a/Userland/Applications/Spreadsheet/CellType/Date.h b/Userland/Applications/Spreadsheet/CellType/Date.h index b8df17a8ff..b1aca31f5b 100644 --- a/Userland/Applications/Spreadsheet/CellType/Date.h +++ b/Userland/Applications/Spreadsheet/CellType/Date.h @@ -16,8 +16,8 @@ class DateCell : public CellType { public: DateCell(); virtual ~DateCell() override = default; - virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override; - virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override; + virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override; String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/Format.cpp b/Userland/Applications/Spreadsheet/CellType/Format.cpp index f33d11e320..82e7d31d37 100644 --- a/Userland/Applications/Spreadsheet/CellType/Format.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Format.cpp @@ -21,23 +21,23 @@ struct SingleEntryListNext { template<typename PutChFunc, typename ArgumentListRefT, template<typename T, typename U = ArgumentListRefT> typename NextArgument, typename CharType> struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument, CharType> { - ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, const int& nwritten) + ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, int const& nwritten) : PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument>(putch, bufptr, nwritten) { } // Disallow pointer formats. - ALWAYS_INLINE int format_n(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const + ALWAYS_INLINE int format_n(PrintfImplementation::ModifierState const&, ArgumentListRefT&) const { return 0; } - ALWAYS_INLINE int format_s(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const + ALWAYS_INLINE int format_s(PrintfImplementation::ModifierState const&, ArgumentListRefT&) const { return 0; } }; -String format_double(const char* format, double value) +String format_double(char const* format, double value) { StringBuilder builder; auto putch = [&](auto, auto ch) { builder.append(ch); }; diff --git a/Userland/Applications/Spreadsheet/CellType/Format.h b/Userland/Applications/Spreadsheet/CellType/Format.h index adbe79f6d1..f9684aacbc 100644 --- a/Userland/Applications/Spreadsheet/CellType/Format.h +++ b/Userland/Applications/Spreadsheet/CellType/Format.h @@ -10,6 +10,6 @@ namespace Spreadsheet { -String format_double(const char* format, double value); +String format_double(char const* format, double value); } diff --git a/Userland/Applications/Spreadsheet/CellType/Identity.cpp b/Userland/Applications/Spreadsheet/CellType/Identity.cpp index b73f026210..b44c7c5802 100644 --- a/Userland/Applications/Spreadsheet/CellType/Identity.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Identity.cpp @@ -15,7 +15,7 @@ IdentityCell::IdentityCell() { } -JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, const CellTypeMetadata& metadata) const +JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const { auto data = cell.js_data(); if (!metadata.format.is_empty()) @@ -24,7 +24,7 @@ JS::ThrowCompletionOr<String> IdentityCell::display(Cell& cell, const CellTypeMe return data.to_string(cell.sheet().global_object()); } -JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, const CellTypeMetadata&) const +JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMetadata const&) const { return cell.js_data(); } diff --git a/Userland/Applications/Spreadsheet/CellType/Identity.h b/Userland/Applications/Spreadsheet/CellType/Identity.h index 8e8cc7c701..2f43f6c820 100644 --- a/Userland/Applications/Spreadsheet/CellType/Identity.h +++ b/Userland/Applications/Spreadsheet/CellType/Identity.h @@ -15,8 +15,8 @@ class IdentityCell : public CellType { public: IdentityCell(); virtual ~IdentityCell() override = default; - virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override; - virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override; + virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override; String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp index 72c59d6529..483c55d0b4 100644 --- a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp @@ -17,7 +17,7 @@ NumericCell::NumericCell() { } -JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, const CellTypeMetadata& metadata) const +JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const { return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr<String> { auto value = TRY(js_value(cell, metadata)); @@ -34,7 +34,7 @@ JS::ThrowCompletionOr<String> NumericCell::display(Cell& cell, const CellTypeMet }); } -JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, const CellTypeMetadata&) const +JS::ThrowCompletionOr<JS::Value> NumericCell::js_value(Cell& cell, CellTypeMetadata const&) const { return propagate_failure(cell, [&]() { return cell.js_data().to_number(cell.sheet().global_object()); diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.h b/Userland/Applications/Spreadsheet/CellType/Numeric.h index d0f3b8491b..2bf94e15cc 100644 --- a/Userland/Applications/Spreadsheet/CellType/Numeric.h +++ b/Userland/Applications/Spreadsheet/CellType/Numeric.h @@ -26,8 +26,8 @@ class NumericCell : public CellType { public: NumericCell(); virtual ~NumericCell() override = default; - virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override; - virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override; + virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override; String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/String.cpp b/Userland/Applications/Spreadsheet/CellType/String.cpp index 310bda6e83..c0707be469 100644 --- a/Userland/Applications/Spreadsheet/CellType/String.cpp +++ b/Userland/Applications/Spreadsheet/CellType/String.cpp @@ -15,7 +15,7 @@ StringCell::StringCell() { } -JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, const CellTypeMetadata& metadata) const +JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const { auto string = TRY(cell.js_data().to_string(cell.sheet().global_object())); if (metadata.length >= 0) @@ -24,7 +24,7 @@ JS::ThrowCompletionOr<String> StringCell::display(Cell& cell, const CellTypeMeta return string; } -JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, const CellTypeMetadata& metadata) const +JS::ThrowCompletionOr<JS::Value> StringCell::js_value(Cell& cell, CellTypeMetadata const& metadata) const { auto string = TRY(display(cell, metadata)); return JS::js_string(cell.sheet().interpreter().heap(), string); diff --git a/Userland/Applications/Spreadsheet/CellType/String.h b/Userland/Applications/Spreadsheet/CellType/String.h index aecf1a23a6..ed6333af7a 100644 --- a/Userland/Applications/Spreadsheet/CellType/String.h +++ b/Userland/Applications/Spreadsheet/CellType/String.h @@ -15,8 +15,8 @@ class StringCell : public CellType { public: StringCell(); virtual ~StringCell() override = default; - virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const override; - virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const override; + virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const override; String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/Type.cpp b/Userland/Applications/Spreadsheet/CellType/Type.cpp index 5690d8b64b..e75665fbbc 100644 --- a/Userland/Applications/Spreadsheet/CellType/Type.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Type.cpp @@ -20,7 +20,7 @@ static Spreadsheet::DateCell s_date_cell; namespace Spreadsheet { -const CellType* CellType::get_by_name(StringView name) +CellType const* CellType::get_by_name(StringView name) { return s_cell_types.get(name).value_or(nullptr); } diff --git a/Userland/Applications/Spreadsheet/CellType/Type.h b/Userland/Applications/Spreadsheet/CellType/Type.h index 10d27027d8..2418c900f3 100644 --- a/Userland/Applications/Spreadsheet/CellType/Type.h +++ b/Userland/Applications/Spreadsheet/CellType/Type.h @@ -32,15 +32,15 @@ enum class MetadataName { class CellType { public: - static const CellType* get_by_name(StringView); + static CellType const* get_by_name(StringView); static Vector<StringView> names(); - virtual JS::ThrowCompletionOr<String> display(Cell&, const CellTypeMetadata&) const = 0; - virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, const CellTypeMetadata&) const = 0; + virtual JS::ThrowCompletionOr<String> display(Cell&, CellTypeMetadata const&) const = 0; + virtual JS::ThrowCompletionOr<JS::Value> js_value(Cell&, CellTypeMetadata const&) const = 0; virtual String metadata_hint(MetadataName) const { return {}; } virtual ~CellType() = default; - const String& name() const { return m_name; } + String const& name() const { return m_name; } protected: CellType(StringView name); diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp index 5775900eaf..045966650c 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp @@ -29,7 +29,7 @@ REGISTER_WIDGET(Spreadsheet, ConditionsView); namespace Spreadsheet { -CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet, GUI::Window* parent) +CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet, GUI::Window* parent) : GUI::Dialog(parent) { VERIFY(!positions.is_empty()); @@ -62,8 +62,8 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet, ok_button.on_click = [&](auto) { done(ExecOK); }; } -const Vector<String> g_horizontal_alignments { "Left", "Center", "Right" }; -const Vector<String> g_vertical_alignments { "Top", "Center", "Bottom" }; +Vector<String> const g_horizontal_alignments { "Left", "Center", "Right" }; +Vector<String> const g_vertical_alignments { "Top", "Center", "Bottom" }; Vector<String> g_types; constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::TextAlignment alignment) @@ -110,7 +110,7 @@ constexpr static CellTypeDialog::HorizontalAlignment horizontal_alignment_from(G return CellTypeDialog::HorizontalAlignment::Right; } -void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& positions, Sheet& sheet) +void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& positions, Sheet& sheet) { g_types.clear(); for (auto& type_name : CellType::names()) diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.h b/Userland/Applications/Spreadsheet/CellTypeDialog.h index d9f7955eb6..f260ddf818 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.h +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.h @@ -18,7 +18,7 @@ class CellTypeDialog : public GUI::Dialog { public: CellTypeMetadata metadata() const; - const CellType* type() const { return m_type; } + CellType const* type() const { return m_type; } Vector<ConditionalFormat> conditional_formats() { return m_conditional_formats; } enum class HorizontalAlignment : int { @@ -33,10 +33,10 @@ public: }; private: - CellTypeDialog(const Vector<Position>&, Sheet&, GUI::Window* parent = nullptr); - void setup_tabs(GUI::TabWidget&, const Vector<Position>&, Sheet&); + CellTypeDialog(Vector<Position> const&, Sheet&, GUI::Window* parent = nullptr); + void setup_tabs(GUI::TabWidget&, Vector<Position> const&, Sheet&); - const CellType* m_type { nullptr }; + CellType const* m_type { nullptr }; int m_length { -1 }; String m_format; diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp index d16c1b55dc..31dc703b98 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp @@ -26,11 +26,11 @@ #include <unistd.h> // This is defined in ImportDialog.cpp, we can't include it twice, since the generated symbol is exported. -extern const char select_format_page_gml[]; +extern char const select_format_page_gml[]; namespace Spreadsheet { -CSVExportDialogPage::CSVExportDialogPage(const Sheet& sheet) +CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet) : m_data(sheet.to_xsv()) { m_headers.extend(m_data.take_first()); @@ -213,7 +213,7 @@ void CSVExportDialogPage::update_preview() m_data_preview_text_editor->update(); } -Result<void, String> CSVExportDialogPage::move_into(const String& target) +Result<void, String> CSVExportDialogPage::move_into(String const& target) { auto& source = m_temp_output_file_path; diff --git a/Userland/Applications/Spreadsheet/ExportDialog.h b/Userland/Applications/Spreadsheet/ExportDialog.h index 59439a29a1..3618ac0793 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.h +++ b/Userland/Applications/Spreadsheet/ExportDialog.h @@ -20,11 +20,11 @@ class Workbook; struct CSVExportDialogPage { using XSV = Writer::XSV<Vector<Vector<String>>, Vector<String>>; - explicit CSVExportDialogPage(const Sheet&); + explicit CSVExportDialogPage(Sheet const&); NonnullRefPtr<GUI::WizardPage> page() { return *m_page; } Optional<XSV>& writer() { return m_previously_made_writer; } - Result<void, String> move_into(const String& target); + Result<void, String> move_into(String const& target); protected: void update_preview(); diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp index 1b24930cc4..f498527712 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.cpp +++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp @@ -39,7 +39,7 @@ public: String key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; } - void set_from(const JsonObject& object) + void set_from(JsonObject const& object) { m_keys.clear(); object.for_each_member([this](auto& name, auto&) { diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index 18314b36a2..a3a047bf27 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -186,7 +186,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) if (!position.has_value()) return vm.throw_completion<JS::TypeError>(global_object, "Invalid cell name"); - const auto* cell = sheet_object->m_sheet.at(position.value()); + auto const* cell = sheet_object->m_sheet.at(position.value()); if (!cell) return JS::js_undefined(); diff --git a/Userland/Applications/Spreadsheet/Position.h b/Userland/Applications/Spreadsheet/Position.h index 301add499e..a1f43ccd1c 100644 --- a/Userland/Applications/Spreadsheet/Position.h +++ b/Userland/Applications/Spreadsheet/Position.h @@ -32,18 +32,18 @@ struct Position { return m_hash; } - bool operator==(const Position& other) const + bool operator==(Position const& other) const { return row == other.row && column == other.column; } - bool operator!=(const Position& other) const + bool operator!=(Position const& other) const { return !(other == *this); } - String to_cell_identifier(const Sheet& sheet) const; - URL to_url(const Sheet& sheet) const; + String to_cell_identifier(Sheet const& sheet) const; + URL to_url(Sheet const& sheet) const; size_t column { 0 }; size_t row { 0 }; diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.cpp b/Userland/Applications/Spreadsheet/Readers/XSV.cpp index 9039ee0f99..4170743195 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.cpp +++ b/Userland/Applications/Spreadsheet/Readers/XSV.cpp @@ -274,7 +274,7 @@ XSV::Field XSV::read_one_unquoted_field() StringView XSV::Row::operator[](StringView name) const { VERIFY(!m_xsv.m_names.is_empty()); - auto it = m_xsv.m_names.find_if([&](const auto& entry) { return name == entry; }); + auto it = m_xsv.m_names.find_if([&](auto const& entry) { return name == entry; }); VERIFY(!it.is_end()); return (*this)[it.index()]; diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.h b/Userland/Applications/Spreadsheet/Readers/XSV.h index 63e7e3d9ef..9962dedf60 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.h +++ b/Userland/Applications/Spreadsheet/Readers/XSV.h @@ -146,11 +146,11 @@ public: } bool is_end() const { return m_index == m_xsv.m_rows.size(); } - bool operator==(const RowIterator& other) const + bool operator==(RowIterator const& other) const { return m_index == other.m_index && &m_xsv == &other.m_xsv; } - bool operator==(const RowIterator<!const_>& other) const + bool operator==(RowIterator<!const_> const& other) const { return m_index == other.m_index && &m_xsv == &other.m_xsv; } diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 14efb02f59..c8cee6ef0e 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -182,7 +182,7 @@ Cell* Sheet::at(StringView name) return nullptr; } -Cell* Sheet::at(const Position& position) +Cell* Sheet::at(Position const& position) { auto it = m_cells.find(position); @@ -271,7 +271,7 @@ Optional<Position> Sheet::position_from_url(const URL& url) const return parse_cell_name(url.fragment()); } -Position Sheet::offset_relative_to(const Position& base, const Position& offset, const Position& offset_base) const +Position Sheet::offset_relative_to(Position const& base, Position const& offset, Position const& offset_base) const { if (offset.column >= m_columns.size()) { dbgln("Column '{}' does not exist!", offset.column); @@ -361,7 +361,7 @@ void Sheet::copy_cells(Vector<Position> from, Vector<Position> to, Optional<Posi } } -RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook) +RefPtr<Sheet> Sheet::from_json(JsonObject const& object, Workbook& workbook) { auto sheet = adopt_ref(*new Sheet(workbook)); auto rows = object.get("rows").to_u32(default_row_count); @@ -391,7 +391,7 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook) auto json = sheet->interpreter().global_object().get_without_side_effects("JSON"); auto& parse_function = json.as_object().get_without_side_effects("parse").as_function(); - auto read_format = [](auto& format, const auto& obj) { + auto read_format = [](auto& format, auto const& obj) { if (auto value = obj.get("foreground_color"); value.is_string()) format.foreground_color = Color::from_string(value.as_string()); if (auto value = obj.get("background_color"); value.is_string()) @@ -519,7 +519,7 @@ JsonObject Sheet::to_json() const JsonObject object; object.set("name", m_name); - auto save_format = [](const auto& format, auto& obj) { + auto save_format = [](auto const& format, auto& obj) { if (format.foreground_color.has_value()) obj.set("foreground_color", format.foreground_color.value().to_string()); if (format.background_color.has_value()) @@ -629,7 +629,7 @@ Vector<Vector<String>> Sheet::to_xsv() const return data; } -RefPtr<Sheet> Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook) +RefPtr<Sheet> Sheet::from_xsv(Reader::XSV const& xsv, Workbook& workbook) { auto cols = xsv.headers(); auto rows = xsv.size(); @@ -736,12 +736,12 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu return builder.build(); } -String Position::to_cell_identifier(const Sheet& sheet) const +String Position::to_cell_identifier(Sheet const& sheet) const { return String::formatted("{}{}", sheet.column(column), row); } -URL Position::to_url(const Sheet& sheet) const +URL Position::to_url(Sheet const& sheet) const { URL url; url.set_protocol("spreadsheet"); diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.h b/Userland/Applications/Spreadsheet/Spreadsheet.h index a3bf270df2..6aa5b0e3db 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.h +++ b/Userland/Applications/Spreadsheet/Spreadsheet.h @@ -36,37 +36,37 @@ public: Optional<String> column_arithmetic(StringView column_name, int offset); Cell* from_url(const URL&); - const Cell* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); } + Cell const* from_url(const URL& url) const { return const_cast<Sheet*>(this)->from_url(url); } Optional<Position> position_from_url(const URL& url) const; /// Resolve 'offset' to an absolute position assuming 'base' is at 'offset_base'. /// Effectively, "Walk the distance between 'offset' and 'offset_base' away from 'base'". - Position offset_relative_to(const Position& base, const Position& offset, const Position& offset_base) const; + Position offset_relative_to(Position const& base, Position const& offset, Position const& offset_base) const; JsonObject to_json() const; - static RefPtr<Sheet> from_json(const JsonObject&, Workbook&); + static RefPtr<Sheet> from_json(JsonObject const&, Workbook&); Vector<Vector<String>> to_xsv() const; - static RefPtr<Sheet> from_xsv(const Reader::XSV&, Workbook&); + static RefPtr<Sheet> from_xsv(Reader::XSV const&, Workbook&); - const String& name() const { return m_name; } + String const& name() const { return m_name; } void set_name(StringView name) { m_name = name; } JsonObject gather_documentation() const; - const HashTable<Position>& selected_cells() const { return m_selected_cells; } + HashTable<Position> const& selected_cells() const { return m_selected_cells; } HashTable<Position>& selected_cells() { return m_selected_cells; } - const HashMap<Position, NonnullOwnPtr<Cell>>& cells() const { return m_cells; } + HashMap<Position, NonnullOwnPtr<Cell>> const& cells() const { return m_cells; } HashMap<Position, NonnullOwnPtr<Cell>>& cells() { return m_cells; } - Cell* at(const Position& position); - const Cell* at(const Position& position) const { return const_cast<Sheet*>(this)->at(position); } + Cell* at(Position const& position); + Cell const* at(Position const& position) const { return const_cast<Sheet*>(this)->at(position); } - const Cell* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); } + Cell const* at(StringView name) const { return const_cast<Sheet*>(this)->at(name); } Cell* at(StringView); - const Cell& ensure(const Position& position) const { return const_cast<Sheet*>(this)->ensure(position); } - Cell& ensure(const Position& position) + Cell const& ensure(Position const& position) const { return const_cast<Sheet*>(this)->ensure(position); } + Cell& ensure(Position const& position) { if (auto cell = at(position)) return *cell; @@ -80,8 +80,8 @@ public: size_t row_count() const { return m_rows; } size_t column_count() const { return m_columns.size(); } - const Vector<String>& columns() const { return m_columns; } - const String& column(size_t index) + Vector<String> const& columns() const { return m_columns; } + String const& column(size_t index) { for (size_t i = column_count(); i < index; ++i) add_column(); @@ -89,7 +89,7 @@ public: VERIFY(column_count() > index); return m_columns[index]; } - const String& column(size_t index) const + String const& column(size_t index) const { VERIFY(column_count() > index); return m_columns[index]; @@ -114,7 +114,7 @@ public: Cell*& current_evaluated_cell() { return m_current_cell_being_evaluated; } bool has_been_visited(Cell* cell) const { return m_visited_cells_in_update.contains(cell); } - const Workbook& workbook() const { return m_workbook; } + Workbook const& workbook() const { return m_workbook; } enum class CopyOperation { Copy, @@ -160,7 +160,7 @@ namespace AK { template<> struct Traits<Spreadsheet::Position> : public GenericTraits<Spreadsheet::Position> { static constexpr bool is_trivial() { return false; } - static unsigned hash(const Spreadsheet::Position& p) + static unsigned hash(Spreadsheet::Position const& p) { return p.hash(); } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index e7980430f0..b190788b7a 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -19,7 +19,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) return {}; if (role == GUI::ModelRole::Display) { - const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); + auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); if (!cell) return String::empty(); @@ -63,7 +63,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_string(); if (role == GUI::ModelRole::TextAlignment) { - const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); + auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); if (!cell) return {}; @@ -71,7 +71,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) } if (role == GUI::ModelRole::ForegroundColor) { - const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); + auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); if (!cell) return {}; @@ -90,7 +90,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) } if (role == GUI::ModelRole::BackgroundColor) { - const auto* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); + auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); if (!cell) return {}; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index ce8b46665f..0f2ce5765e 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -32,7 +32,7 @@ void SpreadsheetView::EditingDelegate::set_value(GUI::Variant const& value, GUI: return StringModelEditingDelegate::set_value(value, selection_behavior); m_has_set_initial_value = true; - const auto option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() }); + auto const option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() }); if (option) return StringModelEditingDelegate::set_value(option->source(), selection_behavior); @@ -461,7 +461,7 @@ void SpreadsheetView::move_cursor(GUI::AbstractView::CursorMovement direction) m_table_view->move_cursor(direction, GUI::AbstractView::SelectionUpdate::Set); } -void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::Palette& palette, const GUI::ModelIndex& index) +void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, Gfx::IntRect const& rect, Gfx::Palette const& palette, const GUI::ModelIndex& index) { // Draw a border. // Undo the horizontal padding done by the table view... diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.h b/Userland/Applications/Spreadsheet/SpreadsheetView.h index aacc0c84cb..2723ed32a7 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.h @@ -121,7 +121,7 @@ private: class EditingDelegate final : public GUI::StringModelEditingDelegate { public: - EditingDelegate(const Sheet& sheet) + EditingDelegate(Sheet const& sheet) : m_sheet(sheet) { } @@ -148,7 +148,7 @@ private: private: bool m_has_set_initial_value { false }; - const Sheet& m_sheet; + Sheet const& m_sheet; }; class TableCellPainter final : public GUI::TableCellPaintingDelegate { @@ -157,7 +157,7 @@ private: : m_table_view(view) { } - void paint(GUI::Painter&, const Gfx::IntRect&, const Gfx::Palette&, const GUI::ModelIndex&) override; + void paint(GUI::Painter&, Gfx::IntRect const&, Gfx::Palette const&, const GUI::ModelIndex&) override; private: const GUI::TableView& m_table_view; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h index b21b103178..ef1c5dcfa0 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h @@ -26,13 +26,13 @@ public: void add_sheet(); void add_sheet(NonnullRefPtr<Sheet>&&); - const String& current_filename() const { return m_workbook->current_filename(); } + String const& current_filename() const { return m_workbook->current_filename(); } SpreadsheetView* current_view() { return static_cast<SpreadsheetView*>(m_tab_widget->active_widget()); } Sheet* current_worksheet_if_available() { return current_view() ? current_view()->sheet_if_available() : nullptr; } void update_window_title(); Workbook& workbook() { return *m_workbook; } - const Workbook& workbook() const { return *m_workbook; } + Workbook const& workbook() const { return *m_workbook; } const GUI::ModelIndex* current_selection_cursor() { diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index 6756b9eafb..73d4e0fe87 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -43,7 +43,7 @@ Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_wind m_vm->enable_default_host_import_module_dynamically_hook(); } -bool Workbook::set_filename(const String& filename) +bool Workbook::set_filename(String const& filename) { if (m_current_filename == filename) return false; diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h index 5c570b21e0..5a035e11ec 100644 --- a/Userland/Applications/Spreadsheet/Workbook.h +++ b/Userland/Applications/Spreadsheet/Workbook.h @@ -21,14 +21,14 @@ public: Result<bool, String> load(StringView filename); Result<bool, String> open_file(Core::File&); - const String& current_filename() const { return m_current_filename; } - bool set_filename(const String& filename); + String const& current_filename() const { return m_current_filename; } + bool set_filename(String const& filename); bool dirty() { return m_dirty; } void set_dirty(bool dirty) { m_dirty = dirty; } bool has_sheets() const { return !m_sheets.is_empty(); } - const NonnullRefPtrVector<Sheet>& sheets() const { return m_sheets; } + NonnullRefPtrVector<Sheet> const& sheets() const { return m_sheets; } NonnullRefPtrVector<Sheet> sheets() { return m_sheets; } Sheet& add_sheet(StringView name) diff --git a/Userland/Applications/Spreadsheet/Writers/CSV.h b/Userland/Applications/Spreadsheet/Writers/CSV.h index d7650e760a..92c3adfe06 100644 --- a/Userland/Applications/Spreadsheet/Writers/CSV.h +++ b/Userland/Applications/Spreadsheet/Writers/CSV.h @@ -15,7 +15,7 @@ namespace Writer { template<typename ContainerType> class CSV : public XSV<ContainerType> { public: - CSV(OutputStream& output, const ContainerType& data, const Vector<StringView>& headers = {}, WriterBehavior behaviors = default_behaviors()) + CSV(OutputStream& output, ContainerType const& data, Vector<StringView> const& headers = {}, WriterBehavior behaviors = default_behaviors()) : XSV<ContainerType>(output, data, { ",", "\"", WriterTraits::Repeat }, headers, behaviors) { } diff --git a/Userland/Applications/Spreadsheet/Writers/XSV.h b/Userland/Applications/Spreadsheet/Writers/XSV.h index 6e1bd8548f..006bc53ce3 100644 --- a/Userland/Applications/Spreadsheet/Writers/XSV.h +++ b/Userland/Applications/Spreadsheet/Writers/XSV.h @@ -62,7 +62,7 @@ constexpr WriterBehavior default_behaviors() template<typename ContainerType, typename HeaderType = Vector<StringView>> class XSV { public: - XSV(OutputStream& output, const ContainerType& data, const WriterTraits& traits, const HeaderType& headers = {}, WriterBehavior behaviors = default_behaviors()) + XSV(OutputStream& output, ContainerType const& data, WriterTraits const& traits, HeaderType const& headers = {}, WriterBehavior behaviors = default_behaviors()) : m_data(data) , m_traits(traits) , m_behaviors(behaviors) @@ -188,10 +188,10 @@ private: set_error(WriteError::InternalError); } - const ContainerType& m_data; - const WriterTraits& m_traits; + ContainerType const& m_data; + WriterTraits const& m_traits; WriterBehavior m_behaviors; - const HeaderType& m_names; + HeaderType const& m_names; WriteError m_error { WriteError::None }; OutputStream& m_output; }; diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 088bdbfba8..210c7da977 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = GUI::Application::construct(arguments); - const char* filename = nullptr; + char const* filename = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(filename, "File to read from", "file", Core::ArgsParser::Required::No); diff --git a/Userland/Applications/SystemMonitor/GraphWidget.cpp b/Userland/Applications/SystemMonitor/GraphWidget.cpp index 238fbb3372..d32c21a83d 100644 --- a/Userland/Applications/SystemMonitor/GraphWidget.cpp +++ b/Userland/Applications/SystemMonitor/GraphWidget.cpp @@ -21,7 +21,7 @@ void GraphWidget::add_value(Vector<u64, 1>&& value) void GraphWidget::paint_event(GUI::PaintEvent& event) { - const auto& system_palette = GUI::Application::the()->palette(); + auto const& system_palette = GUI::Application::the()->palette(); GUI::Frame::paint_event(event); GUI::Painter painter(*this); @@ -35,18 +35,18 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) if (!m_values.is_empty()) { // Draw one set of values at a time for (size_t k = 0; k < m_value_format.size(); k++) { - const auto& format = m_value_format[k]; + auto const& format = m_value_format[k]; if (format.graph_color_role == ColorRole::Base) { continue; } - const auto& line_color = system_palette.color(format.graph_color_role); - const auto& background_color = line_color.with_alpha(0x7f); + auto const& line_color = system_palette.color(format.graph_color_role); + auto const& background_color = line_color.with_alpha(0x7f); m_calculated_points.clear_with_capacity(); for (size_t i = 0; i < m_values.size(); i++) { int x = inner_rect.right() - (i * 2) + 1; if (x < 0) break; - const auto& current_values = m_values.at(m_values.size() - i - 1); + auto const& current_values = m_values.at(m_values.size() - i - 1); if (current_values.size() <= k) { // Don't have a data point m_calculated_points.append({ -1, -1 }); @@ -67,8 +67,8 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) Gfx::Path path; size_t points_in_path = 0; bool started_path = false; - const Gfx::IntPoint* current_point = nullptr; - const Gfx::IntPoint* first_point = nullptr; + Gfx::IntPoint const* current_point = nullptr; + Gfx::IntPoint const* first_point = nullptr; auto check_fill_area = [&]() { if (!started_path) return; @@ -109,9 +109,9 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) } if (format.graph_color_role != ColorRole::Base) { // Draw the line for the data points we have - const Gfx::IntPoint* previous_point = nullptr; + Gfx::IntPoint const* previous_point = nullptr; for (size_t i = 0; i < m_calculated_points.size(); i++) { - const auto& current_point = m_calculated_points[i]; + auto const& current_point = m_calculated_points[i]; if (current_point.x() < 0) { previous_point = nullptr; continue; @@ -125,11 +125,11 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) } if (!m_values.is_empty() && !m_value_format.is_empty()) { - const auto& current_values = m_values.last(); + auto const& current_values = m_values.last(); int y = 0; for (size_t i = 0; i < min(m_value_format.size(), current_values.size()); i++) { - const auto& format = m_value_format[i]; - const auto& graph_color = system_palette.color(format.graph_color_role); + auto const& format = m_value_format[i]; + auto const& graph_color = system_palette.color(format.graph_color_role); if (!format.text_formatter) continue; auto constrain_rect = inner_rect.shrunken(8, 8); diff --git a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp index 398eead9a2..80df7ac14a 100644 --- a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -36,7 +36,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph) layout()->set_margins({ 8, 0, 0 }); layout()->set_spacing(3); - auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> { + auto build_widgets_for_label = [this](String const& description) -> RefPtr<GUI::Label> { auto& container = add<GUI::Widget>(); container.set_layout<GUI::HorizontalBoxLayout>(); container.set_fixed_size(275, 12); diff --git a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index 3295892092..5216c90a4a 100644 --- a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -18,7 +18,7 @@ class PagemapPaintingDelegate final : public GUI::TableCellPaintingDelegate { public: virtual ~PagemapPaintingDelegate() override = default; - virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Gfx::Palette&, const GUI::ModelIndex& index) override + virtual void paint(GUI::Painter& painter, Gfx::IntRect const& a_rect, Gfx::Palette const&, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); auto pagemap = index.data(GUI::ModelRole::Custom).to_string(); @@ -93,7 +93,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget() [](auto&) { return GUI::Variant(0); }, - [](const JsonObject& object) { + [](JsonObject const& object) { auto pagemap = object.get("pagemap").as_string_or({}); return pagemap; }); diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index e9f8c90a54..e3f96643b1 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -64,7 +64,7 @@ class UnavailableProcessWidget final : public GUI::Frame { public: virtual ~UnavailableProcessWidget() override = default; - const String& text() const { return m_text; } + String const& text() const { return m_text; } void set_text(String text) { m_text = move(text); } private: @@ -390,7 +390,7 @@ class ProgressbarPaintingDelegate final : public GUI::TableCellPaintingDelegate public: virtual ~ProgressbarPaintingDelegate() override = default; - virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Palette& palette, const GUI::ModelIndex& index) override + virtual void paint(GUI::Painter& painter, Gfx::IntRect const& a_rect, Palette const& palette, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); auto percentage = index.data(GUI::ModelRole::Custom).to_i32(); @@ -707,7 +707,7 @@ NonnullRefPtr<GUI::Widget> build_performance_tab() cpu_graphs.append(cpu_graph); } } - ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) mutable { + ProcessModel::the().on_cpu_info_change = [cpu_graphs](NonnullOwnPtrVector<ProcessModel::CpuInfo> const& cpus) mutable { float sum_cpu = 0; for (size_t i = 0; i < cpus.size(); ++i) { cpu_graphs[i].add_value({ static_cast<size_t>(cpus[i].total_cpu_percent), static_cast<size_t>(cpus[i].total_cpu_percent_kernel) }); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 0d206343e3..75993d391f 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -141,7 +141,7 @@ static void run_command(String command, bool keep_open) } endpwent(); - const char* args[5] = { shell.characters(), nullptr, nullptr, nullptr, nullptr }; + char const* args[5] = { shell.characters(), nullptr, nullptr, nullptr, nullptr }; if (!command.is_empty()) { int arg_index = 1; if (keep_open) @@ -149,7 +149,7 @@ static void run_command(String command, bool keep_open) args[arg_index++] = "-c"; args[arg_index++] = command.characters(); } - const char* envs[] = { "TERM=xterm", "PAGER=more", "PATH=/usr/local/bin:/usr/bin:/bin", nullptr }; + char const* envs[] = { "TERM=xterm", "PAGER=more", "PATH=/usr/local/bin:/usr/bin:/bin", nullptr }; int rc = execve(shell.characters(), const_cast<char**>(args), const_cast<char**>(envs)); if (rc < 0) { perror("execve"); @@ -247,7 +247,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) Config::pledge_domain("Terminal"); - const char* command_to_execute = nullptr; + char const* command_to_execute = nullptr; bool keep_open = false; Core::ArgsParser args_parser; diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index 0c23c73ae1..a25cb4add0 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -30,7 +30,7 @@ class MiniWidgetGallery final : public GUI::Widget { C_OBJECT(MiniWidgetGallery); public: - void set_preview_palette(const Gfx::Palette& palette) + void set_preview_palette(Gfx::Palette const& palette) { set_palette(palette); Function<void(GUI::Widget&)> recurse = [&](GUI::Widget& parent_widget) { @@ -79,7 +79,7 @@ private: RefPtr<GUI::Statusbar> m_statusbar; }; -PreviewWidget::PreviewWidget(const Gfx::Palette& preview_palette) +PreviewWidget::PreviewWidget(Gfx::Palette const& preview_palette) : m_preview_palette(preview_palette) { m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors(); @@ -131,7 +131,7 @@ void PreviewWidget::load_theme_bitmaps() load_bitmap(m_preview_palette.tooltip_shadow_path(), m_last_tooltip_shadow_path, m_tooltip_shadow); } -void PreviewWidget::set_preview_palette(const Gfx::Palette& palette) +void PreviewWidget::set_preview_palette(Gfx::Palette const& palette) { m_preview_palette = palette; m_gallery->set_preview_palette(palette); @@ -172,7 +172,7 @@ void PreviewWidget::paint_event(GUI::PaintEvent& event) RefPtr<Gfx::Bitmap> bitmap; }; - auto paint_window = [&](auto& title, const Gfx::IntRect& rect, auto state, const Gfx::Bitmap& icon) { + auto paint_window = [&](auto& title, Gfx::IntRect const& rect, auto state, Gfx::Bitmap const& icon) { int window_button_width = m_preview_palette.window_title_button_width(); int window_button_height = m_preview_palette.window_title_button_height(); auto titlebar_text_rect = Gfx::WindowTheme::current().titlebar_text_rect(Gfx::WindowTheme::WindowType::Normal, rect, m_preview_palette); diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.h b/Userland/Applications/ThemeEditor/PreviewWidget.h index f096c8cd89..746c5a464a 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.h +++ b/Userland/Applications/ThemeEditor/PreviewWidget.h @@ -24,8 +24,8 @@ class PreviewWidget final : public GUI::Frame { public: virtual ~PreviewWidget() override = default; - const Gfx::Palette& preview_palette() const { return m_preview_palette; } - void set_preview_palette(const Gfx::Palette&); + Gfx::Palette const& preview_palette() const { return m_preview_palette; } + void set_preview_palette(Gfx::Palette const&); void set_theme_from_file(Core::File&); void set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter>); @@ -33,7 +33,7 @@ public: Function<void(String const&)> on_theme_load_from_file; private: - explicit PreviewWidget(const Gfx::Palette&); + explicit PreviewWidget(Gfx::Palette const&); void load_theme_bitmaps(); diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index fa58efbc2f..ba5006ccde 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -35,7 +35,7 @@ class ColorRoleModel final : public GUI::ItemListModel<Gfx::ColorRole> { public: - explicit ColorRoleModel(const Vector<Gfx::ColorRole>& data) + explicit ColorRoleModel(Vector<Gfx::ColorRole> const& data) : ItemListModel<Gfx::ColorRole>(data) { } diff --git a/Userland/Demos/Cube/Cube.cpp b/Userland/Demos/Cube/Cube.cpp index 224958d7c4..5fc00d9812 100644 --- a/Userland/Demos/Cube/Cube.cpp +++ b/Userland/Demos/Cube/Cube.cpp @@ -24,8 +24,8 @@ #include <stdlib.h> #include <unistd.h> -const int WIDTH = 200; -const int HEIGHT = 200; +int const WIDTH = 200; +int const HEIGHT = 200; static bool flag_hide_window_frame = false; @@ -97,7 +97,7 @@ void Cube::timer_event(Core::TimerEvent&) #define QUAD(a, b, c, d) a, b, c, c, d, a - const int indices[] { + int const indices[] { QUAD(0, 1, 2, 3), QUAD(7, 6, 5, 4), QUAD(4, 5, 1, 0), @@ -141,7 +141,7 @@ void Cube::timer_event(Core::TimerEvent&) else painter.clear_rect(m_bitmap->rect(), Gfx::Color::Transparent); - auto to_point = [](const FloatVector3& v) { + auto to_point = [](FloatVector3 const& v) { return Gfx::IntPoint(v.x(), v.y()); }; diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp index 81e23375fe..6baa3afeda 100644 --- a/Userland/Demos/LibGfxDemo/main.cpp +++ b/Userland/Demos/LibGfxDemo/main.cpp @@ -21,8 +21,8 @@ #include <LibMain/Main.h> #include <unistd.h> -const int WIDTH = 780; -const int HEIGHT = 600; +int const WIDTH = 780; +int const HEIGHT = 600; class Canvas final : public GUI::Widget { C_OBJECT(Canvas) diff --git a/Userland/Demos/LibGfxScaleDemo/main.cpp b/Userland/Demos/LibGfxScaleDemo/main.cpp index 84a8ba3bf0..68295579df 100644 --- a/Userland/Demos/LibGfxScaleDemo/main.cpp +++ b/Userland/Demos/LibGfxScaleDemo/main.cpp @@ -24,8 +24,8 @@ #include <LibMain/Main.h> #include <unistd.h> -const int WIDTH = 300; -const int HEIGHT = 200; +int const WIDTH = 300; +int const HEIGHT = 200; class Canvas final : public GUI::Widget { C_OBJECT(Canvas) diff --git a/Userland/Demos/Mandelbrot/Mandelbrot.cpp b/Userland/Demos/Mandelbrot/Mandelbrot.cpp index 4284a89467..7243314b47 100644 --- a/Userland/Demos/Mandelbrot/Mandelbrot.cpp +++ b/Userland/Demos/Mandelbrot/Mandelbrot.cpp @@ -85,8 +85,8 @@ public: double mandelbrot(double px, double py, i32 max_iterations) { // Based on https://en.wikipedia.org/wiki/Plotting_algorithms_for_the_Mandelbrot_set - const double x0 = px * (m_x_end - m_x_start) / m_bitmap->width() + m_x_start; - const double y0 = py * (m_y_end - m_y_start) / m_bitmap->height() + m_y_start; + double const x0 = px * (m_x_end - m_x_start) / m_bitmap->width() + m_x_start; + double const y0 = py * (m_y_end - m_y_start) / m_bitmap->height() + m_y_start; double x = 0; double y = 0; i32 iteration = 0; @@ -215,7 +215,7 @@ class Mandelbrot : public GUI::Frame { In, Out, }; - void zoom(Zoom in_out, const Gfx::IntPoint& center); + void zoom(Zoom in_out, Gfx::IntPoint const& center); void reset(); @@ -239,7 +239,7 @@ private: MandelbrotSet m_set; }; -void Mandelbrot::zoom(Zoom in_out, const Gfx::IntPoint& center) +void Mandelbrot::zoom(Zoom in_out, Gfx::IntPoint const& center) { static constexpr double zoom_in_multiplier = 0.8; static constexpr double zoom_out_multiplier = 1.25; diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 71e03944e6..0c37668bd3 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -56,7 +56,7 @@ GalleryWidget::GalleryWidget() m_frame_shape_combobox = basics_tab->find_descendant_of_type_named<GUI::ComboBox>("frame_shape_combobox"); m_frame_shape_combobox->set_model(*GUI::ItemListModel<String>::create(m_frame_shapes)); - m_frame_shape_combobox->on_change = [&](auto&, const auto& index) { + m_frame_shape_combobox->on_change = [&](auto&, auto const& index) { m_label_frame->set_frame_shape(static_cast<Gfx::FrameShape>((index.row() - 1) % 3 + 1)); m_label_frame->set_frame_shadow(static_cast<Gfx::FrameShadow>((index.row() - 1) / 3)); m_label_frame->update(); @@ -153,7 +153,7 @@ GalleryWidget::GalleryWidget() m_msgbox_icon_combobox->set_model(*GUI::ItemListModel<String>::create(m_msgbox_icons)); m_msgbox_icon_combobox->set_selected_index(0); - m_msgbox_icon_combobox->on_change = [&](auto&, const auto& index) { + m_msgbox_icon_combobox->on_change = [&](auto&, auto const& index) { m_msgbox_type = static_cast<GUI::MessageBox::Type>(index.row()); }; @@ -161,7 +161,7 @@ GalleryWidget::GalleryWidget() m_msgbox_buttons_combobox->set_model(*GUI::ItemListModel<String>::create(m_msgbox_buttons)); m_msgbox_buttons_combobox->set_selected_index(0); - m_msgbox_buttons_combobox->on_change = [&](auto&, const auto& index) { + m_msgbox_buttons_combobox->on_change = [&](auto&, auto const& index) { m_msgbox_input_type = static_cast<GUI::MessageBox::InputType>(index.row()); }; @@ -237,7 +237,7 @@ GalleryWidget::GalleryWidget() m_wizard_output = wizards_tab->find_descendant_of_type_named<GUI::TextEditor>("wizard_output"); m_wizard_output->set_should_hide_unnecessary_scrollbars(true); - const char* serenityos_ascii = { + char const* serenityos_ascii = { " ____ _ __ ____ ____\n" " / __/__ _______ ___ (_) /___ __/ __ \\/ __/\n" " _\\ \\/ -_) __/ -_) _ \\/ / __/ // / /_/ /\\ \\\n" @@ -245,7 +245,7 @@ GalleryWidget::GalleryWidget() " /___/\n" }; - const char* wizard_ascii = { + char const* wizard_ascii = { " _,-'|\n" " ,-'._ |\n" " .||, |####\\ |\n" diff --git a/Userland/DevTools/HackStudio/ClassViewWidget.cpp b/Userland/DevTools/HackStudio/ClassViewWidget.cpp index d620897308..ac1d9c1a32 100644 --- a/Userland/DevTools/HackStudio/ClassViewWidget.cpp +++ b/Userland/DevTools/HackStudio/ClassViewWidget.cpp @@ -46,7 +46,7 @@ int ClassViewModel::row_count(const GUI::ModelIndex& index) const GUI::Variant ClassViewModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* node = static_cast<const ClassViewNode*>(index.internal_data()); + auto* node = static_cast<ClassViewNode const*>(index.internal_data()); switch (role) { case GUI::ModelRole::Display: { return node->name; @@ -68,7 +68,7 @@ GUI::ModelIndex ClassViewModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* child = static_cast<const ClassViewNode*>(index.internal_data()); + auto* child = static_cast<ClassViewNode const*>(index.internal_data()); auto* parent = child->parent; if (parent == nullptr) return {}; @@ -92,7 +92,7 @@ GUI::ModelIndex ClassViewModel::index(int row, int column, const GUI::ModelIndex { if (!parent_index.is_valid()) return create_index(row, column, &m_root_scope[row]); - auto* parent = static_cast<const ClassViewNode*>(parent_index.internal_data()); + auto* parent = static_cast<ClassViewNode const*>(parent_index.internal_data()); auto* child = &parent->children[row]; return create_index(row, column, child); } diff --git a/Userland/DevTools/HackStudio/CodeDocument.cpp b/Userland/DevTools/HackStudio/CodeDocument.cpp index a8605c24a0..0ba3f46fd6 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.cpp +++ b/Userland/DevTools/HackStudio/CodeDocument.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -NonnullRefPtr<CodeDocument> CodeDocument::create(const String& file_path, Client* client) +NonnullRefPtr<CodeDocument> CodeDocument::create(String const& file_path, Client* client) { return adopt_ref(*new CodeDocument(file_path, client)); } @@ -19,7 +19,7 @@ NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client) return adopt_ref(*new CodeDocument(client)); } -CodeDocument::CodeDocument(const String& file_path, Client* client) +CodeDocument::CodeDocument(String const& file_path, Client* client) : TextDocument(client) , m_file_path(file_path) { diff --git a/Userland/DevTools/HackStudio/CodeDocument.h b/Userland/DevTools/HackStudio/CodeDocument.h index 70a066f4b4..e496a9fa61 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.h +++ b/Userland/DevTools/HackStudio/CodeDocument.h @@ -16,22 +16,22 @@ namespace HackStudio { class CodeDocument final : public GUI::TextDocument { public: virtual ~CodeDocument() override = default; - static NonnullRefPtr<CodeDocument> create(const String& file_path, Client* client = nullptr); + static NonnullRefPtr<CodeDocument> create(String const& file_path, Client* client = nullptr); static NonnullRefPtr<CodeDocument> create(Client* client = nullptr); - const Vector<size_t>& breakpoint_lines() const { return m_breakpoint_lines; } + Vector<size_t> const& breakpoint_lines() const { return m_breakpoint_lines; } Vector<size_t>& breakpoint_lines() { return m_breakpoint_lines; } Optional<size_t> execution_position() const { return m_execution_position; } void set_execution_position(size_t line) { m_execution_position = line; } void clear_execution_position() { m_execution_position.clear(); } - const String& file_path() const { return m_file_path; } - const String& language_name() const { return m_language_name; }; + String const& file_path() const { return m_file_path; } + String const& language_name() const { return m_language_name; }; Language language() const { return m_language; } virtual bool is_code_document() const override final { return true; } private: - explicit CodeDocument(const String& file_path, Client* client = nullptr); + explicit CodeDocument(String const& file_path, Client* client = nullptr); explicit CodeDocument(Client* client = nullptr); String m_file_path; diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp index 0ae6152e44..432dfbab1e 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp @@ -10,7 +10,7 @@ namespace HackStudio { -NonnullRefPtr<BacktraceModel> BacktraceModel::create(Debug::ProcessInspector const& inspector, const PtraceRegisters& regs) +NonnullRefPtr<BacktraceModel> BacktraceModel::create(Debug::ProcessInspector const& inspector, PtraceRegisters const& regs) { return adopt_ref(*new BacktraceModel(create_backtrace(inspector, regs))); } diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h index 4eefb54a89..74aedfc412 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h @@ -43,7 +43,7 @@ public: Optional<Debug::DebugInfo::SourcePosition> m_source_position; }; - const Vector<FrameInfo>& frames() const { return m_frames; } + Vector<FrameInfo> const& frames() const { return m_frames; } private: explicit BacktraceModel(Vector<FrameInfo>&& frames) diff --git a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h index 45a3207c08..98d7b30edc 100644 --- a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h +++ b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h @@ -17,5 +17,5 @@ enum class BreakpointChange { Removed, }; -using BreakpointChangeCallback = Function<void(const String& file, size_t line, BreakpointChange)>; +using BreakpointChangeCallback = Function<void(String const& file, size_t line, BreakpointChange)>; } diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index 997b8a91b2..4ff7c4148c 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -89,7 +89,7 @@ DebugInfoWidget::DebugInfoWidget() }; } -bool DebugInfoWidget::does_variable_support_writing(const Debug::DebugInfo::VariableInfo* variable) +bool DebugInfoWidget::does_variable_support_writing(Debug::DebugInfo::VariableInfo const* variable) { if (variable->location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return false; @@ -102,7 +102,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode return nullptr; auto context_menu = GUI::Menu::construct(); - auto* variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); if (does_variable_support_writing(variable)) { context_menu->add_action(GUI::Action::create("Change value", [&](auto&) { String value; @@ -155,7 +155,7 @@ NonnullRefPtr<GUI::Widget> DebugInfoWidget::build_registers_tab() return registers_widget; } -void DebugInfoWidget::update_state(Debug::ProcessInspector& inspector, const PtraceRegisters& regs) +void DebugInfoWidget::update_state(Debug::ProcessInspector& inspector, PtraceRegisters const& regs) { m_variables_view->set_model(VariablesModel::create(inspector, regs)); m_backtrace_view->set_model(BacktraceModel::create(inspector, regs)); diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h index 0cf30d5648..2f72f4c285 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h @@ -38,7 +38,7 @@ private: NonnullRefPtr<GUI::Widget> build_variables_tab(); NonnullRefPtr<GUI::Widget> build_registers_tab(); - bool does_variable_support_writing(const Debug::DebugInfo::VariableInfo*); + bool does_variable_support_writing(Debug::DebugInfo::VariableInfo const*); RefPtr<GUI::Menu> get_context_menu_for_variable(const GUI::ModelIndex&); RefPtr<GUI::TreeView> m_variables_view; diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp index 9a02d5962a..71d8bf39b7 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp @@ -19,7 +19,7 @@ Debugger& Debugger::the() void Debugger::initialize( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback) { @@ -33,7 +33,7 @@ bool Debugger::is_initialized() Debugger::Debugger( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback) : m_source_root(source_root) @@ -45,14 +45,14 @@ Debugger::Debugger( pthread_cond_init(&m_ui_action_cond, nullptr); } -void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointChange change_type) +void Debugger::on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type) { auto position = create_source_position(file, line); if (change_type == BreakpointChange::Added) { m_breakpoints.append(position); } else { - m_breakpoints.remove_all_matching([&](const Debug::DebugInfo::SourcePosition& val) { return val == position; }); + m_breakpoints.remove_all_matching([&](Debug::DebugInfo::SourcePosition const& val) { return val == position; }); } auto session = Debugger::the().session(); @@ -77,7 +77,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC } } -bool Debugger::set_execution_position(const String& file, size_t line) +bool Debugger::set_execution_position(String const& file, size_t line) { auto position = create_source_position(file, line); auto session = Debugger::the().session(); @@ -92,7 +92,7 @@ bool Debugger::set_execution_position(const String& file, size_t line) return true; } -Debug::DebugInfo::SourcePosition Debugger::create_source_position(const String& file, size_t line) +Debug::DebugInfo::SourcePosition Debugger::create_source_position(String const& file, size_t line) { if (file.starts_with("/")) return { file, line + 1 }; @@ -121,7 +121,7 @@ void Debugger::start() m_debug_session = Debug::DebugSession::exec_and_attach(m_executable_path, m_source_root, move(child_setup_callback)); VERIFY(!!m_debug_session); - for (const auto& breakpoint : m_breakpoints) { + for (auto const& breakpoint : m_breakpoints) { dbgln("inserting breakpoint at: {}:{}", breakpoint.file_path, breakpoint.line_number); auto address = m_debug_session->get_address_from_source_position(breakpoint.file_path, breakpoint.line_number); if (address.has_value()) { @@ -218,7 +218,7 @@ void Debugger::DebuggingState::set_single_stepping(Debug::DebugInfo::SourcePosit m_original_source_position = original_source_position; } -bool Debugger::DebuggingState::should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const +bool Debugger::DebuggingState::should_stop_single_stepping(Debug::DebugInfo::SourcePosition const& current_source_position) const { VERIFY(m_state == State::SingleStepping); return m_original_source_position.value() != current_source_position; @@ -243,7 +243,7 @@ void Debugger::DebuggingState::add_temporary_breakpoint(FlatPtr address) m_addresses_of_temporary_breakpoints.append(address); } -void Debugger::do_step_out(const PtraceRegisters& regs) +void Debugger::do_step_out(PtraceRegisters const& regs) { // To step out, we simply insert a temporary breakpoint at the // instruction the current function returns to, and continue @@ -251,7 +251,7 @@ void Debugger::do_step_out(const PtraceRegisters& regs) insert_temporary_breakpoint_at_return_address(regs); } -void Debugger::do_step_over(const PtraceRegisters& regs) +void Debugger::do_step_over(PtraceRegisters const& regs) { // To step over, we insert a temporary breakpoint at each line in the current function, // as well as at the current function's return point, and continue execution. @@ -265,13 +265,13 @@ void Debugger::do_step_over(const PtraceRegisters& regs) } VERIFY(current_function.has_value()); auto lines_in_current_function = lib->debug_info->source_lines_in_scope(current_function.value()); - for (const auto& line : lines_in_current_function) { + for (auto const& line : lines_in_current_function) { insert_temporary_breakpoint(line.address_of_first_statement.value() + lib->base_address); } insert_temporary_breakpoint_at_return_address(regs); } -void Debugger::insert_temporary_breakpoint_at_return_address(const PtraceRegisters& regs) +void Debugger::insert_temporary_breakpoint_at_return_address(PtraceRegisters const& regs) { auto frame_info = Debug::StackFrameUtils::get_info(*m_debug_session, regs.bp()); VERIFY(frame_info.has_value()); diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.h b/Userland/DevTools/HackStudio/Debugger/Debugger.h index eca9d30b76..eaf14e5a5c 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.h +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.h @@ -27,17 +27,17 @@ public: static void initialize( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback); static bool is_initialized(); - void on_breakpoint_change(const String& file, size_t line, BreakpointChange change_type); - bool set_execution_position(const String& file, size_t line); + void on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type); + bool set_execution_position(String const& file, size_t line); - void set_executable_path(const String& path) { m_executable_path = path; } - void set_source_root(const String& source_root) { m_source_root = source_root; } + void set_executable_path(String const& path) { m_executable_path = path; } + void set_source_root(String const& source_root) { m_source_root = source_root; } Debug::DebugSession* session() { return m_debug_session.ptr(); } @@ -78,10 +78,10 @@ private: void set_stepping_out() { m_state = State::SteppingOut; } void set_stepping_over() { m_state = State::SteppingOver; } - bool should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const; + bool should_stop_single_stepping(Debug::DebugInfo::SourcePosition const& current_source_position) const; void clear_temporary_breakpoints(); void add_temporary_breakpoint(FlatPtr address); - const Vector<FlatPtr>& temporary_breakpoints() const { return m_addresses_of_temporary_breakpoints; } + Vector<FlatPtr> const& temporary_breakpoints() const { return m_addresses_of_temporary_breakpoints; } private: State m_state { Normal }; @@ -91,20 +91,20 @@ private: explicit Debugger( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback); - Debug::DebugInfo::SourcePosition create_source_position(const String& file, size_t line); + Debug::DebugInfo::SourcePosition create_source_position(String const& file, size_t line); void start(); int debugger_loop(); void remove_temporary_breakpoints(); - void do_step_out(const PtraceRegisters&); - void do_step_over(const PtraceRegisters&); + void do_step_out(PtraceRegisters const&); + void do_step_over(PtraceRegisters const&); void insert_temporary_breakpoint(FlatPtr address); - void insert_temporary_breakpoint_at_return_address(const PtraceRegisters&); + void insert_temporary_breakpoint_at_return_address(PtraceRegisters const&); OwnPtr<Debug::DebugSession> m_debug_session; String m_source_root; @@ -118,7 +118,7 @@ private: String m_executable_path; - Function<HasControlPassedToUser(const PtraceRegisters&)> m_on_stopped_callback; + Function<HasControlPassedToUser(PtraceRegisters const&)> m_on_stopped_callback; Function<void()> m_on_continue_callback; Function<void()> m_on_exit_callback; Function<ErrorOr<void>()> m_child_setup_callback; diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp index 90e8abe82e..70822d9299 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp @@ -58,7 +58,7 @@ JS::ThrowCompletionOr<bool> DebuggerGlobalJSObject::internal_set(JS::PropertyKey return vm().throw_completion<JS::TypeError>(const_cast<DebuggerGlobalJSObject&>(*this), move(error_string)); } -Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(const Debug::DebugInfo::VariableInfo& variable) const +Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(Debug::DebugInfo::VariableInfo const& variable) const { if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return {}; @@ -94,7 +94,7 @@ Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(const Debug::DebugInf return JS::Value(object); } -Optional<u32> DebuggerGlobalJSObject::js_to_debugger(JS::Value value, const Debug::DebugInfo::VariableInfo& variable) const +Optional<u32> DebuggerGlobalJSObject::js_to_debugger(JS::Value value, Debug::DebugInfo::VariableInfo const& variable) const { if (value.is_string() && variable.type_name == "char") { auto string = value.as_string().string(); diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h index cb1560ab28..a1f3b09e01 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h @@ -24,8 +24,8 @@ public: virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver) const override; virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; - Optional<JS::Value> debugger_to_js(const Debug::DebugInfo::VariableInfo&) const; - Optional<u32> js_to_debugger(JS::Value value, const Debug::DebugInfo::VariableInfo&) const; + Optional<JS::Value> debugger_to_js(Debug::DebugInfo::VariableInfo const&) const; + Optional<u32> js_to_debugger(JS::Value value, Debug::DebugInfo::VariableInfo const&) const; private: NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables; diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp index 063f1fd4cb..97db4eeffe 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp @@ -15,12 +15,12 @@ namespace HackStudio { -DebuggerVariableJSObject* DebuggerVariableJSObject::create(DebuggerGlobalJSObject& global_object, const Debug::DebugInfo::VariableInfo& variable_info) +DebuggerVariableJSObject* DebuggerVariableJSObject::create(DebuggerGlobalJSObject& global_object, Debug::DebugInfo::VariableInfo const& variable_info) { return global_object.heap().allocate<DebuggerVariableJSObject>(global_object, variable_info, *global_object.object_prototype()); } -DebuggerVariableJSObject::DebuggerVariableJSObject(const Debug::DebugInfo::VariableInfo& variable_info, JS::Object& prototype) +DebuggerVariableJSObject::DebuggerVariableJSObject(Debug::DebugInfo::VariableInfo const& variable_info, JS::Object& prototype) : JS::Object(prototype) , m_variable_info(variable_info) { diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h index c44c0e907d..195e978225 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h @@ -20,9 +20,9 @@ class DebuggerVariableJSObject final : public JS::Object { using Base = JS::Object; public: - static DebuggerVariableJSObject* create(DebuggerGlobalJSObject&, const Debug::DebugInfo::VariableInfo& variable_info); + static DebuggerVariableJSObject* create(DebuggerGlobalJSObject&, Debug::DebugInfo::VariableInfo const& variable_info); - DebuggerVariableJSObject(const Debug::DebugInfo::VariableInfo& variable_info, JS::Object& prototype); + DebuggerVariableJSObject(Debug::DebugInfo::VariableInfo const& variable_info, JS::Object& prototype); virtual ~DebuggerVariableJSObject() override = default; virtual StringView class_name() const override { return m_variable_info.type_name; } @@ -32,7 +32,7 @@ public: private: DebuggerGlobalJSObject& debugger_object() const; - const Debug::DebugInfo::VariableInfo& m_variable_info; + Debug::DebugInfo::VariableInfo const& m_variable_info; }; } diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp index 22d99180fd..3861ae7626 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp @@ -17,7 +17,7 @@ namespace HackStudio { -DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) +DisassemblyModel::DisassemblyModel(Debug::DebugSession const& debug_session, PtraceRegisters const& regs) { auto lib = debug_session.library_at(regs.ip()); if (!lib) @@ -51,7 +51,7 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con auto view = symbol.value().raw_data(); X86::ELFSymbolProvider symbol_provider(*elf); - X86::SimpleInstructionStream stream((const u8*)view.characters_without_null_termination(), view.length()); + X86::SimpleInstructionStream stream((u8 const*)view.characters_without_null_termination(), view.length()); X86::Disassembler disassembler(stream); size_t offset_into_symbol = 0; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h index 6daaea3cc2..10efc05af4 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h @@ -29,7 +29,7 @@ struct InstructionData { class DisassemblyModel final : public GUI::Model { public: - static NonnullRefPtr<DisassemblyModel> create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) + static NonnullRefPtr<DisassemblyModel> create(Debug::DebugSession const& debug_session, PtraceRegisters const& regs) { return adopt_ref(*new DisassemblyModel(debug_session, regs)); } @@ -49,7 +49,7 @@ public: virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; private: - DisassemblyModel(const Debug::DebugSession&, const PtraceRegisters&); + DisassemblyModel(Debug::DebugSession const&, PtraceRegisters const&); Vector<InstructionData> m_instructions; }; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp index ff49fdf897..f2cfe33ae1 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp @@ -39,7 +39,7 @@ DisassemblyWidget::DisassemblyWidget() hide_disassembly("Program isn't running"); } -void DisassemblyWidget::update_state(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) +void DisassemblyWidget::update_state(Debug::DebugSession const& debug_session, PtraceRegisters const& regs) { m_disassembly_view->set_model(DisassemblyModel::create(debug_session, regs)); @@ -73,7 +73,7 @@ void DisassemblyWidget::show_disassembly() m_unavailable_disassembly_widget->set_visible(false); } -void DisassemblyWidget::hide_disassembly(const String& reason) +void DisassemblyWidget::hide_disassembly(String const& reason) { m_top_container->set_visible(false); m_disassembly_view->set_visible(false); diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h index 09254737f7..5805c722ad 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h @@ -21,11 +21,11 @@ class UnavailableDisassemblyWidget final : public GUI::Frame { public: virtual ~UnavailableDisassemblyWidget() override { } - const String& reason() const { return m_reason; } - void set_reason(const String& text) { m_reason = text; } + String const& reason() const { return m_reason; } + void set_reason(String const& text) { m_reason = text; } private: - UnavailableDisassemblyWidget(const String& reason) + UnavailableDisassemblyWidget(String const& reason) : m_reason(reason) { } @@ -40,14 +40,14 @@ class DisassemblyWidget final : public GUI::Widget { public: virtual ~DisassemblyWidget() override { } - void update_state(const Debug::DebugSession&, const PtraceRegisters&); + void update_state(Debug::DebugSession const&, PtraceRegisters const&); void program_stopped(); private: DisassemblyWidget(); void show_disassembly(); - void hide_disassembly(const String&); + void hide_disassembly(String const&); RefPtr<GUI::Widget> m_top_container; RefPtr<GUI::TableView> m_disassembly_view; diff --git a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp index d31f8ae12e..c1fc9a7058 100644 --- a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp +++ b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp @@ -103,7 +103,7 @@ void EvaluateExpressionDialog::build(Window* parent_window) m_text_editor->set_focus(true); } -void EvaluateExpressionDialog::handle_evaluation(const String& expression) +void EvaluateExpressionDialog::handle_evaluation(String const& expression) { m_output_container->remove_all_children(); m_output_view->update(); diff --git a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h index d33873c3bb..201c3c8190 100644 --- a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h +++ b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h @@ -18,7 +18,7 @@ private: explicit EvaluateExpressionDialog(Window* parent_window); void build(Window* parent_window); - void handle_evaluation(const String& expression); + void handle_evaluation(String const& expression); void set_output(StringView html); NonnullOwnPtr<JS::Interpreter> m_interpreter; diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp b/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp index 3bac9fce93..949b6202e6 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -RegistersModel::RegistersModel(const PtraceRegisters& regs) +RegistersModel::RegistersModel(PtraceRegisters const& regs) : m_raw_registers(regs) { #if ARCH(I386) @@ -52,7 +52,7 @@ RegistersModel::RegistersModel(const PtraceRegisters& regs) m_registers.append({ "gs", regs.gs }); } -RegistersModel::RegistersModel(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) +RegistersModel::RegistersModel(PtraceRegisters const& current_regs, PtraceRegisters const& previous_regs) : m_raw_registers(current_regs) { #if ARCH(I386) diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h index 91651e798a..a0e86c1915 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h @@ -21,12 +21,12 @@ struct RegisterData { class RegistersModel final : public GUI::Model { public: - static RefPtr<RegistersModel> create(const PtraceRegisters& regs) + static RefPtr<RegistersModel> create(PtraceRegisters const& regs) { return adopt_ref(*new RegistersModel(regs)); } - static RefPtr<RegistersModel> create(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) + static RefPtr<RegistersModel> create(PtraceRegisters const& current_regs, PtraceRegisters const& previous_regs) { return adopt_ref(*new RegistersModel(current_regs, previous_regs)); } @@ -44,11 +44,11 @@ public: virtual String column_name(int) const override; virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; - const PtraceRegisters& raw_registers() const { return m_raw_registers; } + PtraceRegisters const& raw_registers() const { return m_raw_registers; } private: - explicit RegistersModel(const PtraceRegisters& regs); - RegistersModel(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs); + explicit RegistersModel(PtraceRegisters const& regs); + RegistersModel(PtraceRegisters const& current_regs, PtraceRegisters const& previous_regs); PtraceRegisters m_raw_registers; Vector<RegisterData> m_registers; diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp index 02f57c81d6..5e014b63c1 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -17,7 +17,7 @@ GUI::ModelIndex VariablesModel::index(int row, int column, const GUI::ModelIndex return {}; return create_index(row, column, &m_variables[row]); } - auto* parent = static_cast<const Debug::DebugInfo::VariableInfo*>(parent_index.internal_data()); + auto* parent = static_cast<Debug::DebugInfo::VariableInfo const*>(parent_index.internal_data()); if (static_cast<size_t>(row) >= parent->members.size()) return {}; auto* child = &parent->members[row]; @@ -28,7 +28,7 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* child = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* child = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); auto* parent = child->parent; if (parent == nullptr) return {}; @@ -51,11 +51,11 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_variables.size(); - auto* node = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* node = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); return node->members.size(); } -static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& variable) +static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable) { if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return "N/A"; @@ -65,7 +65,7 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var if (variable.is_enum_type()) { auto value = Debugger::the().session()->peek(variable_address); VERIFY(value.has_value()); - auto it = variable.type->members.find_if([&enumerator_value = value.value()](const auto& enumerator) { + auto it = variable.type->members.find_if([&enumerator_value = value.value()](auto const& enumerator) { return enumerator->constant_data.as_u32 == enumerator_value; }); if (it.is_end()) @@ -94,7 +94,7 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var return String::formatted("type: {} @ {:p}, ", variable.type_name, variable_address); } -static Optional<u32> string_to_variable_value(StringView string_value, const Debug::DebugInfo::VariableInfo& variable) +static Optional<u32> string_to_variable_value(StringView string_value, Debug::DebugInfo::VariableInfo const& variable) { if (variable.is_enum_type()) { auto prefix_string = String::formatted("{}::", variable.type_name); @@ -102,7 +102,7 @@ static Optional<u32> string_to_variable_value(StringView string_value, const Deb if (string_value.starts_with(prefix_string)) string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length()); - auto it = variable.type->members.find_if([string_to_use](const auto& enumerator) { + auto it = variable.type->members.find_if([string_to_use](auto const& enumerator) { return enumerator->name == string_to_use; }); @@ -131,7 +131,7 @@ static Optional<u32> string_to_variable_value(StringView string_value, const Deb void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView string_value, GUI::Window* parent_window) { - auto variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); auto value = string_to_variable_value(string_value, *variable); @@ -150,7 +150,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); switch (role) { case GUI::ModelRole::Display: { auto value_as_string = variable_value_as_string(*variable); diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h index a46a7641ed..c32019bb31 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h @@ -28,7 +28,7 @@ public: Debug::ProcessInspector& inspector() { return m_inspector; } private: - explicit VariablesModel(Debug::ProcessInspector& inspector, NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, const PtraceRegisters& regs) + explicit VariablesModel(Debug::ProcessInspector& inspector, NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, PtraceRegisters const& regs) : m_variables(move(variables)) , m_regs(regs) , m_inspector(inspector) diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index 36d67f5e8f..e33d7ba9fe 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -25,7 +25,7 @@ namespace HackStudio { -static const Regex<PosixExtended> s_project_name_validity_regex("^([A-Za-z0-9_-])*$"); +static Regex<PosixExtended> const s_project_name_validity_regex("^([A-Za-z0-9_-])*$"); int NewProjectDialog::show(GUI::Window* parent_window) { diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index f452428e5b..d50d92247b 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -101,9 +101,9 @@ EditorWrapper& Editor::wrapper() { return static_cast<EditorWrapper&>(*parent()); } -const EditorWrapper& Editor::wrapper() const +EditorWrapper const& Editor::wrapper() const { - return static_cast<const EditorWrapper&>(*parent()); + return static_cast<EditorWrapper const&>(*parent()); } void Editor::focusin_event(GUI::FocusEvent& event) @@ -147,11 +147,11 @@ void Editor::paint_event(GUI::PaintEvent& event) if (line < first_visible_line || line > last_visible_line) { continue; } - const auto& icon = breakpoint_icon_bitmap(); + auto const& icon = breakpoint_icon_bitmap(); painter.blit(gutter_icon_rect(line).top_left(), icon, icon.rect()); } if (execution_position().has_value()) { - const auto& icon = current_position_icon_bitmap(); + auto const& icon = current_position_icon_bitmap(); painter.blit(gutter_icon_rect(execution_position().value()).top_left(), icon, icon.rect()); } @@ -198,7 +198,7 @@ static HashMap<String, String>& man_paths() return paths; } -void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::IntPoint& screen_location) +void Editor::show_documentation_tooltip_if_available(String const& hovered_token, Gfx::IntPoint const& screen_location) { auto it = man_paths().find(hovered_token); if (it == man_paths().end()) { @@ -438,28 +438,28 @@ void Editor::clear_execution_position() update(gutter_icon_rect(previous_position)); } -const Gfx::Bitmap& Editor::breakpoint_icon_bitmap() +Gfx::Bitmap const& Editor::breakpoint_icon_bitmap() { static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png").release_value_but_fixme_should_propagate_errors(); return *bitmap; } -const Gfx::Bitmap& Editor::current_position_icon_bitmap() +Gfx::Bitmap const& Editor::current_position_icon_bitmap() { static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); return *bitmap; } -const CodeDocument& Editor::code_document() const +CodeDocument const& Editor::code_document() const { - const auto& doc = document(); + auto const& doc = document(); VERIFY(doc.is_code_document()); - return static_cast<const CodeDocument&>(doc); + return static_cast<CodeDocument const&>(doc); } CodeDocument& Editor::code_document() { - return const_cast<CodeDocument&>(static_cast<const Editor&>(*this).code_document()); + return const_cast<CodeDocument&>(static_cast<Editor const&>(*this).code_document()); } void Editor::set_document(GUI::TextDocument& doc) @@ -585,7 +585,7 @@ void Editor::on_identifier_click(const GUI::TextDocumentSpan& span) if (!m_language_client) return; - m_language_client->on_declaration_found = [](const String& file, size_t line, size_t column) { + m_language_client->on_declaration_found = [](String const& file, size_t line, size_t column) { HackStudio::open_file(file, line, column); }; m_language_client->search_declaration(code_document().file_path(), span.range.start().line(), span.range.start().column()); @@ -596,7 +596,7 @@ void Editor::set_cursor(const GUI::TextPosition& a_position) TextEditor::set_cursor(a_position); } -void Editor::set_syntax_highlighter_for(const CodeDocument& document) +void Editor::set_syntax_highlighter_for(CodeDocument const& document) { switch (document.language()) { case Language::Cpp: @@ -650,7 +650,7 @@ void Editor::set_autocomplete_provider_for(CodeDocument const& document) } } -void Editor::set_language_client_for(const CodeDocument& document) +void Editor::set_language_client_for(CodeDocument const& document) { if (m_language_client && m_language_client->language() == document.language()) return; diff --git a/Userland/DevTools/HackStudio/Editor.h b/Userland/DevTools/HackStudio/Editor.h index 75755e0f8e..e1bc6206d5 100644 --- a/Userland/DevTools/HackStudio/Editor.h +++ b/Userland/DevTools/HackStudio/Editor.h @@ -32,9 +32,9 @@ public: Function<void(String)> on_open; EditorWrapper& wrapper(); - const EditorWrapper& wrapper() const; + EditorWrapper const& wrapper() const; - const Vector<size_t>& breakpoint_lines() const { return code_document().breakpoint_lines(); } + Vector<size_t> const& breakpoint_lines() const { return code_document().breakpoint_lines(); } Vector<size_t>& breakpoint_lines() { return code_document().breakpoint_lines(); } Optional<size_t> execution_position() const { return code_document().execution_position(); } bool is_program_running() const { return execution_position().has_value(); } @@ -42,7 +42,7 @@ public: void clear_execution_position(); void set_debug_mode(bool); - const CodeDocument& code_document() const; + CodeDocument const& code_document() const; CodeDocument& code_document(); virtual void set_document(GUI::TextDocument&) override; @@ -70,14 +70,14 @@ private: virtual void leave_event(Core::Event&) override; virtual void keydown_event(GUI::KeyEvent&) override; - void show_documentation_tooltip_if_available(const String&, const Gfx::IntPoint& screen_location); + void show_documentation_tooltip_if_available(String const&, Gfx::IntPoint const& screen_location); void navigate_to_include_if_available(String); void on_navigatable_link_click(const GUI::TextDocumentSpan&); void on_identifier_click(const GUI::TextDocumentSpan&); Gfx::IntRect gutter_icon_rect(size_t line_number) const; - static const Gfx::Bitmap& breakpoint_icon_bitmap(); - static const Gfx::Bitmap& current_position_icon_bitmap(); + static Gfx::Bitmap const& breakpoint_icon_bitmap(); + static Gfx::Bitmap const& current_position_icon_bitmap(); struct AutoCompleteRequestData { GUI::TextPosition position; @@ -99,8 +99,8 @@ private: Optional<AutoCompleteRequestData> get_autocomplete_request_data(); void flush_file_content_to_langauge_server(); - void set_syntax_highlighter_for(const CodeDocument&); - void set_language_client_for(const CodeDocument&); + void set_syntax_highlighter_for(CodeDocument const&); + void set_language_client_for(CodeDocument const&); void set_autocomplete_provider_for(CodeDocument const&); void handle_function_parameters_hint_request(); void on_token_info_timer_tick(); diff --git a/Userland/DevTools/HackStudio/EditorWrapper.cpp b/Userland/DevTools/HackStudio/EditorWrapper.cpp index b3eda59f42..c532a1f7c6 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.cpp +++ b/Userland/DevTools/HackStudio/EditorWrapper.cpp @@ -62,7 +62,7 @@ void EditorWrapper::set_mode_non_displayable() editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"); } -void EditorWrapper::set_filename(const String& filename) +void EditorWrapper::set_filename(String const& filename) { m_filename = filename; update_title(); diff --git a/Userland/DevTools/HackStudio/EditorWrapper.h b/Userland/DevTools/HackStudio/EditorWrapper.h index 62c5121d4d..abbc756738 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.h +++ b/Userland/DevTools/HackStudio/EditorWrapper.h @@ -29,7 +29,7 @@ public: virtual ~EditorWrapper() override = default; Editor& editor() { return *m_editor; } - const Editor& editor() const { return *m_editor; } + Editor const& editor() const { return *m_editor; } void save(); @@ -38,8 +38,8 @@ public: void set_mode_displayable(); void set_mode_non_displayable(); void set_debug_mode(bool); - void set_filename(const String&); - const String& filename() const { return m_filename; } + void set_filename(String const&); + String const& filename() const { return m_filename; } String const& filename_title() const { return m_filename_title; } Optional<String> const& project_root() const { return m_project_root; } diff --git a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp index 28e95f5fc7..5b9e99355f 100644 --- a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp @@ -31,7 +31,7 @@ public: __Count }; - explicit SearchResultsModel(const Vector<Match>&& matches) + explicit SearchResultsModel(Vector<Match> const&& matches) : m_matches(move(matches)) { } diff --git a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp index e2f07af251..054d2ddd20 100644 --- a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp +++ b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp @@ -27,7 +27,7 @@ void GMLPreviewWidget::load_gml(String const& gml) return; } - load_from_gml(gml, [](const String& name) -> RefPtr<Core::Object> { + load_from_gml(gml, [](String const& name) -> RefPtr<Core::Object> { return GUI::Label::construct(String::formatted("{} is not registered as a GML element!", name)); }); diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp index 049fbd5978..cf85972dcd 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp @@ -35,7 +35,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) size_t y_offset = 10; size_t current_original_line_index = 0; - for (const auto& hunk : m_hunks) { + for (auto const& hunk : m_hunks) { for (size_t i = current_original_line_index; i < hunk.original_start_line; ++i) { draw_line(painter, m_original_lines[i], y_offset, LinePosition::Both, LineType::Normal); y_offset += line_height(); @@ -43,7 +43,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) current_original_line_index = hunk.original_start_line + hunk.removed_lines.size(); size_t left_y_offset = y_offset; - for (const auto& removed_line : hunk.removed_lines) { + for (auto const& removed_line : hunk.removed_lines) { draw_line(painter, removed_line, left_y_offset, LinePosition::Left, LineType::Diff); left_y_offset += line_height(); } @@ -53,7 +53,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) } size_t right_y_offset = y_offset; - for (const auto& added_line : hunk.added_lines) { + for (auto const& added_line : hunk.added_lines) { draw_line(painter, added_line, right_y_offset, LinePosition::Right, LineType::Diff); right_y_offset += line_height(); } @@ -71,7 +71,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) } } -void DiffViewer::draw_line(GUI::Painter& painter, const String& line, size_t y_offset, LinePosition line_position, LineType line_type) +void DiffViewer::draw_line(GUI::Painter& painter, String const& line, size_t y_offset, LinePosition line_position, LineType line_type) { size_t line_width = font().width(line); @@ -131,7 +131,7 @@ Gfx::IntRect DiffViewer::separator_rect() const frame_inner_rect().height() }; } -void DiffViewer::set_content(const String& original, const String& diff) +void DiffViewer::set_content(String const& original, String const& diff) { m_original_lines = split_to_lines(original); m_hunks = Diff::parse_hunks(diff); @@ -147,7 +147,7 @@ DiffViewer::DiffViewer() setup_properties(); } -DiffViewer::DiffViewer(const String& original, const String& diff) +DiffViewer::DiffViewer(String const& original, String const& diff) : m_original_lines(split_to_lines(original)) , m_hunks(Diff::parse_hunks(diff)) { @@ -161,7 +161,7 @@ void DiffViewer::setup_properties() set_foreground_role(ColorRole::BaseText); } -Vector<String> DiffViewer::split_to_lines(const String& text) +Vector<String> DiffViewer::split_to_lines(String const& text) { // NOTE: This is slightly different than text.split('\n') Vector<String> lines; @@ -204,7 +204,7 @@ void DiffViewer::update_content_size() size_t num_lines = 0; size_t current_original_line_index = 0; - for (const auto& hunk : m_hunks) { + for (auto const& hunk : m_hunks) { num_lines += ((int)hunk.original_start_line - (int)current_original_line_index); num_lines += hunk.removed_lines.size(); diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.h b/Userland/DevTools/HackStudio/Git/DiffViewer.h index 38b27bf0df..a700809a4f 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.h +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.h @@ -18,10 +18,10 @@ class DiffViewer final : public GUI::AbstractScrollableWidget { public: virtual ~DiffViewer() override = default; - void set_content(const String& original, const String& diff); + void set_content(String const& original, String const& diff); private: - DiffViewer(const String& original, const String& diff); + DiffViewer(String const& original, String const& diff); DiffViewer(); void setup_properties(); @@ -43,9 +43,9 @@ private: Missing, }; - void draw_line(GUI::Painter&, const String& line, size_t y_offset, LinePosition, LineType); + void draw_line(GUI::Painter&, String const& line, size_t y_offset, LinePosition, LineType); - static Vector<String> split_to_lines(const String& text); + static Vector<String> split_to_lines(String const& text); static Gfx::Color red_background(); static Gfx::Color green_background(); diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 92238f7293..a6e6e0465a 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -167,8 +167,8 @@ void GitWidget::show_diff(String const& file_path) m_view_diff_callback("", Diff::generate_only_additions(content_string)); return; } - const auto& original_content = m_git_repo->original_file_content(file_path); - const auto& diff = m_git_repo->unstaged_diff(file_path); + auto const& original_content = m_git_repo->original_file_content(file_path); + auto const& diff = m_git_repo->unstaged_diff(file_path); VERIFY(original_content.has_value() && diff.has_value()); m_view_diff_callback(original_content.value(), diff.value()); } diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.h b/Userland/DevTools/HackStudio/Git/GitWidget.h index 87f7c1bd2f..a0ff4ac209 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.h +++ b/Userland/DevTools/HackStudio/Git/GitWidget.h @@ -14,7 +14,7 @@ namespace HackStudio { -using ViewDiffCallback = Function<void(const String& original_content, const String& diff)>; +using ViewDiffCallback = Function<void(String const& original_content, String const& diff)>; class GitWidget final : public GUI::Widget { C_OBJECT(GitWidget) diff --git a/Userland/DevTools/HackStudio/HackStudio.h b/Userland/DevTools/HackStudio/HackStudio.h index 68924f5523..3458b7c116 100644 --- a/Userland/DevTools/HackStudio/HackStudio.h +++ b/Userland/DevTools/HackStudio/HackStudio.h @@ -15,9 +15,9 @@ namespace HackStudio { GUI::TextEditor& current_editor(); -void open_file(const String&); +void open_file(String const&); RefPtr<EditorWrapper> current_editor_wrapper(); -void open_file(const String&, size_t line, size_t column); +void open_file(String const&, size_t line, size_t column); Project& project(); String currently_open_file(); void set_current_editor_wrapper(RefPtr<EditorWrapper>); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index df1b66220b..b741203914 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -233,7 +233,7 @@ Vector<String> HackStudioWidget::read_recent_projects() return paths; } -void HackStudioWidget::open_project(const String& root_path) +void HackStudioWidget::open_project(String const& root_path) { if (warn_unsaved_changes("There are unsaved changes, do you want to save before closing current project?") == ContinueDecision::No) return; @@ -300,7 +300,7 @@ Vector<String> HackStudioWidget::selected_file_paths() const return files; } -bool HackStudioWidget::open_file(const String& full_filename, size_t line, size_t column) +bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_t column) { String filename = full_filename; if (full_filename.starts_with(project().root_path())) { @@ -972,7 +972,7 @@ void HackStudioWidget::initialize_debugger() { Debugger::initialize( m_project->root_path(), - [this](const PtraceRegisters& regs) { + [this](PtraceRegisters const& regs) { VERIFY(Debugger::the().session()); const auto& debug_session = *Debugger::the().session(); auto source_position = debug_session.get_source_position(regs.ip()); @@ -1025,7 +1025,7 @@ void HackStudioWidget::initialize_debugger() }); } -String HackStudioWidget::get_full_path_of_serenity_source(const String& file) +String HackStudioWidget::get_full_path_of_serenity_source(String const& file) { auto path_parts = LexicalPath(file).parts(); while (!path_parts.is_empty() && path_parts[0] == "..") { @@ -1038,7 +1038,7 @@ String HackStudioWidget::get_full_path_of_serenity_source(const String& file) return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string()); } -String HackStudioWidget::get_absolute_path(const String& path) const +String HackStudioWidget::get_absolute_path(String const& path) const { // TODO: We can probably do a more specific condition here, something like // "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))" @@ -1048,7 +1048,7 @@ String HackStudioWidget::get_absolute_path(const String& path) const return m_project->to_absolute_path(path); } -RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& filename) +RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(String const& filename) { String file_path = filename; @@ -1261,7 +1261,7 @@ void HackStudioWidget::create_action_tab(GUI::Widget& parent) m_disassembly_widget = m_action_tab_widget->add_tab<DisassemblyWidget>("Disassembly"); m_git_widget = m_action_tab_widget->add_tab<GitWidget>("Git", m_project->root_path()); - m_git_widget->set_view_diff_callback([this](const auto& original_content, const auto& diff) { + m_git_widget->set_view_diff_callback([this](auto const& original_content, auto const& diff) { m_diff_viewer->set_content(original_content, diff); set_edit_mode(EditMode::Diff); }); @@ -1497,7 +1497,7 @@ void HackStudioWidget::update_statusbar() m_statusbar->set_text(2, String::formatted("Ln {}, Col {}", current_editor().cursor().line() + 1, current_editor().cursor().column())); } -void HackStudioWidget::handle_external_file_deletion(const String& filepath) +void HackStudioWidget::handle_external_file_deletion(String const& filepath) { close_file_in_all_editors(filepath); } @@ -1534,7 +1534,7 @@ HackStudioWidget::~HackStudioWidget() stop_debugger_if_running(); } -HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(const String& prompt) +HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(String const& prompt) { if (!any_document_is_dirty()) return ContinueDecision::Yes; diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 29f76a148c..b8305e5f75 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -53,7 +53,7 @@ public: GUI::TabWidget& current_editor_tab_widget(); GUI::TabWidget const& current_editor_tab_widget() const; - const String& active_file() const { return m_current_editor_wrapper->filename(); } + String const& active_file() const { return m_current_editor_wrapper->filename(); } void initialize_menubar(GUI::Window&); Locator& locator() @@ -66,7 +66,7 @@ public: No, Yes }; - ContinueDecision warn_unsaved_changes(const String& prompt); + ContinueDecision warn_unsaved_changes(String const& prompt); enum class Mode { Code, @@ -82,12 +82,12 @@ public: private: static constexpr size_t recent_projects_history_size = 15; - static String get_full_path_of_serenity_source(const String& file); + static String get_full_path_of_serenity_source(String const& file); String get_absolute_path(String const&) const; Vector<String> selected_file_paths() const; HackStudioWidget(String path_to_project); - void open_project(const String& root_path); + void open_project(String const& root_path); enum class EditMode { Text, @@ -124,7 +124,7 @@ private: void add_new_editor_tab_widget(GUI::Widget& parent); void add_new_editor(GUI::TabWidget& parent); - RefPtr<EditorWrapper> get_editor_of_file(const String& filename); + RefPtr<EditorWrapper> get_editor_of_file(String const& filename); String get_project_executable_path() const; void on_action_tab_change(); @@ -132,7 +132,7 @@ private: void initialize_debugger(); void update_statusbar(); - void handle_external_file_deletion(const String& filepath); + void handle_external_file_deletion(String const& filepath); void stop_debugger_if_running(); void close_current_project(); diff --git a/Userland/DevTools/HackStudio/Language.cpp b/Userland/DevTools/HackStudio/Language.cpp index f00c5bfc27..bc6fc82f34 100644 --- a/Userland/DevTools/HackStudio/Language.cpp +++ b/Userland/DevTools/HackStudio/Language.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -Language language_from_file(const LexicalPath& file) +Language language_from_file(LexicalPath const& file) { if (file.title() == "COMMIT_EDITMSG") return Language::GitCommit; @@ -37,7 +37,7 @@ Language language_from_file(const LexicalPath& file) return Language::Unknown; } -Language language_from_name(const String& name) +Language language_from_name(String const& name) { if (name == "Cpp") return Language::Cpp; @@ -51,7 +51,7 @@ Language language_from_name(const String& name) return Language::Unknown; } -String language_name_from_file(const LexicalPath& file) +String language_name_from_file(LexicalPath const& file) { if (file.title() == "COMMIT_EDITMSG") return "GitCommit"; diff --git a/Userland/DevTools/HackStudio/Language.h b/Userland/DevTools/HackStudio/Language.h index 2ace198813..16a70d1d17 100644 --- a/Userland/DevTools/HackStudio/Language.h +++ b/Userland/DevTools/HackStudio/Language.h @@ -23,8 +23,8 @@ enum class Language { SQL, }; -Language language_from_file(const LexicalPath&); -Language language_from_name(const String&); -String language_name_from_file(const LexicalPath&); +Language language_from_file(LexicalPath const&); +Language language_from_name(String const&); +String language_name_from_file(LexicalPath const&); } diff --git a/Userland/DevTools/HackStudio/LanguageClient.cpp b/Userland/DevTools/HackStudio/LanguageClient.cpp index 75833bbc2d..42aa25e3a9 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageClient.cpp @@ -14,7 +14,7 @@ namespace HackStudio { -void ConnectionToServer::auto_complete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>& suggestions) +void ConnectionToServer::auto_complete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const& suggestions) { if (!m_current_language_client) { dbgln("Language Server connection has no attached language client"); @@ -60,35 +60,35 @@ void ConnectionToServer::die() m_wrapper->on_crash(); } -void LanguageClient::open_file(const String& path, int fd) +void LanguageClient::open_file(String const& path, int fd) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_opened(path, fd); } -void LanguageClient::set_file_content(const String& path, const String& content) +void LanguageClient::set_file_content(String const& path, String const& content) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_set_file_content(path, content); } -void LanguageClient::insert_text(const String& path, const String& text, size_t line, size_t column) +void LanguageClient::insert_text(String const& path, String const& text, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_edit_insert_text(path, text, line, column); } -void LanguageClient::remove_text(const String& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column) +void LanguageClient::remove_text(String const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_edit_remove_text(path, from_line, from_column, to_line, to_column); } -void LanguageClient::request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column) +void LanguageClient::request_autocomplete(String const& path, size_t cursor_line, size_t cursor_column) { if (!m_connection_wrapper.connection()) return; @@ -96,7 +96,7 @@ void LanguageClient::request_autocomplete(const String& path, size_t cursor_line m_connection_wrapper.connection()->async_auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation { path, cursor_line, cursor_column }); } -void LanguageClient::provide_autocomplete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>& suggestions) const +void LanguageClient::provide_autocomplete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const& suggestions) const { if (on_autocomplete_suggestions) on_autocomplete_suggestions(suggestions); @@ -120,7 +120,7 @@ bool LanguageClient::is_active_client() const HashMap<String, NonnullOwnPtr<ConnectionToServerWrapper>> ConnectionToServerInstances::s_instance_for_language; -void ConnectionToServer::declarations_in_document(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>& declarations) +void ConnectionToServer::declarations_in_document(String const& filename, Vector<GUI::AutocompleteProvider::Declaration> const& declarations) { ProjectDeclarations::the().set_declared_symbols(filename, declarations); } @@ -130,7 +130,7 @@ void ConnectionToServer::todo_entries_in_document(String const& filename, Vector ToDoEntries::the().set_entries(filename, move(todo_entries)); } -void LanguageClient::search_declaration(const String& path, size_t line, size_t column) +void LanguageClient::search_declaration(String const& path, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; @@ -138,7 +138,7 @@ void LanguageClient::search_declaration(const String& path, size_t line, size_t m_connection_wrapper.connection()->async_find_declaration(GUI::AutocompleteProvider::ProjectLocation { path, line, column }); } -void LanguageClient::get_parameters_hint(const String& path, size_t line, size_t column) +void LanguageClient::get_parameters_hint(String const& path, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; @@ -146,7 +146,7 @@ void LanguageClient::get_parameters_hint(const String& path, size_t line, size_t m_connection_wrapper.connection()->async_get_parameters_hint(GUI::AutocompleteProvider::ProjectLocation { path, line, column }); } -void LanguageClient::get_tokens_info(const String& filename) +void LanguageClient::get_tokens_info(String const& filename) { if (!m_connection_wrapper.connection()) return; @@ -154,7 +154,7 @@ void LanguageClient::get_tokens_info(const String& filename) m_connection_wrapper.connection()->async_get_tokens_info(filename); } -void LanguageClient::declaration_found(const String& file, size_t line, size_t column) const +void LanguageClient::declaration_found(String const& file, size_t line, size_t column) const { if (!on_declaration_found) { dbgln("on_declaration_found callback is not set"); @@ -172,17 +172,17 @@ void LanguageClient::parameters_hint_result(Vector<String> const& params, size_t on_function_parameters_hint_result(params, argument_index); } -void ConnectionToServerInstances::set_instance_for_language(const String& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper) +void ConnectionToServerInstances::set_instance_for_language(String const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper) { s_instance_for_language.set(language_name, move(connection_wrapper)); } -void ConnectionToServerInstances::remove_instance_for_language(const String& language_name) +void ConnectionToServerInstances::remove_instance_for_language(String const& language_name) { s_instance_for_language.remove(language_name); } -ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(const String& language_name) +ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(String const& language_name) { if (auto instance = s_instance_for_language.get(language_name); instance.has_value()) { return const_cast<ConnectionToServerWrapper*>(instance.value()); @@ -223,7 +223,7 @@ void ConnectionToServerWrapper::show_crash_notification() const notification->show(); } -ConnectionToServerWrapper::ConnectionToServerWrapper(const String& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator) +ConnectionToServerWrapper::ConnectionToServerWrapper(String const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator) : m_language(language_from_name(language_name)) , m_connection_creator(move(connection_creator)) { @@ -267,7 +267,7 @@ void ConnectionToServerWrapper::try_respawn_connection() // After respawning the language-server, we have to send the content of open project files // so the server's FileDB will be up-to-date. - for_each_open_file([this](const ProjectFile& file) { + for_each_open_file([this](ProjectFile const& file) { if (file.code_document().language() != m_language) return; m_connection->async_set_file_content(file.code_document().file_path(), file.document().text()); diff --git a/Userland/DevTools/HackStudio/LanguageClient.h b/Userland/DevTools/HackStudio/LanguageClient.h index e8a6600c73..9c9a6083ad 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.h +++ b/Userland/DevTools/HackStudio/LanguageClient.h @@ -31,7 +31,7 @@ class ConnectionToServer friend class ConnectionToServerWrapper; public: - ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, const String& project_path) + ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, String const& project_path) : IPC::ConnectionToServer<LanguageClientEndpoint, LanguageServerEndpoint>(*this, move(socket)) { m_project_path = project_path; @@ -39,11 +39,11 @@ public: } WeakPtr<LanguageClient> language_client() { return m_current_language_client; } - const String& project_path() const { return m_project_path; } + String const& project_path() const { return m_project_path; } virtual void die() override; - const LanguageClient* active_client() const { return !m_current_language_client ? nullptr : m_current_language_client.ptr(); } + LanguageClient const* active_client() const { return !m_current_language_client ? nullptr : m_current_language_client.ptr(); } protected: virtual void auto_complete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const&) override; @@ -63,11 +63,11 @@ class ConnectionToServerWrapper { AK_MAKE_NONCOPYABLE(ConnectionToServerWrapper); public: - explicit ConnectionToServerWrapper(const String& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator); + explicit ConnectionToServerWrapper(String const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator); ~ConnectionToServerWrapper() = default; template<typename LanguageServerType> - static ConnectionToServerWrapper& get_or_create(const String& project_path); + static ConnectionToServerWrapper& get_or_create(String const& project_path); Language language() const { return m_language; } ConnectionToServer* connection(); @@ -93,10 +93,10 @@ private: class ConnectionToServerInstances { public: - static void set_instance_for_language(const String& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper); - static void remove_instance_for_language(const String& language_name); + static void set_instance_for_language(String const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper); + static void remove_instance_for_language(String const& language_name); - static ConnectionToServerWrapper* get_instance_wrapper(const String& language_name); + static ConnectionToServerWrapper* get_instance_wrapper(String const& language_name); private: static HashMap<String, NonnullOwnPtr<ConnectionToServerWrapper>> s_instance_for_language; @@ -128,22 +128,22 @@ public: Language language() const { return m_connection_wrapper.language(); } void set_active_client(); bool is_active_client() const; - virtual void open_file(const String& path, int fd); - virtual void set_file_content(const String& path, const String& content); - virtual void insert_text(const String& path, const String& text, size_t line, size_t column); - virtual void remove_text(const String& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); - virtual void request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column); - virtual void search_declaration(const String& path, size_t line, size_t column); - virtual void get_parameters_hint(const String& path, size_t line, size_t column); - virtual void get_tokens_info(const String& filename); - - void provide_autocomplete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>&) const; - void declaration_found(const String& file, size_t line, size_t column) const; + virtual void open_file(String const& path, int fd); + virtual void set_file_content(String const& path, String const& content); + virtual void insert_text(String const& path, String const& text, size_t line, size_t column); + virtual void remove_text(String const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); + virtual void request_autocomplete(String const& path, size_t cursor_line, size_t cursor_column); + virtual void search_declaration(String const& path, size_t line, size_t column); + virtual void get_parameters_hint(String const& path, size_t line, size_t column); + virtual void get_tokens_info(String const& filename); + + void provide_autocomplete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const&) const; + void declaration_found(String const& file, size_t line, size_t column) const; void parameters_hint_result(Vector<String> const& params, size_t argument_index) const; // Callbacks that get called when the result of a language server query is ready Function<void(Vector<GUI::AutocompleteProvider::Entry>)> on_autocomplete_suggestions; - Function<void(const String&, size_t, size_t)> on_declaration_found; + Function<void(String const&, size_t, size_t)> on_declaration_found; Function<void(Vector<String> const&, size_t)> on_function_parameters_hint_result; Function<void(Vector<GUI::AutocompleteProvider::TokenInfo> const&)> on_tokens_info_result; @@ -153,13 +153,13 @@ private: }; template<typename ConnectionToServerT> -static inline NonnullOwnPtr<LanguageClient> get_language_client(const String& project_path) +static inline NonnullOwnPtr<LanguageClient> get_language_client(String const& project_path) { return make<LanguageClient>(ConnectionToServerWrapper::get_or_create<ConnectionToServerT>(project_path)); } template<typename LanguageServerType> -ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(const String& project_path) +ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(String const& project_path) { auto* wrapper = ConnectionToServerInstances::get_instance_wrapper(LanguageServerType::language_name()); if (wrapper) diff --git a/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h b/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h index ad430f6eca..97a642410e 100644 --- a/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h +++ b/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h @@ -17,10 +17,10 @@ class ConnectionToServer final : public HackStudio::ConnectionToServer { \ IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/portal/language/" #socket_name) \ public: \ - static const char* language_name() { return #language_name_; } \ + static char const* language_name() { return #language_name_; } \ \ private: \ - ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, const String& project_path) \ + ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, String const& project_path) \ : HackStudio::ConnectionToServer(move(socket), project_path) \ { \ } \ diff --git a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp index 044aae97ab..381a918b59 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp @@ -9,13 +9,13 @@ namespace LanguageServers { -CodeComprehensionEngine::CodeComprehensionEngine(const FileDB& filedb, bool should_store_all_declarations) +CodeComprehensionEngine::CodeComprehensionEngine(FileDB const& filedb, bool should_store_all_declarations) : m_filedb(filedb) , m_store_all_declarations(should_store_all_declarations) { } -void CodeComprehensionEngine::set_declarations_of_document(const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) +void CodeComprehensionEngine::set_declarations_of_document(String const& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { // Callback may not be configured if we're running tests if (!set_declarations_of_document_callback) diff --git a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h index 7a9f0db06d..ddca934520 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h +++ b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h @@ -18,38 +18,38 @@ class ConnectionFromClient; class CodeComprehensionEngine { public: - CodeComprehensionEngine(const FileDB& filedb, bool store_all_declarations = false); + CodeComprehensionEngine(FileDB const& filedb, bool store_all_declarations = false); virtual ~CodeComprehensionEngine() = default; - virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) = 0; + virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position) = 0; // TODO: In the future we can pass the range that was edited and only re-parse what we have to. - virtual void on_edit([[maybe_unused]] const String& file) {}; - virtual void file_opened([[maybe_unused]] const String& file) {}; + virtual void on_edit([[maybe_unused]] String const& file) {}; + virtual void file_opened([[maybe_unused]] String const& file) {}; - virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String&, const GUI::TextPosition&) { return {}; } + virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(String const&, const GUI::TextPosition&) { return {}; } struct FunctionParamsHint { Vector<String> params; size_t current_index { 0 }; }; - virtual Optional<FunctionParamsHint> get_function_params_hint(const String&, const GUI::TextPosition&) { return {}; } + virtual Optional<FunctionParamsHint> get_function_params_hint(String const&, const GUI::TextPosition&) { return {}; } - virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(const String&) { return {}; } + virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(String const&) { return {}; } public: - Function<void(const String&, Vector<GUI::AutocompleteProvider::Declaration>&&)> set_declarations_of_document_callback; + Function<void(String const&, Vector<GUI::AutocompleteProvider::Declaration>&&)> set_declarations_of_document_callback; Function<void(String const&, Vector<Cpp::Parser::TodoEntry>&&)> set_todo_entries_of_document_callback; protected: - const FileDB& filedb() const { return m_filedb; } - void set_declarations_of_document(const String&, Vector<GUI::AutocompleteProvider::Declaration>&&); + FileDB const& filedb() const { return m_filedb; } + void set_declarations_of_document(String const&, Vector<GUI::AutocompleteProvider::Declaration>&&); void set_todo_entries_of_document(String const&, Vector<Cpp::Parser::TodoEntry>&&); - const HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>>& all_declarations() const { return m_all_declarations; } + HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> const& all_declarations() const { return m_all_declarations; } private: HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> m_all_declarations; - const FileDB& m_filedb; + FileDB const& m_filedb; bool m_store_all_declarations { false }; }; } diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h index 91a34958f2..ff5744c369 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h @@ -19,7 +19,7 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make<CppComprehensionEngine>(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { async_declarations_in_document(filename, move(declarations)); }; m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<Cpp::Parser::TodoEntry>&& todo_entries) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp index 4485f2b3c1..4abfdc7861 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp @@ -20,12 +20,12 @@ namespace LanguageServers::Cpp { -CppComprehensionEngine::CppComprehensionEngine(const FileDB& filedb) +CppComprehensionEngine::CppComprehensionEngine(FileDB const& filedb) : CodeComprehensionEngine(filedb, true) { } -const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_or_create_document_data(const String& file) +CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(String const& file) { auto absolute_path = filedb().to_absolute_path(file); if (!m_documents.contains(absolute_path)) { @@ -34,7 +34,7 @@ const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_or_creat return get_document_data(absolute_path); } -const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_document_data(const String& file) const +CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(String const& file) const { auto absolute_path = filedb().to_absolute_path(file); auto document_data = m_documents.get(absolute_path); @@ -43,7 +43,7 @@ const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_document return document_data.value(); } -OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(const String& file) +OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(String const& file) { if (m_unfinished_documents.contains(file)) { return {}; @@ -56,22 +56,22 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu return create_document_data(document->text(), file); } -void CppComprehensionEngine::set_document_data(const String& file, OwnPtr<DocumentData>&& data) +void CppComprehensionEngine::set_document_data(String const& file, OwnPtr<DocumentData>&& data) { m_documents.set(filedb().to_absolute_path(file), move(data)); } -Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) +Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position) { Cpp::Position position { autocomplete_position.line(), autocomplete_position.column() > 0 ? autocomplete_position.column() - 1 : 0 }; dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine position {}:{}", position.line, position.column); - const auto* document_ptr = get_or_create_document_data(file); + auto const* document_ptr = get_or_create_document_data(file); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; auto containing_token = document.parser().token_at(position); if (containing_token.has_value() && containing_token->type() == Token::Type::IncludePath) { @@ -102,7 +102,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::get_suggestions return {}; } -Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_name(const DocumentData& document, const ASTNode& node, Optional<Token> containing_token) const +Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_name(DocumentData const& document, ASTNode const& node, Optional<Token> containing_token) const { auto partial_text = String::empty(); if (containing_token.has_value() && containing_token.value().type() != Token::Type::ColonColon) { @@ -111,7 +111,7 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a return autocomplete_name(document, node, partial_text); } -Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_property(const DocumentData& document, const ASTNode& node, Optional<Token> containing_token) const +Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_property(DocumentData const& document, ASTNode const& node, Optional<Token> containing_token) const { if (!containing_token.has_value()) return {}; @@ -119,7 +119,7 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a if (!node.parent()->is_member_expression()) return {}; - const auto& parent = static_cast<const MemberExpression&>(*node.parent()); + auto const& parent = static_cast<MemberExpression const&>(*node.parent()); auto partial_text = String::empty(); if (containing_token.value().type() != Token::Type::Dot) { @@ -131,12 +131,12 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a return autocomplete_property(document, parent, partial_text); } -Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_name(const DocumentData& document, const ASTNode& node, const String& partial_text) const +Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, String const& partial_text) const { auto reference_scope = scope_of_reference_to_symbol(node); auto current_scope = scope_of_node(node); - auto symbol_matches = [&](const Symbol& symbol) { + auto symbol_matches = [&](Symbol const& symbol) { if (!is_symbol_available(symbol, current_scope, reference_scope)) { return false; } @@ -156,7 +156,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_na Vector<Symbol> matches; - for_each_available_symbol(document, [&](const Symbol& symbol) { + for_each_available_symbol(document, [&](Symbol const& symbol) { if (symbol_matches(symbol)) { matches.append(symbol); } @@ -179,17 +179,17 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_na return suggestions; } -Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(const ASTNode& node) const +Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode const& node) const { - const Name* name = nullptr; + Name const* name = nullptr; if (node.is_name()) { // FIXME It looks like this code path is never taken - name = reinterpret_cast<const Name*>(&node); + name = reinterpret_cast<Name const*>(&node); } else if (node.is_identifier()) { auto* parent = node.parent(); if (!(parent && parent->is_name())) return {}; - name = reinterpret_cast<const Name*>(parent); + name = reinterpret_cast<Name const*>(parent); } else { return {}; } @@ -206,7 +206,7 @@ Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(const AS return scope_parts; } -Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_property(const DocumentData& document, const MemberExpression& parent, const String partial_text) const +Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const String partial_text) const { VERIFY(parent.object()); auto type = type_of(document, *parent.object()); @@ -224,7 +224,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_pr return suggestions; } -bool CppComprehensionEngine::is_property(const ASTNode& node) const +bool CppComprehensionEngine::is_property(ASTNode const& node) const { if (!node.parent()->is_member_expression()) return false; @@ -233,7 +233,7 @@ bool CppComprehensionEngine::is_property(const ASTNode& node) const return parent.property() == &node; } -String CppComprehensionEngine::type_of_property(const DocumentData& document, const Identifier& identifier) const +String CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const { auto& parent = verify_cast<MemberExpression>(*identifier.parent()); VERIFY(parent.object()); @@ -241,7 +241,7 @@ String CppComprehensionEngine::type_of_property(const DocumentData& document, co for (auto& prop : properties) { if (prop.name.name != identifier.name()) continue; - const Type* type { nullptr }; + Type const* type { nullptr }; if (prop.declaration->is_variable_declaration()) { type = verify_cast<VariableDeclaration>(*prop.declaration).type(); } @@ -258,9 +258,9 @@ String CppComprehensionEngine::type_of_property(const DocumentData& document, co return {}; } -String CppComprehensionEngine::type_of_variable(const Identifier& identifier) const +String CppComprehensionEngine::type_of_variable(Identifier const& identifier) const { - const ASTNode* current = &identifier; + ASTNode const* current = &identifier; while (current) { for (auto& decl : current->declarations()) { if (decl.is_variable_or_parameter_declaration()) { @@ -278,21 +278,21 @@ String CppComprehensionEngine::type_of_variable(const Identifier& identifier) co return {}; } -String CppComprehensionEngine::type_of(const DocumentData& document, const Expression& expression) const +String CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const { if (expression.is_member_expression()) { auto& member_expression = verify_cast<MemberExpression>(expression); VERIFY(member_expression.property()); if (member_expression.property()->is_identifier()) - return type_of_property(document, static_cast<const Identifier&>(*member_expression.property())); + return type_of_property(document, static_cast<Identifier const&>(*member_expression.property())); return {}; } - const Identifier* identifier { nullptr }; + Identifier const* identifier { nullptr }; if (expression.is_name()) { - identifier = static_cast<const Name&>(expression).name(); + identifier = static_cast<Name const&>(expression).name(); } else if (expression.is_identifier()) { - identifier = &static_cast<const Identifier&>(expression); + identifier = &static_cast<Identifier const&>(expression); } else { dbgln("expected identifier or name, got: {}", expression.class_name()); VERIFY_NOT_REACHED(); // TODO @@ -304,7 +304,7 @@ String CppComprehensionEngine::type_of(const DocumentData& document, const Expre return type_of_variable(*identifier); } -Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(const DocumentData& document, const String& type) const +Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(DocumentData const& document, String const& type) const { auto type_symbol = SymbolName::create(type); auto decl = find_declaration_of(document, type_symbol); @@ -331,17 +331,17 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_typ return properties; } -CppComprehensionEngine::Symbol CppComprehensionEngine::Symbol::create(StringView name, const Vector<StringView>& scope, NonnullRefPtr<Declaration> declaration, IsLocal is_local) +CppComprehensionEngine::Symbol CppComprehensionEngine::Symbol::create(StringView name, Vector<StringView> const& scope, NonnullRefPtr<Declaration> declaration, IsLocal is_local) { return { { name, scope }, move(declaration), is_local == IsLocal::Yes }; } -Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(const ASTNode& node) const +Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(ASTNode const& node) const { return get_child_symbols(node, {}, Symbol::IsLocal::No); } -Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(const ASTNode& node, const Vector<StringView>& scope, Symbol::IsLocal is_local) const +Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(ASTNode const& node, Vector<StringView> const& scope, Symbol::IsLocal is_local) const { Vector<Symbol> symbols; @@ -391,23 +391,23 @@ String CppComprehensionEngine::document_path_from_include_path(StringView includ return result; } -void CppComprehensionEngine::on_edit(const String& file) +void CppComprehensionEngine::on_edit(String const& file) { set_document_data(file, create_document_data_for(file)); } -void CppComprehensionEngine::file_opened([[maybe_unused]] const String& file) +void CppComprehensionEngine::file_opened([[maybe_unused]] String const& file) { get_or_create_document_data(file); } -Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) +Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) { - const auto* document_ptr = get_or_create_document_data(filename); + auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; auto decl = find_declaration_of(document, identifier_position); if (decl) { return GUI::AutocompleteProvider::ProjectLocation { decl->filename(), decl->start().line, decl->start().column }; @@ -416,7 +416,7 @@ Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::fin return find_preprocessor_definition(document, identifier_position); } -RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentData& document, const GUI::TextPosition& identifier_position) +RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(DocumentData const& document, const GUI::TextPosition& identifier_position) { auto node = document.parser().node_at(Cpp::Position { identifier_position.line(), identifier_position.column() }); if (!node) { @@ -426,7 +426,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa return find_declaration_of(document, *node); } -Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_preprocessor_definition(const DocumentData& document, const GUI::TextPosition& text_position) +Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_preprocessor_definition(DocumentData const& document, const GUI::TextPosition& text_position) { Position cpp_position { text_position.line(), text_position.column() }; auto substitution = find_preprocessor_substitution(document, cpp_position); @@ -459,11 +459,11 @@ struct TargetDeclaration { String name; }; -static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, String name); -static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node) +static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, String name); +static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node) { if (node.is_identifier()) { - return get_target_declaration(node, static_cast<const Identifier&>(node).name()); + return get_target_declaration(node, static_cast<Identifier const&>(node).name()); } if (node.is_declaration()) { @@ -478,7 +478,7 @@ static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node) return {}; } -static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, String name) +static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, String name) { if (node.parent() && node.parent()->is_name()) { auto& name_node = *verify_cast<Name>(node.parent()); @@ -509,7 +509,7 @@ static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, S return TargetDeclaration { TargetDeclaration::Type::Variable, name }; } -RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentData& document_data, const ASTNode& node) const +RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(DocumentData const& document_data, ASTNode const& node) const { dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "find_declaration_of: {} ({})", document_data.parser().text_of_node(node), node.class_name()); @@ -520,7 +520,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa auto reference_scope = scope_of_reference_to_symbol(node); auto current_scope = scope_of_node(node); - auto symbol_matches = [&](const Symbol& symbol) { + auto symbol_matches = [&](Symbol const& symbol) { bool match_function = target_decl.value().type == TargetDeclaration::Function && symbol.declaration->is_function(); bool match_variable = target_decl.value().type == TargetDeclaration::Variable && symbol.declaration->is_variable_declaration(); bool match_type = target_decl.value().type == TargetDeclaration::Type && (symbol.declaration->is_struct_or_class() || symbol.declaration->is_enum()); @@ -558,7 +558,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa Optional<Symbol> match; - for_each_available_symbol(document_data, [&](const Symbol& symbol) { + for_each_available_symbol(document_data, [&](Symbol const& symbol) { if (symbol_matches(symbol)) { match = symbol; return IterationDecision::Break; @@ -595,7 +595,7 @@ void CppComprehensionEngine::update_todo_entries(DocumentData& document) set_todo_entries_of_document(document.filename(), document.parser().get_todo_entries()); } -GUI::AutocompleteProvider::DeclarationType CppComprehensionEngine::type_of_declaration(const Declaration& decl) +GUI::AutocompleteProvider::DeclarationType CppComprehensionEngine::type_of_declaration(Declaration const& decl) { if (decl.is_struct()) return GUI::AutocompleteProvider::DeclarationType::Struct; @@ -612,7 +612,7 @@ GUI::AutocompleteProvider::DeclarationType CppComprehensionEngine::type_of_decla return GUI::AutocompleteProvider::DeclarationType::Variable; } -OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(String&& text, const String& filename) +OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(String&& text, String const& filename) { auto document_data = make<DocumentData>(); document_data->m_filename = filename; @@ -657,7 +657,7 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu return document_data; } -Vector<StringView> CppComprehensionEngine::scope_of_node(const ASTNode& node) const +Vector<StringView> CppComprehensionEngine::scope_of_node(ASTNode const& node) const { auto parent = node.parent(); @@ -683,7 +683,7 @@ Vector<StringView> CppComprehensionEngine::scope_of_node(const ASTNode& node) co return parent_scope; } -Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_include(const DocumentData&, Token include_path_token, Cpp::Position const& cursor_position) const +Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const { VERIFY(include_path_token.type() == Token::Type::IncludePath); auto partial_include = include_path_token.text().trim_whitespace(); @@ -751,10 +751,10 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a return options; } -RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const CppComprehensionEngine::DocumentData& document, const CppComprehensionEngine::SymbolName& target_symbol_name) const +RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(CppComprehensionEngine::DocumentData const& document, CppComprehensionEngine::SymbolName const& target_symbol_name) const { RefPtr<Declaration> target_declaration; - for_each_available_symbol(document, [&](const Symbol& symbol) { + for_each_available_symbol(document, [&](Symbol const& symbol) { if (symbol.name == target_symbol_name) { target_declaration = symbol.declaration; return IterationDecision::Break; @@ -797,7 +797,7 @@ String CppComprehensionEngine::SymbolName::to_string() const return String::formatted("{}::{}", scope_as_string(), name); } -bool CppComprehensionEngine::is_symbol_available(const Symbol& symbol, const Vector<StringView>& current_scope, const Vector<StringView>& reference_scope) +bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector<StringView> const& current_scope, Vector<StringView> const& reference_scope) { if (!reference_scope.is_empty()) { @@ -818,13 +818,13 @@ bool CppComprehensionEngine::is_symbol_available(const Symbol& symbol, const Vec return true; } -Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(const String& filename, const GUI::TextPosition& identifier_position) +Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(String const& filename, const GUI::TextPosition& identifier_position) { - const auto* document_ptr = get_or_create_document_data(filename); + auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; Cpp::Position cpp_position { identifier_position.line(), identifier_position.column() }; auto node = document.parser().node_at(cpp_position); if (!node) { @@ -883,7 +883,7 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get FunctionCall& call_node, size_t argument_index) { - const Identifier* callee = nullptr; + Identifier const* callee = nullptr; VERIFY(call_node.callee()); if (call_node.callee()->is_identifier()) { callee = verify_cast<Identifier>(call_node.callee()); @@ -929,15 +929,15 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get return hint; } -Vector<GUI::AutocompleteProvider::TokenInfo> CppComprehensionEngine::get_tokens_info(const String& filename) +Vector<GUI::AutocompleteProvider::TokenInfo> CppComprehensionEngine::get_tokens_info(String const& filename) { dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine::get_tokens_info: {}", filename); - const auto* document_ptr = get_or_create_document_data(filename); + auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; Vector<GUI::AutocompleteProvider::TokenInfo> tokens_info; size_t i = 0; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h index 91eb1f1b64..0473480d1d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h @@ -23,14 +23,14 @@ using namespace ::Cpp; class CppComprehensionEngine : public CodeComprehensionEngine { public: - CppComprehensionEngine(const FileDB& filedb); + CppComprehensionEngine(FileDB const& filedb); - virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override; - virtual void on_edit(const String& file) override; - virtual void file_opened([[maybe_unused]] const String& file) override; - virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) override; - virtual Optional<FunctionParamsHint> get_function_params_hint(const String&, const GUI::TextPosition&) override; - virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(const String& filename) override; + virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position) override; + virtual void on_edit(String const& file) override; + virtual void file_opened([[maybe_unused]] String const& file) override; + virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) override; + virtual Optional<FunctionParamsHint> get_function_params_hint(String const&, const GUI::TextPosition&) override; + virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(String const& filename) override; private: struct SymbolName { @@ -42,7 +42,7 @@ private: String scope_as_string() const; String to_string() const; - bool operator==(const SymbolName&) const = default; + bool operator==(SymbolName const&) const = default; }; struct Symbol { @@ -57,15 +57,15 @@ private: No, Yes }; - static Symbol create(StringView name, const Vector<StringView>& scope, NonnullRefPtr<Declaration>, IsLocal is_local); + static Symbol create(StringView name, Vector<StringView> const& scope, NonnullRefPtr<Declaration>, IsLocal is_local); }; friend Traits<SymbolName>; struct DocumentData { - const String& filename() const { return m_filename; } - const String& text() const { return m_text; } - const Preprocessor& preprocessor() const + String const& filename() const { return m_filename; } + String const& text() const { return m_text; } + Preprocessor const& preprocessor() const { VERIFY(m_preprocessor); return *m_preprocessor; @@ -75,7 +75,7 @@ private: VERIFY(m_preprocessor); return *m_preprocessor; } - const Parser& parser() const + Parser const& parser() const { VERIFY(m_parser); return *m_parser; @@ -95,52 +95,52 @@ private: HashTable<String> m_available_headers; }; - Vector<GUI::AutocompleteProvider::Entry> autocomplete_property(const DocumentData&, const MemberExpression&, const String partial_text) const; - Vector<GUI::AutocompleteProvider::Entry> autocomplete_name(const DocumentData&, const ASTNode&, const String& partial_text) const; - String type_of(const DocumentData&, const Expression&) const; - String type_of_property(const DocumentData&, const Identifier&) const; - String type_of_variable(const Identifier&) const; - bool is_property(const ASTNode&) const; - RefPtr<Declaration> find_declaration_of(const DocumentData&, const ASTNode&) const; - RefPtr<Declaration> find_declaration_of(const DocumentData&, const SymbolName&) const; - RefPtr<Declaration> find_declaration_of(const DocumentData&, const GUI::TextPosition& identifier_position); + Vector<GUI::AutocompleteProvider::Entry> autocomplete_property(DocumentData const&, MemberExpression const&, const String partial_text) const; + Vector<GUI::AutocompleteProvider::Entry> autocomplete_name(DocumentData const&, ASTNode const&, String const& partial_text) const; + String type_of(DocumentData const&, Expression const&) const; + String type_of_property(DocumentData const&, Identifier const&) const; + String type_of_variable(Identifier const&) const; + bool is_property(ASTNode const&) const; + RefPtr<Declaration> find_declaration_of(DocumentData const&, ASTNode const&) const; + RefPtr<Declaration> find_declaration_of(DocumentData const&, SymbolName const&) const; + RefPtr<Declaration> find_declaration_of(DocumentData const&, const GUI::TextPosition& identifier_position); enum class RecurseIntoScopes { No, Yes }; - Vector<Symbol> properties_of_type(const DocumentData& document, const String& type) const; - Vector<Symbol> get_child_symbols(const ASTNode&) const; - Vector<Symbol> get_child_symbols(const ASTNode&, const Vector<StringView>& scope, Symbol::IsLocal) const; + Vector<Symbol> properties_of_type(DocumentData const& document, String const& type) const; + Vector<Symbol> get_child_symbols(ASTNode const&) const; + Vector<Symbol> get_child_symbols(ASTNode const&, Vector<StringView> const& scope, Symbol::IsLocal) const; - const DocumentData* get_document_data(const String& file) const; - const DocumentData* get_or_create_document_data(const String& file); - void set_document_data(const String& file, OwnPtr<DocumentData>&& data); + DocumentData const* get_document_data(String const& file) const; + DocumentData const* get_or_create_document_data(String const& file); + void set_document_data(String const& file, OwnPtr<DocumentData>&& data); - OwnPtr<DocumentData> create_document_data_for(const String& file); + OwnPtr<DocumentData> create_document_data_for(String const& file); String document_path_from_include_path(StringView include_path) const; void update_declared_symbols(DocumentData&); void update_todo_entries(DocumentData&); - GUI::AutocompleteProvider::DeclarationType type_of_declaration(const Declaration&); - Vector<StringView> scope_of_node(const ASTNode&) const; - Vector<StringView> scope_of_reference_to_symbol(const ASTNode&) const; + GUI::AutocompleteProvider::DeclarationType type_of_declaration(Declaration const&); + Vector<StringView> scope_of_node(ASTNode const&) const; + Vector<StringView> scope_of_reference_to_symbol(ASTNode const&) const; - Optional<GUI::AutocompleteProvider::ProjectLocation> find_preprocessor_definition(const DocumentData&, const GUI::TextPosition&); + Optional<GUI::AutocompleteProvider::ProjectLocation> find_preprocessor_definition(DocumentData const&, const GUI::TextPosition&); Optional<Cpp::Preprocessor::Substitution> find_preprocessor_substitution(DocumentData const&, Cpp::Position const&); - OwnPtr<DocumentData> create_document_data(String&& text, const String& filename); - Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_property(const DocumentData&, const ASTNode&, Optional<Token> containing_token) const; - Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_name(const DocumentData&, const ASTNode&, Optional<Token> containing_token) const; - Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_include(const DocumentData&, Token include_path_token, Cpp::Position const& cursor_position) const; - static bool is_symbol_available(const Symbol&, const Vector<StringView>& current_scope, const Vector<StringView>& reference_scope); + OwnPtr<DocumentData> create_document_data(String&& text, String const& filename); + Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_property(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const; + Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_name(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const; + Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const; + static bool is_symbol_available(Symbol const&, Vector<StringView> const& current_scope, Vector<StringView> const& reference_scope); Optional<FunctionParamsHint> get_function_params_hint(DocumentData const&, FunctionCall&, size_t argument_index); template<typename Func> - void for_each_available_symbol(const DocumentData&, Func) const; + void for_each_available_symbol(DocumentData const&, Func) const; template<typename Func> - void for_each_included_document_recursive(const DocumentData&, Func) const; + void for_each_included_document_recursive(DocumentData const&, Func) const; GUI::AutocompleteProvider::TokenInfo::SemanticType get_token_semantic_type(DocumentData const&, Token const&); GUI::AutocompleteProvider::TokenInfo::SemanticType get_semantic_type_for_identifier(DocumentData const&, Position); @@ -154,7 +154,7 @@ private: }; template<typename Func> -void CppComprehensionEngine::for_each_available_symbol(const DocumentData& document, Func func) const +void CppComprehensionEngine::for_each_available_symbol(DocumentData const& document, Func func) const { for (auto& item : document.m_symbols) { auto decision = func(item.value); @@ -162,7 +162,7 @@ void CppComprehensionEngine::for_each_available_symbol(const DocumentData& docum return; } - for_each_included_document_recursive(document, [&](const DocumentData& document) { + for_each_included_document_recursive(document, [&](DocumentData const& document) { for (auto& item : document.m_symbols) { auto decision = func(item.value); if (decision == IterationDecision::Break) @@ -173,7 +173,7 @@ void CppComprehensionEngine::for_each_available_symbol(const DocumentData& docum } template<typename Func> -void CppComprehensionEngine::for_each_included_document_recursive(const DocumentData& document, Func func) const +void CppComprehensionEngine::for_each_included_document_recursive(DocumentData const& document, Func func) const { for (auto& included_path : document.m_available_headers) { auto* included_document = get_document_data(included_path); @@ -190,7 +190,7 @@ namespace AK { template<> struct Traits<LanguageServers::Cpp::CppComprehensionEngine::SymbolName> : public GenericTraits<LanguageServers::Cpp::CppComprehensionEngine::SymbolName> { - static unsigned hash(const LanguageServers::Cpp::CppComprehensionEngine::SymbolName& key) + static unsigned hash(LanguageServers::Cpp::CppComprehensionEngine::SymbolName const& key) { unsigned hash = 0; hash = pair_int_hash(hash, string_hash(key.name.characters_without_null_termination(), key.name.length())); diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp index cb2dd30fa9..14dbd87944 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp @@ -55,7 +55,7 @@ int run_tests() return s_some_test_failed ? 1 : 0; } -static void add_file(FileDB& filedb, const String& name) +static void add_file(FileDB& filedb, String const& name) { auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::OpenMode::ReadOnly); VERIFY(!file.is_error()); diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp index e3f91b9124..a45882afbe 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp @@ -12,7 +12,7 @@ namespace LanguageServers { -RefPtr<const GUI::TextDocument> FileDB::get(const String& filename) const +RefPtr<const GUI::TextDocument> FileDB::get(String const& filename) const { auto absolute_path = to_absolute_path(filename); auto document_optional = m_open_files.get(absolute_path); @@ -22,15 +22,15 @@ RefPtr<const GUI::TextDocument> FileDB::get(const String& filename) const return *document_optional.value(); } -RefPtr<GUI::TextDocument> FileDB::get(const String& filename) +RefPtr<GUI::TextDocument> FileDB::get(String const& filename) { - auto document = reinterpret_cast<const FileDB*>(this)->get(filename); + auto document = reinterpret_cast<FileDB const*>(this)->get(filename); if (document.is_null()) return nullptr; return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref())); } -RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& filename) const +RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(String const& filename) const { auto absolute_path = to_absolute_path(filename); auto document = get(absolute_path); @@ -39,20 +39,20 @@ RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const Stri return create_from_filesystem(absolute_path); } -RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& filename) +RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(String const& filename) { - auto document = reinterpret_cast<const FileDB*>(this)->get_or_create_from_filesystem(filename); + auto document = reinterpret_cast<FileDB const*>(this)->get_or_create_from_filesystem(filename); if (document.is_null()) return nullptr; return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref())); } -bool FileDB::is_open(const String& filename) const +bool FileDB::is_open(String const& filename) const { return m_open_files.contains(to_absolute_path(filename)); } -bool FileDB::add(const String& filename, int fd) +bool FileDB::add(String const& filename, int fd) { auto document = create_from_fd(fd); if (!document) @@ -62,7 +62,7 @@ bool FileDB::add(const String& filename, int fd) return true; } -String FileDB::to_absolute_path(const String& filename) const +String FileDB::to_absolute_path(String const& filename) const { if (LexicalPath { filename }.is_absolute()) { return filename; @@ -72,7 +72,7 @@ String FileDB::to_absolute_path(const String& filename) const return LexicalPath { String::formatted("{}/{}", m_project_root, filename) }.string(); } -RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(const String& filename) const +RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(String const& filename) const { auto file = Core::File::open(to_absolute_path(filename), Core::OpenMode::ReadOnly); if (file.is_error()) { @@ -120,7 +120,7 @@ RefPtr<GUI::TextDocument> FileDB::create_from_file(Core::File& file) const return document; } -void FileDB::on_file_edit_insert_text(const String& filename, const String& inserted_text, size_t start_line, size_t start_column) +void FileDB::on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column) { VERIFY(is_open(filename)); auto document = get(filename); @@ -131,7 +131,7 @@ void FileDB::on_file_edit_insert_text(const String& filename, const String& inse dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text()); } -void FileDB::on_file_edit_remove_text(const String& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column) +void FileDB::on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column) { // TODO: If file is not open - need to get its contents // Otherwise- somehow verify that respawned language server is synced with all file contents @@ -148,7 +148,7 @@ void FileDB::on_file_edit_remove_text(const String& filename, size_t start_line, dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text()); } -RefPtr<GUI::TextDocument> FileDB::create_with_content(const String& content) +RefPtr<GUI::TextDocument> FileDB::create_with_content(String const& content) { StringView content_view(content); auto document = GUI::TextDocument::create(&s_default_document_client); @@ -156,7 +156,7 @@ RefPtr<GUI::TextDocument> FileDB::create_with_content(const String& content) return document; } -bool FileDB::add(const String& filename, const String& content) +bool FileDB::add(String const& filename, String const& content) { auto document = create_with_content(content); if (!document) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h index 3e744604fb..c8d64b2182 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h @@ -15,26 +15,26 @@ namespace LanguageServers { class FileDB final { public: - RefPtr<const GUI::TextDocument> get(const String& filename) const; - RefPtr<GUI::TextDocument> get(const String& filename); - RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(const String& filename) const; - RefPtr<GUI::TextDocument> get_or_create_from_filesystem(const String& filename); - bool add(const String& filename, int fd); - bool add(const String& filename, const String& content); + RefPtr<const GUI::TextDocument> get(String const& filename) const; + RefPtr<GUI::TextDocument> get(String const& filename); + RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(String const& filename) const; + RefPtr<GUI::TextDocument> get_or_create_from_filesystem(String const& filename); + bool add(String const& filename, int fd); + bool add(String const& filename, String const& content); - void set_project_root(const String& root_path) { m_project_root = root_path; } - const String& project_root() const { return m_project_root; } + void set_project_root(String const& root_path) { m_project_root = root_path; } + String const& project_root() const { return m_project_root; } - void on_file_edit_insert_text(const String& filename, const String& inserted_text, size_t start_line, size_t start_column); - void on_file_edit_remove_text(const String& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column); - String to_absolute_path(const String& filename) const; - bool is_open(const String& filename) const; + void on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column); + void on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column); + String to_absolute_path(String const& filename) const; + bool is_open(String const& filename) const; private: - RefPtr<GUI::TextDocument> create_from_filesystem(const String& filename) const; + RefPtr<GUI::TextDocument> create_from_filesystem(String const& filename) const; RefPtr<GUI::TextDocument> create_from_fd(int fd) const; RefPtr<GUI::TextDocument> create_from_file(Core::File&) const; - static RefPtr<GUI::TextDocument> create_with_content(const String&); + static RefPtr<GUI::TextDocument> create_with_content(String const&); private: HashMap<String, NonnullRefPtr<GUI::TextDocument>> m_open_files; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h index 20eff7faf0..7e5ab2682d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h @@ -20,7 +20,7 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make<ShellComprehensionEngine>(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { async_declarations_in_document(filename, move(declarations)); }; m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<Cpp::Parser::TodoEntry>&& todo_entries) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp index 9b3dcd56ee..090ceaaa3d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp @@ -14,12 +14,12 @@ namespace LanguageServers::Shell { RefPtr<::Shell::Shell> ShellComprehensionEngine::s_shell {}; -ShellComprehensionEngine::ShellComprehensionEngine(const FileDB& filedb) +ShellComprehensionEngine::ShellComprehensionEngine(FileDB const& filedb) : CodeComprehensionEngine(filedb, true) { } -const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_or_create_document_data(const String& file) +ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(String const& file) { auto absolute_path = filedb().to_absolute_path(file); if (!m_documents.contains(absolute_path)) { @@ -28,7 +28,7 @@ const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_or_c return get_document_data(absolute_path); } -const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_document_data(const String& file) const +ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(String const& file) const { auto absolute_path = filedb().to_absolute_path(file); auto document_data = m_documents.get(absolute_path); @@ -36,7 +36,7 @@ const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_docu return *document_data.value(); } -OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(const String& file) +OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(String const& file) { auto document = filedb().get(file); if (!document) @@ -50,7 +50,7 @@ OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_ return document_data; } -void ShellComprehensionEngine::set_document_data(const String& file, OwnPtr<DocumentData>&& data) +void ShellComprehensionEngine::set_document_data(String const& file, OwnPtr<DocumentData>&& data) { m_documents.set(filedb().to_absolute_path(file), move(data)); } @@ -62,7 +62,7 @@ ShellComprehensionEngine::DocumentData::DocumentData(String&& _text, String _fil { } -const Vector<String>& ShellComprehensionEngine::DocumentData::sourced_paths() const +Vector<String> const& ShellComprehensionEngine::DocumentData::sourced_paths() const { if (all_sourced_paths.has_value()) return all_sourced_paths.value(); @@ -110,7 +110,7 @@ NonnullRefPtr<::Shell::AST::Node> ShellComprehensionEngine::DocumentData::parse( return ::Shell::AST::make_ref_counted<::Shell::AST::SyntaxError>(::Shell::AST::Position {}, "Unable to parse file"); } -size_t ShellComprehensionEngine::resolve(const ShellComprehensionEngine::DocumentData& document, const GUI::TextPosition& position) +size_t ShellComprehensionEngine::resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position) { size_t offset = 0; @@ -133,11 +133,11 @@ size_t ShellComprehensionEngine::resolve(const ShellComprehensionEngine::Documen return offset; } -Vector<GUI::AutocompleteProvider::Entry> ShellComprehensionEngine::get_suggestions(const String& file, const GUI::TextPosition& position) +Vector<GUI::AutocompleteProvider::Entry> ShellComprehensionEngine::get_suggestions(String const& file, const GUI::TextPosition& position) { dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "ShellComprehensionEngine position {}:{}", position.line(), position.column()); - const auto& document = get_or_create_document_data(file); + auto const& document = get_or_create_document_data(file); size_t offset_in_file = resolve(document, position); ::Shell::AST::HitTestResult hit_test = document.node->hit_test_position(offset_in_file); @@ -154,20 +154,20 @@ Vector<GUI::AutocompleteProvider::Entry> ShellComprehensionEngine::get_suggestio return entries; } -void ShellComprehensionEngine::on_edit(const String& file) +void ShellComprehensionEngine::on_edit(String const& file) { set_document_data(file, create_document_data_for(file)); } -void ShellComprehensionEngine::file_opened([[maybe_unused]] const String& file) +void ShellComprehensionEngine::file_opened([[maybe_unused]] String const& file) { set_document_data(file, create_document_data_for(file)); } -Optional<GUI::AutocompleteProvider::ProjectLocation> ShellComprehensionEngine::find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) +Optional<GUI::AutocompleteProvider::ProjectLocation> ShellComprehensionEngine::find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) { dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", filename, identifier_position.line(), identifier_position.column()); - const auto& document = get_or_create_document_data(filename); + auto const& document = get_or_create_document_data(filename); auto position = resolve(document, identifier_position); auto result = document.node->hit_test_position(position); if (!result.matching_node) { @@ -192,10 +192,10 @@ Optional<GUI::AutocompleteProvider::ProjectLocation> ShellComprehensionEngine::f return {}; } -void ShellComprehensionEngine::update_declared_symbols(const DocumentData& document) +void ShellComprehensionEngine::update_declared_symbols(DocumentData const& document) { struct Visitor : public ::Shell::AST::NodeVisitor { - explicit Visitor(const String& filename) + explicit Visitor(String const& filename) : filename(filename) { } @@ -225,7 +225,7 @@ void ShellComprehensionEngine::update_declared_symbols(const DocumentData& docum declarations.append({ node->name().name, { filename, node->position().start_line.line_number, node->position().start_line.line_column }, GUI::AutocompleteProvider::DeclarationType::Function, {} }); } - const String& filename; + String const& filename; Vector<GUI::AutocompleteProvider::Declaration> declarations; } visitor { document.filename }; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h index eaf4c64bd9..774a7be45a 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h @@ -13,11 +13,11 @@ namespace LanguageServers::Shell { class ShellComprehensionEngine : public CodeComprehensionEngine { public: - ShellComprehensionEngine(const FileDB& filedb); - virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& position) override; - virtual void on_edit(const String& file) override; - virtual void file_opened([[maybe_unused]] const String& file) override; - virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) override; + ShellComprehensionEngine(FileDB const& filedb); + virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(String const& file, const GUI::TextPosition& position) override; + virtual void on_edit(String const& file) override; + virtual void file_opened([[maybe_unused]] String const& file) override; + virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) override; private: struct DocumentData { @@ -26,7 +26,7 @@ private: String text; NonnullRefPtr<::Shell::AST::Node> node; - const Vector<String>& sourced_paths() const; + Vector<String> const& sourced_paths() const; private: NonnullRefPtr<::Shell::AST::Node> parse() const; @@ -34,15 +34,15 @@ private: mutable Optional<Vector<String>> all_sourced_paths {}; }; - const DocumentData& get_document_data(const String& file) const; - const DocumentData& get_or_create_document_data(const String& file); - void set_document_data(const String& file, OwnPtr<DocumentData>&& data); + DocumentData const& get_document_data(String const& file) const; + DocumentData const& get_or_create_document_data(String const& file); + void set_document_data(String const& file, OwnPtr<DocumentData>&& data); - OwnPtr<DocumentData> create_document_data_for(const String& file); + OwnPtr<DocumentData> create_document_data_for(String const& file); String document_path_from_include_path(StringView include_path) const; - void update_declared_symbols(const DocumentData&); + void update_declared_symbols(DocumentData const&); - static size_t resolve(const ShellComprehensionEngine::DocumentData& document, const GUI::TextPosition& position); + static size_t resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position); ::Shell::Shell& shell() { diff --git a/Userland/DevTools/HackStudio/Locator.cpp b/Userland/DevTools/HackStudio/Locator.cpp index 0e0a4d1379..5470a1db55 100644 --- a/Userland/DevTools/HackStudio/Locator.cpp +++ b/Userland/DevTools/HackStudio/Locator.cpp @@ -21,7 +21,7 @@ namespace HackStudio { class LocatorSuggestionModel final : public GUI::Model { public: struct Suggestion { - static Suggestion create_filename(const String& filename); + static Suggestion create_filename(String const& filename); static Suggestion create_symbol_declaration(const GUI::AutocompleteProvider::Declaration&); bool is_filename() const { return as_filename.has_value(); } @@ -76,13 +76,13 @@ public: return {}; } - const Vector<Suggestion>& suggestions() const { return m_suggestions; } + Vector<Suggestion> const& suggestions() const { return m_suggestions; } private: Vector<Suggestion> m_suggestions; }; -LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(const String& filename) +LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(String const& filename) { LocatorSuggestionModel::Suggestion s; s.as_filename = filename; diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index 561684ec36..ed91439b87 100644 --- a/Userland/DevTools/HackStudio/Project.cpp +++ b/Userland/DevTools/HackStudio/Project.cpp @@ -10,13 +10,13 @@ namespace HackStudio { -Project::Project(const String& root_path) +Project::Project(String const& root_path) : m_root_path(root_path) { m_model = GUI::FileSystemModel::create(root_path, GUI::FileSystemModel::Mode::FilesAndDirectories); } -OwnPtr<Project> Project::open_with_root_path(const String& root_path) +OwnPtr<Project> Project::open_with_root_path(String const& root_path) { if (!Core::File::is_directory(root_path)) return {}; @@ -37,7 +37,7 @@ static void traverse_model(const GUI::FileSystemModel& model, const GUI::ModelIn } } -void Project::for_each_text_file(Function<void(const ProjectFile&)> callback) const +void Project::for_each_text_file(Function<void(ProjectFile const&)> callback) const { traverse_model(model(), {}, [&](auto& index) { auto file = create_file(model().full_path(index)); @@ -45,7 +45,7 @@ void Project::for_each_text_file(Function<void(const ProjectFile&)> callback) co }); } -NonnullRefPtr<ProjectFile> Project::create_file(const String& path) const +NonnullRefPtr<ProjectFile> Project::create_file(String const& path) const { auto full_path = to_absolute_path(path); return ProjectFile::construct_with_name(full_path); diff --git a/Userland/DevTools/HackStudio/Project.h b/Userland/DevTools/HackStudio/Project.h index 573564e02f..7763cfe752 100644 --- a/Userland/DevTools/HackStudio/Project.h +++ b/Userland/DevTools/HackStudio/Project.h @@ -19,21 +19,21 @@ class Project { AK_MAKE_NONMOVABLE(Project); public: - static OwnPtr<Project> open_with_root_path(const String& root_path); + static OwnPtr<Project> open_with_root_path(String const& root_path); GUI::FileSystemModel& model() { return *m_model; } const GUI::FileSystemModel& model() const { return *m_model; } String name() const { return LexicalPath::basename(m_root_path); } String root_path() const { return m_root_path; } - NonnullRefPtr<ProjectFile> create_file(const String& path) const; + NonnullRefPtr<ProjectFile> create_file(String const& path) const; - void for_each_text_file(Function<void(const ProjectFile&)>) const; + void for_each_text_file(Function<void(ProjectFile const&)>) const; String to_absolute_path(String const&) const; bool project_is_serenity() const; private: - explicit Project(const String& root_path); + explicit Project(String const& root_path); RefPtr<GUI::FileSystemModel> m_model; diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index 22cfdbdeba..e5d924fbbb 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -98,7 +98,7 @@ ErrorOr<String> ProjectBuilder::component_name(StringView cmake_file_path) { auto content = TRY(Core::File::open(cmake_file_path, Core::OpenMode::ReadOnly))->read_all(); - static const Regex<ECMA262> component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~"); + static Regex<ECMA262> const component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~"); RegexResult result; if (!component_name.search(StringView { content }, result)) return Error::from_string_literal("component not found"sv); @@ -192,7 +192,7 @@ void ProjectBuilder::for_each_library_definition(Function<void(String, String)> return; } - static const Regex<ECMA262> parse_library_definition(R"~~~(.+:serenity_lib[c]?\((\w+) (\w+)\).*)~~~"); + static Regex<ECMA262> const parse_library_definition(R"~~~(.+:serenity_lib[c]?\((\w+) (\w+)\).*)~~~"); for (auto& line : res.value().output.split('\n')) { RegexResult result; if (!parse_library_definition.search(line, result)) @@ -219,7 +219,7 @@ void ProjectBuilder::for_each_library_dependencies(Function<void(String, Vector< return; } - static const Regex<ECMA262> parse_library_definition(R"~~~(.+:target_link_libraries\((\w+) ([\w\s]+)\).*)~~~"); + static Regex<ECMA262> const parse_library_definition(R"~~~(.+:target_link_libraries\((\w+) ([\w\s]+)\).*)~~~"); for (auto& line : res.value().output.split('\n')) { RegexResult result; diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp index 4e75eaa580..8828de0418 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp @@ -11,7 +11,7 @@ HackStudio::ProjectDeclarations& HackStudio::ProjectDeclarations::the() static ProjectDeclarations s_instance; return s_instance; } -void HackStudio::ProjectDeclarations::set_declared_symbols(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>& declarations) +void HackStudio::ProjectDeclarations::set_declared_symbols(String const& filename, Vector<GUI::AutocompleteProvider::Declaration> const& declarations) { m_document_to_declarations.set(filename, declarations); if (on_update) diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.h b/Userland/DevTools/HackStudio/ProjectDeclarations.h index e7ffd5b4b0..70c2a15d4a 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.h +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.h @@ -23,7 +23,7 @@ public: template<typename Func> void for_each_declared_symbol(Func); - void set_declared_symbols(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>&); + void set_declared_symbols(String const& filename, Vector<GUI::AutocompleteProvider::Declaration> const&); static Optional<GUI::Icon> get_icon_for(GUI::AutocompleteProvider::DeclarationType); diff --git a/Userland/DevTools/HackStudio/ProjectFile.cpp b/Userland/DevTools/HackStudio/ProjectFile.cpp index 90136b2fdd..70e8b9073d 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.cpp +++ b/Userland/DevTools/HackStudio/ProjectFile.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -ProjectFile::ProjectFile(const String& name) +ProjectFile::ProjectFile(String const& name) : m_name(name) { } diff --git a/Userland/DevTools/HackStudio/ProjectFile.h b/Userland/DevTools/HackStudio/ProjectFile.h index 72fc3e7a24..e2b3c96404 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.h +++ b/Userland/DevTools/HackStudio/ProjectFile.h @@ -16,12 +16,12 @@ namespace HackStudio { class ProjectFile : public RefCounted<ProjectFile> { public: - static NonnullRefPtr<ProjectFile> construct_with_name(const String& name) + static NonnullRefPtr<ProjectFile> construct_with_name(String const& name) { return adopt_ref(*new ProjectFile(name)); } - const String& name() const { return m_name; } + String const& name() const { return m_name; } bool could_render_text() const { return m_could_render_text; } GUI::TextDocument& document() const; @@ -33,7 +33,7 @@ public: void horizontal_scroll_value(int); private: - explicit ProjectFile(const String& name); + explicit ProjectFile(String const& name); void create_document_if_needed() const; String m_name; diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 2f823c9143..ad265b9b72 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -19,7 +19,7 @@ namespace HackStudio { -ProjectTemplate::ProjectTemplate(const String& id, const String& name, const String& description, const GUI::Icon& icon, int priority) +ProjectTemplate::ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority) : m_id(id) , m_name(name) , m_description(description) @@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(const String& id, const String& name, const Str { } -RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manifest_path) +RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manifest_path) { auto maybe_config = Core::ConfigFile::open(manifest_path); if (maybe_config.is_error()) @@ -61,7 +61,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manife return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority)); } -Result<void, String> ProjectTemplate::create_project(const String& name, const String& path) +Result<void, String> ProjectTemplate::create_project(String const& name, String const& path) { // Check if a file or directory already exists at the project path if (Core::File::exists(path)) @@ -97,7 +97,7 @@ Result<void, String> ProjectTemplate::create_project(const String& name, const S auto namespace_safe = name.replace("-", "_", true); pid_t child_pid; - const char* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr }; + char const* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr }; if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.h b/Userland/DevTools/HackStudio/ProjectTemplate.h index 35f09bd70d..7a42e90d5d 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.h +++ b/Userland/DevTools/HackStudio/ProjectTemplate.h @@ -20,15 +20,15 @@ class ProjectTemplate : public RefCounted<ProjectTemplate> { public: static String templates_path() { return "/res/devel/templates"; } - static RefPtr<ProjectTemplate> load_from_manifest(const String& manifest_path); + static RefPtr<ProjectTemplate> load_from_manifest(String const& manifest_path); - explicit ProjectTemplate(const String& id, const String& name, const String& description, const GUI::Icon& icon, int priority); + explicit ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority); - Result<void, String> create_project(const String& name, const String& path); + Result<void, String> create_project(String const& name, String const& path); - const String& id() const { return m_id; } - const String& name() const { return m_name; } - const String& description() const { return m_description; } + String const& id() const { return m_id; } + String const& name() const { return m_name; } + String const& description() const { return m_description; } const GUI::Icon& icon() const { return m_icon; } const String content_path() const { diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.cpp b/Userland/DevTools/HackStudio/TerminalWrapper.cpp index de85ad006d..1c1ee04c0b 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.cpp +++ b/Userland/DevTools/HackStudio/TerminalWrapper.cpp @@ -24,7 +24,7 @@ namespace HackStudio { -ErrorOr<void> TerminalWrapper::run_command(const String& command, Optional<String> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message) +ErrorOr<void> TerminalWrapper::run_command(String const& command, Optional<String> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message) { if (m_pid != -1) { GUI::MessageBox::show(window(), @@ -62,7 +62,7 @@ ErrorOr<void> TerminalWrapper::run_command(const String& command, Optional<Strin auto parts = command.split(' '); VERIFY(!parts.is_empty()); - const char** args = (const char**)calloc(parts.size() + 1, sizeof(const char*)); + char const** args = (char const**)calloc(parts.size() + 1, sizeof(char const*)); for (size_t i = 0; i < parts.size(); i++) { args[i] = parts[i].characters(); } diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.h b/Userland/DevTools/HackStudio/TerminalWrapper.h index 128aff05e2..28373a7942 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.h +++ b/Userland/DevTools/HackStudio/TerminalWrapper.h @@ -21,7 +21,7 @@ public: No, Yes }; - ErrorOr<void> run_command(const String&, Optional<String> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {}); + ErrorOr<void> run_command(String const&, Optional<String> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {}); ErrorOr<void> kill_running_command(); void clear_including_history(); diff --git a/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp b/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp index f734e45247..1228098553 100644 --- a/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp +++ b/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp @@ -86,7 +86,7 @@ private: void ToDoEntriesWidget::refresh() { - const auto& entries = ToDoEntries::the().get_entries(); + auto const& entries = ToDoEntries::the().get_entries(); auto results_model = adopt_ref(*new ToDoEntriesModel(move(entries))); m_result_view->set_model(results_model); } diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index 0b1cd19290..9473fcdc4d 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) notify_make_not_available(); } - const char* path_argument = nullptr; + char const* path_argument = nullptr; bool mode_coredump = false; Core::ArgsParser args_parser; args_parser.add_positional_argument(path_argument, "Path to a workspace or a file", "path", Core::ArgsParser::Required::No); @@ -94,7 +94,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) static bool make_is_available() { pid_t pid; - const char* argv[] = { "make", "--version", nullptr }; + char const* argv[] = { "make", "--version", nullptr }; posix_spawn_file_actions_t action; posix_spawn_file_actions_init(&action); posix_spawn_file_actions_addopen(&action, STDOUT_FILENO, "/dev/null", O_WRONLY, 0); @@ -147,12 +147,12 @@ GUI::TextEditor& current_editor() return s_hack_studio_widget->current_editor(); } -void open_file(const String& filename) +void open_file(String const& filename) { s_hack_studio_widget->open_file(filename); } -void open_file(const String& filename, size_t line, size_t column) +void open_file(String const& filename, size_t line, size_t column) { s_hack_studio_widget->open_file(filename, line, column); } diff --git a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp index 85f3aa1936..c9f73d000a 100644 --- a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp +++ b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp @@ -17,7 +17,7 @@ RemoteObjectPropertyModel::RemoteObjectPropertyModel(RemoteObject& object) int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const { - Function<int(const JsonValue&)> do_count = [&](const JsonValue& value) { + Function<int(JsonValue const&)> do_count = [&](JsonValue const& value) { if (value.is_array()) return value.as_array().size(); else if (value.is_object()) @@ -26,7 +26,7 @@ int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const }; if (index.is_valid()) { - auto* path = static_cast<const JsonPath*>(index.internal_data()); + auto* path = static_cast<JsonPath const*>(index.internal_data()); return do_count(path->resolve(m_object.json)); } else { return do_count(m_object.json); @@ -46,7 +46,7 @@ String RemoteObjectPropertyModel::column_name(int column) const GUI::Variant RemoteObjectPropertyModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* path = static_cast<const JsonPath*>(index.internal_data()); + auto* path = static_cast<JsonPath const*>(index.internal_data()); if (!path) return {}; @@ -72,7 +72,7 @@ void RemoteObjectPropertyModel::set_data(const GUI::ModelIndex& index, const GUI if (!index.is_valid()) return; - auto* path = static_cast<const JsonPath*>(index.internal_data()); + auto* path = static_cast<JsonPath const*>(index.internal_data()); if (path->size() != 1) return; @@ -83,9 +83,9 @@ void RemoteObjectPropertyModel::set_data(const GUI::ModelIndex& index, const GUI GUI::ModelIndex RemoteObjectPropertyModel::index(int row, int column, const GUI::ModelIndex& parent) const { - const auto& parent_path = parent.is_valid() ? *static_cast<const JsonPath*>(parent.internal_data()) : JsonPath {}; + auto const& parent_path = parent.is_valid() ? *static_cast<JsonPath const*>(parent.internal_data()) : JsonPath {}; - auto nth_child = [&](int n, const JsonValue& value) -> const JsonPath* { + auto nth_child = [&](int n, JsonValue const& value) -> JsonPath const* { auto path = make<JsonPath>(); path->extend(parent_path); int row_index = n; @@ -135,7 +135,7 @@ GUI::ModelIndex RemoteObjectPropertyModel::parent_index(const GUI::ModelIndex& i if (!index.is_valid()) return index; - auto path = *static_cast<const JsonPath*>(index.internal_data()); + auto path = *static_cast<JsonPath const*>(index.internal_data()); if (path.is_empty()) return {}; @@ -168,12 +168,12 @@ GUI::ModelIndex RemoteObjectPropertyModel::parent_index(const GUI::ModelIndex& i return {}; } -const JsonPath* RemoteObjectPropertyModel::cached_path_at(int n, const Vector<JsonPathElement>& prefix) const +JsonPath const* RemoteObjectPropertyModel::cached_path_at(int n, Vector<JsonPathElement> const& prefix) const { // FIXME: ModelIndex wants a void*, so we have to keep these // indices alive, but allocating a new path every time // we're asked for an index is silly, so we have to look for existing ones first. - const JsonPath* index_path = nullptr; + JsonPath const* index_path = nullptr; int row_index = n; for (auto& path : m_paths) { if (path.size() != prefix.size() + 1) @@ -195,7 +195,7 @@ const JsonPath* RemoteObjectPropertyModel::cached_path_at(int n, const Vector<Js return index_path; }; -const JsonPath* RemoteObjectPropertyModel::find_cached_path(const Vector<JsonPathElement>& path) const +JsonPath const* RemoteObjectPropertyModel::find_cached_path(Vector<JsonPathElement> const& path) const { for (auto& cpath : m_paths) { if (cpath.size() != path.size()) diff --git a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h index 8dc7a3d134..5b724996e0 100644 --- a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h +++ b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h @@ -41,8 +41,8 @@ public: private: explicit RemoteObjectPropertyModel(RemoteObject&); - const JsonPath* cached_path_at(int n, const Vector<JsonPathElement>& prefix) const; - const JsonPath* find_cached_path(const Vector<JsonPathElement>& path) const; + JsonPath const* cached_path_at(int n, Vector<JsonPathElement> const& prefix) const; + JsonPath const* find_cached_path(Vector<JsonPathElement> const& path) const; RemoteObject& m_object; mutable NonnullOwnPtrVector<JsonPath> m_paths; diff --git a/Userland/DevTools/Inspector/RemoteProcess.cpp b/Userland/DevTools/Inspector/RemoteProcess.cpp index 20227702f2..5bb52c020b 100644 --- a/Userland/DevTools/Inspector/RemoteProcess.cpp +++ b/Userland/DevTools/Inspector/RemoteProcess.cpp @@ -27,7 +27,7 @@ RemoteProcess::RemoteProcess(pid_t pid) m_client = InspectorServerClient::try_create().release_value_but_fixme_should_propagate_errors(); } -void RemoteProcess::handle_identify_response(const JsonObject& response) +void RemoteProcess::handle_identify_response(JsonObject const& response) { int pid = response.get("pid").to_int(); VERIFY(pid == m_pid); @@ -38,7 +38,7 @@ void RemoteProcess::handle_identify_response(const JsonObject& response) on_update(); } -void RemoteProcess::handle_get_all_objects_response(const JsonObject& response) +void RemoteProcess::handle_get_all_objects_response(JsonObject const& response) { // FIXME: It would be good if we didn't have to make a local copy of the array value here! auto objects = response.get("objects"); @@ -82,7 +82,7 @@ void RemoteProcess::set_inspected_object(FlatPtr address) m_client->async_set_inspected_object(m_pid, address); } -void RemoteProcess::set_property(FlatPtr object, StringView name, const JsonValue& value) +void RemoteProcess::set_property(FlatPtr object, StringView name, JsonValue const& value) { m_client->async_set_object_property(m_pid, object, name, value.to_string()); } diff --git a/Userland/DevTools/Inspector/RemoteProcess.h b/Userland/DevTools/Inspector/RemoteProcess.h index 6f6fd4bc7d..a012424ef1 100644 --- a/Userland/DevTools/Inspector/RemoteProcess.h +++ b/Userland/DevTools/Inspector/RemoteProcess.h @@ -22,24 +22,24 @@ public: void update(); pid_t pid() const { return m_pid; } - const String& process_name() const { return m_process_name; } + String const& process_name() const { return m_process_name; } RemoteObjectGraphModel& object_graph_model() { return *m_object_graph_model; } - const NonnullOwnPtrVector<RemoteObject>& roots() const { return m_roots; } + NonnullOwnPtrVector<RemoteObject> const& roots() const { return m_roots; } void set_inspected_object(FlatPtr); - void set_property(FlatPtr object, StringView name, const JsonValue& value); + void set_property(FlatPtr object, StringView name, JsonValue const& value); bool is_inspectable(); Function<void()> on_update; private: - void handle_get_all_objects_response(const JsonObject&); - void handle_identify_response(const JsonObject&); + void handle_get_all_objects_response(JsonObject const&); + void handle_identify_response(JsonObject const&); - void send_request(const JsonObject&); + void send_request(JsonObject const&); pid_t m_pid { -1 }; String m_process_name; diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index d0cfe3e5ea..f7a2781684 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -37,14 +37,14 @@ class UnregisteredWidget final : public GUI::Widget { C_OBJECT(UnregisteredWidget); private: - UnregisteredWidget(const String& class_name); + UnregisteredWidget(String const& class_name); virtual void paint_event(GUI::PaintEvent& event) override; String m_text; }; -UnregisteredWidget::UnregisteredWidget(const String& class_name) +UnregisteredWidget::UnregisteredWidget(String const& class_name) { StringBuilder builder; builder.append(class_name); @@ -72,7 +72,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio thread recvfd sendfd rpath cpath wpath")); - const char* path = nullptr; + char const* path = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(path, "GML file to edit", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); diff --git a/Userland/DevTools/Profiler/FilesystemEventModel.cpp b/Userland/DevTools/Profiler/FilesystemEventModel.cpp index 96b9835cf1..f673bb0e0e 100644 --- a/Userland/DevTools/Profiler/FilesystemEventModel.cpp +++ b/Userland/DevTools/Profiler/FilesystemEventModel.cpp @@ -108,7 +108,7 @@ GUI::ModelIndex FileEventModel::parent_index(GUI::ModelIndex const& index) const return {}; if (node.parent()->parent()) { - const auto& children = node.parent()->parent()->children(); + auto const& children = node.parent()->parent()->children(); for (size_t row = 0; row < children.size(); ++row) { if (children.at(row).ptr() == node.parent()) { @@ -117,7 +117,7 @@ GUI::ModelIndex FileEventModel::parent_index(GUI::ModelIndex const& index) const } } - const auto& children = node.parent()->children(); + auto const& children = node.parent()->children(); for (size_t row = 0; row < children.size(); ++row) { if (children.at(row).ptr() == &node) { diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index c94426fc0d..c8644a38c7 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -388,7 +388,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path it->value->handle_thread_exit(event.tid, event.serial); continue; } else if (type_string == "read"sv) { - const auto string_index = perf_event.get("filename_index"sv).to_number<FlatPtr>(); + auto const string_index = perf_event.get("filename_index"sv).to_number<FlatPtr>(); event.data = Event::ReadData { .fd = perf_event.get("fd"sv).to_number<int>(), .size = perf_event.get("size"sv).to_number<size_t>(), diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index 29b113f8ff..4f53aa50c8 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -125,8 +125,8 @@ public: private: const String m_executable_path; - const Vector<StringView> m_arguments; - const Vector<String> m_environment; + Vector<StringView> const m_arguments; + Vector<String> const m_environment; SoftMMU m_mmu; NonnullOwnPtr<SoftCPU> m_cpu; diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index e2b2e668e3..7f10a25c6b 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -371,11 +371,11 @@ int Emulator::virt$symlink(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto target = mmu().copy_buffer_from_vm((FlatPtr)params.target.characters, params.target.length); - params.target.characters = (const char*)target.data(); + params.target.characters = (char const*)target.data(); params.target.length = target.size(); auto link = mmu().copy_buffer_from_vm((FlatPtr)params.linkpath.characters, params.linkpath.length); - params.linkpath.characters = (const char*)link.data(); + params.linkpath.characters = (char const*)link.data(); params.linkpath.length = link.size(); return syscall(SC_symlink, ¶ms); @@ -387,11 +387,11 @@ int Emulator::virt$rename(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto new_path = mmu().copy_buffer_from_vm((FlatPtr)params.new_path.characters, params.new_path.length); - params.new_path.characters = (const char*)new_path.data(); + params.new_path.characters = (char const*)new_path.data(); params.new_path.length = new_path.size(); auto old_path = mmu().copy_buffer_from_vm((FlatPtr)params.old_path.characters, params.old_path.length); - params.old_path.characters = (const char*)old_path.data(); + params.old_path.characters = (char const*)old_path.data(); params.old_path.length = old_path.size(); return syscall(SC_rename, ¶ms); @@ -403,11 +403,11 @@ int Emulator::virt$set_coredump_metadata(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto key = mmu().copy_buffer_from_vm((FlatPtr)params.key.characters, params.key.length); - params.key.characters = (const char*)key.data(); + params.key.characters = (char const*)key.data(); params.key.length = key.size(); auto value = mmu().copy_buffer_from_vm((FlatPtr)params.value.characters, params.value.length); - params.value.characters = (const char*)value.data(); + params.value.characters = (char const*)value.data(); params.value.length = value.size(); return syscall(SC_set_coredump_metadata, ¶ms); @@ -416,7 +416,7 @@ int Emulator::virt$set_coredump_metadata(FlatPtr params_addr) int Emulator::virt$dbgputstr(FlatPtr characters, int length) { auto buffer = mmu().copy_buffer_from_vm(characters, length); - dbgputstr((const char*)buffer.data(), buffer.size()); + dbgputstr((char const*)buffer.data(), buffer.size()); return 0; } @@ -437,7 +437,7 @@ int Emulator::virt$chown(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto path = mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length); - params.path.characters = (const char*)path.data(); + params.path.characters = (char const*)path.data(); params.path.length = path.size(); return syscall(SC_chown, ¶ms); @@ -635,7 +635,7 @@ int Emulator::virt$recvmsg(int sockfd, FlatPtr msg_addr, int flags) mmu().copy_from_vm(mmu_iovs.data(), (FlatPtr)mmu_msg.msg_iov, mmu_msg.msg_iovlen * sizeof(iovec)); Vector<ByteBuffer, 1> buffers; Vector<iovec, 1> iovs; - for (const auto& iov : mmu_iovs) { + for (auto const& iov : mmu_iovs) { auto buffer_result = ByteBuffer::create_uninitialized(iov.iov_len); if (buffer_result.is_error()) return -ENOMEM; @@ -819,7 +819,7 @@ u32 Emulator::virt$open(u32 params_addr) host_params.dirfd = params.dirfd; host_params.mode = params.mode; host_params.options = params.options; - host_params.path.characters = (const char*)path.data(); + host_params.path.characters = (char const*)path.data(); host_params.path.length = path.size(); return syscall(SC_open, &host_params); @@ -1315,7 +1315,7 @@ int Emulator::virt$realpath(FlatPtr params_addr) auto& host_buffer = buffer_result.value(); Syscall::SC_realpath_params host_params; - host_params.path = { (const char*)path.data(), path.size() }; + host_params.path = { (char const*)path.data(), path.size() }; host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() }; int rc = syscall(SC_realpath, &host_params); if (rc < 0) @@ -1587,7 +1587,7 @@ int Emulator::virt$readlink(FlatPtr params_addr) auto& host_buffer = buffer_result.value(); Syscall::SC_readlink_params host_params; - host_params.path = { (const char*)path.data(), path.size() }; + host_params.path = { (char const*)path.data(), path.size() }; host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() }; int rc = syscall(SC_readlink, &host_params); if (rc < 0) diff --git a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp index 291d8f8d48..2ba544f9af 100644 --- a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -208,7 +208,7 @@ Mallocation* MallocTracer::find_mallocation_after(FlatPtr address) return found_mallocation; } -void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size) +void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size) { if (!m_auditing_enabled) return; @@ -259,7 +259,7 @@ void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size } } -void MallocTracer::audit_write(const Region& region, FlatPtr address, size_t size) +void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t size) { if (!m_auditing_enabled) return; diff --git a/Userland/DevTools/UserspaceEmulator/MallocTracer.h b/Userland/DevTools/UserspaceEmulator/MallocTracer.h index 8d35d9ed04..fe43d79987 100644 --- a/Userland/DevTools/UserspaceEmulator/MallocTracer.h +++ b/Userland/DevTools/UserspaceEmulator/MallocTracer.h @@ -63,8 +63,8 @@ public: void target_did_realloc(Badge<Emulator>, FlatPtr address, size_t); void target_did_change_chunk_size(Badge<Emulator>, FlatPtr, size_t); - void audit_read(const Region&, FlatPtr address, size_t); - void audit_write(const Region&, FlatPtr address, size_t); + void audit_read(Region const&, FlatPtr address, size_t); + void audit_write(Region const&, FlatPtr address, size_t); void dump_leak_report(); @@ -72,7 +72,7 @@ private: template<typename Callback> void for_each_mallocation(Callback callback) const; - Mallocation* find_mallocation(const Region&, FlatPtr); + Mallocation* find_mallocation(Region const&, FlatPtr); Mallocation* find_mallocation(FlatPtr); Mallocation* find_mallocation_before(FlatPtr); Mallocation* find_mallocation_after(FlatPtr); @@ -89,11 +89,11 @@ private: bool m_auditing_enabled { true }; }; -ALWAYS_INLINE Mallocation* MallocTracer::find_mallocation(const Region& region, FlatPtr address) +ALWAYS_INLINE Mallocation* MallocTracer::find_mallocation(Region const& region, FlatPtr address) { if (!is<MmapRegion>(region)) return nullptr; - if (!static_cast<const MmapRegion&>(region).is_malloc_block()) + if (!static_cast<MmapRegion const&>(region).is_malloc_block()) return nullptr; auto* malloc_data = static_cast<MmapRegion&>(const_cast<Region&>(region)).malloc_metadata(); if (!malloc_data) diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp index 7a2d6a78be..9c525c6ec9 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -12,7 +12,7 @@ namespace UserspaceEmulator { -static void* mmap_initialized(size_t bytes, char initial_value, const char* name) +static void* mmap_initialized(size_t bytes, char initial_value, char const* name) { auto* ptr = mmap_with_name(nullptr, bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, name); VERIFY(ptr != MAP_FAILED); diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.h b/Userland/DevTools/UserspaceEmulator/MmapRegion.h index 82ee22a6aa..62d0e50308 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.h +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.h @@ -51,7 +51,7 @@ public: MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; } void set_malloc_metadata(Badge<MallocTracer>, NonnullOwnPtr<MallocRegionMetadata> metadata) { m_malloc_metadata = move(metadata); } - const String& name() const { return m_name; } + String const& name() const { return m_name; } String lib_name() const { if (m_name.contains("Loader.so"sv)) diff --git a/Userland/DevTools/UserspaceEmulator/Range.cpp b/Userland/DevTools/UserspaceEmulator/Range.cpp index 59bfcff501..ca1e13b4f8 100644 --- a/Userland/DevTools/UserspaceEmulator/Range.cpp +++ b/Userland/DevTools/UserspaceEmulator/Range.cpp @@ -9,7 +9,7 @@ namespace UserspaceEmulator { -Vector<Range, 2> Range::carve(const Range& taken) const +Vector<Range, 2> Range::carve(Range const& taken) const { VERIFY((taken.size() % PAGE_SIZE) == 0); Vector<Range, 2> parts; diff --git a/Userland/DevTools/UserspaceEmulator/Range.h b/Userland/DevTools/UserspaceEmulator/Range.h index 31a1d9e09d..29750e0530 100644 --- a/Userland/DevTools/UserspaceEmulator/Range.h +++ b/Userland/DevTools/UserspaceEmulator/Range.h @@ -30,7 +30,7 @@ public: VirtualAddress end() const { return m_base.offset(m_size); } - bool operator==(const Range& other) const + bool operator==(Range const& other) const { return m_base == other.m_base && m_size == other.m_size; } @@ -42,12 +42,12 @@ public: return base >= m_base && base.offset(size) <= end(); } - bool contains(const Range& other) const + bool contains(Range const& other) const { return contains(other.base(), other.size()); } - Vector<Range, 2> carve(const Range&) const; + Vector<Range, 2> carve(Range const&) const; Range split_at(VirtualAddress address) { diff --git a/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp b/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp index 8ed75c51cd..d673d7febd 100644 --- a/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp +++ b/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp @@ -33,7 +33,7 @@ void RangeAllocator::dump() const } } -void RangeAllocator::carve_at_index(int index, const Range& range) +void RangeAllocator::carve_at_index(int index, Range const& range) { auto remaining_parts = m_available_ranges[index].carve(range); VERIFY(remaining_parts.size() >= 1); @@ -142,7 +142,7 @@ Optional<Range> RangeAllocator::allocate_specific(VirtualAddress base, size_t si return {}; } -void RangeAllocator::deallocate(const Range& range) +void RangeAllocator::deallocate(Range const& range) { VERIFY(m_total_range.contains(range)); VERIFY(range.size()); diff --git a/Userland/DevTools/UserspaceEmulator/RangeAllocator.h b/Userland/DevTools/UserspaceEmulator/RangeAllocator.h index c0957d8021..63f9155d1a 100644 --- a/Userland/DevTools/UserspaceEmulator/RangeAllocator.h +++ b/Userland/DevTools/UserspaceEmulator/RangeAllocator.h @@ -20,16 +20,16 @@ public: Optional<Range> allocate_anywhere(size_t, size_t alignment = PAGE_SIZE); Optional<Range> allocate_specific(VirtualAddress, size_t); Optional<Range> allocate_randomized(size_t, size_t alignment); - void deallocate(const Range&); + void deallocate(Range const&); void reserve_user_range(VirtualAddress, size_t); void dump() const; - bool contains(const Range& range) const { return m_total_range.contains(range); } + bool contains(Range const& range) const { return m_total_range.contains(range); } private: - void carve_at_index(int, const Range&); + void carve_at_index(int, Range const&); Vector<Range> m_available_ranges; Range m_total_range; diff --git a/Userland/DevTools/UserspaceEmulator/Region.h b/Userland/DevTools/UserspaceEmulator/Region.h index 3efea3ad1a..9309ae38a5 100644 --- a/Userland/DevTools/UserspaceEmulator/Region.h +++ b/Userland/DevTools/UserspaceEmulator/Region.h @@ -21,7 +21,7 @@ class Region { public: virtual ~Region() = default; - const Range& range() const { return m_range; } + Range const& range() const { return m_range; } u32 base() const { return m_range.base().get(); } u32 size() const { return m_range.size(); } @@ -63,7 +63,7 @@ public: virtual u8* shadow_data() = 0; Emulator& emulator() { return m_emulator; } - const Emulator& emulator() const { return m_emulator; } + Emulator const& emulator() const { return m_emulator; } template<typename T> bool fast_is() const = delete; diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp index 5c664d2fdf..50782cd0d9 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -46,7 +46,7 @@ namespace UserspaceEmulator { template<typename T> -ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message) +ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message) { if (value_with_shadow.is_uninitialized()) [[unlikely]] { reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); @@ -54,7 +54,7 @@ ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* messag } } -ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(const char* message) const +ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(char const* message) const { if (m_flags_tainted) [[unlikely]] { reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message); @@ -208,7 +208,7 @@ void SoftCPU::push_string(StringView string) m_emulator.mmu().write8({ 0x23, esp().value() + string.length() }, shadow_wrap_as_initialized((u8)'\0')); } -void SoftCPU::push_buffer(const u8* data, size_t size) +void SoftCPU::push_buffer(u8 const* data, size_t size) { set_esp({ esp().value() - size, esp().shadow() }); warn_if_uninitialized(esp(), "push_buffer"); diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.h b/Userland/DevTools/UserspaceEmulator/SoftCPU.h index e139a3a810..070d451092 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.h @@ -81,7 +81,7 @@ public: ValueWithShadow<u16> pop16(); void push_string(StringView); - void push_buffer(const u8* data, size_t); + void push_buffer(u8 const* data, size_t); u16 segment(X86::SegmentRegister seg) const { return m_segment[(int)seg]; } u16& segment(X86::SegmentRegister seg) { return m_segment[(int)seg]; } @@ -463,7 +463,7 @@ public: m_flags_tainted = a.is_uninitialized() || b.is_uninitialized() || c.is_uninitialized(); } - void warn_if_flags_tainted(const char* message) const; + void warn_if_flags_tainted(char const* message) const; // ^X86::InstructionStream virtual bool can_read() override { return false; } diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp index a5146a13e0..67c2bba6a9 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp @@ -28,7 +28,7 @@ } while (0) template<typename T> -ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message) +ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message) { if (value_with_shadow.is_uninitialized()) [[unlikely]] { reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp index b11e968a15..ab99784cb7 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp @@ -305,11 +305,11 @@ void SoftMMU::write256(X86::LogicalAddress address, ValueWithShadow<u256> value) region->write256(address.offset() - region->base(), value); } -void SoftMMU::copy_to_vm(FlatPtr destination, const void* source, size_t size) +void SoftMMU::copy_to_vm(FlatPtr destination, void const* source, size_t size) { // FIXME: We should have a way to preserve the shadow data here as well. for (size_t i = 0; i < size; ++i) - write8({ 0x23, destination + i }, shadow_wrap_as_initialized(((const u8*)source)[i])); + write8({ 0x23, destination + i }, shadow_wrap_as_initialized(((u8 const*)source)[i])); } void SoftMMU::copy_from_vm(void* destination, const FlatPtr source, size_t size) @@ -336,7 +336,7 @@ bool SoftMMU::fast_fill_memory8(X86::LogicalAddress address, size_t size, ValueW if (!region->contains(address.offset() + size - 1)) return false; - if (is<MmapRegion>(*region) && static_cast<const MmapRegion&>(*region).is_malloc_block()) { + if (is<MmapRegion>(*region) && static_cast<MmapRegion const&>(*region).is_malloc_block()) { if (auto* tracer = m_emulator.malloc_tracer()) { // FIXME: Add a way to audit an entire range of memory instead of looping here! for (size_t i = 0; i < size; ++i) { @@ -361,7 +361,7 @@ bool SoftMMU::fast_fill_memory32(X86::LogicalAddress address, size_t count, Valu if (!region->contains(address.offset() + (count * sizeof(u32)) - 1)) return false; - if (is<MmapRegion>(*region) && static_cast<const MmapRegion&>(*region).is_malloc_block()) { + if (is<MmapRegion>(*region) && static_cast<MmapRegion const&>(*region).is_malloc_block()) { if (auto* tracer = m_emulator.malloc_tracer()) { // FIXME: Add a way to audit an entire range of memory instead of looping here! for (size_t i = 0; i < count; ++i) { diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.h b/Userland/DevTools/UserspaceEmulator/SoftMMU.h index 24f1a27b41..f36bb39bd6 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.h @@ -88,7 +88,7 @@ public: bool fast_fill_memory8(X86::LogicalAddress, size_t size, ValueWithShadow<u8>); bool fast_fill_memory32(X86::LogicalAddress, size_t size, ValueWithShadow<u32>); - void copy_to_vm(FlatPtr destination, const void* source, size_t); + void copy_to_vm(FlatPtr destination, void const* source, size_t); void copy_from_vm(void* destination, const FlatPtr source, size_t); ByteBuffer copy_buffer_from_vm(const FlatPtr source, size_t); diff --git a/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h b/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h index e7ad1988a0..6dc10e0653 100644 --- a/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h +++ b/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h @@ -116,7 +116,7 @@ public: return false; } - ValueAndShadowReference<T>& operator=(const ValueWithShadow<T>&); + ValueAndShadowReference<T>& operator=(ValueWithShadow<T> const&); T shadow_as_value() const requires(IsTriviallyConstructible<T>) { @@ -165,14 +165,14 @@ ALWAYS_INLINE ValueWithShadow<T> shadow_wrap_with_taint_from(T value, U const& t } template<typename T> -inline ValueWithShadow<T>::ValueWithShadow(const ValueAndShadowReference<T>& other) +inline ValueWithShadow<T>::ValueWithShadow(ValueAndShadowReference<T> const& other) : m_value(other.value()) , m_shadow(other.shadow()) { } template<typename T> -inline ValueAndShadowReference<T>& ValueAndShadowReference<T>::operator=(const ValueWithShadow<T>& other) +inline ValueAndShadowReference<T>& ValueAndShadowReference<T>::operator=(ValueWithShadow<T> const& other) { m_value = other.value(); m_shadow = other.shadow(); diff --git a/Userland/DynamicLoader/main.cpp b/Userland/DynamicLoader/main.cpp index b6f792b509..872c260622 100644 --- a/Userland/DynamicLoader/main.cpp +++ b/Userland/DynamicLoader/main.cpp @@ -42,7 +42,7 @@ static void perform_self_relocations(auxv_t* auxvp) static void display_help() { - const char message[] = + char const message[] = R"(You have invoked `Loader.so'. This is the helper program for programs that use shared libraries. Special directives embedded in executables tell the kernel to load this program. @@ -85,7 +85,7 @@ void _entry(int argc, char** argv, char** envp) main_program_fd = auxvp->a_un.a_val; } if (auxvp->a_type == ELF::AuxiliaryValue::ExecFilename) { - main_program_name = (const char*)auxvp->a_un.a_ptr; + main_program_name = (char const*)auxvp->a_un.a_ptr; } if (auxvp->a_type == ELF::AuxiliaryValue::Secure) { is_secure = auxvp->a_un.a_val == 1; diff --git a/Userland/DynamicLoader/misc.cpp b/Userland/DynamicLoader/misc.cpp index 9f3662e4b8..3bd22e2eec 100644 --- a/Userland/DynamicLoader/misc.cpp +++ b/Userland/DynamicLoader/misc.cpp @@ -8,7 +8,7 @@ #include <AK/Format.h> extern "C" { -const char* __cxa_demangle(const char*, void*, void*, int*) +char const* __cxa_demangle(char const*, void*, void*, int*) { dbgln("WARNING: __cxa_demangle not supported"); return ""; diff --git a/Userland/DynamicLoader/misc.h b/Userland/DynamicLoader/misc.h index cfa26ef95e..104ebc0de3 100644 --- a/Userland/DynamicLoader/misc.h +++ b/Userland/DynamicLoader/misc.h @@ -7,7 +7,7 @@ #pragma once extern "C" { -const char* __cxa_demangle(const char*, void*, void*, int*); +char const* __cxa_demangle(char const*, void*, void*, int*); extern void* __dso_handle; } diff --git a/Userland/Games/Breakout/Game.cpp b/Userland/Games/Breakout/Game.cpp index c8720ef22b..bf38388717 100644 --- a/Userland/Games/Breakout/Game.cpp +++ b/Userland/Games/Breakout/Game.cpp @@ -139,7 +139,7 @@ void Game::paint_event(GUI::PaintEvent& event) painter.draw_text(lives_left_rect(), String::formatted("Lives: {}", m_lives), Gfx::TextAlignment::Center, Color::White); if (m_paused) { - const char* msg = m_cheater ? "C H E A T E R" : "P A U S E D"; + char const* msg = m_cheater ? "C H E A T E R" : "P A U S E D"; painter.draw_text(pause_rect(), msg, Gfx::TextAlignment::Center, Color::White); } } diff --git a/Userland/Games/Breakout/Game.h b/Userland/Games/Breakout/Game.h index 40e68cee0a..998ba51e6a 100644 --- a/Userland/Games/Breakout/Game.h +++ b/Userland/Games/Breakout/Game.h @@ -86,7 +86,7 @@ private: Gfx::IntRect pause_rect() const { - const char* msg = m_cheater ? "C H E A T E R" : "P A U S E D"; + char const* msg = m_cheater ? "C H E A T E R" : "P A U S E D"; int msg_width = font().width(msg); int msg_height = font().glyph_height(); return { (game_width / 2) - (msg_width / 2), (game_height / 2) - (msg_height / 2), msg_width, msg_height }; diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index ee2ea37db7..63e7815a94 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -24,9 +24,9 @@ ChessWidget::ChessWidget() void ChessWidget::paint_event(GUI::PaintEvent& event) { - const int min_size = min(width(), height()); - const int widget_offset_x = (window()->width() - min_size) / 2; - const int widget_offset_y = (window()->height() - min_size) / 2; + int const min_size = min(width(), height()); + int const widget_offset_x = (window()->width() - min_size) / 2; + int const widget_offset_y = (window()->height() - min_size) / 2; GUI::Frame::paint_event(event); @@ -144,7 +144,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) Gfx::IntPoint move_point; Gfx::IntPoint point_offset = { tile_width / 3, tile_height / 3 }; Gfx::IntSize rect_size = { tile_width / 3, tile_height / 3 }; - for (const auto& square : m_available_moves) { + for (auto const& square : m_available_moves) { if (side() == Chess::Color::White) { move_point = { square.file * tile_width, (7 - square.rank) * tile_height }; } else { @@ -165,9 +165,9 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) void ChessWidget::mousedown_event(GUI::MouseEvent& event) { - const int min_size = min(width(), height()); - const int widget_offset_x = (window()->width() - min_size) / 2; - const int widget_offset_y = (window()->height() - min_size) / 2; + int const min_size = min(width(), height()); + int const widget_offset_x = (window()->width() - min_size) / 2; + int const widget_offset_y = (window()->height() - min_size) / 2; if (!frame_inner_rect().contains(event.position())) return; @@ -306,9 +306,9 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) void ChessWidget::mousemove_event(GUI::MouseEvent& event) { - const int min_size = min(width(), height()); - const int widget_offset_x = (window()->width() - min_size) / 2; - const int widget_offset_y = (window()->height() - min_size) / 2; + int const min_size = min(width(), height()); + int const widget_offset_x = (window()->width() - min_size) / 2; + int const widget_offset_y = (window()->height() - min_size) / 2; if (!frame_inner_rect().contains(event.position())) return; @@ -391,9 +391,9 @@ void ChessWidget::set_piece_set(StringView set) Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const { - const int min_size = min(width(), height()); - const int widget_offset_x = (window()->width() - min_size) / 2; - const int widget_offset_y = (window()->height() - min_size) / 2; + int const min_size = min(width(), height()); + int const widget_offset_x = (window()->width() - min_size) / 2; + int const widget_offset_y = (window()->height() - min_size) / 2; int tile_width = min_size / 8; int tile_height = min_size / 8; @@ -405,7 +405,7 @@ Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const } } -RefPtr<Gfx::Bitmap> ChessWidget::get_piece_graphic(const Chess::Piece& piece) const +RefPtr<Gfx::Bitmap> ChessWidget::get_piece_graphic(Chess::Piece const& piece) const { return m_pieces.get(piece).value(); } diff --git a/Userland/Games/Chess/ChessWidget.h b/Userland/Games/Chess/ChessWidget.h index a62c00d193..ad80b767f5 100644 --- a/Userland/Games/Chess/ChessWidget.h +++ b/Userland/Games/Chess/ChessWidget.h @@ -27,22 +27,22 @@ public: virtual void keydown_event(GUI::KeyEvent&) override; Chess::Board& board() { return m_board; }; - const Chess::Board& board() const { return m_board; }; + Chess::Board const& board() const { return m_board; }; Chess::Board& board_playback() { return m_board_playback; }; - const Chess::Board& board_playback() const { return m_board_playback; }; + Chess::Board const& board_playback() const { return m_board_playback; }; Chess::Color side() const { return m_side; }; void set_side(Chess::Color side) { m_side = side; }; void set_piece_set(StringView set); - const String& piece_set() const { return m_piece_set; }; + String const& piece_set() const { return m_piece_set; }; Chess::Square mouse_to_square(GUI::MouseEvent& event) const; bool drag_enabled() const { return m_drag_enabled; } void set_drag_enabled(bool e) { m_drag_enabled = e; } - RefPtr<Gfx::Bitmap> get_piece_graphic(const Chess::Piece& piece) const; + RefPtr<Gfx::Bitmap> get_piece_graphic(Chess::Piece const& piece) const; bool show_available_moves() const { return m_show_available_moves; } void set_show_available_moves(bool e) { m_show_available_moves = e; } @@ -61,8 +61,8 @@ public: Color light_square_color; }; - const BoardTheme& board_theme() const { return m_board_theme; } - void set_board_theme(const BoardTheme& theme) { m_board_theme = theme; } + BoardTheme const& board_theme() const { return m_board_theme; } + void set_board_theme(BoardTheme const& theme) { m_board_theme = theme; } void set_board_theme(StringView name); enum class PlaybackDirection { @@ -101,7 +101,7 @@ public: return Type::None; } - bool operator==(const BoardMarking& other) const { return from == other.from && to == other.to; } + bool operator==(BoardMarking const& other) const { return from == other.from && to == other.to; } }; private: diff --git a/Userland/Games/Chess/Engine.cpp b/Userland/Games/Chess/Engine.cpp index 90cb414113..5bc0f7626e 100644 --- a/Userland/Games/Chess/Engine.cpp +++ b/Userland/Games/Chess/Engine.cpp @@ -37,7 +37,7 @@ Engine::Engine(StringView command) posix_spawn_file_actions_adddup2(&file_actions, rpipefds[1], STDOUT_FILENO); String cstr(command); - const char* argv[] = { cstr.characters(), nullptr }; + char const* argv[] = { cstr.characters(), nullptr }; if (posix_spawnp(&m_pid, cstr.characters(), &file_actions, nullptr, const_cast<char**>(argv), environ) < 0) { perror("posix_spawnp"); VERIFY_NOT_REACHED(); @@ -59,7 +59,7 @@ Engine::Engine(StringView command) send_command(Chess::UCI::UCICommand()); } -void Engine::handle_bestmove(const Chess::UCI::BestMoveCommand& command) +void Engine::handle_bestmove(Chess::UCI::BestMoveCommand const& command) { if (m_bestmove_callback) m_bestmove_callback(command.move()); diff --git a/Userland/Games/Chess/Engine.h b/Userland/Games/Chess/Engine.h index c41eaec0e9..d91127714b 100644 --- a/Userland/Games/Chess/Engine.h +++ b/Userland/Games/Chess/Engine.h @@ -17,13 +17,13 @@ public: Engine(StringView command); - Engine(const Engine&) = delete; - Engine& operator=(const Engine&) = delete; + Engine(Engine const&) = delete; + Engine& operator=(Engine const&) = delete; - virtual void handle_bestmove(const Chess::UCI::BestMoveCommand&) override; + virtual void handle_bestmove(Chess::UCI::BestMoveCommand const&) override; template<typename Callback> - void get_best_move(const Chess::Board& board, int time_limit, Callback&& callback) + void get_best_move(Chess::Board const& board, int time_limit, Callback&& callback) { send_command(Chess::UCI::PositionCommand({}, board.moves())); Chess::UCI::GoCommand go_command; diff --git a/Userland/Games/FlappyBug/Game.h b/Userland/Games/FlappyBug/Game.h index 58ed680f56..f2d01329e5 100644 --- a/Userland/Games/FlappyBug/Game.h +++ b/Userland/Games/FlappyBug/Game.h @@ -41,9 +41,9 @@ private: public: struct Bug { - const float x { 50 }; - const float radius { 16 }; - const float starting_y { 200 }; + float const x { 50 }; + float const radius { 16 }; + float const starting_y { 200 }; NonnullRefPtr<Gfx::Bitmap> falling_bitmap; NonnullRefPtr<Gfx::Bitmap> flapping_bitmap; float y {}; @@ -81,13 +81,13 @@ public: void flap() { - const float flap_strength = 10.0f; + float const flap_strength = 10.0f; velocity = -flap_strength; } void fall() { - const float gravity = 1.0f; + float const gravity = 1.0f; velocity += gravity; } @@ -98,7 +98,7 @@ public: }; struct Obstacle { - const float width { 20 }; + float const width { 20 }; Color color { Color::DarkGray }; float x {}; float gap_top_y { 200 }; diff --git a/Userland/Games/GameOfLife/Board.h b/Userland/Games/GameOfLife/Board.h index 227311c1bb..8f1408858f 100644 --- a/Userland/Games/GameOfLife/Board.h +++ b/Userland/Games/GameOfLife/Board.h @@ -23,7 +23,7 @@ public: void toggle_cell(size_t row, size_t column); void set_cell(size_t row, size_t column, bool on); bool cell(size_t row, size_t column) const; - const Vector<Vector<bool>>& cells() const { return m_cells; } + Vector<Vector<bool>> const& cells() const { return m_cells; } void run_generation(); bool is_stalled() const { return m_stalled; } diff --git a/Userland/Games/GameOfLife/BoardWidget.h b/Userland/Games/GameOfLife/BoardWidget.h index 97d1b5df30..ef185cb5b9 100644 --- a/Userland/Games/GameOfLife/BoardWidget.h +++ b/Userland/Games/GameOfLife/BoardWidget.h @@ -45,7 +45,7 @@ public: Optional<Board::RowAndColumn> get_row_and_column_for_point(int x, int y) const; void resize_board(size_t rows, size_t columns); - const Board* board() const { return m_board.ptr(); } + Board const* board() const { return m_board.ptr(); } bool is_running() const { return m_running; } void set_running(bool r); diff --git a/Userland/Games/GameOfLife/main.cpp b/Userland/Games/GameOfLife/main.cpp index dabb0caac3..e655265d9f 100644 --- a/Userland/Games/GameOfLife/main.cpp +++ b/Userland/Games/GameOfLife/main.cpp @@ -23,7 +23,7 @@ #include <LibGUI/Window.h> #include <LibMain/Main.h> -const char* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells"; +char const* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells"; ErrorOr<int> serenity_main(Main::Arguments arguments) { diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index 1b377931a5..444b0d89e7 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -929,13 +929,13 @@ void Game::dump_state() const auto& player = m_players[i]; dbgln("Player {}", player.name); dbgln("Hand:"); - for (const auto& card : player.hand) + for (auto const& card : player.hand) if (card.is_null()) dbgln(" <empty>"); else dbgln(" {}", *card); dbgln("Taken:"); - for (const auto& card : player.cards_taken) + for (auto const& card : player.cards_taken) dbgln(" {}", card); } } diff --git a/Userland/Games/Hearts/Player.cpp b/Userland/Games/Hearts/Player.cpp index a30f3ddb5a..9094122d38 100644 --- a/Userland/Games/Hearts/Player.cpp +++ b/Userland/Games/Hearts/Player.cpp @@ -158,7 +158,7 @@ bool Player::has_card_of_suit(Card::Suit suit) return matching_card.has_value(); } -void Player::remove_cards(const NonnullRefPtrVector<Card>& cards) +void Player::remove_cards(NonnullRefPtrVector<Card> const& cards) { for (auto& card : cards) { hand.remove_first_matching([&card](auto& other_card) { diff --git a/Userland/Games/Minesweeper/Field.h b/Userland/Games/Minesweeper/Field.h index 681e2d364b..b4d986d42f 100644 --- a/Userland/Games/Minesweeper/Field.h +++ b/Userland/Games/Minesweeper/Field.h @@ -122,7 +122,7 @@ private: void set_flag(Square&, bool); Square& square(size_t row, size_t column) { return *m_squares[row * columns() + column]; } - const Square& square(size_t row, size_t column) const { return *m_squares[row * columns() + column]; } + Square const& square(size_t row, size_t column) const { return *m_squares[row * columns() + column]; } void flood_fill(Square&); void on_square_clicked_impl(Square&, bool); diff --git a/Userland/Games/Snake/SnakeGame.cpp b/Userland/Games/Snake/SnakeGame.cpp index 059e97125d..c5b3881517 100644 --- a/Userland/Games/Snake/SnakeGame.cpp +++ b/Userland/Games/Snake/SnakeGame.cpp @@ -41,7 +41,7 @@ void SnakeGame::reset() update(); } -bool SnakeGame::is_available(const Coordinate& coord) +bool SnakeGame::is_available(Coordinate const& coord) { for (size_t i = 0; i < m_tail.size(); ++i) { if (m_tail[i] == coord) @@ -171,7 +171,7 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event) } } -Gfx::IntRect SnakeGame::cell_rect(const Coordinate& coord) const +Gfx::IntRect SnakeGame::cell_rect(Coordinate const& coord) const { auto game_rect = frame_inner_rect(); auto cell_size = Gfx::IntSize(game_rect.width() / m_columns, game_rect.height() / m_rows); @@ -224,7 +224,7 @@ void SnakeGame::queue_velocity(int v, int h) m_velocity_queue.enqueue({ v, h }); } -const SnakeGame::Velocity& SnakeGame::last_velocity() const +SnakeGame::Velocity const& SnakeGame::last_velocity() const { if (!m_velocity_queue.is_empty()) return m_velocity_queue.last(); diff --git a/Userland/Games/Snake/SnakeGame.h b/Userland/Games/Snake/SnakeGame.h index 4b7e36ec4a..063b6c8474 100644 --- a/Userland/Games/Snake/SnakeGame.h +++ b/Userland/Games/Snake/SnakeGame.h @@ -29,7 +29,7 @@ private: int row { 0 }; int column { 0 }; - bool operator==(const Coordinate& other) const + bool operator==(Coordinate const& other) const { return row == other.row && column == other.column; } @@ -42,10 +42,10 @@ private: void game_over(); void spawn_fruit(); - bool is_available(const Coordinate&); + bool is_available(Coordinate const&); void queue_velocity(int v, int h); - const Velocity& last_velocity() const; - Gfx::IntRect cell_rect(const Coordinate&) const; + Velocity const& last_velocity() const; + Gfx::IntRect cell_rect(Coordinate const&) const; Gfx::IntRect score_rect() const; Gfx::IntRect high_score_rect() const; diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp index d7c7055b66..a3fc67f156 100644 --- a/Userland/Games/Solitaire/Game.cpp +++ b/Userland/Games/Solitaire/Game.cpp @@ -660,7 +660,7 @@ void Game::dump_layout() const { if constexpr (SOLITAIRE_DEBUG) { dbgln("------------------------------"); - for (const auto& stack : m_stacks) + for (auto const& stack : m_stacks) dbgln("{}", stack); } } diff --git a/Userland/Games/Solitaire/Game.h b/Userland/Games/Solitaire/Game.h index 06da854500..b3afd1c803 100644 --- a/Userland/Games/Solitaire/Game.h +++ b/Userland/Games/Solitaire/Game.h @@ -143,7 +143,7 @@ private: static constexpr Array piles = { Pile1, Pile2, Pile3, Pile4, Pile5, Pile6, Pile7 }; static constexpr Array foundations = { Foundation1, Foundation2, Foundation3, Foundation4 }; - ALWAYS_INLINE const WasteRecycleRules& recycle_rules() + ALWAYS_INLINE WasteRecycleRules const& recycle_rules() { static constexpr Array<WasteRecycleRules, 2> rules { { { 0, -100 }, diff --git a/Userland/Libraries/LibArchive/Tar.cpp b/Userland/Libraries/LibArchive/Tar.cpp index 65954ba64f..41b69dab59 100644 --- a/Userland/Libraries/LibArchive/Tar.cpp +++ b/Userland/Libraries/LibArchive/Tar.cpp @@ -12,8 +12,8 @@ namespace Archive { unsigned TarFileHeader::expected_checksum() const { auto checksum = 0u; - const u8* u8_this = reinterpret_cast<const u8*>(this); - const u8* u8_m_checksum = reinterpret_cast<const u8*>(&m_checksum); + u8 const* u8_this = reinterpret_cast<u8 const*>(this); + u8 const* u8_m_checksum = reinterpret_cast<u8 const*>(&m_checksum); for (auto i = 0u; i < sizeof(TarFileHeader); ++i) { if (u8_this + i >= u8_m_checksum && u8_this + i < u8_m_checksum + sizeof(m_checksum)) { checksum += ' '; diff --git a/Userland/Libraries/LibArchive/Tar.h b/Userland/Libraries/LibArchive/Tar.h index 3310a6140b..f175b3a5e0 100644 --- a/Userland/Libraries/LibArchive/Tar.h +++ b/Userland/Libraries/LibArchive/Tar.h @@ -38,7 +38,7 @@ constexpr StringView posix1_tar_magic = ""; // POSIX.1-1988 format magic constexpr StringView posix1_tar_version = ""; // POSIX.1-1988 format version template<size_t N> -static size_t get_field_as_integral(const char (&field)[N]) +static size_t get_field_as_integral(char const (&field)[N]) { size_t value = 0; for (size_t i = 0; i < N; ++i) { @@ -53,7 +53,7 @@ static size_t get_field_as_integral(const char (&field)[N]) } template<size_t N> -static StringView get_field_as_string_view(const char (&field)[N]) +static StringView get_field_as_string_view(char const (&field)[N]) { return { field, min(__builtin_strlen(field), N) }; } @@ -95,23 +95,23 @@ public: // FIXME: support ustar filename prefix StringView prefix() const { return get_field_as_string_view(m_prefix); } - void set_filename(const String& filename) { set_field(m_filename, filename); } + void set_filename(String const& filename) { set_field(m_filename, filename); } void set_mode(mode_t mode) { set_octal_field(m_mode, mode); } void set_uid(uid_t uid) { set_octal_field(m_uid, uid); } void set_gid(gid_t gid) { set_octal_field(m_gid, gid); } void set_size(size_t size) { set_octal_field(m_size, size); } void set_timestamp(time_t timestamp) { set_octal_field(m_timestamp, timestamp); } void set_type_flag(TarFileType type) { m_type_flag = to_underlying(type); } - void set_link_name(const String& link_name) { set_field(m_link_name, link_name); } + void set_link_name(String const& link_name) { set_field(m_link_name, link_name); } // magic doesn't necessarily include a null byte void set_magic(StringView magic) { set_field(m_magic, magic); } // version doesn't necessarily include a null byte void set_version(StringView version) { set_field(m_version, version); } - void set_owner_name(const String& owner_name) { set_field(m_owner_name, owner_name); } - void set_group_name(const String& group_name) { set_field(m_group_name, group_name); } + void set_owner_name(String const& owner_name) { set_field(m_owner_name, owner_name); } + void set_group_name(String const& group_name) { set_field(m_group_name, group_name); } void set_major(int major) { set_octal_field(m_major, major); } void set_minor(int minor) { set_octal_field(m_minor, minor); } - void set_prefix(const String& prefix) { set_field(m_prefix, prefix); } + void set_prefix(String const& prefix) { set_field(m_prefix, prefix); } unsigned expected_checksum() const; void calculate_checksum(); diff --git a/Userland/Libraries/LibArchive/TarStream.cpp b/Userland/Libraries/LibArchive/TarStream.cpp index 2b12eea374..80945af341 100644 --- a/Userland/Libraries/LibArchive/TarStream.cpp +++ b/Userland/Libraries/LibArchive/TarStream.cpp @@ -128,7 +128,7 @@ TarOutputStream::TarOutputStream(OutputStream& stream) { } -void TarOutputStream::add_directory(const String& path, mode_t mode) +void TarOutputStream::add_directory(String const& path, mode_t mode) { VERIFY(!m_finished); TarFileHeader header {}; @@ -144,7 +144,7 @@ void TarOutputStream::add_directory(const String& path, mode_t mode) VERIFY(m_stream.write_or_error(Bytes { &padding, block_size - sizeof(header) })); } -void TarOutputStream::add_file(const String& path, mode_t mode, ReadonlyBytes bytes) +void TarOutputStream::add_file(String const& path, mode_t mode, ReadonlyBytes bytes) { VERIFY(!m_finished); TarFileHeader header {}; diff --git a/Userland/Libraries/LibArchive/TarStream.h b/Userland/Libraries/LibArchive/TarStream.h index 5ffa04991e..a27c30c971 100644 --- a/Userland/Libraries/LibArchive/TarStream.h +++ b/Userland/Libraries/LibArchive/TarStream.h @@ -37,7 +37,7 @@ public: void advance(); bool finished() const { return m_finished; } bool valid() const; - const TarFileHeader& header() const { return m_header; } + TarFileHeader const& header() const { return m_header; } TarFileStream file_contents(); template<VoidFunction<StringView, StringView> F> @@ -56,8 +56,8 @@ private: class TarOutputStream { public: TarOutputStream(OutputStream&); - void add_file(const String& path, mode_t, ReadonlyBytes); - void add_directory(const String& path, mode_t); + void add_file(String const& path, mode_t, ReadonlyBytes); + void add_directory(String const& path, mode_t); void finish(); private: diff --git a/Userland/Libraries/LibArchive/Zip.cpp b/Userland/Libraries/LibArchive/Zip.cpp index d5aa5d112f..71d173bab3 100644 --- a/Userland/Libraries/LibArchive/Zip.cpp +++ b/Userland/Libraries/LibArchive/Zip.cpp @@ -80,7 +80,7 @@ Optional<Zip> Zip::try_create(ReadonlyBytes buffer) }; } -bool Zip::for_each_member(Function<IterationDecision(const ZipMember&)> callback) +bool Zip::for_each_member(Function<IterationDecision(ZipMember const&)> callback) { size_t member_offset = m_members_start_offset; for (size_t i = 0; i < m_member_count; i++) { @@ -119,7 +119,7 @@ static u16 minimum_version_needed(ZipCompressionMethod method) return method == ZipCompressionMethod::Deflate ? 20 : 10; } -void ZipOutputStream::add_member(const ZipMember& member) +void ZipOutputStream::add_member(ZipMember const& member) { VERIFY(!m_finished); VERIFY(member.name.length() <= UINT16_MAX); @@ -151,7 +151,7 @@ void ZipOutputStream::finish() auto file_header_offset = 0u; auto central_directory_size = 0u; - for (const ZipMember& member : m_members) { + for (ZipMember const& member : m_members) { auto zip_version = minimum_version_needed(member.compression_method); CentralDirectoryRecord central_directory_record { .made_by_version = zip_version, diff --git a/Userland/Libraries/LibArchive/Zip.h b/Userland/Libraries/LibArchive/Zip.h index 1575743154..95913f7b5c 100644 --- a/Userland/Libraries/LibArchive/Zip.h +++ b/Userland/Libraries/LibArchive/Zip.h @@ -42,7 +42,7 @@ struct [[gnu::packed]] EndOfCentralDirectory { u32 central_directory_size; u32 central_directory_offset; u16 comment_length; - const u8* comment; + u8 const* comment; bool read(ReadonlyBytes buffer) { @@ -103,9 +103,9 @@ struct [[gnu::packed]] CentralDirectoryRecord { u16 internal_attributes; u32 external_attributes; u32 local_file_header_offset; - const u8* name; - const u8* extra_data; - const u8* comment; + u8 const* name; + u8 const* extra_data; + u8 const* comment; bool read(ReadonlyBytes buffer) { @@ -167,9 +167,9 @@ struct [[gnu::packed]] LocalFileHeader { u32 uncompressed_size; u16 name_length; u16 extra_data_length; - const u8* name; - const u8* extra_data; - const u8* compressed_data; + u8 const* name; + u8 const* extra_data; + u8 const* compressed_data; bool read(ReadonlyBytes buffer) { @@ -218,7 +218,7 @@ struct ZipMember { class Zip { public: static Optional<Zip> try_create(ReadonlyBytes buffer); - bool for_each_member(Function<IterationDecision(const ZipMember&)>); + bool for_each_member(Function<IterationDecision(ZipMember const&)>); private: static bool find_end_of_central_directory_offset(ReadonlyBytes, size_t& offset); @@ -237,7 +237,7 @@ private: class ZipOutputStream { public: ZipOutputStream(OutputStream&); - void add_member(const ZipMember&); + void add_member(ZipMember const&); void finish(); private: diff --git a/Userland/Libraries/LibAudio/Buffer.h b/Userland/Libraries/LibAudio/Buffer.h index 536d313998..cb05a06219 100644 --- a/Userland/Libraries/LibAudio/Buffer.h +++ b/Userland/Libraries/LibAudio/Buffer.h @@ -47,7 +47,7 @@ public: return MUST(adopt_nonnull_ref_or_enomem(new (nothrow) Buffer)); } - Sample const* samples() const { return (const Sample*)data(); } + Sample const* samples() const { return (Sample const*)data(); } ErrorOr<FixedArray<Sample>> to_sample_array() const { @@ -86,7 +86,7 @@ private: Core::AnonymousBuffer m_buffer; const i32 m_id { -1 }; - const int m_sample_count { 0 }; + int const m_sample_count { 0 }; }; // This only works for double resamplers, and therefore cannot be part of the class diff --git a/Userland/Libraries/LibAudio/FlacLoader.h b/Userland/Libraries/LibAudio/FlacLoader.h index fdd19a8182..23f1fba00f 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.h +++ b/Userland/Libraries/LibAudio/FlacLoader.h @@ -101,7 +101,7 @@ private: u16 m_min_block_size { 0 }; u16 m_max_block_size { 0 }; // Frames are units of encoded audio data, both of these are 24-bit - u32 m_min_frame_size { 0 }; //24 bit + u32 m_min_frame_size { 0 }; // 24 bit u32 m_max_frame_size { 0 }; // 24 bit u64 m_total_samples { 0 }; // 36 bit u8 m_md5_checksum[128 / 8]; // 128 bit (!) diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h index 0294bba603..bca513c083 100644 --- a/Userland/Libraries/LibAudio/Loader.h +++ b/Userland/Libraries/LibAudio/Loader.h @@ -35,7 +35,7 @@ public: virtual MaybeLoaderError reset() = 0; - virtual MaybeLoaderError seek(const int sample_index) = 0; + virtual MaybeLoaderError seek(int const sample_index) = 0; // total_samples() and loaded_samples() should be independent // of the number of channels. @@ -63,7 +63,7 @@ public: LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) const { return m_plugin->get_more_samples(max_bytes_to_read_from_input); } MaybeLoaderError reset() const { return m_plugin->reset(); } - MaybeLoaderError seek(const int position) const { return m_plugin->seek(position); } + MaybeLoaderError seek(int const position) const { return m_plugin->seek(position); } int loaded_samples() const { return m_plugin->loaded_samples(); } int total_samples() const { return m_plugin->total_samples(); } diff --git a/Userland/Libraries/LibAudio/MP3HuffmanTables.h b/Userland/Libraries/LibAudio/MP3HuffmanTables.h index e07a91eabb..674d8d402b 100644 --- a/Userland/Libraries/LibAudio/MP3HuffmanTables.h +++ b/Userland/Libraries/LibAudio/MP3HuffmanTables.h @@ -112,7 +112,7 @@ HuffmanDecodeResult<T> huffman_decode(InputBitStream& bitstream, Span<HuffmanNod size_t bits_read = 0; while (!node->is_leaf() && !bitstream.has_any_error() && max_bits_to_read-- > 0) { - const bool direction = bitstream.read_bit_big_endian(); + bool const direction = bitstream.read_bit_big_endian(); ++bits_read; if (direction) { if (node->left == -1) diff --git a/Userland/Libraries/LibAudio/WavLoader.cpp b/Userland/Libraries/LibAudio/WavLoader.cpp index 69a556cb6d..6168cf5926 100644 --- a/Userland/Libraries/LibAudio/WavLoader.cpp +++ b/Userland/Libraries/LibAudio/WavLoader.cpp @@ -36,7 +36,7 @@ MaybeLoaderError WavLoaderPlugin::initialize() return {}; } -WavLoaderPlugin::WavLoaderPlugin(const Bytes& buffer) +WavLoaderPlugin::WavLoaderPlugin(Bytes const& buffer) { m_stream = make<InputMemoryStream>(buffer); if (!m_stream) { @@ -91,7 +91,7 @@ LoaderSamples WavLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_in return buffer.release_value(); } -MaybeLoaderError WavLoaderPlugin::seek(const int sample_index) +MaybeLoaderError WavLoaderPlugin::seek(int const sample_index) { dbgln_if(AWAVLOADER_DEBUG, "seek sample_index {}", sample_index); if (sample_index < 0 || sample_index >= m_total_samples) diff --git a/Userland/Libraries/LibAudio/WavLoader.h b/Userland/Libraries/LibAudio/WavLoader.h index bb6cea82df..50e97b5648 100644 --- a/Userland/Libraries/LibAudio/WavLoader.h +++ b/Userland/Libraries/LibAudio/WavLoader.h @@ -34,7 +34,7 @@ class Buffer; class WavLoaderPlugin : public LoaderPlugin { public: explicit WavLoaderPlugin(StringView path); - explicit WavLoaderPlugin(const Bytes& buffer); + explicit WavLoaderPlugin(Bytes const& buffer); virtual MaybeLoaderError initialize() override; @@ -46,7 +46,7 @@ public: // sample_index 0 is the start of the raw audio sample data // within the file/stream. - virtual MaybeLoaderError seek(const int sample_index) override; + virtual MaybeLoaderError seek(int const sample_index) override; virtual int loaded_samples() override { return m_loaded_samples; } virtual int total_samples() override { return m_total_samples; } diff --git a/Userland/Libraries/LibAudio/WavWriter.cpp b/Userland/Libraries/LibAudio/WavWriter.cpp index 4428a38f9d..4ba2524797 100644 --- a/Userland/Libraries/LibAudio/WavWriter.cpp +++ b/Userland/Libraries/LibAudio/WavWriter.cpp @@ -40,7 +40,7 @@ void WavWriter::set_file(StringView path) m_finalized = false; } -void WavWriter::write_samples(const u8* samples, size_t size) +void WavWriter::write_samples(u8 const* samples, size_t size) { m_data_sz += size; m_file->write(samples, size); diff --git a/Userland/Libraries/LibAudio/WavWriter.h b/Userland/Libraries/LibAudio/WavWriter.h index d36059ab12..bfb06caf6f 100644 --- a/Userland/Libraries/LibAudio/WavWriter.h +++ b/Userland/Libraries/LibAudio/WavWriter.h @@ -22,9 +22,9 @@ public: ~WavWriter(); bool has_error() const { return !m_error_string.is_null(); } - const char* error_string() const { return m_error_string.characters(); } + char const* error_string() const { return m_error_string.characters(); } - void write_samples(const u8* samples, size_t size); + void write_samples(u8 const* samples, size_t size); void finalize(); // You can finalize manually or let the destructor do it. u32 sample_rate() const { return m_sample_rate; } diff --git a/Userland/Libraries/LibC/arpa/inet.cpp b/Userland/Libraries/LibC/arpa/inet.cpp index ca669086af..86c6f307a6 100644 --- a/Userland/Libraries/LibC/arpa/inet.cpp +++ b/Userland/Libraries/LibC/arpa/inet.cpp @@ -12,16 +12,16 @@ extern "C" { -const char* inet_ntop(int af, const void* src, char* dst, socklen_t len) +char const* inet_ntop(int af, void const* src, char* dst, socklen_t len) { if (af == AF_INET) { if (len < INET_ADDRSTRLEN) { errno = ENOSPC; return nullptr; } - auto* bytes = (const unsigned char*)src; + auto* bytes = (unsigned char const*)src; snprintf(dst, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]); - return (const char*)dst; + return (char const*)dst; } else if (af == AF_INET6) { if (len < INET6_ADDRSTRLEN) { errno = ENOSPC; @@ -32,14 +32,14 @@ const char* inet_ntop(int af, const void* src, char* dst, socklen_t len) errno = ENOSPC; return nullptr; } - return (const char*)dst; + return (char const*)dst; } errno = EAFNOSUPPORT; return nullptr; } -int inet_pton(int af, const char* src, void* dst) +int inet_pton(int af, char const* src, void* dst) { if (af == AF_INET) { unsigned a, b, c, d; @@ -78,7 +78,7 @@ int inet_pton(int af, const char* src, void* dst) return -1; } -in_addr_t inet_addr(const char* str) +in_addr_t inet_addr(char const* str) { in_addr_t tmp {}; int rc = inet_pton(AF_INET, str, &tmp); diff --git a/Userland/Libraries/LibC/arpa/inet.h b/Userland/Libraries/LibC/arpa/inet.h index 3ba673731f..b5c4d64a0d 100644 --- a/Userland/Libraries/LibC/arpa/inet.h +++ b/Userland/Libraries/LibC/arpa/inet.h @@ -16,10 +16,10 @@ __BEGIN_DECLS #define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46 -const char* inet_ntop(int af, const void* src, char* dst, socklen_t); -int inet_pton(int af, const char* src, void* dst); +char const* inet_ntop(int af, void const* src, char* dst, socklen_t); +int inet_pton(int af, char const* src, void* dst); -static inline int inet_aton(const char* cp, struct in_addr* inp) +static inline int inet_aton(char const* cp, struct in_addr* inp) { return inet_pton(AF_INET, cp, inp); } diff --git a/Userland/Libraries/LibC/assert.cpp b/Userland/Libraries/LibC/assert.cpp index 20f0f2dc36..31145f26eb 100644 --- a/Userland/Libraries/LibC/assert.cpp +++ b/Userland/Libraries/LibC/assert.cpp @@ -17,7 +17,7 @@ extern "C" { extern bool __stdio_is_initialized; -void __assertion_failed(const char* msg) +void __assertion_failed(char const* msg) { if (__heap_is_stable) { dbgln("ASSERTION FAILED: {}", msg); diff --git a/Userland/Libraries/LibC/assert.h b/Userland/Libraries/LibC/assert.h index c64b51ecd0..b90b115cf6 100644 --- a/Userland/Libraries/LibC/assert.h +++ b/Userland/Libraries/LibC/assert.h @@ -22,7 +22,7 @@ __BEGIN_DECLS #ifndef NDEBUG -__attribute__((noreturn)) void __assertion_failed(const char* msg); +__attribute__((noreturn)) void __assertion_failed(char const* msg); # define assert(expr) \ (__builtin_expect(!(expr), 0) \ ? __assertion_failed(#expr "\n" __FILE__ ":" __stringify(__LINE__)) \ diff --git a/Userland/Libraries/LibC/bits/pthread_forward.h b/Userland/Libraries/LibC/bits/pthread_forward.h index 21f60072a5..3480383db2 100644 --- a/Userland/Libraries/LibC/bits/pthread_forward.h +++ b/Userland/Libraries/LibC/bits/pthread_forward.h @@ -19,7 +19,7 @@ struct PthreadFunctions { int (*pthread_once)(pthread_once_t*, void (*)(void)); int (*pthread_cond_broadcast)(pthread_cond_t*); - int (*pthread_cond_init)(pthread_cond_t*, const pthread_condattr_t*); + int (*pthread_cond_init)(pthread_cond_t*, pthread_condattr_t const*); int (*pthread_cond_signal)(pthread_cond_t*); int (*pthread_cond_wait)(pthread_cond_t*, pthread_mutex_t*); int (*pthread_cond_destroy)(pthread_cond_t*); diff --git a/Userland/Libraries/LibC/bits/pthread_integration.h b/Userland/Libraries/LibC/bits/pthread_integration.h index bbc7e820de..85147c4254 100644 --- a/Userland/Libraries/LibC/bits/pthread_integration.h +++ b/Userland/Libraries/LibC/bits/pthread_integration.h @@ -18,7 +18,7 @@ void __pthread_fork_atfork_register_prepare(void (*)(void)); void __pthread_fork_atfork_register_parent(void (*)(void)); void __pthread_fork_atfork_register_child(void (*)(void)); -int __pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*); +int __pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t const*); int __pthread_mutex_lock(pthread_mutex_t*); int __pthread_mutex_trylock(pthread_mutex_t*); int __pthread_mutex_lock_pessimistic_np(pthread_mutex_t*); @@ -29,7 +29,7 @@ typedef void (*KeyDestructor)(void*); int __pthread_key_create(pthread_key_t*, KeyDestructor); int __pthread_key_delete(pthread_key_t); void* __pthread_getspecific(pthread_key_t); -int __pthread_setspecific(pthread_key_t, const void*); +int __pthread_setspecific(pthread_key_t, void const*); int __pthread_self(void); diff --git a/Userland/Libraries/LibC/bits/search.h b/Userland/Libraries/LibC/bits/search.h index 9c68cd8a93..5807267ad9 100644 --- a/Userland/Libraries/LibC/bits/search.h +++ b/Userland/Libraries/LibC/bits/search.h @@ -9,10 +9,10 @@ // This is technically an implementation detail, but we require this for testing. // The key always has to be the first struct member. struct search_tree_node { - const void* key; + void const* key; struct search_tree_node* left; struct search_tree_node* right; }; -struct search_tree_node* new_tree_node(const void* key); +struct search_tree_node* new_tree_node(void const* key); void delete_node_recursive(struct search_tree_node* node); diff --git a/Userland/Libraries/LibC/bits/stdio_file_implementation.h b/Userland/Libraries/LibC/bits/stdio_file_implementation.h index 7181d7e96b..173e88f44d 100644 --- a/Userland/Libraries/LibC/bits/stdio_file_implementation.h +++ b/Userland/Libraries/LibC/bits/stdio_file_implementation.h @@ -46,7 +46,7 @@ public: void clear_err() { m_error = 0; } size_t read(u8*, size_t); - size_t write(const u8*, size_t); + size_t write(u8 const*, size_t); template<typename CharType> bool gets(CharType*, size_t); @@ -84,7 +84,7 @@ private: bool is_not_empty() const { return m_ungotten || !m_empty; } size_t buffered_size() const; - const u8* begin_dequeue(size_t& available_size) const; + u8 const* begin_dequeue(size_t& available_size) const; void did_dequeue(size_t actual_size); u8* begin_enqueue(size_t& available_size) const; @@ -114,7 +114,7 @@ private: // Read or write using the underlying fd, bypassing the buffer. ssize_t do_read(u8*, size_t); - ssize_t do_write(const u8*, size_t); + ssize_t do_write(u8 const*, size_t); // Read some data into the buffer. bool read_into_buffer(); diff --git a/Userland/Libraries/LibC/ctype.cpp b/Userland/Libraries/LibC/ctype.cpp index 9ea35ac642..81a69a8bce 100644 --- a/Userland/Libraries/LibC/ctype.cpp +++ b/Userland/Libraries/LibC/ctype.cpp @@ -8,7 +8,7 @@ extern "C" { -const char _ctype_[256] = { +char const _ctype_[256] = { _C, _C, _C, _C, _C, _C, _C, _C, _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, diff --git a/Userland/Libraries/LibC/ctype.h b/Userland/Libraries/LibC/ctype.h index 64faf788e5..b7493b8138 100644 --- a/Userland/Libraries/LibC/ctype.h +++ b/Userland/Libraries/LibC/ctype.h @@ -20,7 +20,7 @@ __BEGIN_DECLS #define _X 0100 #define _B 0200 -extern const char _ctype_[256]; +extern char const _ctype_[256]; static inline int __inline_isalnum(int c) { diff --git a/Userland/Libraries/LibC/dirent.cpp b/Userland/Libraries/LibC/dirent.cpp index 35d6ce394b..a1bd95774f 100644 --- a/Userland/Libraries/LibC/dirent.cpp +++ b/Userland/Libraries/LibC/dirent.cpp @@ -22,7 +22,7 @@ extern "C" { // https://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html -DIR* opendir(const char* name) +DIR* opendir(char const* name) { int fd = open(name, O_RDONLY | O_DIRECTORY); if (fd == -1) @@ -229,7 +229,7 @@ int alphasort(const struct dirent** d1, const struct dirent** d2) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html -int scandir(const char* dir_name, +int scandir(char const* dir_name, struct dirent*** namelist, int (*select)(const struct dirent*), int (*compare)(const struct dirent**, const struct dirent**)) @@ -273,10 +273,10 @@ int scandir(const char* dir_name, // Sort the entries if the user provided a comparator. if (compare) { - qsort(tmp_names.data(), tmp_names.size(), sizeof(struct dirent*), (int (*)(const void*, const void*))compare); + qsort(tmp_names.data(), tmp_names.size(), sizeof(struct dirent*), (int (*)(void const*, void const*))compare); } - const int size = tmp_names.size(); + int const size = tmp_names.size(); auto** names = static_cast<struct dirent**>(kmalloc_array(size, sizeof(struct dirent*))); if (names == nullptr) { return -1; diff --git a/Userland/Libraries/LibC/dirent.h b/Userland/Libraries/LibC/dirent.h index 7d0b1bf2d2..1d132a3db1 100644 --- a/Userland/Libraries/LibC/dirent.h +++ b/Userland/Libraries/LibC/dirent.h @@ -28,7 +28,7 @@ struct __DIR { typedef struct __DIR DIR; DIR* fdopendir(int fd); -DIR* opendir(const char* name); +DIR* opendir(char const* name); int closedir(DIR*); void rewinddir(DIR*); struct dirent* readdir(DIR*); @@ -36,7 +36,7 @@ int readdir_r(DIR*, struct dirent*, struct dirent**); int dirfd(DIR*); int alphasort(const struct dirent** d1, const struct dirent** d2); -int scandir(const char* dirp, struct dirent*** namelist, +int scandir(char const* dirp, struct dirent*** namelist, int (*filter)(const struct dirent*), int (*compar)(const struct dirent**, const struct dirent**)); diff --git a/Userland/Libraries/LibC/elf.h b/Userland/Libraries/LibC/elf.h index 01c497259e..d61dc831d2 100644 --- a/Userland/Libraries/LibC/elf.h +++ b/Userland/Libraries/LibC/elf.h @@ -145,7 +145,7 @@ typedef struct elfhdr { Elf32_Half e_shentsize; /* section header entry size */ Elf32_Half e_shnum; /* number of section header entries */ Elf32_Half e_shstrndx; /* section header table's "section - header string table" entry offset */ + header string table" entry offset */ } Elf32_Ehdr; typedef struct { @@ -223,7 +223,7 @@ typedef struct { /* Section Header */ typedef struct { Elf32_Word sh_name; /* name - index into section header - string table section */ + string table section */ Elf32_Word sh_type; /* type */ Elf32_Word sh_flags; /* flags */ Elf32_Addr sh_addr; /* address */ diff --git a/Userland/Libraries/LibC/errno.h b/Userland/Libraries/LibC/errno.h index 75b75ddf63..ad4b251366 100644 --- a/Userland/Libraries/LibC/errno.h +++ b/Userland/Libraries/LibC/errno.h @@ -20,7 +20,7 @@ __BEGIN_DECLS -extern const char* const sys_errlist[]; +extern char const* const sys_errlist[]; extern int sys_nerr; #ifdef NO_TLS diff --git a/Userland/Libraries/LibC/fcntl.cpp b/Userland/Libraries/LibC/fcntl.cpp index 47805d0a44..5c1ed89ded 100644 --- a/Userland/Libraries/LibC/fcntl.cpp +++ b/Userland/Libraries/LibC/fcntl.cpp @@ -30,7 +30,7 @@ int create_inode_watcher(unsigned flags) __RETURN_WITH_ERRNO(rc, rc, -1); } -int inode_watcher_add_watch(int fd, const char* path, size_t path_length, unsigned event_mask) +int inode_watcher_add_watch(int fd, char const* path, size_t path_length, unsigned event_mask) { Syscall::SC_inode_watcher_add_watch_params params { { path, path_length }, fd, event_mask }; int rc = syscall(SC_inode_watcher_add_watch, ¶ms); @@ -43,12 +43,12 @@ int inode_watcher_remove_watch(int fd, int wd) __RETURN_WITH_ERRNO(rc, rc, -1); } -int creat(const char* path, mode_t mode) +int creat(char const* path, mode_t mode) { return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode); } -int open(const char* path, int options, ...) +int open(char const* path, int options, ...) { if (!path) { errno = EFAULT; @@ -68,7 +68,7 @@ int open(const char* path, int options, ...) __RETURN_WITH_ERRNO(rc, rc, -1); } -int openat(int dirfd, const char* path, int options, ...) +int openat(int dirfd, char const* path, int options, ...) { if (!path) { errno = EFAULT; diff --git a/Userland/Libraries/LibC/fcntl.h b/Userland/Libraries/LibC/fcntl.h index 7056d874a9..ae1e290824 100644 --- a/Userland/Libraries/LibC/fcntl.h +++ b/Userland/Libraries/LibC/fcntl.h @@ -11,13 +11,13 @@ __BEGIN_DECLS -int creat(const char* path, mode_t); -int open(const char* path, int options, ...); -int openat(int dirfd, const char* path, int options, ...); +int creat(char const* path, mode_t); +int open(char const* path, int options, ...); +int openat(int dirfd, char const* path, int options, ...); int fcntl(int fd, int cmd, ...); int create_inode_watcher(unsigned flags); -int inode_watcher_add_watch(int fd, const char* path, size_t path_length, unsigned event_mask); +int inode_watcher_add_watch(int fd, char const* path, size_t path_length, unsigned event_mask); int inode_watcher_remove_watch(int fd, int wd); __END_DECLS diff --git a/Userland/Libraries/LibC/fenv.cpp b/Userland/Libraries/LibC/fenv.cpp index a9f057f25e..d4dc20d98a 100644 --- a/Userland/Libraries/LibC/fenv.cpp +++ b/Userland/Libraries/LibC/fenv.cpp @@ -61,7 +61,7 @@ int fegetenv(fenv_t* env) return 0; } -int fesetenv(const fenv_t* env) +int fesetenv(fenv_t const* env) { if (!env) return 1; @@ -96,7 +96,7 @@ int feholdexcept(fenv_t* env) return 0; } -int feupdateenv(const fenv_t* env) +int feupdateenv(fenv_t const* env) { auto currently_raised_exceptions = fetestexcept(FE_ALL_EXCEPT); @@ -113,7 +113,7 @@ int fegetexceptflag(fexcept_t* except, int exceptions) *except = (uint16_t)fetestexcept(exceptions); return 0; } -int fesetexceptflag(const fexcept_t* except, int exceptions) +int fesetexceptflag(fexcept_t const* except, int exceptions) { if (!except) return 1; diff --git a/Userland/Libraries/LibC/fenv.h b/Userland/Libraries/LibC/fenv.h index 415223d289..f5f1d8f7e6 100644 --- a/Userland/Libraries/LibC/fenv.h +++ b/Userland/Libraries/LibC/fenv.h @@ -32,12 +32,12 @@ typedef struct fenv_t { uint32_t __mxcsr; } fenv_t; -#define FE_DFL_ENV ((const fenv_t*)-1) +#define FE_DFL_ENV ((fenv_t const*)-1) int fegetenv(fenv_t*); -int fesetenv(const fenv_t*); +int fesetenv(fenv_t const*); int feholdexcept(fenv_t*); -int feupdateenv(const fenv_t*); +int feupdateenv(fenv_t const*); #define FE_INVALID 1u << 0 #define FE_DIVBYZERO 1u << 2 @@ -48,7 +48,7 @@ int feupdateenv(const fenv_t*); typedef uint16_t fexcept_t; int fegetexceptflag(fexcept_t*, int exceptions); -int fesetexceptflag(const fexcept_t*, int exceptions); +int fesetexceptflag(fexcept_t const*, int exceptions); int feclearexcept(int exceptions); int fetestexcept(int exceptions); diff --git a/Userland/Libraries/LibC/getopt.cpp b/Userland/Libraries/LibC/getopt.cpp index addfa3e63e..9c3e97ee84 100644 --- a/Userland/Libraries/LibC/getopt.cpp +++ b/Userland/Libraries/LibC/getopt.cpp @@ -22,7 +22,7 @@ char* optarg = nullptr; // processed". Well, this is how we do it. static size_t s_index_into_multioption_argument = 0; -[[gnu::format(printf, 1, 2)]] static inline void report_error(const char* format, ...) +[[gnu::format(printf, 1, 2)]] static inline void report_error(char const* format, ...) { if (!opterr) return; @@ -41,14 +41,14 @@ namespace { class OptionParser { public: - OptionParser(int argc, char* const* argv, StringView short_options, const option* long_options, int* out_long_option_index = nullptr); + OptionParser(int argc, char* const* argv, StringView short_options, option const* long_options, int* out_long_option_index = nullptr); int getopt(); private: bool lookup_short_option(char option, int& needs_value) const; int handle_short_option(); - const option* lookup_long_option(char* raw) const; + option const* lookup_long_option(char* raw) const; int handle_long_option(); void shift_argv(); @@ -57,7 +57,7 @@ private: size_t m_argc { 0 }; char* const* m_argv { nullptr }; StringView m_short_options; - const option* m_long_options { nullptr }; + option const* m_long_options { nullptr }; int* m_out_long_option_index { nullptr }; bool m_stop_on_first_non_option { false }; @@ -65,7 +65,7 @@ private: size_t m_consumed_args { 0 }; }; -OptionParser::OptionParser(int argc, char* const* argv, StringView short_options, const option* long_options, int* out_long_option_index) +OptionParser::OptionParser(int argc, char* const* argv, StringView short_options, option const* long_options, int* out_long_option_index) : m_argc(argc) , m_argv(argv) , m_short_options(short_options) @@ -204,7 +204,7 @@ int OptionParser::handle_short_option() return option; } -const option* OptionParser::lookup_long_option(char* raw) const +option const* OptionParser::lookup_long_option(char* raw) const { StringView arg = raw; @@ -336,14 +336,14 @@ bool OptionParser::find_next_option() } -int getopt(int argc, char* const* argv, const char* short_options) +int getopt(int argc, char* const* argv, char const* short_options) { option dummy { nullptr, 0, nullptr, 0 }; OptionParser parser { argc, argv, short_options, &dummy }; return parser.getopt(); } -int getopt_long(int argc, char* const* argv, const char* short_options, const struct option* long_options, int* out_long_option_index) +int getopt_long(int argc, char* const* argv, char const* short_options, const struct option* long_options, int* out_long_option_index) { OptionParser parser { argc, argv, short_options, long_options, out_long_option_index }; return parser.getopt(); diff --git a/Userland/Libraries/LibC/getopt.h b/Userland/Libraries/LibC/getopt.h index 4649322bce..f5fca0c682 100644 --- a/Userland/Libraries/LibC/getopt.h +++ b/Userland/Libraries/LibC/getopt.h @@ -15,7 +15,7 @@ __BEGIN_DECLS #define optional_argument 2 struct option { - const char* name; + char const* name; int has_arg; int* flag; int val; @@ -26,6 +26,6 @@ extern int optopt; extern int optind; extern int optreset; extern char* optarg; -int getopt_long(int argc, char* const* argv, const char* short_options, const struct option* long_options, int* out_long_option_index); +int getopt_long(int argc, char* const* argv, char const* short_options, const struct option* long_options, int* out_long_option_index); __END_DECLS diff --git a/Userland/Libraries/LibC/grp.cpp b/Userland/Libraries/LibC/grp.cpp index 9a4d55ca05..676be6b1c3 100644 --- a/Userland/Libraries/LibC/grp.cpp +++ b/Userland/Libraries/LibC/grp.cpp @@ -24,7 +24,7 @@ static struct group s_group; static String s_name; static String s_passwd; static Vector<String> s_members; -static Vector<const char*> s_members_ptrs; +static Vector<char const*> s_members_ptrs; void setgrent() { @@ -65,7 +65,7 @@ struct group* getgrgid(gid_t gid) return nullptr; } -struct group* getgrnam(const char* name) +struct group* getgrnam(char const* name) { setgrent(); while (auto* gr = getgrent()) { @@ -75,7 +75,7 @@ struct group* getgrnam(const char* name) return nullptr; } -static bool parse_grpdb_entry(const String& line) +static bool parse_grpdb_entry(String const& line) { auto parts = line.split_view(':', true); if (parts.size() != 4) { @@ -140,7 +140,7 @@ struct group* getgrent() } } -int initgroups(const char* user, gid_t extra_gid) +int initgroups(char const* user, gid_t extra_gid) { size_t count = 0; gid_t gids[32]; @@ -169,7 +169,7 @@ int putgrent(const struct group* group, FILE* stream) return -1; } - auto is_valid_field = [](const char* str) { + auto is_valid_field = [](char const* str) { return str && !strpbrk(str, ":\n"); }; diff --git a/Userland/Libraries/LibC/grp.h b/Userland/Libraries/LibC/grp.h index 20df7747c7..8fefd99811 100644 --- a/Userland/Libraries/LibC/grp.h +++ b/Userland/Libraries/LibC/grp.h @@ -23,10 +23,10 @@ struct group { struct group* getgrent(void); void setgrent(void); void endgrent(void); -struct group* getgrnam(const char* name); +struct group* getgrnam(char const* name); struct group* getgrgid(gid_t); int putgrent(const struct group*, FILE*); -int initgroups(const char* user, gid_t); +int initgroups(char const* user, gid_t); __END_DECLS diff --git a/Userland/Libraries/LibC/iconv.h b/Userland/Libraries/LibC/iconv.h index 5f86bfa960..925e045fc5 100644 --- a/Userland/Libraries/LibC/iconv.h +++ b/Userland/Libraries/LibC/iconv.h @@ -13,7 +13,7 @@ __BEGIN_DECLS typedef void* iconv_t; -extern iconv_t iconv_open(const char* tocode, const char* fromcode); +extern iconv_t iconv_open(char const* tocode, char const* fromcode); extern size_t iconv(iconv_t, char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft); extern int iconv_close(iconv_t); diff --git a/Userland/Libraries/LibC/inttypes.cpp b/Userland/Libraries/LibC/inttypes.cpp index b55e1aa964..c4160ad4da 100644 --- a/Userland/Libraries/LibC/inttypes.cpp +++ b/Userland/Libraries/LibC/inttypes.cpp @@ -25,7 +25,7 @@ imaxdiv_t imaxdiv(intmax_t numerator, intmax_t denominator) return result; } -intmax_t strtoimax(const char* str, char** endptr, int base) +intmax_t strtoimax(char const* str, char** endptr, int base) { long long_value = strtoll(str, endptr, base); @@ -42,7 +42,7 @@ intmax_t strtoimax(const char* str, char** endptr, int base) return long_value; } -uintmax_t strtoumax(const char* str, char** endptr, int base) +uintmax_t strtoumax(char const* str, char** endptr, int base) { unsigned long ulong_value = strtoull(str, endptr, base); diff --git a/Userland/Libraries/LibC/inttypes.h b/Userland/Libraries/LibC/inttypes.h index d4ae75c719..8755cbd62e 100644 --- a/Userland/Libraries/LibC/inttypes.h +++ b/Userland/Libraries/LibC/inttypes.h @@ -102,7 +102,7 @@ typedef struct imaxdiv_t { } imaxdiv_t; imaxdiv_t imaxdiv(intmax_t, intmax_t); -intmax_t strtoimax(const char*, char** endptr, int base); -uintmax_t strtoumax(const char*, char** endptr, int base); +intmax_t strtoimax(char const*, char** endptr, int base); +uintmax_t strtoumax(char const*, char** endptr, int base); __END_DECLS diff --git a/Userland/Libraries/LibC/langinfo.cpp b/Userland/Libraries/LibC/langinfo.cpp index 912dce3f4c..a44f70afe1 100644 --- a/Userland/Libraries/LibC/langinfo.cpp +++ b/Userland/Libraries/LibC/langinfo.cpp @@ -8,7 +8,7 @@ #include <langinfo.h> // Values taken from glibc's en_US locale files. -static const char* __nl_langinfo(nl_item item) +static char const* __nl_langinfo(nl_item item) { switch (item) { case CODESET: diff --git a/Userland/Libraries/LibC/link.h b/Userland/Libraries/LibC/link.h index 73ad8ad07f..eaa28ec4de 100644 --- a/Userland/Libraries/LibC/link.h +++ b/Userland/Libraries/LibC/link.h @@ -18,7 +18,7 @@ __BEGIN_DECLS struct dl_phdr_info { ElfW(Addr) dlpi_addr; - const char* dlpi_name; + char const* dlpi_name; const ElfW(Phdr) * dlpi_phdr; ElfW(Half) dlpi_phnum; }; diff --git a/Userland/Libraries/LibC/locale.cpp b/Userland/Libraries/LibC/locale.cpp index 8eca939fb7..06cbcdb6ce 100644 --- a/Userland/Libraries/LibC/locale.cpp +++ b/Userland/Libraries/LibC/locale.cpp @@ -45,7 +45,7 @@ static struct lconv default_locale = { default_empty_value }; -char* setlocale(int, const char*) +char* setlocale(int, char const*) { static char locale[2]; memcpy(locale, "C", 2); diff --git a/Userland/Libraries/LibC/locale.h b/Userland/Libraries/LibC/locale.h index 7d4069ecba..0fe99ba7d8 100644 --- a/Userland/Libraries/LibC/locale.h +++ b/Userland/Libraries/LibC/locale.h @@ -55,6 +55,6 @@ struct lconv { }; struct lconv* localeconv(void); -char* setlocale(int category, const char* locale); +char* setlocale(int category, char const* locale); __END_DECLS diff --git a/Userland/Libraries/LibC/malloc.cpp b/Userland/Libraries/LibC/malloc.cpp index f67dc0b4f3..5b3e7add2b 100644 --- a/Userland/Libraries/LibC/malloc.cpp +++ b/Userland/Libraries/LibC/malloc.cpp @@ -56,25 +56,25 @@ static bool s_scrub_free = true; static bool s_profiling = false; static bool s_in_userspace_emulator = false; -ALWAYS_INLINE static void ue_notify_malloc(const void* ptr, size_t size) +ALWAYS_INLINE static void ue_notify_malloc(void const* ptr, size_t size) { if (s_in_userspace_emulator) syscall(SC_emuctl, 1, size, (FlatPtr)ptr); } -ALWAYS_INLINE static void ue_notify_free(const void* ptr) +ALWAYS_INLINE static void ue_notify_free(void const* ptr) { if (s_in_userspace_emulator) syscall(SC_emuctl, 2, (FlatPtr)ptr, 0); } -ALWAYS_INLINE static void ue_notify_realloc(const void* ptr, size_t size) +ALWAYS_INLINE static void ue_notify_realloc(void const* ptr, size_t size) { if (s_in_userspace_emulator) syscall(SC_emuctl, 3, size, (FlatPtr)ptr); } -ALWAYS_INLINE static void ue_notify_chunk_size_changed(const void* block, size_t chunk_size) +ALWAYS_INLINE static void ue_notify_chunk_size_changed(void const* block, size_t chunk_size) { if (s_in_userspace_emulator) syscall(SC_emuctl, 4, chunk_size, (FlatPtr)block); @@ -176,7 +176,7 @@ static BigAllocator* big_allocator_for_size(size_t size) extern "C" { -static void* os_alloc(size_t size, const char* name) +static void* os_alloc(size_t size, char const* name) { int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_PURGEABLE; #if ARCH(X86_64) @@ -525,7 +525,7 @@ size_t malloc_size(void const* ptr) if (!ptr) return 0; void* page_base = (void*)((FlatPtr)ptr & ChunkedBlock::block_mask); - auto* header = (const CommonHeader*)page_base; + auto* header = (CommonHeader const*)page_base; auto size = header->m_size; if (header->m_magic == MAGIC_BIGALLOC_HEADER) size -= sizeof(BigAllocationBlock); diff --git a/Userland/Libraries/LibC/net.cpp b/Userland/Libraries/LibC/net.cpp index aa76ec0a6c..9a6b113529 100644 --- a/Userland/Libraries/LibC/net.cpp +++ b/Userland/Libraries/LibC/net.cpp @@ -11,7 +11,7 @@ const in6_addr in6addr_any = IN6ADDR_ANY_INIT; const in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; -unsigned int if_nametoindex([[maybe_unused]] const char* ifname) +unsigned int if_nametoindex([[maybe_unused]] char const* ifname) { errno = ENODEV; return -1; diff --git a/Userland/Libraries/LibC/netdb.cpp b/Userland/Libraries/LibC/netdb.cpp index 6dc38f2ca4..45b13b39e1 100644 --- a/Userland/Libraries/LibC/netdb.cpp +++ b/Userland/Libraries/LibC/netdb.cpp @@ -37,9 +37,9 @@ static constexpr u32 lookup_server_endpoint_magic = "LookupServer"sv.hash(); // Get service entry buffers and file information for the getservent() family of functions. static FILE* services_file = nullptr; -static const char* services_path = "/etc/services"; +static char const* services_path = "/etc/services"; -static bool fill_getserv_buffers(const char* line, ssize_t read); +static bool fill_getserv_buffers(char const* line, ssize_t read); static servent __getserv_buffer; static String __getserv_name_buffer; static String __getserv_protocol_buffer; @@ -51,9 +51,9 @@ static ssize_t service_file_offset = 0; // Get protocol entry buffers and file information for the getprotent() family of functions. static FILE* protocols_file = nullptr; -static const char* protocols_path = "/etc/protocols"; +static char const* protocols_path = "/etc/protocols"; -static bool fill_getproto_buffers(const char* line, ssize_t read); +static bool fill_getproto_buffers(char const* line, ssize_t read); static protoent __getproto_buffer; static String __getproto_name_buffer; static Vector<ByteBuffer> __getproto_alias_list_buffer; @@ -75,7 +75,7 @@ static int connect_to_lookup_server() "/tmp/portal/lookup" }; - if (connect(fd, (const sockaddr*)&address, sizeof(address)) < 0) { + if (connect(fd, (sockaddr const*)&address, sizeof(address)) < 0) { perror("connect_to_lookup_server"); close(fd); return -1; @@ -85,7 +85,7 @@ static int connect_to_lookup_server() static String gethostbyname_name_buffer; -hostent* gethostbyname(const char* name) +hostent* gethostbyname(char const* name) { h_errno = 0; @@ -205,7 +205,7 @@ hostent* gethostbyname(const char* name) static String gethostbyaddr_name_buffer; -hostent* gethostbyaddr(const void* addr, socklen_t addr_size, int type) +hostent* gethostbyaddr(void const* addr, socklen_t addr_size, int type) { h_errno = 0; @@ -229,7 +229,7 @@ hostent* gethostbyaddr(const void* addr, socklen_t addr_size, int type) close(fd); }); - const in_addr_t& in_addr = ((const struct in_addr*)addr)->s_addr; + in_addr_t const& in_addr = ((const struct in_addr*)addr)->s_addr; struct [[gnu::packed]] { u32 message_size; @@ -367,7 +367,7 @@ struct servent* getservent() return service_entry; } -struct servent* getservbyname(const char* name, const char* protocol) +struct servent* getservbyname(char const* name, char const* protocol) { if (name == nullptr) return nullptr; @@ -394,7 +394,7 @@ struct servent* getservbyname(const char* name, const char* protocol) return current_service; } -struct servent* getservbyport(int port, const char* protocol) +struct servent* getservbyport(int port, char const* protocol) { bool previous_file_open_setting = keep_service_file_open; setservent(1); @@ -444,7 +444,7 @@ void endservent() // Fill the service entry buffer with the information contained // in the currently read line, returns true if successful, // false if failure occurs. -static bool fill_getserv_buffers(const char* line, ssize_t read) +static bool fill_getserv_buffers(char const* line, ssize_t read) { // Splitting the line by tab delimiter and filling the servent buffers name, port, and protocol members. auto split_line = StringView(line, read).replace(" ", "\t", true).split('\t'); @@ -555,7 +555,7 @@ struct protoent* getprotoent() return protocol_entry; } -struct protoent* getprotobyname(const char* name) +struct protoent* getprotobyname(char const* name) { bool previous_file_open_setting = keep_protocols_file_open; setprotoent(1); @@ -623,7 +623,7 @@ void endprotoent() protocols_file = nullptr; } -static bool fill_getproto_buffers(const char* line, ssize_t read) +static bool fill_getproto_buffers(char const* line, ssize_t read) { String string_line = String(line, read); auto split_line = string_line.replace(" ", "\t", true).split('\t'); @@ -660,7 +660,7 @@ static bool fill_getproto_buffers(const char* line, ssize_t read) return true; } -int getaddrinfo(const char* __restrict node, const char* __restrict service, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res) +int getaddrinfo(char const* __restrict node, char const* __restrict service, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res) { *res = nullptr; @@ -678,7 +678,7 @@ int getaddrinfo(const char* __restrict node, const char* __restrict service, con if (!host_ent) return EAI_FAIL; - const char* proto = nullptr; + char const* proto = nullptr; if (hints && hints->ai_socktype) { switch (hints->ai_socktype) { case SOCK_STREAM: @@ -767,7 +767,7 @@ void freeaddrinfo(struct addrinfo* res) } } -const char* gai_strerror(int errcode) +char const* gai_strerror(int errcode) { switch (errcode) { case EAI_ADDRFAMILY: @@ -804,7 +804,7 @@ int getnameinfo(const struct sockaddr* __restrict addr, socklen_t addrlen, char* if (addr->sa_family != AF_INET || addrlen < sizeof(sockaddr_in)) return EAI_FAMILY; - const sockaddr_in* sin = reinterpret_cast<const sockaddr_in*>(addr); + sockaddr_in const* sin = reinterpret_cast<sockaddr_in const*>(addr); if (host && hostlen > 0) { if (flags != 0) diff --git a/Userland/Libraries/LibC/netdb.h b/Userland/Libraries/LibC/netdb.h index 409be7d437..72561ebb79 100644 --- a/Userland/Libraries/LibC/netdb.h +++ b/Userland/Libraries/LibC/netdb.h @@ -20,8 +20,8 @@ struct hostent { #define h_addr h_addr_list[0] }; -struct hostent* gethostbyname(const char*); -struct hostent* gethostbyaddr(const void* addr, socklen_t len, int type); +struct hostent* gethostbyname(char const*); +struct hostent* gethostbyaddr(void const* addr, socklen_t len, int type); struct servent { char* s_name; @@ -31,8 +31,8 @@ struct servent { }; struct servent* getservent(void); -struct servent* getservbyname(const char* name, const char* protocol); -struct servent* getservbyport(int port, const char* protocol); +struct servent* getservbyname(char const* name, char const* protocol); +struct servent* getservbyport(int port, char const* protocol); void setservent(int stay_open); void endservent(void); @@ -43,7 +43,7 @@ struct protoent { }; void endprotoent(void); -struct protoent* getprotobyname(const char* name); +struct protoent* getprotobyname(char const* name); struct protoent* getprotobynumber(int proto); struct protoent* getprotoent(void); void setprotoent(int stay_open); @@ -96,9 +96,9 @@ struct addrinfo { #define NI_NOFQDN 4 #define NI_DGRAM 5 -int getaddrinfo(const char* __restrict node, const char* __restrict service, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res); +int getaddrinfo(char const* __restrict node, char const* __restrict service, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res); void freeaddrinfo(struct addrinfo* res); -const char* gai_strerror(int errcode); +char const* gai_strerror(int errcode); int getnameinfo(const struct sockaddr* __restrict addr, socklen_t addrlen, char* __restrict host, socklen_t hostlen, char* __restrict serv, socklen_t servlen, int flags); __END_DECLS diff --git a/Userland/Libraries/LibC/poll.cpp b/Userland/Libraries/LibC/poll.cpp index 8b5f5605f1..7491346d5b 100644 --- a/Userland/Libraries/LibC/poll.cpp +++ b/Userland/Libraries/LibC/poll.cpp @@ -23,7 +23,7 @@ int poll(pollfd* fds, nfds_t nfds, int timeout_ms) return ppoll(fds, nfds, timeout_ts, nullptr); } -int ppoll(pollfd* fds, nfds_t nfds, const timespec* timeout, const sigset_t* sigmask) +int ppoll(pollfd* fds, nfds_t nfds, timespec const* timeout, sigset_t const* sigmask) { Syscall::SC_poll_params params { fds, nfds, timeout, sigmask }; int rc = syscall(SC_poll, ¶ms); diff --git a/Userland/Libraries/LibC/poll.h b/Userland/Libraries/LibC/poll.h index cdc838242e..7667468442 100644 --- a/Userland/Libraries/LibC/poll.h +++ b/Userland/Libraries/LibC/poll.h @@ -12,6 +12,6 @@ __BEGIN_DECLS int poll(struct pollfd* fds, nfds_t nfds, int timeout); -int ppoll(struct pollfd* fds, nfds_t nfds, const struct timespec* timeout, const sigset_t* sigmask); +int ppoll(struct pollfd* fds, nfds_t nfds, const struct timespec* timeout, sigset_t const* sigmask); __END_DECLS diff --git a/Userland/Libraries/LibC/pthread_forward.cpp b/Userland/Libraries/LibC/pthread_forward.cpp index e610613cbb..32fcd015e7 100644 --- a/Userland/Libraries/LibC/pthread_forward.cpp +++ b/Userland/Libraries/LibC/pthread_forward.cpp @@ -56,7 +56,7 @@ int pthread_cond_broadcast(pthread_cond_t* cond) return s_pthread_functions.pthread_cond_broadcast(cond); } -int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) +int pthread_cond_init(pthread_cond_t* cond, pthread_condattr_t const* attr) { VERIFY(s_pthread_functions.pthread_cond_init); return s_pthread_functions.pthread_cond_init(cond, attr); diff --git a/Userland/Libraries/LibC/pthread_integration.cpp b/Userland/Libraries/LibC/pthread_integration.cpp index 64762f5d74..f802cd5247 100644 --- a/Userland/Libraries/LibC/pthread_integration.cpp +++ b/Userland/Libraries/LibC/pthread_integration.cpp @@ -97,7 +97,7 @@ static constexpr u32 MUTEX_UNLOCKED = 0; static constexpr u32 MUTEX_LOCKED_NO_NEED_TO_WAKE = 1; static constexpr u32 MUTEX_LOCKED_NEED_TO_WAKE = 2; -int __pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attributes) +int __pthread_mutex_init(pthread_mutex_t* mutex, pthread_mutexattr_t const* attributes) { mutex->lock = 0; mutex->owner = 0; @@ -106,7 +106,7 @@ int __pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr return 0; } -int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __attribute__((weak, alias("__pthread_mutex_init"))); +int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t const*) __attribute__((weak, alias("__pthread_mutex_init"))); int __pthread_mutex_trylock(pthread_mutex_t* mutex) { diff --git a/Userland/Libraries/LibC/pthread_tls.cpp b/Userland/Libraries/LibC/pthread_tls.cpp index 6c32260dcd..abae74b75d 100644 --- a/Userland/Libraries/LibC/pthread_tls.cpp +++ b/Userland/Libraries/LibC/pthread_tls.cpp @@ -68,7 +68,7 @@ void* __pthread_getspecific(pthread_key_t key) void* pthread_getspecific(pthread_key_t) __attribute__((weak, alias("__pthread_getspecific"))); -int __pthread_setspecific(pthread_key_t key, const void* value) +int __pthread_setspecific(pthread_key_t key, void const* value) { if (key < 0) return EINVAL; @@ -79,7 +79,7 @@ int __pthread_setspecific(pthread_key_t key, const void* value) return 0; } -int pthread_setspecific(pthread_key_t, const void*) __attribute__((weak, alias("__pthread_setspecific"))); +int pthread_setspecific(pthread_key_t, void const*) __attribute__((weak, alias("__pthread_setspecific"))); void __pthread_key_destroy_for_current_thread() { diff --git a/Userland/Libraries/LibC/pwd.cpp b/Userland/Libraries/LibC/pwd.cpp index e55691d592..6b47b3d6f9 100644 --- a/Userland/Libraries/LibC/pwd.cpp +++ b/Userland/Libraries/LibC/pwd.cpp @@ -66,7 +66,7 @@ struct passwd* getpwuid(uid_t uid) return nullptr; } -struct passwd* getpwnam(const char* name) +struct passwd* getpwnam(char const* name) { setpwent(); while (auto* pw = getpwent()) { @@ -76,7 +76,7 @@ struct passwd* getpwnam(const char* name) return nullptr; } -static bool parse_pwddb_entry(const String& line) +static bool parse_pwddb_entry(String const& line) { auto parts = line.split_view(':', true); if (parts.size() != 7) { @@ -168,7 +168,7 @@ static void construct_pwd(struct passwd* pwd, char* buf, struct passwd** result) pwd->pw_shell = buf_shell; } -int getpwnam_r(const char* name, struct passwd* pwd, char* buf, size_t buflen, struct passwd** result) +int getpwnam_r(char const* name, struct passwd* pwd, char* buf, size_t buflen, struct passwd** result) { // FIXME: This is a HACK! TemporaryChange name_change { s_name, {} }; @@ -191,7 +191,7 @@ int getpwnam_r(const char* name, struct passwd* pwd, char* buf, size_t buflen, s return 0; } - const auto total_buffer_length = s_name.length() + s_passwd.length() + s_gecos.length() + s_dir.length() + s_shell.length() + 5; + auto const total_buffer_length = s_name.length() + s_passwd.length() + s_gecos.length() + s_dir.length() + s_shell.length() + 5; if (buflen < total_buffer_length) return ERANGE; @@ -222,7 +222,7 @@ int getpwuid_r(uid_t uid, struct passwd* pwd, char* buf, size_t buflen, struct p return 0; } - const auto total_buffer_length = s_name.length() + s_passwd.length() + s_gecos.length() + s_dir.length() + s_shell.length() + 5; + auto const total_buffer_length = s_name.length() + s_passwd.length() + s_gecos.length() + s_dir.length() + s_shell.length() + 5; if (buflen < total_buffer_length) return ERANGE; @@ -237,7 +237,7 @@ int putpwent(const struct passwd* p, FILE* stream) return -1; } - auto is_valid_field = [](const char* str) { + auto is_valid_field = [](char const* str) { return str && !strpbrk(str, ":\n"); }; diff --git a/Userland/Libraries/LibC/pwd.h b/Userland/Libraries/LibC/pwd.h index a7d8acd24c..4554888d3a 100644 --- a/Userland/Libraries/LibC/pwd.h +++ b/Userland/Libraries/LibC/pwd.h @@ -25,11 +25,11 @@ struct passwd { struct passwd* getpwent(void); void setpwent(void); void endpwent(void); -struct passwd* getpwnam(const char* name); +struct passwd* getpwnam(char const* name); struct passwd* getpwuid(uid_t); int putpwent(const struct passwd* p, FILE* stream); -int getpwnam_r(const char* name, struct passwd* pwd, char* buf, size_t buflen, struct passwd** result); +int getpwnam_r(char const* name, struct passwd* pwd, char* buf, size_t buflen, struct passwd** result); int getpwuid_r(uid_t, struct passwd* pwd, char* buf, size_t buflen, struct passwd** result); __END_DECLS diff --git a/Userland/Libraries/LibC/qsort.cpp b/Userland/Libraries/LibC/qsort.cpp index 6425f6bbcb..f628e0e189 100644 --- a/Userland/Libraries/LibC/qsort.cpp +++ b/Userland/Libraries/LibC/qsort.cpp @@ -28,12 +28,12 @@ private: namespace AK { template<> -inline void swap(const SizedObject& a, const SizedObject& b) +inline void swap(SizedObject const& a, SizedObject const& b) { VERIFY(a.size() == b.size()); const size_t size = a.size(); - const auto a_data = reinterpret_cast<char*>(a.data()); - const auto b_data = reinterpret_cast<char*>(b.data()); + auto const a_data = reinterpret_cast<char*>(a.data()); + auto const b_data = reinterpret_cast<char*>(b.data()); for (auto i = 0u; i < size; ++i) { swap(a_data[i], b_data[i]); } @@ -60,7 +60,7 @@ private: }; // https://pubs.opengroup.org/onlinepubs/9699919799/functions/qsort.html -void qsort(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*)) +void qsort(void* bot, size_t nmemb, size_t size, int (*compar)(void const*, void const*)) { if (nmemb <= 1) { return; @@ -68,10 +68,10 @@ void qsort(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, cons SizedObjectSlice slice { bot, size }; - AK::dual_pivot_quick_sort(slice, 0, nmemb - 1, [=](const SizedObject& a, const SizedObject& b) { return compar(a.data(), b.data()) < 0; }); + AK::dual_pivot_quick_sort(slice, 0, nmemb - 1, [=](SizedObject const& a, SizedObject const& b) { return compar(a.data(), b.data()) < 0; }); } -void qsort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg) +void qsort_r(void* bot, size_t nmemb, size_t size, int (*compar)(void const*, void const*, void*), void* arg) { if (nmemb <= 1) { return; @@ -79,5 +79,5 @@ void qsort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, co SizedObjectSlice slice { bot, size }; - AK::dual_pivot_quick_sort(slice, 0, nmemb - 1, [=](const SizedObject& a, const SizedObject& b) { return compar(a.data(), b.data(), arg) < 0; }); + AK::dual_pivot_quick_sort(slice, 0, nmemb - 1, [=](SizedObject const& a, SizedObject const& b) { return compar(a.data(), b.data(), arg) < 0; }); } diff --git a/Userland/Libraries/LibC/regex.cpp b/Userland/Libraries/LibC/regex.cpp index dca3624113..394abb708a 100644 --- a/Userland/Libraries/LibC/regex.cpp +++ b/Userland/Libraries/LibC/regex.cpp @@ -13,9 +13,9 @@ static void* s_libregex; static pthread_mutex_t s_libregex_lock; -static int (*s_regcomp)(regex_t*, const char*, int); -static int (*s_regexec)(const regex_t*, const char*, size_t, regmatch_t[], int); -static size_t (*s_regerror)(int, const regex_t*, char*, size_t); +static int (*s_regcomp)(regex_t*, char const*, int); +static int (*s_regexec)(regex_t const*, char const*, size_t, regmatch_t[], int); +static size_t (*s_regerror)(int, regex_t const*, char*, size_t); static void (*s_regfree)(regex_t*); static void ensure_libregex() @@ -24,9 +24,9 @@ static void ensure_libregex() if (!s_libregex) { s_libregex = __dlopen("libregex.so", RTLD_NOW).value(); - s_regcomp = reinterpret_cast<int (*)(regex_t*, const char*, int)>(__dlsym(s_libregex, "regcomp").value()); - s_regexec = reinterpret_cast<int (*)(const regex_t*, const char*, size_t, regmatch_t[], int)>(__dlsym(s_libregex, "regexec").value()); - s_regerror = reinterpret_cast<size_t (*)(int, const regex_t*, char*, size_t)>(__dlsym(s_libregex, "regerror").value()); + s_regcomp = reinterpret_cast<int (*)(regex_t*, char const*, int)>(__dlsym(s_libregex, "regcomp").value()); + s_regexec = reinterpret_cast<int (*)(regex_t const*, char const*, size_t, regmatch_t[], int)>(__dlsym(s_libregex, "regexec").value()); + s_regerror = reinterpret_cast<size_t (*)(int, regex_t const*, char*, size_t)>(__dlsym(s_libregex, "regerror").value()); s_regfree = reinterpret_cast<void (*)(regex_t*)>(__dlsym(s_libregex, "regfree").value()); } pthread_mutex_unlock(&s_libregex_lock); @@ -34,19 +34,19 @@ static void ensure_libregex() extern "C" { -int __attribute__((weak)) regcomp(regex_t* reg, const char* pattern, int cflags) +int __attribute__((weak)) regcomp(regex_t* reg, char const* pattern, int cflags) { ensure_libregex(); return s_regcomp(reg, pattern, cflags); } -int __attribute__((weak)) regexec(const regex_t* reg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags) +int __attribute__((weak)) regexec(regex_t const* reg, char const* string, size_t nmatch, regmatch_t pmatch[], int eflags) { ensure_libregex(); return s_regexec(reg, string, nmatch, pmatch, eflags); } -size_t __attribute__((weak)) regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_size) +size_t __attribute__((weak)) regerror(int errcode, regex_t const* reg, char* errbuf, size_t errbuf_size) { ensure_libregex(); return s_regerror(errcode, reg, errbuf, errbuf_size); diff --git a/Userland/Libraries/LibC/regex.h b/Userland/Libraries/LibC/regex.h index da11c82d96..d51c138a65 100644 --- a/Userland/Libraries/LibC/regex.h +++ b/Userland/Libraries/LibC/regex.h @@ -101,9 +101,9 @@ enum __RegexAllFlags { #define REG_SEARCH __Regex_Last << 1 -int regcomp(regex_t*, const char*, int); -int regexec(const regex_t*, const char*, size_t, regmatch_t[], int); -size_t regerror(int, const regex_t*, char*, size_t); +int regcomp(regex_t*, char const*, int); +int regexec(regex_t const*, char const*, size_t, regmatch_t[], int); +size_t regerror(int, regex_t const*, char*, size_t); void regfree(regex_t*); __END_DECLS diff --git a/Userland/Libraries/LibC/resolv.h b/Userland/Libraries/LibC/resolv.h index 5b73bd9600..ff0a7f3447 100644 --- a/Userland/Libraries/LibC/resolv.h +++ b/Userland/Libraries/LibC/resolv.h @@ -10,6 +10,6 @@ __BEGIN_DECLS -int res_query(const char* dname, int class_, int type, unsigned char* answer, int anslen); +int res_query(char const* dname, int class_, int type, unsigned char* answer, int anslen); __END_DECLS diff --git a/Userland/Libraries/LibC/scanf.cpp b/Userland/Libraries/LibC/scanf.cpp index 246e54e48a..27e981427d 100644 --- a/Userland/Libraries/LibC/scanf.cpp +++ b/Userland/Libraries/LibC/scanf.cpp @@ -384,7 +384,7 @@ private: size_t count { 0 }; }; -extern "C" int vsscanf(const char* input, const char* format, va_list ap) +extern "C" int vsscanf(char const* input, char const* format, va_list ap) { GenericLexer format_lexer { format }; GenericLexer input_lexer { input }; diff --git a/Userland/Libraries/LibC/search.cpp b/Userland/Libraries/LibC/search.cpp index 7059297605..bad67a0b79 100644 --- a/Userland/Libraries/LibC/search.cpp +++ b/Userland/Libraries/LibC/search.cpp @@ -9,7 +9,7 @@ #include <bits/search.h> #include <search.h> -struct search_tree_node* new_tree_node(const void* key) +struct search_tree_node* new_tree_node(void const* key) { auto* node = static_cast<struct search_tree_node*>(malloc(sizeof(struct search_tree_node))); @@ -37,7 +37,7 @@ void delete_node_recursive(struct search_tree_node* node) extern "C" { // https://pubs.opengroup.org/onlinepubs/9699919799/functions/tsearch.html -void* tsearch(const void* key, void** rootp, int (*comparator)(const void*, const void*)) +void* tsearch(void const* key, void** rootp, int (*comparator)(void const*, void const*)) { if (!rootp) return nullptr; @@ -71,7 +71,7 @@ void* tsearch(const void* key, void** rootp, int (*comparator)(const void*, cons } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/tfind.html -void* tfind(const void* key, void* const* rootp, int (*comparator)(const void*, const void*)) +void* tfind(void const* key, void* const* rootp, int (*comparator)(void const*, void const*)) { if (!rootp) return nullptr; @@ -93,13 +93,13 @@ void* tfind(const void* key, void* const* rootp, int (*comparator)(const void*, } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/tdelete.html -void* tdelete(const void*, void**, int (*)(const void*, const void*)) +void* tdelete(void const*, void**, int (*)(void const*, void const*)) { dbgln("FIXME: Implement tdelete()"); return nullptr; } -static void twalk_internal(const struct search_tree_node* node, void (*action)(const void*, VISIT, int), int depth) +static void twalk_internal(const struct search_tree_node* node, void (*action)(void const*, VISIT, int), int depth) { if (!node) return; @@ -117,7 +117,7 @@ static void twalk_internal(const struct search_tree_node* node, void (*action)(c } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/twalk.html -void twalk(const void* rootp, void (*action)(const void*, VISIT, int)) +void twalk(void const* rootp, void (*action)(void const*, VISIT, int)) { auto node = static_cast<const struct search_tree_node*>(rootp); diff --git a/Userland/Libraries/LibC/search.h b/Userland/Libraries/LibC/search.h index cd02738a5a..1020c34487 100644 --- a/Userland/Libraries/LibC/search.h +++ b/Userland/Libraries/LibC/search.h @@ -17,9 +17,9 @@ typedef enum { leaf, } VISIT; -void* tsearch(const void*, void**, int (*)(const void*, const void*)); -void* tfind(const void*, void* const*, int (*)(const void*, const void*)); -void* tdelete(const void*, void**, int (*)(const void*, const void*)); -void twalk(const void*, void (*)(const void*, VISIT, int)); +void* tsearch(void const*, void**, int (*)(void const*, void const*)); +void* tfind(void const*, void* const*, int (*)(void const*, void const*)); +void* tdelete(void const*, void**, int (*)(void const*, void const*)); +void twalk(void const*, void (*)(void const*, VISIT, int)); __END_DECLS diff --git a/Userland/Libraries/LibC/serenity.cpp b/Userland/Libraries/LibC/serenity.cpp index e67e98e284..11c9524d4e 100644 --- a/Userland/Libraries/LibC/serenity.cpp +++ b/Userland/Libraries/LibC/serenity.cpp @@ -101,7 +101,7 @@ int anon_create(size_t size, int options) __RETURN_WITH_ERRNO(rc, rc, -1); } -int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t buffer_size) +int serenity_readlink(char const* path, size_t path_length, char* buffer, size_t buffer_size) { Syscall::SC_readlink_params small_params { { path, path_length }, @@ -111,7 +111,7 @@ int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t __RETURN_WITH_ERRNO(rc, rc, -1); } -int setkeymap(const char* name, const u32* map, u32* const shift_map, const u32* alt_map, const u32* altgr_map, const u32* shift_altgr_map) +int setkeymap(char const* name, u32 const* map, u32* const shift_map, u32 const* alt_map, u32 const* altgr_map, u32 const* shift_altgr_map) { Syscall::SC_setkeymap_params params { map, shift_map, alt_map, altgr_map, shift_altgr_map, { name, strlen(name) } }; return syscall(SC_setkeymap, ¶ms); @@ -131,10 +131,10 @@ int getkeymap(char* name_buffer, size_t name_buffer_size, u32* map, u32* shift_m __RETURN_WITH_ERRNO(rc, rc, -1); } -u16 internet_checksum(const void* ptr, size_t count) +u16 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 += ntohs(*w++); if (checksum & 0x80000000) diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index c60625494b..6ab5538743 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -60,12 +60,12 @@ int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size); int anon_create(size_t size, int options); -int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t buffer_size); +int serenity_readlink(char const* path, size_t path_length, char* buffer, size_t buffer_size); int getkeymap(char* name_buffer, size_t name_buffer_size, uint32_t* map, uint32_t* shift_map, uint32_t* alt_map, uint32_t* altgr_map, uint32_t* shift_altgr_map); -int setkeymap(const char* name, const uint32_t* map, uint32_t* const shift_map, const uint32_t* alt_map, const uint32_t* altgr_map, const uint32_t* shift_altgr_map); +int setkeymap(char const* name, uint32_t const* map, uint32_t* const shift_map, uint32_t const* alt_map, uint32_t const* altgr_map, uint32_t const* shift_altgr_map); -uint16_t internet_checksum(const void* ptr, size_t count); +uint16_t internet_checksum(void const* ptr, size_t count); int emuctl(uintptr_t command, uintptr_t arg0, uintptr_t arg1); diff --git a/Userland/Libraries/LibC/shadow.cpp b/Userland/Libraries/LibC/shadow.cpp index 628925ea29..a7504ec3d9 100644 --- a/Userland/Libraries/LibC/shadow.cpp +++ b/Userland/Libraries/LibC/shadow.cpp @@ -51,7 +51,7 @@ void endspent() s_pwdp = {}; } -struct spwd* getspnam(const char* name) +struct spwd* getspnam(char const* name) { setspent(); while (auto* sp = getspent()) { @@ -62,7 +62,7 @@ struct spwd* getspnam(const char* name) return nullptr; } -static bool parse_shadow_entry(const String& line) +static bool parse_shadow_entry(String const& line) { auto parts = line.split_view(':', true); if (parts.size() != 9) { @@ -192,7 +192,7 @@ static void construct_spwd(struct spwd* sp, char* buf, struct spwd** result) sp->sp_pwdp = buf_pwdp; } -int getspnam_r(const char* name, struct spwd* sp, char* buf, size_t buflen, struct spwd** result) +int getspnam_r(char const* name, struct spwd* sp, char* buf, size_t buflen, struct spwd** result) { // FIXME: This is a HACK! TemporaryChange name_change { s_name, {} }; @@ -212,7 +212,7 @@ int getspnam_r(const char* name, struct spwd* sp, char* buf, size_t buflen, stru return 0; } - const auto total_buffer_length = s_name.length() + s_pwdp.length() + 8; + auto const total_buffer_length = s_name.length() + s_pwdp.length() + 8; if (buflen < total_buffer_length) return ERANGE; @@ -227,7 +227,7 @@ int putspent(struct spwd* p, FILE* stream) return -1; } - auto is_valid_field = [](const char* str) { + auto is_valid_field = [](char const* str) { return str && !strpbrk(str, ":\n"); }; diff --git a/Userland/Libraries/LibC/shadow.h b/Userland/Libraries/LibC/shadow.h index a766451f7e..0d3e463931 100644 --- a/Userland/Libraries/LibC/shadow.h +++ b/Userland/Libraries/LibC/shadow.h @@ -27,13 +27,13 @@ struct spwd { struct spwd* getspent(void); void setspent(void); void endspent(void); -struct spwd* getspnam(const char* name); +struct spwd* getspnam(char const* name); int putspent(struct spwd* p, FILE* stream); int getspent_r(struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp); -int getspnam_r(const char* name, struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp); +int getspnam_r(char const* name, struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp); int fgetspent_r(FILE* fp, struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp); -int sgetspent_r(const char* s, struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp); +int sgetspent_r(char const* s, struct spwd* spbuf, char* buf, size_t buflen, struct spwd** spbufp); __END_DECLS diff --git a/Userland/Libraries/LibC/signal.cpp b/Userland/Libraries/LibC/signal.cpp index abbab504a4..37fba25965 100644 --- a/Userland/Libraries/LibC/signal.cpp +++ b/Userland/Libraries/LibC/signal.cpp @@ -84,7 +84,7 @@ int sigaddset(sigset_t* set, int sig) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaltstack.html -int sigaltstack(const stack_t* ss, stack_t* old_ss) +int sigaltstack(stack_t const* ss, stack_t* old_ss) { int rc = syscall(SC_sigaltstack, ss, old_ss); __RETURN_WITH_ERRNO(rc, rc, -1); @@ -102,7 +102,7 @@ int sigdelset(sigset_t* set, int sig) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigismember.html -int sigismember(const sigset_t* set, int sig) +int sigismember(sigset_t const* set, int sig) { if (sig < 1 || sig > 32) { errno = EINVAL; @@ -114,7 +114,7 @@ int sigismember(const sigset_t* set, int sig) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigprocmask.html -int sigprocmask(int how, const sigset_t* set, sigset_t* old_set) +int sigprocmask(int how, sigset_t const* set, sigset_t* old_set) { int rc = syscall(SC_sigprocmask, how, set, old_set); __RETURN_WITH_ERRNO(rc, rc, -1); @@ -127,7 +127,7 @@ int sigpending(sigset_t* set) __RETURN_WITH_ERRNO(rc, rc, -1); } -const char* sys_siglist[NSIG] = { +char const* sys_siglist[NSIG] = { "Invalid signal number", "Hangup", "Interrupt", @@ -173,7 +173,7 @@ void siglongjmp(jmp_buf env, int val) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigsuspend.html -int sigsuspend(const sigset_t* set) +int sigsuspend(sigset_t const* set) { return pselect(0, nullptr, nullptr, nullptr, nullptr, set); } @@ -202,7 +202,7 @@ int sigtimedwait(sigset_t const* set, siginfo_t* info, struct timespec const* ti __RETURN_WITH_ERRNO(rc, rc, -1); } -const char* sys_signame[] = { +char const* sys_signame[] = { "INVAL", "HUP", "INT", @@ -237,9 +237,9 @@ const char* sys_signame[] = { "SYS", }; -static_assert(sizeof(sys_signame) == sizeof(const char*) * NSIG); +static_assert(sizeof(sys_signame) == sizeof(char const*) * NSIG); -int getsignalbyname(const char* name) +int getsignalbyname(char const* name) { VERIFY(name); StringView name_sv(name); @@ -252,7 +252,7 @@ int getsignalbyname(const char* name) return -1; } -const char* getsignalname(int signal) +char const* getsignalname(int signal) { if (signal < 0 || signal >= NSIG) { errno = EINVAL; diff --git a/Userland/Libraries/LibC/signal.h b/Userland/Libraries/LibC/signal.h index 3ed14348a0..2431e052db 100644 --- a/Userland/Libraries/LibC/signal.h +++ b/Userland/Libraries/LibC/signal.h @@ -17,25 +17,25 @@ __BEGIN_DECLS int kill(pid_t, int sig); int killpg(int pgrp, int sig); sighandler_t signal(int sig, sighandler_t); -int pthread_sigmask(int how, const sigset_t* set, sigset_t* old_set); +int pthread_sigmask(int how, sigset_t const* set, sigset_t* old_set); int sigaction(int sig, const struct sigaction* act, struct sigaction* old_act); int sigemptyset(sigset_t*); int sigfillset(sigset_t*); int sigaddset(sigset_t*, int sig); -int sigaltstack(const stack_t* ss, stack_t* old_ss); +int sigaltstack(stack_t const* ss, stack_t* old_ss); int sigdelset(sigset_t*, int sig); -int sigismember(const sigset_t*, int sig); -int sigprocmask(int how, const sigset_t* set, sigset_t* old_set); +int sigismember(sigset_t const*, int sig); +int sigprocmask(int how, sigset_t const* set, sigset_t* old_set); int sigpending(sigset_t*); -int sigsuspend(const sigset_t*); +int sigsuspend(sigset_t const*); int sigtimedwait(sigset_t const*, siginfo_t*, struct timespec const*); int sigwait(sigset_t const*, int*); int sigwaitinfo(sigset_t const*, siginfo_t*); int raise(int sig); -int getsignalbyname(const char*); -const char* getsignalname(int); +int getsignalbyname(char const*); +char const* getsignalname(int); -extern const char* sys_siglist[NSIG]; -extern const char* sys_signame[NSIG]; +extern char const* sys_siglist[NSIG]; +extern char const* sys_signame[NSIG]; __END_DECLS diff --git a/Userland/Libraries/LibC/spawn.cpp b/Userland/Libraries/LibC/spawn.cpp index c1ac4b5a7b..8cdc1fe0e1 100644 --- a/Userland/Libraries/LibC/spawn.cpp +++ b/Userland/Libraries/LibC/spawn.cpp @@ -29,7 +29,7 @@ struct posix_spawn_file_actions_state { extern "C" { -[[noreturn]] static void posix_spawn_child(const char* path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* attr, char* const argv[], char* const envp[], int (*exec)(const char*, char* const[], char* const[])) +[[noreturn]] static void posix_spawn_child(char const* path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const argv[], char* const envp[], int (*exec)(char const*, char* const[], char* const[])) { if (attr) { short flags = attr->flags; @@ -86,7 +86,7 @@ extern "C" { } if (file_actions) { - for (const auto& action : file_actions->state->actions) { + for (auto const& action : file_actions->state->actions) { if (action() < 0) { perror("posix_spawn file action"); _exit(127); @@ -100,7 +100,7 @@ extern "C" { } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html -int posix_spawn(pid_t* out_pid, const char* path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* attr, char* const argv[], char* const envp[]) +int posix_spawn(pid_t* out_pid, char const* path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const argv[], char* const envp[]) { pid_t child_pid = fork(); if (child_pid < 0) @@ -115,7 +115,7 @@ int posix_spawn(pid_t* out_pid, const char* path, const posix_spawn_file_actions } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnp.html -int posix_spawnp(pid_t* out_pid, const char* path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* attr, char* const argv[], char* const envp[]) +int posix_spawnp(pid_t* out_pid, char const* path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const argv[], char* const envp[]) { pid_t child_pid = fork(); if (child_pid < 0) @@ -130,7 +130,7 @@ int posix_spawnp(pid_t* out_pid, const char* path, const posix_spawn_file_action } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addchdir.html -int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t* actions, const char* path) +int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t* actions, char const* path) { actions->state->actions.append([path]() { return chdir(path); }); return 0; @@ -157,7 +157,7 @@ int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* actions, int ol } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addopen.html -int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* actions, int want_fd, const char* path, int flags, mode_t mode) +int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* actions, int want_fd, char const* path, int flags, mode_t mode) { actions->state->actions.append([want_fd, path, flags, mode]() { int opened_fd = open(path, flags, mode); @@ -191,42 +191,42 @@ int posix_spawnattr_destroy(posix_spawnattr_t*) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getflags.html -int posix_spawnattr_getflags(const posix_spawnattr_t* attr, short* out_flags) +int posix_spawnattr_getflags(posix_spawnattr_t const* attr, short* out_flags) { *out_flags = attr->flags; return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getpgroup.html -int posix_spawnattr_getpgroup(const posix_spawnattr_t* attr, pid_t* out_pgroup) +int posix_spawnattr_getpgroup(posix_spawnattr_t const* attr, pid_t* out_pgroup) { *out_pgroup = attr->pgroup; return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getschedparam.html -int posix_spawnattr_getschedparam(const posix_spawnattr_t* attr, struct sched_param* out_schedparam) +int posix_spawnattr_getschedparam(posix_spawnattr_t const* attr, struct sched_param* out_schedparam) { *out_schedparam = attr->schedparam; return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getschedpolicy.html -int posix_spawnattr_getschedpolicy(const posix_spawnattr_t* attr, int* out_schedpolicy) +int posix_spawnattr_getschedpolicy(posix_spawnattr_t const* attr, int* out_schedpolicy) { *out_schedpolicy = attr->schedpolicy; return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getsigdefault.html -int posix_spawnattr_getsigdefault(const posix_spawnattr_t* attr, sigset_t* out_sigdefault) +int posix_spawnattr_getsigdefault(posix_spawnattr_t const* attr, sigset_t* out_sigdefault) { *out_sigdefault = attr->sigdefault; return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getsigmask.html -int posix_spawnattr_getsigmask(const posix_spawnattr_t* attr, sigset_t* out_sigmask) +int posix_spawnattr_getsigmask(posix_spawnattr_t const* attr, sigset_t* out_sigmask) { *out_sigmask = attr->sigmask; return 0; @@ -276,14 +276,14 @@ int posix_spawnattr_setschedpolicy(posix_spawnattr_t* attr, int schedpolicy) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setsigdefault.html -int posix_spawnattr_setsigdefault(posix_spawnattr_t* attr, const sigset_t* sigdefault) +int posix_spawnattr_setsigdefault(posix_spawnattr_t* attr, sigset_t const* sigdefault) { attr->sigdefault = *sigdefault; return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setsigmask.html -int posix_spawnattr_setsigmask(posix_spawnattr_t* attr, const sigset_t* sigmask) +int posix_spawnattr_setsigmask(posix_spawnattr_t* attr, sigset_t const* sigmask) { attr->sigmask = *sigmask; return 0; diff --git a/Userland/Libraries/LibC/spawn.h b/Userland/Libraries/LibC/spawn.h index c5f2168b1a..8531e67044 100644 --- a/Userland/Libraries/LibC/spawn.h +++ b/Userland/Libraries/LibC/spawn.h @@ -49,30 +49,30 @@ typedef struct { sigset_t sigmask; } posix_spawnattr_t; -int posix_spawn(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const argv[], char* const envp[]); -int posix_spawnp(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const argv[], char* const envp[]); +int posix_spawn(pid_t*, char const*, posix_spawn_file_actions_t const*, posix_spawnattr_t const*, char* const argv[], char* const envp[]); +int posix_spawnp(pid_t*, char const*, posix_spawn_file_actions_t const*, posix_spawnattr_t const*, char* const argv[], char* const envp[]); -int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t*, const char*); +int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t*, char const*); int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t*, int); int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t*, int); int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t*, int old_fd, int new_fd); -int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t*, int fd, const char*, int flags, mode_t); +int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t*, int fd, char const*, int flags, mode_t); int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t*); int posix_spawn_file_actions_init(posix_spawn_file_actions_t*); int posix_spawnattr_destroy(posix_spawnattr_t*); -int posix_spawnattr_getflags(const posix_spawnattr_t*, short*); -int posix_spawnattr_getpgroup(const posix_spawnattr_t*, pid_t*); -int posix_spawnattr_getschedparam(const posix_spawnattr_t*, struct sched_param*); -int posix_spawnattr_getschedpolicy(const posix_spawnattr_t*, int*); -int posix_spawnattr_getsigdefault(const posix_spawnattr_t*, sigset_t*); -int posix_spawnattr_getsigmask(const posix_spawnattr_t*, sigset_t*); +int posix_spawnattr_getflags(posix_spawnattr_t const*, short*); +int posix_spawnattr_getpgroup(posix_spawnattr_t const*, pid_t*); +int posix_spawnattr_getschedparam(posix_spawnattr_t const*, struct sched_param*); +int posix_spawnattr_getschedpolicy(posix_spawnattr_t const*, int*); +int posix_spawnattr_getsigdefault(posix_spawnattr_t const*, sigset_t*); +int posix_spawnattr_getsigmask(posix_spawnattr_t const*, sigset_t*); int posix_spawnattr_init(posix_spawnattr_t*); int posix_spawnattr_setflags(posix_spawnattr_t*, short); int posix_spawnattr_setpgroup(posix_spawnattr_t*, pid_t); int posix_spawnattr_setschedparam(posix_spawnattr_t*, const struct sched_param*); int posix_spawnattr_setschedpolicy(posix_spawnattr_t*, int); -int posix_spawnattr_setsigdefault(posix_spawnattr_t*, const sigset_t*); -int posix_spawnattr_setsigmask(posix_spawnattr_t*, const sigset_t*); +int posix_spawnattr_setsigdefault(posix_spawnattr_t*, sigset_t const*); +int posix_spawnattr_setsigmask(posix_spawnattr_t*, sigset_t const*); __END_DECLS diff --git a/Userland/Libraries/LibC/stat.cpp b/Userland/Libraries/LibC/stat.cpp index 3516de8df3..bcb52fd898 100644 --- a/Userland/Libraries/LibC/stat.cpp +++ b/Userland/Libraries/LibC/stat.cpp @@ -22,7 +22,7 @@ mode_t umask(mode_t mask) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html -int mkdir(const char* pathname, mode_t mode) +int mkdir(char const* pathname, mode_t mode) { if (!pathname) { errno = EFAULT; @@ -33,7 +33,7 @@ int mkdir(const char* pathname, mode_t mode) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html -int chmod(const char* pathname, mode_t mode) +int chmod(char const* pathname, mode_t mode) { return fchmodat(AT_FDCWD, pathname, mode, 0); } @@ -69,12 +69,12 @@ int fchmod(int fd, mode_t mode) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkfifo.html -int mkfifo(const char* pathname, mode_t mode) +int mkfifo(char const* pathname, mode_t mode) { return mknod(pathname, mode | S_IFIFO, 0); } -static int do_stat(int dirfd, const char* path, struct stat* statbuf, bool follow_symlinks) +static int do_stat(int dirfd, char const* path, struct stat* statbuf, bool follow_symlinks) { if (!path) { errno = EFAULT; @@ -86,13 +86,13 @@ static int do_stat(int dirfd, const char* path, struct stat* statbuf, bool follo } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/lstat.html -int lstat(const char* path, struct stat* statbuf) +int lstat(char const* path, struct stat* statbuf) { return do_stat(AT_FDCWD, path, statbuf, false); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html -int stat(const char* path, struct stat* statbuf) +int stat(char const* path, struct stat* statbuf) { return do_stat(AT_FDCWD, path, statbuf, true); } @@ -105,7 +105,7 @@ int fstat(int fd, struct stat* statbuf) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatat.html -int fstatat(int fd, const char* path, struct stat* statbuf, int flags) +int fstatat(int fd, char const* path, struct stat* statbuf, int flags) { return do_stat(fd, path, statbuf, !(flags & AT_SYMLINK_NOFOLLOW)); } diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp index efcab202e5..ee23401c5c 100644 --- a/Userland/Libraries/LibC/stdio.cpp +++ b/Userland/Libraries/LibC/stdio.cpp @@ -124,7 +124,7 @@ ssize_t FILE::do_read(u8* data, size_t size) return nread; } -ssize_t FILE::do_write(const u8* data, size_t size) +ssize_t FILE::do_write(u8 const* data, size_t size) { int nwritten = ::write(m_fd, data, size); @@ -154,7 +154,7 @@ bool FILE::read_into_buffer() bool FILE::write_from_buffer() { size_t size; - const u8* data = m_buffer.begin_dequeue(size); + u8 const* data = m_buffer.begin_dequeue(size); // If we want to write, the buffer must have something in it! VERIFY(size); @@ -180,7 +180,7 @@ size_t FILE::read(u8* data, size_t size) if (m_buffer.may_use()) { // Let's see if the buffer has something queued for us. size_t queued_size; - const u8* queued_data = m_buffer.begin_dequeue(queued_size); + u8 const* queued_data = m_buffer.begin_dequeue(queued_size); if (queued_size == 0) { // Nothing buffered; we're going to have to read some. bool read_some_more = read_into_buffer(); @@ -209,7 +209,7 @@ size_t FILE::read(u8* data, size_t size) return total_read; } -size_t FILE::write(const u8* data, size_t size) +size_t FILE::write(u8 const* data, size_t size) { size_t total_written = 0; @@ -426,7 +426,7 @@ size_t FILE::Buffer::buffered_size() const return m_capacity - (m_begin - m_end); } -const u8* FILE::Buffer::begin_dequeue(size_t& available_size) const +u8 const* FILE::Buffer::begin_dequeue(size_t& available_size) const { if (m_ungotten != 0u) { auto available_bytes = count_trailing_zeroes(m_ungotten) + 1; @@ -743,19 +743,19 @@ int putchar(int ch) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fputs.html -int fputs(const char* s, FILE* stream) +int fputs(char const* s, FILE* stream) { VERIFY(stream); size_t len = strlen(s); ScopedFileLock lock(stream); - size_t nwritten = stream->write(reinterpret_cast<const u8*>(s), len); + size_t nwritten = stream->write(reinterpret_cast<u8 const*>(s), len); if (nwritten < len) return EOF; return 1; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/puts.html -int puts(const char* s) +int puts(char const* s) { int rc = fputs(s, stdout); if (rc == EOF) @@ -799,13 +799,13 @@ size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fwrite.html -size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream) +size_t fwrite(void const* ptr, size_t size, size_t nmemb, FILE* stream) { VERIFY(stream); VERIFY(!Checked<size_t>::multiplication_would_overflow(size, nmemb)); ScopedFileLock lock(stream); - size_t nwritten = stream->write(reinterpret_cast<const u8*>(ptr), size * nmemb); + size_t nwritten = stream->write(reinterpret_cast<u8 const*>(ptr), size * nmemb); if (!nwritten) return 0; return nwritten / size; @@ -859,7 +859,7 @@ int fgetpos(FILE* stream, fpos_t* pos) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsetpos.html -int fsetpos(FILE* stream, const fpos_t* pos) +int fsetpos(FILE* stream, fpos_t const* pos) { VERIFY(stream); VERIFY(pos); @@ -881,13 +881,13 @@ ALWAYS_INLINE void stdout_putch(char*&, char ch) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vfprintf.html -int vfprintf(FILE* stream, const char* fmt, va_list ap) +int vfprintf(FILE* stream, char const* fmt, va_list ap) { return printf_internal([stream](auto, char ch) { fputc(ch, stream); }, nullptr, fmt, ap); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html -int fprintf(FILE* stream, const char* fmt, ...) +int fprintf(FILE* stream, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -897,13 +897,13 @@ int fprintf(FILE* stream, const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vprintf.html -int vprintf(const char* fmt, va_list ap) +int vprintf(char const* fmt, va_list ap) { return printf_internal(stdout_putch, nullptr, fmt, ap); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html -int printf(const char* fmt, ...) +int printf(char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -913,7 +913,7 @@ int printf(const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vasprintf.html -int vasprintf(char** strp, const char* fmt, va_list ap) +int vasprintf(char** strp, char const* fmt, va_list ap) { StringBuilder builder; builder.appendvf(fmt, ap); @@ -924,7 +924,7 @@ int vasprintf(char** strp, const char* fmt, va_list ap) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/asprintf.html -int asprintf(char** strp, const char* fmt, ...) +int asprintf(char** strp, char const* fmt, ...) { StringBuilder builder; va_list ap; @@ -943,7 +943,7 @@ static void buffer_putch(char*& bufptr, char ch) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vsprintf.html -int vsprintf(char* buffer, const char* fmt, va_list ap) +int vsprintf(char* buffer, char const* fmt, va_list ap) { int ret = printf_internal(buffer_putch, buffer, fmt, ap); buffer[ret] = '\0'; @@ -951,7 +951,7 @@ int vsprintf(char* buffer, const char* fmt, va_list ap) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sprintf.html -int sprintf(char* buffer, const char* fmt, ...) +int sprintf(char* buffer, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -961,7 +961,7 @@ int sprintf(char* buffer, const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vsnprintf.html -int vsnprintf(char* buffer, size_t size, const char* fmt, va_list ap) +int vsnprintf(char* buffer, size_t size, char const* fmt, va_list ap) { size_t space_remaining = 0; if (size) { @@ -985,7 +985,7 @@ int vsnprintf(char* buffer, size_t size, const char* fmt, va_list ap) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/snprintf.html -int snprintf(char* buffer, size_t size, const char* fmt, ...) +int snprintf(char* buffer, size_t size, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -995,14 +995,14 @@ int snprintf(char* buffer, size_t size, const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/perror.html -void perror(const char* s) +void perror(char const* s) { int saved_errno = errno; dbgln("perror(): {}: {}", s, strerror(saved_errno)); warnln("{}: {}", s, strerror(saved_errno)); } -static int parse_mode(const char* mode) +static int parse_mode(char const* mode) { int flags = 0; @@ -1040,7 +1040,7 @@ static int parse_mode(const char* mode) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html -FILE* fopen(const char* pathname, const char* mode) +FILE* fopen(char const* pathname, char const* mode) { int flags = parse_mode(mode); int fd = open(pathname, flags, 0666); @@ -1050,7 +1050,7 @@ FILE* fopen(const char* pathname, const char* mode) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/freopen.html -FILE* freopen(const char* pathname, const char* mode, FILE* stream) +FILE* freopen(char const* pathname, char const* mode, FILE* stream) { VERIFY(stream); if (!pathname) { @@ -1068,7 +1068,7 @@ FILE* freopen(const char* pathname, const char* mode, FILE* stream) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdopen.html -FILE* fdopen(int fd, const char* mode) +FILE* fdopen(int fd, char const* mode) { int flags = parse_mode(mode); // FIXME: Verify that the mode matches how fd is already open. @@ -1078,7 +1078,7 @@ FILE* fdopen(int fd, const char* mode) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html -FILE* fmemopen(void*, size_t, const char*) +FILE* fmemopen(void*, size_t, char const*) { // FIXME: Implement me :^) TODO(); @@ -1113,7 +1113,7 @@ int fclose(FILE* stream) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html -int rename(const char* oldpath, const char* newpath) +int rename(char const* oldpath, char const* newpath) { if (!oldpath || !newpath) { errno = EFAULT; @@ -1124,7 +1124,7 @@ int rename(const char* oldpath, const char* newpath) __RETURN_WITH_ERRNO(rc, rc, -1); } -void dbgputstr(const char* characters, size_t length) +void dbgputstr(char const* characters, size_t length) { syscall(SC_dbgputstr, characters, length); } @@ -1137,7 +1137,7 @@ char* tmpnam(char*) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/popen.html -FILE* popen(const char* command, const char* type) +FILE* popen(char const* command, char const* type) { if (!type || (*type != 'r' && *type != 'w')) { errno = EINVAL; @@ -1208,7 +1208,7 @@ int pclose(FILE* stream) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/remove.html -int remove(const char* pathname) +int remove(char const* pathname) { if (unlink(pathname) < 0) { if (errno == EISDIR) @@ -1219,7 +1219,7 @@ int remove(const char* pathname) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/scanf.html -int scanf(const char* fmt, ...) +int scanf(char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -1229,7 +1229,7 @@ int scanf(const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fscanf.html -int fscanf(FILE* stream, const char* fmt, ...) +int fscanf(FILE* stream, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -1239,7 +1239,7 @@ int fscanf(FILE* stream, const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sscanf.html -int sscanf(const char* buffer, const char* fmt, ...) +int sscanf(char const* buffer, char const* fmt, ...) { va_list ap; va_start(ap, fmt); @@ -1249,7 +1249,7 @@ int sscanf(const char* buffer, const char* fmt, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vfscanf.html -int vfscanf(FILE* stream, const char* fmt, va_list ap) +int vfscanf(FILE* stream, char const* fmt, va_list ap) { char buffer[BUFSIZ]; if (!fgets(buffer, sizeof(buffer) - 1, stream)) @@ -1258,7 +1258,7 @@ int vfscanf(FILE* stream, const char* fmt, va_list ap) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/vscanf.html -int vscanf(const char* fmt, va_list ap) +int vscanf(char const* fmt, va_list ap) { return vfscanf(stdin, fmt, ap); } diff --git a/Userland/Libraries/LibC/stdio.h b/Userland/Libraries/LibC/stdio.h index 8128beca77..96999ae422 100644 --- a/Userland/Libraries/LibC/stdio.h +++ b/Userland/Libraries/LibC/stdio.h @@ -39,7 +39,7 @@ typedef off_t fpos_t; int fseek(FILE*, long offset, int whence); int fseeko(FILE*, off_t offset, int whence); int fgetpos(FILE*, fpos_t*); -int fsetpos(FILE*, const fpos_t*); +int fsetpos(FILE*, fpos_t const*); long ftell(FILE*); off_t ftello(FILE*); char* fgets(char* buffer, int size, FILE*); @@ -53,11 +53,11 @@ int getchar(void); ssize_t getdelim(char**, size_t*, int, FILE*); ssize_t getline(char**, size_t*, FILE*); int ungetc(int c, FILE*); -int remove(const char* pathname); -FILE* fdopen(int fd, const char* mode); -FILE* fopen(const char* pathname, const char* mode); -FILE* freopen(const char* pathname, const char* mode, FILE*); -FILE* fmemopen(void* buf, size_t size, const char* mode); +int remove(char const* pathname); +FILE* fdopen(int fd, char const* mode); +FILE* fopen(char const* pathname, char const* mode); +FILE* freopen(char const* pathname, char const* mode, FILE*); +FILE* fmemopen(void* buf, size_t size, char const* mode); void flockfile(FILE* filehandle); void funlockfile(FILE* filehandle); int fclose(FILE*); @@ -68,36 +68,36 @@ int feof(FILE*); int fflush(FILE*); size_t fread(void* ptr, size_t size, size_t nmemb, FILE*); size_t fread_unlocked(void* ptr, size_t size, size_t nmemb, FILE*); -size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE*); -int vprintf(const char* fmt, va_list) __attribute__((format(printf, 1, 0))); -int vfprintf(FILE*, const char* fmt, va_list) __attribute__((format(printf, 2, 0))); -int vasprintf(char** strp, const char* fmt, va_list) __attribute__((format(printf, 2, 0))); -int vsprintf(char* buffer, const char* fmt, va_list) __attribute__((format(printf, 2, 0))); -int vsnprintf(char* buffer, size_t, const char* fmt, va_list) __attribute__((format(printf, 3, 0))); -int fprintf(FILE*, const char* fmt, ...) __attribute__((format(printf, 2, 3))); -int printf(const char* fmt, ...) __attribute__((format(printf, 1, 2))); -void dbgputstr(const char*, size_t); -int sprintf(char* buffer, const char* fmt, ...) __attribute__((format(printf, 2, 3))); -int asprintf(char** strp, const char* fmt, ...) __attribute__((format(printf, 2, 3))); -int snprintf(char* buffer, size_t, const char* fmt, ...) __attribute__((format(printf, 3, 4))); +size_t fwrite(void const* ptr, size_t size, size_t nmemb, FILE*); +int vprintf(char const* fmt, va_list) __attribute__((format(printf, 1, 0))); +int vfprintf(FILE*, char const* fmt, va_list) __attribute__((format(printf, 2, 0))); +int vasprintf(char** strp, char const* fmt, va_list) __attribute__((format(printf, 2, 0))); +int vsprintf(char* buffer, char const* fmt, va_list) __attribute__((format(printf, 2, 0))); +int vsnprintf(char* buffer, size_t, char const* fmt, va_list) __attribute__((format(printf, 3, 0))); +int fprintf(FILE*, char const* fmt, ...) __attribute__((format(printf, 2, 3))); +int printf(char const* fmt, ...) __attribute__((format(printf, 1, 2))); +void dbgputstr(char const*, size_t); +int sprintf(char* buffer, char const* fmt, ...) __attribute__((format(printf, 2, 3))); +int asprintf(char** strp, char const* fmt, ...) __attribute__((format(printf, 2, 3))); +int snprintf(char* buffer, size_t, char const* fmt, ...) __attribute__((format(printf, 3, 4))); int putchar(int ch); int putc(int ch, FILE*); -int puts(const char*); -int fputs(const char*, FILE*); -void perror(const char*); -int scanf(const char* fmt, ...) __attribute__((format(scanf, 1, 2))); -int sscanf(const char* str, const char* fmt, ...) __attribute__((format(scanf, 2, 3))); -int fscanf(FILE*, const char* fmt, ...) __attribute__((format(scanf, 2, 3))); -int vscanf(const char*, va_list) __attribute__((format(scanf, 1, 0))); -int vfscanf(FILE*, const char*, va_list) __attribute__((format(scanf, 2, 0))); -int vsscanf(const char*, const char*, va_list) __attribute__((format(scanf, 2, 0))); +int puts(char const*); +int fputs(char const*, FILE*); +void perror(char const*); +int scanf(char const* fmt, ...) __attribute__((format(scanf, 1, 2))); +int sscanf(char const* str, char const* fmt, ...) __attribute__((format(scanf, 2, 3))); +int fscanf(FILE*, char const* fmt, ...) __attribute__((format(scanf, 2, 3))); +int vscanf(char const*, va_list) __attribute__((format(scanf, 1, 0))); +int vfscanf(FILE*, char const*, va_list) __attribute__((format(scanf, 2, 0))); +int vsscanf(char const*, char const*, va_list) __attribute__((format(scanf, 2, 0))); int setvbuf(FILE*, char* buf, int mode, size_t); void setbuf(FILE*, char* buf); void setlinebuf(FILE*); -int rename(const char* oldpath, const char* newpath); +int rename(char const* oldpath, char const* newpath); FILE* tmpfile(void); char* tmpnam(char*); -FILE* popen(const char* command, const char* type); +FILE* popen(char const* command, char const* type); int pclose(FILE*); __END_DECLS diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index d9e7d73ead..695c9c35e8 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -34,7 +34,7 @@ #include <unistd.h> #include <wchar.h> -static void strtons(const char* str, char** endptr) +static void strtons(char const* str, char** endptr) { assert(endptr); char* ptr = const_cast<char*>(str); @@ -49,7 +49,7 @@ enum Sign { Positive, }; -static Sign strtosign(const char* str, char** endptr) +static Sign strtosign(char const* str, char** endptr) { assert(endptr); if (*str == '+') { @@ -128,7 +128,7 @@ public: private: bool can_append_digit(int digit) { - const bool is_below_cutoff = positive() ? (m_num < m_cutoff) : (m_num > m_cutoff); + bool const is_below_cutoff = positive() ? (m_num < m_cutoff) : (m_num > m_cutoff); if (is_below_cutoff) { return true; @@ -232,7 +232,7 @@ void abort() static HashTable<FlatPtr> s_malloced_environment_variables; -static void free_environment_variable_if_needed(const char* var) +static void free_environment_variable_if_needed(char const* var) { if (!s_malloced_environment_variables.contains((FlatPtr)var)) return; @@ -240,11 +240,11 @@ static void free_environment_variable_if_needed(const char* var) s_malloced_environment_variables.remove((FlatPtr)var); } -char* getenv(const char* name) +char* getenv(char const* name) { size_t vl = strlen(name); for (size_t i = 0; environ[i]; ++i) { - const char* decl = environ[i]; + char const* decl = environ[i]; char* eq = strchr(decl, '='); if (!eq) continue; @@ -258,7 +258,7 @@ char* getenv(const char* name) return nullptr; } -char* secure_getenv(const char* name) +char* secure_getenv(char const* name) { if (getauxval(AT_SECURE)) return nullptr; @@ -266,7 +266,7 @@ char* secure_getenv(const char* name) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/unsetenv.html -int unsetenv(const char* name) +int unsetenv(char const* name) { auto new_var_len = strlen(name); size_t environ_size = 0; @@ -307,12 +307,12 @@ int clearenv() } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html -int setenv(const char* name, const char* value, int overwrite) +int setenv(char const* name, char const* value, int overwrite) { return serenity_setenv(name, strlen(name), value, strlen(value), overwrite); } -int serenity_setenv(const char* name, ssize_t name_length, const char* value, ssize_t value_length, int overwrite) +int serenity_setenv(char const* name, ssize_t name_length, char const* value, ssize_t value_length, int overwrite) { if (!overwrite && getenv(name)) return 0; @@ -374,14 +374,14 @@ int putenv(char* new_var) return 0; } -static const char* __progname = NULL; +static char const* __progname = NULL; -const char* getprogname() +char const* getprogname() { return __progname; } -void setprogname(const char* progname) +void setprogname(char const* progname) { for (int i = strlen(progname) - 1; i >= 0; i--) { if (progname[i] == '/') { @@ -394,7 +394,7 @@ void setprogname(const char* progname) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtod.html -double strtod(const char* str, char** endptr) +double strtod(char const* str, char** endptr) { // Parse spaces, sign, and base char* parse_ptr = const_cast<char*>(str); @@ -451,7 +451,7 @@ double strtod(const char* str, char** endptr) char exponent_upper; int base = 10; if (*parse_ptr == '0') { - const char base_ch = *(parse_ptr + 1); + char const base_ch = *(parse_ptr + 1); if (base_ch == 'x' || base_ch == 'X') { base = 16; parse_ptr += 2; @@ -676,26 +676,26 @@ double strtod(const char* str, char** endptr) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtold.html -long double strtold(const char* str, char** endptr) +long double strtold(char const* str, char** endptr) { assert(sizeof(double) == sizeof(long double)); return strtod(str, endptr); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtof.html -float strtof(const char* str, char** endptr) +float strtof(char const* str, char** endptr) { return strtod(str, endptr); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/atof.html -double atof(const char* str) +double atof(char const* str) { return strtod(str, nullptr); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/atoi.html -int atoi(const char* str) +int atoi(char const* str) { long value = strtol(str, nullptr, 10); if (value > INT_MAX) { @@ -705,13 +705,13 @@ int atoi(const char* str) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/atol.html -long atol(const char* str) +long atol(char const* str) { return strtol(str, nullptr, 10); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/atoll.html -long long atoll(const char* str) +long long atoll(char const* str) { return strtoll(str, nullptr, 10); } @@ -808,13 +808,13 @@ void srandom(unsigned seed) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html -int system(const char* command) +int system(char const* command) { if (!command) return 1; pid_t child; - const char* argv[] = { "sh", "-c", command, nullptr }; + char const* argv[] = { "sh", "-c", command, nullptr }; if ((errno = posix_spawn(&child, "/bin/sh", nullptr, nullptr, const_cast<char**>(argv), environ))) return -1; int wstatus; @@ -872,7 +872,7 @@ char* mkdtemp(char* pattern) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/bsearch.html -void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)) +void* bsearch(void const* key, void const* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*)) { char* start = static_cast<char*>(const_cast<void*>(base)); while (nmemb > 0) { @@ -956,14 +956,14 @@ int mblen(char const* s, size_t n) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbstowcs.html -size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n) +size_t mbstowcs(wchar_t* pwcs, char const* s, size_t n) { static mbstate_t state = {}; return mbsrtowcs(pwcs, &s, n, &state); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbtowc.html -int mbtowc(wchar_t* pwc, const char* s, size_t n) +int mbtowc(wchar_t* pwc, char const* s, size_t n) { static mbstate_t internal_state = {}; @@ -998,11 +998,11 @@ int wctomb(char* s, wchar_t wc) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcstombs.html -size_t wcstombs(char* dest, const wchar_t* src, size_t max) +size_t wcstombs(char* dest, wchar_t const* src, size_t max) { char* original_dest = dest; while ((size_t)(dest - original_dest) < max) { - StringView v { (const char*)src, sizeof(wchar_t) }; + StringView v { (char const*)src, sizeof(wchar_t) }; // FIXME: dependent on locale, for now utf-8 is supported. Utf8View utf8 { v }; @@ -1021,7 +1021,7 @@ size_t wcstombs(char* dest, const wchar_t* src, size_t max) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtol.html -long strtol(const char* str, char** endptr, int base) +long strtol(char const* str, char** endptr, int base) { long long value = strtoll(str, endptr, base); if (value < LONG_MIN) { @@ -1035,7 +1035,7 @@ long strtol(const char* str, char** endptr, int base) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtoul.html -unsigned long strtoul(const char* str, char** endptr, int base) +unsigned long strtoul(char const* str, char** endptr, int base) { unsigned long long value = strtoull(str, endptr, base); if (value > ULONG_MAX) { @@ -1046,7 +1046,7 @@ unsigned long strtoul(const char* str, char** endptr, int base) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtoll.html -long long strtoll(const char* str, char** endptr, int base) +long long strtoll(char const* str, char** endptr, int base) { // Parse spaces and sign char* parse_ptr = const_cast<char*>(str); @@ -1124,7 +1124,7 @@ long long strtoll(const char* str, char** endptr, int base) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtoull.html -unsigned long long strtoull(const char* str, char** endptr, int base) +unsigned long long strtoull(char const* str, char** endptr, int base) { // Parse spaces and sign char* parse_ptr = const_cast<char*>(str); @@ -1257,7 +1257,7 @@ uint32_t arc4random_uniform(uint32_t max_bounds) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html -char* realpath(const char* pathname, char* buffer) +char* realpath(char const* pathname, char* buffer) { if (!pathname) { errno = EFAULT; diff --git a/Userland/Libraries/LibC/stdlib.h b/Userland/Libraries/LibC/stdlib.h index 21865cd398..8a76ae78fe 100644 --- a/Userland/Libraries/LibC/stdlib.h +++ b/Userland/Libraries/LibC/stdlib.h @@ -27,27 +27,27 @@ void free(void*); __attribute__((alloc_size(2))) void* realloc(void* ptr, size_t); __attribute__((malloc, alloc_size(1), alloc_align(2))) void* _aligned_malloc(size_t size, size_t alignment); void _aligned_free(void* memblock); -char* getenv(const char* name); -char* secure_getenv(const char* name); +char* getenv(char const* name); +char* secure_getenv(char const* name); int putenv(char*); -int unsetenv(const char*); +int unsetenv(char const*); int clearenv(void); -int setenv(const char* name, const char* value, int overwrite); -int serenity_setenv(const char* name, ssize_t name_length, const char* value, ssize_t value_length, int overwrite); -const char* getprogname(void); -void setprogname(const char*); -int atoi(const char*); -long atol(const char*); -long long atoll(const char*); -double strtod(const char*, char** endptr); -long double strtold(const char*, char** endptr); -float strtof(const char*, char** endptr); -long strtol(const char*, char** endptr, int base); -long long strtoll(const char*, char** endptr, int base); -unsigned long long strtoull(const char*, char** endptr, int base); -unsigned long strtoul(const char*, char** endptr, int base); -void qsort(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); -void qsort_r(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg); +int setenv(char const* name, char const* value, int overwrite); +int serenity_setenv(char const* name, ssize_t name_length, char const* value, ssize_t value_length, int overwrite); +char const* getprogname(void); +void setprogname(char const*); +int atoi(char const*); +long atol(char const*); +long long atoll(char const*); +double strtod(char const*, char** endptr); +long double strtold(char const*, char** endptr); +float strtof(char const*, char** endptr); +long strtol(char const*, char** endptr, int base); +long long strtoll(char const*, char** endptr, int base); +unsigned long long strtoull(char const*, char** endptr, int base); +unsigned long strtoul(char const*, char** endptr, int base); +void qsort(void* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*)); +void qsort_r(void* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*, void*), void* arg); int atexit(void (*function)(void)); __attribute__((noreturn)) void exit(int status); __attribute__((noreturn)) void abort(void); @@ -56,18 +56,18 @@ int ptsname_r(int fd, char* buffer, size_t); int abs(int); long labs(long); long long int llabs(long long int); -double atof(const char*); -int system(const char* command); +double atof(char const*); +int system(char const* command); char* mktemp(char*); int mkstemp(char*); char* mkdtemp(char*); -void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); +void* bsearch(void const* key, void const* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*)); int mblen(char const*, size_t); -size_t mbstowcs(wchar_t*, const char*, size_t); -int mbtowc(wchar_t*, const char*, size_t); +size_t mbstowcs(wchar_t*, char const*, size_t); +int mbtowc(wchar_t*, char const*, size_t); int wctomb(char*, wchar_t); -size_t wcstombs(char*, const wchar_t*, size_t); -char* realpath(const char* pathname, char* buffer); +size_t wcstombs(char*, wchar_t const*, size_t); +char* realpath(char const* pathname, char* buffer); __attribute__((noreturn)) void _Exit(int status); #define RAND_MAX 32767 diff --git a/Userland/Libraries/LibC/string.cpp b/Userland/Libraries/LibC/string.cpp index 093e77c871..90847bf63c 100644 --- a/Userland/Libraries/LibC/string.cpp +++ b/Userland/Libraries/LibC/string.cpp @@ -22,13 +22,13 @@ extern "C" { // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strspn.html -size_t strspn(const char* s, const char* accept) +size_t strspn(char const* s, char const* accept) { - const char* p = s; + char const* p = s; cont: char ch = *p++; char ac; - for (const char* ap = accept; (ac = *ap++) != '\0';) { + for (char const* ap = accept; (ac = *ap++) != '\0';) { if (ac == ch) goto cont; } @@ -36,7 +36,7 @@ cont: } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcspn.html -size_t strcspn(const char* s, const char* reject) +size_t strcspn(char const* s, char const* reject) { for (auto* p = s;;) { char c = *p++; @@ -50,7 +50,7 @@ size_t strcspn(const char* s, const char* reject) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strlen.html -size_t strlen(const char* str) +size_t strlen(char const* str) { size_t len = 0; while (*(str++)) @@ -59,7 +59,7 @@ size_t strlen(const char* str) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strnlen.html -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++) @@ -68,7 +68,7 @@ size_t strnlen(const char* str, size_t maxlen) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.html -char* strdup(const char* str) +char* strdup(char const* str) { size_t len = strlen(str); char* new_str = (char*)malloc(len + 1); @@ -78,7 +78,7 @@ char* strdup(const char* str) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html -char* strndup(const char* str, size_t maxlen) +char* strndup(char const* str, size_t maxlen) { size_t len = strnlen(str, maxlen); char* new_str = (char*)malloc(len + 1); @@ -88,22 +88,22 @@ char* strndup(const char* str, size_t maxlen) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html -int strcmp(const char* s1, const char* s2) +int strcmp(char const* s1, char const* s2) { while (*s1 == *s2++) if (*s1++ == 0) return 0; - return *(const unsigned char*)s1 - *(const unsigned char*)--s2; + return *(unsigned char const*)s1 - *(unsigned char const*)--s2; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html -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); @@ -111,10 +111,10 @@ int strncmp(const char* s1, const char* s2, size_t n) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/memcmp.html -int memcmp(const void* v1, const void* v2, size_t n) +int memcmp(void const* v1, void const* v2, size_t n) { - auto* s1 = (const uint8_t*)v1; - auto* s2 = (const uint8_t*)v2; + auto* s1 = (uint8_t const*)v1; + auto* s2 = (uint8_t const*)v2; while (n-- > 0) { if (*s1++ != *s2++) return s1[-1] < s2[-1] ? -1 : 1; @@ -122,13 +122,13 @@ int memcmp(const void* v1, const void* v2, size_t n) return 0; } -int timingsafe_memcmp(const void* b1, const void* b2, size_t len) +int timingsafe_memcmp(void const* b1, void const* b2, size_t len) { return AK::timing_safe_compare(b1, b2, len) ? 1 : 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/memcpy.html -void* memcpy(void* dest_ptr, const void* src_ptr, size_t n) +void* memcpy(void* dest_ptr, void const* src_ptr, size_t n) { void* original_dest = dest_ptr; asm volatile( @@ -171,25 +171,25 @@ void* memset(void* dest_ptr, int c, size_t n) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/memmove.html -void* memmove(void* dest, const void* src, size_t n) +void* memmove(void* dest, void const* src, size_t n) { if (((FlatPtr)dest - (FlatPtr)src) >= n) 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; } -const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) +void const* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length) { return AK::memmem(haystack, haystack_length, needle, needle_length); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcpy.html -char* strcpy(char* dest, const char* src) +char* strcpy(char* dest, char const* src) { char* original_dest = dest; while ((*dest++ = *src++) != '\0') @@ -198,7 +198,7 @@ char* strcpy(char* dest, const char* src) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncpy.html -char* strncpy(char* dest, const char* src, size_t n) +char* strncpy(char* dest, char const* src, size_t n) { size_t i; for (i = 0; i < n && src[i] != '\0'; ++i) @@ -208,7 +208,7 @@ char* strncpy(char* dest, const char* src, size_t n) return dest; } -size_t strlcpy(char* dest, const char* src, size_t n) +size_t strlcpy(char* dest, char const* src, size_t n) { size_t i; // Would like to test i < n - 1 here, but n might be 0. @@ -222,7 +222,7 @@ size_t strlcpy(char* dest, const char* src, size_t n) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strchr.html -char* strchr(const char* str, int c) +char* strchr(char const* str, int c) { char ch = c; for (;; ++str) { @@ -234,12 +234,12 @@ char* strchr(const char* str, int c) } // https://pubs.opengroup.org/onlinepubs/9699959399/functions/index.html -char* index(const char* str, int c) +char* index(char const* str, int c) { return strchr(str, c); } -char* strchrnul(const char* str, int c) +char* strchrnul(char const* str, int c) { char ch = c; for (;; ++str) { @@ -249,10 +249,10 @@ char* strchrnul(const char* str, int c) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/memchr.html -void* memchr(const void* ptr, int c, size_t size) +void* memchr(void const* ptr, int c, size_t size) { char ch = c; - auto* cptr = (const char*)ptr; + auto* cptr = (char const*)ptr; for (size_t i = 0; i < size; ++i) { if (cptr[i] == ch) return const_cast<char*>(cptr + i); @@ -261,7 +261,7 @@ void* memchr(const void* ptr, int c, size_t size) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strrchr.html -char* strrchr(const char* str, int ch) +char* strrchr(char const* str, int ch) { char* last = nullptr; char c; @@ -273,13 +273,13 @@ char* strrchr(const char* str, int ch) } // https://pubs.opengroup.org/onlinepubs/9699959399/functions/rindex.html -char* rindex(const char* str, int ch) +char* rindex(char const* str, int ch) { return strrchr(str, ch); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcat.html -char* strcat(char* dest, const char* src) +char* strcat(char* dest, char const* src) { size_t dest_length = strlen(dest); size_t i; @@ -290,7 +290,7 @@ char* strcat(char* dest, const char* src) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncat.html -char* strncat(char* dest, const char* src, size_t n) +char* strncat(char* dest, char const* src, size_t n) { size_t dest_length = strlen(dest); size_t i; @@ -300,7 +300,7 @@ char* strncat(char* dest, const char* src, size_t n) return dest; } -const char* const sys_errlist[] = { +char const* const sys_errlist[] = { #define __ENUMERATE_ERRNO_CODE(c, s) s, ENUMERATE_ERRNO_CODES(__ENUMERATE_ERRNO_CODE) #undef __ENUMERATE_ERRNO_CODE @@ -350,7 +350,7 @@ char* strsignal(int signum) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strstr.html -char* strstr(const char* haystack, const char* needle) +char* strstr(char const* haystack, char const* needle) { char nch; char hch; @@ -369,7 +369,7 @@ char* strstr(const char* haystack, const char* needle) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strpbrk.html -char* strpbrk(const char* s, const char* accept) +char* strpbrk(char const* s, char const* accept) { while (*s) if (strchr(accept, *s++)) @@ -378,7 +378,7 @@ char* strpbrk(const char* s, const char* accept) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok_r.html -char* strtok_r(char* str, const char* delim, char** saved_str) +char* strtok_r(char* str, char const* delim, char** saved_str) { if (!str) { if (!saved_str || *saved_str == nullptr) @@ -433,20 +433,20 @@ char* strtok_r(char* str, const char* delim, char** saved_str) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html -char* strtok(char* str, const char* delim) +char* strtok(char* str, char const* delim) { static char* saved_str; return strtok_r(str, delim, &saved_str); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcoll.html -int strcoll(const char* s1, const char* s2) +int strcoll(char const* s1, char const* s2) { return strcmp(s1, s2); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strxfrm.html -size_t strxfrm(char* dest, const char* src, size_t n) +size_t strxfrm(char* dest, char const* src, size_t n) { size_t i; for (i = 0; i < n && src[i] != '\0'; ++i) diff --git a/Userland/Libraries/LibC/string.h b/Userland/Libraries/LibC/string.h index c58ee96836..c3681c89ca 100644 --- a/Userland/Libraries/LibC/string.h +++ b/Userland/Libraries/LibC/string.h @@ -17,50 +17,50 @@ __BEGIN_DECLS // do the same here to maintain compatibility #include <strings.h> -size_t strlen(const char*); -size_t strnlen(const char*, size_t maxlen); +size_t strlen(char const*); +size_t strnlen(char const*, size_t maxlen); -int strcmp(const char*, const char*); -int strncmp(const char*, const char*, size_t); +int strcmp(char const*, char const*); +int strncmp(char const*, char const*, size_t); -int memcmp(const void*, const void*, size_t); -int timingsafe_memcmp(const void*, const void*, size_t); -void* memcpy(void*, const void*, size_t); -void* memmove(void*, const void*, size_t); -void* memchr(const void*, int c, size_t); -const void* memmem(const void* haystack, size_t, const void* needle, size_t); +int memcmp(void const*, void const*, size_t); +int timingsafe_memcmp(void const*, void const*, size_t); +void* memcpy(void*, void const*, size_t); +void* memmove(void*, void const*, size_t); +void* memchr(void const*, int c, size_t); +void const* memmem(void const* haystack, size_t, void const* needle, size_t); void* memset(void*, int, size_t); void explicit_bzero(void*, size_t) __attribute__((nonnull(1))); -__attribute__((malloc)) char* strdup(const char*); -__attribute__((malloc)) char* strndup(const char*, size_t); +__attribute__((malloc)) char* strdup(char const*); +__attribute__((malloc)) char* strndup(char const*, size_t); -char* strcpy(char* dest, const char* src); -char* strncpy(char* dest, const char* src, size_t); -__attribute__((warn_unused_result)) size_t strlcpy(char* dest, const char* src, size_t); +char* strcpy(char* dest, char const* src); +char* strncpy(char* dest, char const* src, size_t); +__attribute__((warn_unused_result)) size_t strlcpy(char* dest, char const* src, size_t); -char* strchr(const char*, int c); -char* strchrnul(const char*, int c); -char* strstr(const char* haystack, const char* needle); -char* strrchr(const char*, int c); +char* strchr(char const*, int c); +char* strchrnul(char const*, int c); +char* strstr(char const* haystack, char const* needle); +char* strrchr(char const*, int c); -char* index(const char* str, int ch); -char* rindex(const char* str, int ch); +char* index(char const* str, int ch); +char* rindex(char const* str, int ch); -char* strcat(char* dest, const char* src); -char* strncat(char* dest, const char* src, size_t); +char* strcat(char* dest, char const* src); +char* strncat(char* dest, char const* src, size_t); -size_t strspn(const char*, const char* accept); -size_t strcspn(const char*, const char* reject); +size_t strspn(char const*, char const* accept); +size_t strcspn(char const*, char const* reject); int strerror_r(int, char*, size_t); char* strerror(int errnum); char* strsignal(int signum); -char* strpbrk(const char*, const char* accept); -char* strtok_r(char* str, const char* delim, char** saved_str); -char* strtok(char* str, const char* delim); -int strcoll(const char* s1, const char* s2); -size_t strxfrm(char* dest, const char* src, size_t n); +char* strpbrk(char const*, char const* accept); +char* strtok_r(char* str, char const* delim, char** saved_str); +char* strtok(char* str, char const* delim); +int strcoll(char const* s1, char const* s2); +size_t strxfrm(char* dest, char const* src, size_t n); char* strsep(char** str, char const* delim); __END_DECLS diff --git a/Userland/Libraries/LibC/strings.cpp b/Userland/Libraries/LibC/strings.cpp index 4f0d49c92a..0937cc2e1a 100644 --- a/Userland/Libraries/LibC/strings.cpp +++ b/Userland/Libraries/LibC/strings.cpp @@ -16,7 +16,7 @@ void bzero(void* dest, size_t n) memset(dest, 0, n); } -void bcopy(const void* src, void* dest, size_t n) +void bcopy(void const* src, void* dest, size_t n) { memmove(dest, src, n); } @@ -29,23 +29,23 @@ static char foldcase(char ch) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html -int strcasecmp(const char* s1, const char* s2) +int strcasecmp(char const* s1, char const* s2) { for (; foldcase(*s1) == foldcase(*s2); ++s1, ++s2) { if (*s1 == 0) return 0; } - return foldcase(*(const unsigned char*)s1) < foldcase(*(const unsigned char*)s2) ? -1 : 1; + return foldcase(*(unsigned char const*)s1) < foldcase(*(unsigned char const*)s2) ? -1 : 1; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncasecmp.html -int strncasecmp(const char* s1, const char* s2, size_t n) +int strncasecmp(char const* s1, char const* s2, size_t n) { if (!n) return 0; do { if (foldcase(*s1) != foldcase(*s2++)) - return foldcase(*(const unsigned char*)s1) - foldcase(*(const unsigned char*)--s2); + return foldcase(*(unsigned char const*)s1) - foldcase(*(unsigned char const*)--s2); if (*s1++ == 0) break; } while (--n); diff --git a/Userland/Libraries/LibC/strings.h b/Userland/Libraries/LibC/strings.h index 36e2e3621b..1805bc887c 100644 --- a/Userland/Libraries/LibC/strings.h +++ b/Userland/Libraries/LibC/strings.h @@ -11,9 +11,9 @@ __BEGIN_DECLS -int strcasecmp(const char*, const char*); -int strncasecmp(const char*, const char*, size_t); +int strcasecmp(char const*, char const*); +int strncasecmp(char const*, char const*, size_t); void bzero(void*, size_t); -void bcopy(const void*, void*, size_t); +void bcopy(void const*, void*, size_t); __END_DECLS diff --git a/Userland/Libraries/LibC/sys/mman.cpp b/Userland/Libraries/LibC/sys/mman.cpp index ff40f87e17..9dd9d4ef3a 100644 --- a/Userland/Libraries/LibC/sys/mman.cpp +++ b/Userland/Libraries/LibC/sys/mman.cpp @@ -13,7 +13,7 @@ extern "C" { -void* serenity_mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset, size_t alignment, const char* name) +void* serenity_mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset, size_t alignment, char const* name) { Syscall::SC_mmap_params params { addr, size, alignment, prot, flags, fd, offset, { name, name ? strlen(name) : 0 } }; ptrdiff_t rc = syscall(SC_mmap, ¶ms); @@ -30,7 +30,7 @@ void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) return serenity_mmap(addr, size, prot, flags, fd, offset, PAGE_SIZE, nullptr); } -void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t offset, const char* name) +void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t offset, char const* name) { return serenity_mmap(addr, size, prot, flags, fd, offset, PAGE_SIZE, name); } @@ -60,7 +60,7 @@ int mprotect(void* addr, size_t size, int prot) __RETURN_WITH_ERRNO(rc, rc, -1); } -int set_mmap_name(void* addr, size_t size, const char* name) +int set_mmap_name(void* addr, size_t size, char const* name) { if (!name) { errno = EFAULT; @@ -83,7 +83,7 @@ int posix_madvise(void* address, size_t len, int advice) return madvise(address, len, advice); } -void* allocate_tls(const char* initial_data, size_t size) +void* allocate_tls(char const* initial_data, size_t size) { ptrdiff_t rc = syscall(SC_allocate_tls, initial_data, size); if (rc < 0 && rc > -EMAXERRNO) { @@ -94,14 +94,14 @@ void* allocate_tls(const char* initial_data, size_t size) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlock.html -int mlock(const void*, size_t) +int mlock(void const*, size_t) { dbgln("FIXME: Implement mlock()"); return 0; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/munlock.html -int munlock(const void*, size_t) +int munlock(void const*, size_t) { dbgln("FIXME: Implement munlock()"); return 0; diff --git a/Userland/Libraries/LibC/sys/mman.h b/Userland/Libraries/LibC/sys/mman.h index d5cd1d80ec..d5d5ed2b44 100644 --- a/Userland/Libraries/LibC/sys/mman.h +++ b/Userland/Libraries/LibC/sys/mman.h @@ -11,17 +11,17 @@ __BEGIN_DECLS void* mmap(void* addr, size_t, int prot, int flags, int fd, off_t); -void* mmap_with_name(void* addr, size_t, int prot, int flags, int fd, off_t, const char* name); -void* serenity_mmap(void* addr, size_t, int prot, int flags, int fd, off_t, size_t alignment, const char* name); +void* mmap_with_name(void* addr, size_t, int prot, int flags, int fd, off_t, char const* name); +void* serenity_mmap(void* addr, size_t, int prot, int flags, int fd, off_t, size_t alignment, char const* name); void* mremap(void* old_address, size_t old_size, size_t new_size, int flags); int munmap(void*, size_t); int mprotect(void*, size_t, int prot); -int set_mmap_name(void*, size_t, const char*); +int set_mmap_name(void*, size_t, char const*); int madvise(void*, size_t, int advice); int posix_madvise(void*, size_t, int advice); -void* allocate_tls(const char* initial_data, size_t); -int mlock(const void*, size_t); -int munlock(const void*, size_t); +void* allocate_tls(char const* initial_data, size_t); +int mlock(void const*, size_t); +int munlock(void const*, size_t); int msync(void*, size_t, int flags); __END_DECLS diff --git a/Userland/Libraries/LibC/sys/select.cpp b/Userland/Libraries/LibC/sys/select.cpp index 30f005c9c7..b3441a4910 100644 --- a/Userland/Libraries/LibC/sys/select.cpp +++ b/Userland/Libraries/LibC/sys/select.cpp @@ -28,7 +28,7 @@ int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timev } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html -int pselect(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const timespec* timeout, const sigset_t* sigmask) +int pselect(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timespec const* timeout, sigset_t const* sigmask) { Vector<pollfd, FD_SETSIZE> fds; diff --git a/Userland/Libraries/LibC/sys/select.h b/Userland/Libraries/LibC/sys/select.h index 57a61cc145..02e9f0d6f6 100644 --- a/Userland/Libraries/LibC/sys/select.h +++ b/Userland/Libraries/LibC/sys/select.h @@ -16,6 +16,6 @@ __BEGIN_DECLS int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout); -int pselect(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timespec* timeout, const sigset_t* sigmask); +int pselect(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timespec* timeout, sigset_t const* sigmask); __END_DECLS diff --git a/Userland/Libraries/LibC/sys/socket.cpp b/Userland/Libraries/LibC/sys/socket.cpp index 3e78ff1486..6cfedc0c0e 100644 --- a/Userland/Libraries/LibC/sys/socket.cpp +++ b/Userland/Libraries/LibC/sys/socket.cpp @@ -22,7 +22,7 @@ int socket(int domain, int type, int protocol) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html -int bind(int sockfd, const sockaddr* addr, socklen_t addrlen) +int bind(int sockfd, sockaddr const* addr, socklen_t addrlen) { int rc = syscall(SC_bind, sockfd, addr, addrlen); __RETURN_WITH_ERRNO(rc, rc, -1); @@ -49,7 +49,7 @@ int accept4(int sockfd, sockaddr* addr, socklen_t* addrlen, int flags) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html -int connect(int sockfd, const sockaddr* addr, socklen_t addrlen) +int connect(int sockfd, sockaddr const* addr, socklen_t addrlen) { int rc = syscall(SC_connect, sockfd, addr, addrlen); __RETURN_WITH_ERRNO(rc, rc, -1); @@ -70,7 +70,7 @@ ssize_t sendmsg(int sockfd, const struct msghdr* msg, int flags) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html -ssize_t sendto(int sockfd, const void* data, size_t data_length, int flags, const struct sockaddr* addr, socklen_t addr_length) +ssize_t sendto(int sockfd, void const* data, size_t data_length, int flags, const struct sockaddr* addr, socklen_t addr_length) { iovec iov = { const_cast<void*>(data), data_length }; msghdr msg = { const_cast<struct sockaddr*>(addr), addr_length, &iov, 1, nullptr, 0, 0 }; @@ -78,7 +78,7 @@ ssize_t sendto(int sockfd, const void* data, size_t data_length, int flags, cons } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html -ssize_t send(int sockfd, const void* data, size_t data_length, int flags) +ssize_t send(int sockfd, void const* data, size_t data_length, int flags) { return sendto(sockfd, data, data_length, flags, nullptr, 0); } @@ -124,7 +124,7 @@ int getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_ } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -int setsockopt(int sockfd, int level, int option, const void* value, socklen_t value_size) +int setsockopt(int sockfd, int level, int option, void const* value, socklen_t value_size) { Syscall::SC_setsockopt_params params { value, sockfd, level, option, value_size }; int rc = syscall(SC_setsockopt, ¶ms); diff --git a/Userland/Libraries/LibC/sys/socket.h b/Userland/Libraries/LibC/sys/socket.h index 87b4ecea8d..f37be8e7ae 100644 --- a/Userland/Libraries/LibC/sys/socket.h +++ b/Userland/Libraries/LibC/sys/socket.h @@ -18,14 +18,14 @@ int accept(int sockfd, struct sockaddr*, socklen_t*); int accept4(int sockfd, struct sockaddr*, socklen_t*, int); int connect(int sockfd, const struct sockaddr*, socklen_t); int shutdown(int sockfd, int how); -ssize_t send(int sockfd, const void*, size_t, int flags); +ssize_t send(int sockfd, void const*, size_t, int flags); ssize_t sendmsg(int sockfd, const struct msghdr*, int flags); -ssize_t sendto(int sockfd, const void*, size_t, int flags, const struct sockaddr*, socklen_t); +ssize_t sendto(int sockfd, void const*, size_t, int flags, const struct sockaddr*, socklen_t); ssize_t recv(int sockfd, void*, size_t, int flags); ssize_t recvmsg(int sockfd, struct msghdr*, int flags); ssize_t recvfrom(int sockfd, void*, size_t, int flags, struct sockaddr*, socklen_t*); int getsockopt(int sockfd, int level, int option, void*, socklen_t*); -int setsockopt(int sockfd, int level, int option, const void*, socklen_t); +int setsockopt(int sockfd, int level, int option, void const*, socklen_t); int getsockname(int sockfd, struct sockaddr*, socklen_t*); int getpeername(int sockfd, struct sockaddr*, socklen_t*); int socketpair(int domain, int type, int protocol, int sv[2]); diff --git a/Userland/Libraries/LibC/sys/stat.h b/Userland/Libraries/LibC/sys/stat.h index 9aeb90611f..4ada805708 100644 --- a/Userland/Libraries/LibC/sys/stat.h +++ b/Userland/Libraries/LibC/sys/stat.h @@ -14,14 +14,14 @@ __BEGIN_DECLS mode_t umask(mode_t); -int chmod(const char* pathname, mode_t); +int chmod(char const* pathname, mode_t); int fchmodat(int fd, char const* path, mode_t mode, int flag); int fchmod(int fd, mode_t); -int mkdir(const char* pathname, mode_t); -int mkfifo(const char* pathname, mode_t); +int mkdir(char const* pathname, mode_t); +int mkfifo(char const* pathname, mode_t); int fstat(int fd, struct stat* statbuf); -int lstat(const char* path, struct stat* statbuf); -int stat(const char* path, struct stat* statbuf); -int fstatat(int fd, const char* path, struct stat* statbuf, int flags); +int lstat(char const* path, struct stat* statbuf); +int stat(char const* path, struct stat* statbuf); +int fstatat(int fd, char const* path, struct stat* statbuf, int flags); __END_DECLS diff --git a/Userland/Libraries/LibC/sys/statvfs.cpp b/Userland/Libraries/LibC/sys/statvfs.cpp index d49e38623b..d7b238520b 100644 --- a/Userland/Libraries/LibC/sys/statvfs.cpp +++ b/Userland/Libraries/LibC/sys/statvfs.cpp @@ -11,7 +11,7 @@ extern "C" { -int statvfs(const char* path, struct statvfs* buf) +int statvfs(char const* path, struct statvfs* buf) { Syscall::SC_statvfs_params params { { path, strlen(path) }, buf }; int rc = syscall(SC_statvfs, ¶ms); diff --git a/Userland/Libraries/LibC/sys/time.h b/Userland/Libraries/LibC/sys/time.h index 452774f71c..8dc88f672a 100644 --- a/Userland/Libraries/LibC/sys/time.h +++ b/Userland/Libraries/LibC/sys/time.h @@ -19,7 +19,7 @@ struct timezone { int adjtime(const struct timeval* delta, struct timeval* old_delta); int gettimeofday(struct timeval* __restrict__, void* __restrict__); int settimeofday(struct timeval* __restrict__, void* __restrict__); -int utimes(const char* pathname, const struct timeval[2]); +int utimes(char const* pathname, const struct timeval[2]); static inline void timeradd(const struct timeval* a, const struct timeval* b, struct timeval* out) { diff --git a/Userland/Libraries/LibC/sys/xattr.cpp b/Userland/Libraries/LibC/sys/xattr.cpp index 61c6f1afaf..cc30458c90 100644 --- a/Userland/Libraries/LibC/sys/xattr.cpp +++ b/Userland/Libraries/LibC/sys/xattr.cpp @@ -7,49 +7,49 @@ #include <AK/Format.h> #include <sys/xattr.h> -ssize_t getxattr(const char*, const char*, void*, size_t) +ssize_t getxattr(char const*, char const*, void*, size_t) { dbgln("FIXME: Implement getxattr()"); return 0; } -ssize_t lgetxattr(const char*, const char*, void*, size_t) +ssize_t lgetxattr(char const*, char const*, void*, size_t) { dbgln("FIXME: Implement lgetxattr()"); return 0; } -ssize_t fgetxattr(int, const char*, void*, size_t) +ssize_t fgetxattr(int, char const*, void*, size_t) { dbgln("FIXME: Implement fgetxattr()"); return 0; } -int setxattr(const char*, const char*, const void*, size_t, int) +int setxattr(char const*, char const*, void const*, size_t, int) { dbgln("FIXME: Implement setxattr()"); return 0; } -int lsetxattr(const char*, const char*, const void*, size_t, int) +int lsetxattr(char const*, char const*, void const*, size_t, int) { dbgln("FIXME: Implement lsetxattr()"); return 0; } -int fsetxattr(int, const char*, const void*, size_t, int) +int fsetxattr(int, char const*, void const*, size_t, int) { dbgln("FIXME: Implement fsetxattr()"); return 0; } -ssize_t listxattr(const char*, char*, size_t) +ssize_t listxattr(char const*, char*, size_t) { dbgln("FIXME: Implement listxattr()"); return 0; } -ssize_t llistxattr(const char*, char*, size_t) +ssize_t llistxattr(char const*, char*, size_t) { dbgln("FIXME: Implement llistxattr()"); return 0; diff --git a/Userland/Libraries/LibC/sys/xattr.h b/Userland/Libraries/LibC/sys/xattr.h index 69c0735cab..0da4ead659 100644 --- a/Userland/Libraries/LibC/sys/xattr.h +++ b/Userland/Libraries/LibC/sys/xattr.h @@ -10,16 +10,16 @@ __BEGIN_DECLS -ssize_t getxattr(const char* path, const char* name, void* value, size_t size); -ssize_t lgetxattr(const char* path, const char* name, void* value, size_t size); -ssize_t fgetxattr(int fd, const char* name, void* value, size_t size); +ssize_t getxattr(char const* path, char const* name, void* value, size_t size); +ssize_t lgetxattr(char const* path, char const* name, void* value, size_t size); +ssize_t fgetxattr(int fd, char const* name, void* value, size_t size); -int setxattr(const char* path, const char* name, const void* value, size_t size, int flags); -int lsetxattr(const char* path, const char* name, const void* value, size_t size, int flags); -int fsetxattr(int fd, const char* name, const void* value, size_t size, int flags); +int setxattr(char const* path, char const* name, void const* value, size_t size, int flags); +int lsetxattr(char const* path, char const* name, void const* value, size_t size, int flags); +int fsetxattr(int fd, char const* name, void const* value, size_t size, int flags); -ssize_t listxattr(const char* path, char* list, size_t size); -ssize_t llistxattr(const char* path, char* list, size_t size); +ssize_t listxattr(char const* path, char* list, size_t size); +ssize_t llistxattr(char const* path, char* list, size_t size); ssize_t flistxattr(int fd, char* list, size_t size); __END_DECLS diff --git a/Userland/Libraries/LibC/syslog.cpp b/Userland/Libraries/LibC/syslog.cpp index 7e17a51498..9c563a22f7 100644 --- a/Userland/Libraries/LibC/syslog.cpp +++ b/Userland/Libraries/LibC/syslog.cpp @@ -36,7 +36,7 @@ static bool program_name_set = false; // Convenience function for initialization and checking what string to use // for the program name. -static const char* get_syslog_ident(struct syslog_data* data) +static char const* get_syslog_ident(struct syslog_data* data) { if (!program_name_set && data->ident == nullptr) program_name_set = get_process_name(program_name_buffer, sizeof(program_name_buffer)) >= 0; @@ -49,7 +49,7 @@ static const char* get_syslog_ident(struct syslog_data* data) VERIFY_NOT_REACHED(); } -void openlog_r(const char* ident, int logopt, int facility, struct syslog_data* data) +void openlog_r(char const* ident, int logopt, int facility, struct syslog_data* data) { data->ident = ident; data->logopt = logopt; @@ -59,7 +59,7 @@ void openlog_r(const char* ident, int logopt, int facility, struct syslog_data* // would be where we connect to a daemon } -void openlog(const char* ident, int logopt, int facility) +void openlog(char const* ident, int logopt, int facility) { openlog_r(ident, logopt, facility, &global_log_data); } @@ -92,7 +92,7 @@ int setlogmask(int maskpri) return setlogmask_r(maskpri, &global_log_data); } -void syslog_r(int priority, struct syslog_data* data, const char* message, ...) +void syslog_r(int priority, struct syslog_data* data, char const* message, ...) { va_list ap; va_start(ap, message); @@ -100,7 +100,7 @@ void syslog_r(int priority, struct syslog_data* data, const char* message, ...) va_end(ap); } -void syslog(int priority, const char* message, ...) +void syslog(int priority, char const* message, ...) { va_list ap; va_start(ap, message); @@ -108,7 +108,7 @@ void syslog(int priority, const char* message, ...) va_end(ap); } -void vsyslog_r(int priority, struct syslog_data* data, const char* message, va_list args) +void vsyslog_r(int priority, struct syslog_data* data, char const* message, va_list args) { StringBuilder combined; @@ -132,7 +132,7 @@ void vsyslog_r(int priority, struct syslog_data* data, const char* message, va_l fputs(combined_string.characters(), stderr); } -void vsyslog(int priority, const char* message, va_list args) +void vsyslog(int priority, char const* message, va_list args) { vsyslog_r(priority, &global_log_data, message, args); } diff --git a/Userland/Libraries/LibC/syslog.h b/Userland/Libraries/LibC/syslog.h index f2186f42f7..92d97aae40 100644 --- a/Userland/Libraries/LibC/syslog.h +++ b/Userland/Libraries/LibC/syslog.h @@ -12,7 +12,7 @@ __BEGIN_DECLS struct syslog_data { - const char* ident; + char const* ident; int logopt; int facility; int maskpri; @@ -95,7 +95,7 @@ typedef struct _code { * Most Unices define this as char*, but in C++, we have to define it as a * const char* if we want to use string constants. */ - const char* c_name; + char const* c_name; int c_val; } CODE; @@ -146,12 +146,12 @@ CODE facilitynames[] = { #endif /* The re-entrant versions are an OpenBSD extension we also implement. */ -void syslog(int, const char*, ...); -void syslog_r(int, struct syslog_data*, const char*, ...); -void vsyslog(int, const char* message, va_list); -void vsyslog_r(int, struct syslog_data* data, const char* message, va_list); -void openlog(const char*, int, int); -void openlog_r(const char*, int, int, struct syslog_data*); +void syslog(int, char const*, ...); +void syslog_r(int, struct syslog_data*, char const*, ...); +void vsyslog(int, char const* message, va_list); +void vsyslog_r(int, struct syslog_data* data, char const* message, va_list); +void openlog(char const*, int, int); +void openlog_r(char const*, int, int, struct syslog_data*); void closelog(void); void closelog_r(struct syslog_data*); int setlogmask(int); diff --git a/Userland/Libraries/LibC/termcap.cpp b/Userland/Libraries/LibC/termcap.cpp index 24a99c6f69..a62a225be4 100644 --- a/Userland/Libraries/LibC/termcap.cpp +++ b/Userland/Libraries/LibC/termcap.cpp @@ -18,7 +18,7 @@ char PC; char* UP; char* BC; -int __attribute__((weak)) tgetent([[maybe_unused]] char* bp, [[maybe_unused]] const char* name) +int __attribute__((weak)) tgetent([[maybe_unused]] char* bp, [[maybe_unused]] char const* name) { warnln_if(TERMCAP_DEBUG, "tgetent: bp={:p}, name='{}'", bp, name); PC = '\0'; @@ -27,13 +27,13 @@ int __attribute__((weak)) tgetent([[maybe_unused]] char* bp, [[maybe_unused]] co return 1; } -static HashMap<String, const char*>* caps = nullptr; +static HashMap<String, char const*>* caps = nullptr; static void ensure_caps() { if (caps) return; - caps = new HashMap<String, const char*>; + caps = new HashMap<String, char const*>; caps->set("DC", "\033[%p1%dP"); caps->set("IC", "\033[%p1%d@"); caps->set("ce", "\033[K"); @@ -75,14 +75,14 @@ static void ensure_caps() #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -char* __attribute__((weak)) tgetstr(const char* id, char** area) +char* __attribute__((weak)) tgetstr(char const* id, char** area) { ensure_caps(); warnln_if(TERMCAP_DEBUG, "tgetstr: id='{}'", id); auto it = caps->find(id); if (it != caps->end()) { char* ret = *area; - const char* val = (*it).value; + char const* val = (*it).value; strcpy(*area, val); *area += strlen(val) + 1; return ret; @@ -93,7 +93,7 @@ char* __attribute__((weak)) tgetstr(const char* id, char** area) #pragma GCC diagnostic pop -int __attribute__((weak)) tgetflag([[maybe_unused]] const char* id) +int __attribute__((weak)) tgetflag([[maybe_unused]] char const* id) { warnln_if(TERMCAP_DEBUG, "tgetflag: '{}'", id); auto it = caps->find(id); @@ -102,7 +102,7 @@ int __attribute__((weak)) tgetflag([[maybe_unused]] const char* id) return 0; } -int __attribute__((weak)) tgetnum(const char* id) +int __attribute__((weak)) tgetnum(char const* id) { warnln_if(TERMCAP_DEBUG, "tgetnum: '{}'", id); auto it = caps->find(id); @@ -112,7 +112,7 @@ int __attribute__((weak)) tgetnum(const char* id) } static Vector<char> s_tgoto_buffer; -char* __attribute__((weak)) tgoto([[maybe_unused]] const char* cap, [[maybe_unused]] int col, [[maybe_unused]] int row) +char* __attribute__((weak)) tgoto([[maybe_unused]] char const* cap, [[maybe_unused]] int col, [[maybe_unused]] int row) { auto cap_str = StringView(cap).replace("%p1%d", String::number(col)).replace("%p2%d", String::number(row)); @@ -122,7 +122,7 @@ char* __attribute__((weak)) tgoto([[maybe_unused]] const char* cap, [[maybe_unus return s_tgoto_buffer.data(); } -int __attribute__((weak)) tputs(const char* str, [[maybe_unused]] int affcnt, int (*putc)(int)) +int __attribute__((weak)) tputs(char const* str, [[maybe_unused]] int affcnt, int (*putc)(int)) { size_t len = strlen(str); for (size_t i = 0; i < len; ++i) diff --git a/Userland/Libraries/LibC/termcap.h b/Userland/Libraries/LibC/termcap.h index a6a70c4b2d..451151aa75 100644 --- a/Userland/Libraries/LibC/termcap.h +++ b/Userland/Libraries/LibC/termcap.h @@ -14,11 +14,11 @@ extern char PC; extern char* UP; extern char* BC; -int tgetent(char* bp, const char* name); -int tgetflag(const char* id); -int tgetnum(const char* id); -char* tgetstr(const char* id, char** area); -char* tgoto(const char* cap, int col, int row); -int tputs(const char* str, int affcnt, int (*putc)(int)); +int tgetent(char* bp, char const* name); +int tgetflag(char const* id); +int tgetnum(char const* id); +char* tgetstr(char const* id, char** area); +char* tgoto(char const* cap, int col, int row); +int tputs(char const* str, int affcnt, int (*putc)(int)); __END_DECLS diff --git a/Userland/Libraries/LibC/time.cpp b/Userland/Libraries/LibC/time.cpp index 6f6dfa67b1..c28351c97a 100644 --- a/Userland/Libraries/LibC/time.cpp +++ b/Userland/Libraries/LibC/time.cpp @@ -68,7 +68,7 @@ int settimeofday(struct timeval* __restrict__ tv, void* __restrict__) return clock_settime(CLOCK_REALTIME, &ts); } -int utimes(const char* pathname, const struct timeval times[2]) +int utimes(char const* pathname, const struct timeval times[2]) { if (!times) { return utime(pathname, nullptr); @@ -78,18 +78,18 @@ int utimes(const char* pathname, const struct timeval times[2]) return utime(pathname, &buf); } -char* ctime(const time_t* t) +char* ctime(time_t const* t) { return asctime(localtime(t)); } -char* ctime_r(const time_t* t, char* buf) +char* ctime_r(time_t const* t, char* buf) { struct tm tm_buf; return asctime_r(localtime_r(t, &tm_buf), buf); } -static const int __seconds_per_day = 60 * 60 * 24; +static int const __seconds_per_day = 60 * 60 * 24; static void time_to_tm(struct tm* tm, time_t t) { @@ -150,7 +150,7 @@ time_t mktime(struct tm* tm) return tm_to_time(tm, daylight ? altzone : timezone); } -struct tm* localtime(const time_t* t) +struct tm* localtime(time_t const* t) { tzset(); @@ -158,7 +158,7 @@ struct tm* localtime(const time_t* t) return localtime_r(t, &tm_buf); } -struct tm* localtime_r(const time_t* t, struct tm* tm) +struct tm* localtime_r(time_t const* t, struct tm* tm) { if (!t) return nullptr; @@ -172,13 +172,13 @@ time_t timegm(struct tm* tm) return tm_to_time(tm, 0); } -struct tm* gmtime(const time_t* t) +struct tm* gmtime(time_t const* t) { static struct tm tm_buf; return gmtime_r(t, &tm_buf); } -struct tm* gmtime_r(const time_t* t, struct tm* tm) +struct tm* gmtime_r(time_t const* t, struct tm* tm) { if (!t) return nullptr; @@ -205,13 +205,13 @@ char* asctime_r(const struct tm* tm, char* buffer) } // FIXME: Some formats are not supported. -size_t strftime(char* destination, size_t max_size, const char* format, const struct tm* tm) +size_t strftime(char* destination, size_t max_size, char const* format, const struct tm* tm) { tzset(); StringBuilder builder { max_size }; - const int format_len = strlen(format); + int const format_len = strlen(format); for (int i = 0; i < format_len; ++i) { if (format[i] != '%') { builder.append(format[i]); @@ -287,20 +287,20 @@ size_t strftime(char* destination, size_t max_size, const char* format, const st builder.appendff("{}", tm->tm_wday ? tm->tm_wday : 7); break; case 'U': { - const int wday_of_year_beginning = (tm->tm_wday + 6 * tm->tm_yday) % 7; - const int week_number = (tm->tm_yday + wday_of_year_beginning) / 7; + int const wday_of_year_beginning = (tm->tm_wday + 6 * tm->tm_yday) % 7; + int const week_number = (tm->tm_yday + wday_of_year_beginning) / 7; builder.appendff("{:02}", week_number); break; } case 'V': { - const int wday_of_year_beginning = (tm->tm_wday + 6 + 6 * tm->tm_yday) % 7; + int const wday_of_year_beginning = (tm->tm_wday + 6 + 6 * tm->tm_yday) % 7; int week_number = (tm->tm_yday + wday_of_year_beginning) / 7 + 1; if (wday_of_year_beginning > 3) { if (tm->tm_yday >= 7 - wday_of_year_beginning) --week_number; else { - const int days_of_last_year = days_in_year(tm->tm_year + 1900 - 1); - const int wday_of_last_year_beginning = (wday_of_year_beginning + 6 * days_of_last_year) % 7; + int const days_of_last_year = days_in_year(tm->tm_year + 1900 - 1); + int const wday_of_last_year_beginning = (wday_of_year_beginning + 6 * days_of_last_year) % 7; week_number = (days_of_last_year + wday_of_last_year_beginning) / 7 + 1; if (wday_of_last_year_beginning > 3) --week_number; @@ -313,8 +313,8 @@ size_t strftime(char* destination, size_t max_size, const char* format, const st builder.appendff("{}", tm->tm_wday); break; case 'W': { - const int wday_of_year_beginning = (tm->tm_wday + 6 + 6 * tm->tm_yday) % 7; - const int week_number = (tm->tm_yday + wday_of_year_beginning) / 7; + int const wday_of_year_beginning = (tm->tm_wday + 6 + 6 * tm->tm_yday) % 7; + int const week_number = (tm->tm_yday + wday_of_year_beginning) / 7; builder.appendff("{:02}", week_number); break; } @@ -342,7 +342,7 @@ size_t strftime(char* destination, size_t max_size, const char* format, const st static char __tzname_standard[TZNAME_MAX]; static char __tzname_daylight[TZNAME_MAX]; -constexpr const char* __utc = "UTC"; +constexpr char const* __utc = "UTC"; long timezone = 0; long altzone = 0; diff --git a/Userland/Libraries/LibC/time.h b/Userland/Libraries/LibC/time.h index d5316c4ee4..caf8d9d6e5 100644 --- a/Userland/Libraries/LibC/time.h +++ b/Userland/Libraries/LibC/time.h @@ -30,13 +30,13 @@ extern int daylight; typedef uint32_t clock_t; typedef int64_t time_t; -struct tm* localtime(const time_t*); -struct tm* gmtime(const time_t*); +struct tm* localtime(time_t const*); +struct tm* gmtime(time_t const*); time_t mktime(struct tm*); time_t timegm(struct tm*); time_t time(time_t*); -char* ctime(const time_t*); -char* ctime_r(const time_t* tm, char* buf); +char* ctime(time_t const*); +char* ctime_r(time_t const* tm, char* buf); void tzset(void); char* asctime(const struct tm*); char* asctime_r(const struct tm*, char* buf); @@ -48,10 +48,10 @@ int clock_settime(clockid_t, struct timespec*); int clock_nanosleep(clockid_t, int flags, const struct timespec* requested_sleep, struct timespec* remaining_sleep); int clock_getres(clockid_t, struct timespec* result); int nanosleep(const struct timespec* requested_sleep, struct timespec* remaining_sleep); -struct tm* gmtime_r(const time_t* timep, struct tm* result); -struct tm* localtime_r(const time_t* timep, struct tm* result); +struct tm* gmtime_r(time_t const* timep, struct tm* result); +struct tm* localtime_r(time_t const* timep, struct tm* result); double difftime(time_t, time_t); -size_t strftime(char* s, size_t max, const char* format, const struct tm*) __attribute__((format(strftime, 3, 0))); +size_t strftime(char* s, size_t max, char const* format, const struct tm*) __attribute__((format(strftime, 3, 0))); __END_DECLS diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index 386de58260..f613be7a19 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -44,7 +44,7 @@ static __thread int s_cached_tid = 0; static int s_cached_pid = 0; // https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html -int lchown(const char* pathname, uid_t uid, gid_t gid) +int lchown(char const* pathname, uid_t uid, gid_t gid) { if (!pathname) { errno = EFAULT; @@ -56,7 +56,7 @@ int lchown(const char* pathname, uid_t uid, gid_t gid) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html -int chown(const char* pathname, uid_t uid, gid_t gid) +int chown(char const* pathname, uid_t uid, gid_t gid) { if (!pathname) { errno = EFAULT; @@ -74,7 +74,7 @@ int fchown(int fd, uid_t uid, gid_t gid) __RETURN_WITH_ERRNO(rc, rc, -1); } -int fchownat(int fd, const char* pathname, uid_t uid, gid_t gid, int flags) +int fchownat(int fd, char const* pathname, uid_t uid, gid_t gid, int flags) { if (!pathname) { errno = EFAULT; @@ -141,13 +141,13 @@ int daemon(int nochdir, int noclose) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/execv.html -int execv(const char* path, char* const argv[]) +int execv(char const* path, char* const argv[]) { return execve(path, argv, environ); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/execve.html -int execve(const char* filename, char* const argv[], char* const envp[]) +int execve(char const* filename, char* const argv[], char* const envp[]) { size_t arg_count = 0; for (size_t i = 0; argv[i]; ++i) @@ -177,7 +177,7 @@ int execve(const char* filename, char* const argv[], char* const envp[]) __RETURN_WITH_ERRNO(rc, rc, -1); } -int execvpe(const char* filename, char* const argv[], char* const envp[]) +int execvpe(char const* filename, char* const argv[], char* const envp[]) { if (strchr(filename, '/')) return execve(filename, argv, envp); @@ -202,7 +202,7 @@ int execvpe(const char* filename, char* const argv[], char* const envp[]) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/execvp.html -int execvp(const char* filename, char* const argv[]) +int execvp(char const* filename, char* const argv[]) { int rc = execvpe(filename, argv, environ); int saved_errno = errno; @@ -212,15 +212,15 @@ int execvp(const char* filename, char* const argv[]) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html -int execl(const char* filename, const char* arg0, ...) +int execl(char const* filename, char const* arg0, ...) { - Vector<const char*, 16> args; + Vector<char const*, 16> args; args.append(arg0); va_list ap; va_start(ap, arg0); for (;;) { - const char* arg = va_arg(ap, const char*); + char const* arg = va_arg(ap, char const*); if (!arg) break; args.append(arg); @@ -252,15 +252,15 @@ int execle(char const* filename, char const* arg0, ...) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/execlp.html -int execlp(const char* filename, const char* arg0, ...) +int execlp(char const* filename, char const* arg0, ...) { - Vector<const char*, 16> args; + Vector<char const*, 16> args; args.append(arg0); va_list ap; va_start(ap, arg0); for (;;) { - const char* arg = va_arg(ap, const char*); + char const* arg = va_arg(ap, char const*); if (!arg) break; args.append(arg); @@ -386,14 +386,14 @@ ssize_t pread(int fd, void* buf, size_t count, off_t offset) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html -ssize_t write(int fd, const void* buf, size_t count) +ssize_t write(int fd, void const* buf, size_t count) { int rc = syscall(SC_write, fd, buf, count); __RETURN_WITH_ERRNO(rc, rc, -1); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html -ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) +ssize_t pwrite(int fd, void const* buf, size_t count, off_t offset) { // FIXME: This is not thread safe and should be implemented in the kernel instead. off_t old_offset = lseek(fd, 0, SEEK_CUR); @@ -404,7 +404,7 @@ ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) } // Note: Be sure to send to directory_name parameter a directory name ended with trailing slash. -static int ttyname_r_for_directory(const char* directory_name, dev_t device_mode, ino_t inode_number, char* buffer, size_t size) +static int ttyname_r_for_directory(char const* directory_name, dev_t device_mode, ino_t inode_number, char* buffer, size_t size) { DIR* dirstream = opendir(directory_name); if (!dirstream) { @@ -489,7 +489,7 @@ int close(int fd) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/chdir.html -int chdir(const char* path) +int chdir(char const* path) { if (!path) { errno = EFAULT; @@ -608,14 +608,14 @@ int gethostname(char* buffer, size_t size) __RETURN_WITH_ERRNO(rc, rc, -1); } -int sethostname(const char* hostname, ssize_t size) +int sethostname(char const* hostname, ssize_t size) { int rc = syscall(SC_sethostname, hostname, size); __RETURN_WITH_ERRNO(rc, rc, -1); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html -ssize_t readlink(const char* path, char* buffer, size_t size) +ssize_t readlink(char const* path, char* buffer, size_t size) { Syscall::SC_readlink_params params { { path, strlen(path) }, { buffer, size } }; int rc = syscall(SC_readlink, ¶ms); @@ -630,7 +630,7 @@ off_t lseek(int fd, off_t offset, int whence) __RETURN_WITH_ERRNO(rc, offset, -1); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html -int link(const char* old_path, const char* new_path) +int link(char const* old_path, char const* new_path) { if (!old_path || !new_path) { errno = EFAULT; @@ -642,14 +642,14 @@ int link(const char* old_path, const char* new_path) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html -int unlink(const char* pathname) +int unlink(char const* pathname) { int rc = syscall(SC_unlink, pathname, strlen(pathname)); __RETURN_WITH_ERRNO(rc, rc, -1); } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html -int symlink(const char* target, const char* linkpath) +int symlink(char const* target, char const* linkpath) { if (!target || !linkpath) { errno = EFAULT; @@ -661,7 +661,7 @@ int symlink(const char* target, const char* linkpath) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html -int rmdir(const char* pathname) +int rmdir(char const* pathname) { if (!pathname) { errno = EFAULT; @@ -690,7 +690,7 @@ int dup2(int old_fd, int new_fd) __RETURN_WITH_ERRNO(rc, rc, -1); } -int setgroups(size_t size, const gid_t* list) +int setgroups(size_t size, gid_t const* list) { int rc = syscall(SC_setgroups, size, list); __RETURN_WITH_ERRNO(rc, rc, -1); @@ -763,7 +763,7 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html -int access(const char* pathname, int mode) +int access(char const* pathname, int mode) { if (!pathname) { errno = EFAULT; @@ -774,7 +774,7 @@ int access(const char* pathname, int mode) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html -int mknod(const char* pathname, mode_t mode, dev_t dev) +int mknod(char const* pathname, mode_t mode, dev_t dev) { if (!pathname) { errno = EFAULT; @@ -803,7 +803,7 @@ long fpathconf([[maybe_unused]] int fd, int name) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html -long pathconf([[maybe_unused]] const char* path, int name) +long pathconf([[maybe_unused]] char const* path, int name) { switch (name) { case _PC_NAME_MAX: @@ -853,7 +853,7 @@ int ftruncate(int fd, off_t length) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html -int truncate(const char* path, off_t length) +int truncate(char const* path, off_t length) { int fd = open(path, O_RDWR | O_CREAT, 0666); if (fd < 0) @@ -889,7 +889,7 @@ int fsync(int fd) __RETURN_WITH_ERRNO(rc, rc, -1); } -int mount(int source_fd, const char* target, const char* fs_type, int flags) +int mount(int source_fd, char const* target, char const* fs_type, int flags) { if (!target || !fs_type) { errno = EFAULT; @@ -906,7 +906,7 @@ int mount(int source_fd, const char* target, const char* fs_type, int flags) __RETURN_WITH_ERRNO(rc, rc, -1); } -int umount(const char* mountpoint) +int umount(char const* mountpoint) { int rc = syscall(SC_umount, mountpoint, strlen(mountpoint)); __RETURN_WITH_ERRNO(rc, rc, -1); @@ -923,13 +923,13 @@ int get_process_name(char* buffer, int buffer_size) __RETURN_WITH_ERRNO(rc, rc, -1); } -int set_process_name(const char* name, size_t name_length) +int set_process_name(char const* name, size_t name_length) { int rc = syscall(SC_set_process_name, name, name_length); __RETURN_WITH_ERRNO(rc, rc, -1); } -int pledge(const char* promises, const char* execpromises) +int pledge(char const* promises, char const* execpromises) { Syscall::SC_pledge_params params { { promises, promises ? strlen(promises) : 0 }, @@ -939,7 +939,7 @@ int pledge(const char* promises, const char* execpromises) __RETURN_WITH_ERRNO(rc, rc, -1); } -int unveil(const char* path, const char* permissions) +int unveil(char const* path, char const* permissions) { Syscall::SC_unveil_params params { { path, path ? strlen(path) : 0 }, @@ -950,7 +950,7 @@ int unveil(const char* path, const char* permissions) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpass.html -char* getpass(const char* prompt) +char* getpass(char const* prompt) { dbgln("FIXME: getpass('{}')", prompt); TODO(); @@ -976,7 +976,7 @@ int pause() } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/chroot.html -int chroot(const char* path) +int chroot(char const* path) { dbgln("FIXME: chroot(\"{}\")", path); return -1; diff --git a/Userland/Libraries/LibC/unistd.h b/Userland/Libraries/LibC/unistd.h index 3300981169..8ce3ac92e4 100644 --- a/Userland/Libraries/LibC/unistd.h +++ b/Userland/Libraries/LibC/unistd.h @@ -31,7 +31,7 @@ __BEGIN_DECLS extern char** environ; int get_process_name(char* buffer, int buffer_size); -int set_process_name(const char* name, size_t name_length); +int set_process_name(char const* name, size_t name_length); void dump_backtrace(void); int fsync(int fd); int sysbeep(void); @@ -40,13 +40,13 @@ int getpagesize(void); pid_t fork(void); pid_t vfork(void); int daemon(int nochdir, int noclose); -int execv(const char* path, char* const argv[]); -int execve(const char* filename, char* const argv[], char* const envp[]); -int execvpe(const char* filename, char* const argv[], char* const envp[]); -int execvp(const char* filename, char* const argv[]); -int execl(const char* filename, const char* arg, ...); -int execle(const char* filename, const char* arg, ...); -int execlp(const char* filename, const char* arg, ...); +int execv(char const* path, char* const argv[]); +int execve(char const* filename, char* const argv[], char* const envp[]); +int execvpe(char const* filename, char* const argv[], char* const envp[]); +int execvp(char const* filename, char* const argv[]); +int execl(char const* filename, char const* arg, ...); +int execle(char const* filename, char const* arg, ...); +int execlp(char const* filename, char const* arg, ...); void sync(void); __attribute__((noreturn)) void _exit(int status); pid_t getsid(pid_t); @@ -63,7 +63,7 @@ pid_t getppid(void); int getresuid(uid_t*, uid_t*, uid_t*); int getresgid(gid_t*, gid_t*, gid_t*); int getgroups(int size, gid_t list[]); -int setgroups(size_t, const gid_t*); +int setgroups(size_t, gid_t const*); int seteuid(uid_t); int setegid(gid_t); int setuid(uid_t); @@ -75,49 +75,49 @@ pid_t tcgetpgrp(int fd); int tcsetpgrp(int fd, pid_t pgid); ssize_t read(int fd, void* buf, size_t count); ssize_t pread(int fd, void* buf, size_t count, off_t); -ssize_t write(int fd, const void* buf, size_t count); -ssize_t pwrite(int fd, const void* buf, size_t count, off_t); +ssize_t write(int fd, void const* buf, size_t count); +ssize_t pwrite(int fd, void const* buf, size_t count, off_t); int close(int fd); -int chdir(const char* path); +int chdir(char const* path); int fchdir(int fd); char* getcwd(char* buffer, size_t size); char* getwd(char* buffer); unsigned int sleep(unsigned int seconds); int usleep(useconds_t); int gethostname(char*, size_t); -int sethostname(const char*, ssize_t); -ssize_t readlink(const char* path, char* buffer, size_t); +int sethostname(char const*, ssize_t); +ssize_t readlink(char const* path, char* buffer, size_t); char* ttyname(int fd); int ttyname_r(int fd, char* buffer, size_t); off_t lseek(int fd, off_t, int whence); -int link(const char* oldpath, const char* newpath); -int unlink(const char* pathname); -int symlink(const char* target, const char* linkpath); -int rmdir(const char* pathname); +int link(char const* oldpath, char const* newpath); +int unlink(char const* pathname); +int symlink(char const* target, char const* linkpath); +int rmdir(char const* pathname); int dup(int old_fd); int dup2(int old_fd, int new_fd); int pipe(int pipefd[2]); int pipe2(int pipefd[2], int flags); unsigned int alarm(unsigned int seconds); -int access(const char* pathname, int mode); +int access(char const* pathname, int mode); int isatty(int fd); -int mknod(const char* pathname, mode_t, dev_t); +int mknod(char const* pathname, mode_t, dev_t); long fpathconf(int fd, int name); -long pathconf(const char* path, int name); +long pathconf(char const* path, int name); char* getlogin(void); -int lchown(const char* pathname, uid_t uid, gid_t gid); -int chown(const char* pathname, uid_t, gid_t); +int lchown(char const* pathname, uid_t uid, gid_t gid); +int chown(char const* pathname, uid_t, gid_t); int fchown(int fd, uid_t, gid_t); -int fchownat(int fd, const char* pathname, uid_t uid, gid_t gid, int flags); +int fchownat(int fd, char const* pathname, uid_t uid, gid_t gid, int flags); int ftruncate(int fd, off_t length); -int truncate(const char* path, off_t length); -int mount(int source_fd, const char* target, const char* fs_type, int flags); -int umount(const char* mountpoint); -int pledge(const char* promises, const char* execpromises); -int unveil(const char* path, const char* permissions); -char* getpass(const char* prompt); +int truncate(char const* path, off_t length); +int mount(int source_fd, char const* target, char const* fs_type, int flags); +int umount(char const* mountpoint); +int pledge(char const* promises, char const* execpromises); +int unveil(char const* path, char const* permissions); +char* getpass(char const* prompt); int pause(void); -int chroot(const char*); +int chroot(char const*); int getdtablesize(void); enum { @@ -155,6 +155,6 @@ extern int optreset; // value. extern char* optarg; -int getopt(int argc, char* const* argv, const char* short_options); +int getopt(int argc, char* const* argv, char const* short_options); __END_DECLS diff --git a/Userland/Libraries/LibC/utime.cpp b/Userland/Libraries/LibC/utime.cpp index 4160b28ab9..4fe8147a1a 100644 --- a/Userland/Libraries/LibC/utime.cpp +++ b/Userland/Libraries/LibC/utime.cpp @@ -11,7 +11,7 @@ extern "C" { -int utime(const char* pathname, const struct utimbuf* buf) +int utime(char const* pathname, const struct utimbuf* buf) { if (!pathname) { errno = EFAULT; diff --git a/Userland/Libraries/LibC/utime.h b/Userland/Libraries/LibC/utime.h index 6a86c8b64c..71904ba7e7 100644 --- a/Userland/Libraries/LibC/utime.h +++ b/Userland/Libraries/LibC/utime.h @@ -10,6 +10,6 @@ __BEGIN_DECLS -int utime(const char* pathname, const struct utimbuf*); +int utime(char const* pathname, const struct utimbuf*); __END_DECLS diff --git a/Userland/Libraries/LibC/wchar.h b/Userland/Libraries/LibC/wchar.h index 33d129bf6e..7f38900b95 100644 --- a/Userland/Libraries/LibC/wchar.h +++ b/Userland/Libraries/LibC/wchar.h @@ -29,47 +29,47 @@ typedef struct { struct tm; -size_t wcslen(const wchar_t*); -wchar_t* wcscpy(wchar_t*, const wchar_t*); -wchar_t* wcsdup(const wchar_t*); -wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t); -__attribute__((warn_unused_result)) size_t wcslcpy(wchar_t*, const wchar_t*, size_t); -int wcscmp(const wchar_t*, const wchar_t*); -int wcsncmp(const wchar_t*, const wchar_t*, size_t); -wchar_t* wcschr(const wchar_t*, int); -wchar_t* wcsrchr(const wchar_t*, wchar_t); -wchar_t* wcscat(wchar_t*, const wchar_t*); -wchar_t* wcsncat(wchar_t*, const wchar_t*, size_t); -wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**); -long wcstol(const wchar_t*, wchar_t**, int); -long long wcstoll(const wchar_t*, wchar_t**, int); +size_t wcslen(wchar_t const*); +wchar_t* wcscpy(wchar_t*, wchar_t const*); +wchar_t* wcsdup(wchar_t const*); +wchar_t* wcsncpy(wchar_t*, wchar_t const*, size_t); +__attribute__((warn_unused_result)) size_t wcslcpy(wchar_t*, wchar_t const*, size_t); +int wcscmp(wchar_t const*, wchar_t const*); +int wcsncmp(wchar_t const*, wchar_t const*, size_t); +wchar_t* wcschr(wchar_t const*, int); +wchar_t* wcsrchr(wchar_t const*, wchar_t); +wchar_t* wcscat(wchar_t*, wchar_t const*); +wchar_t* wcsncat(wchar_t*, wchar_t const*, size_t); +wchar_t* wcstok(wchar_t*, wchar_t const*, wchar_t**); +long wcstol(wchar_t const*, wchar_t**, int); +long long wcstoll(wchar_t const*, wchar_t**, int); wint_t btowc(int c); -size_t mbrtowc(wchar_t*, const char*, size_t, mbstate_t*); -size_t mbrlen(const char*, size_t, mbstate_t*); +size_t mbrtowc(wchar_t*, char const*, size_t, mbstate_t*); +size_t mbrlen(char const*, size_t, mbstate_t*); size_t wcrtomb(char*, wchar_t, mbstate_t*); -int wcscoll(const wchar_t*, const wchar_t*); -size_t wcsxfrm(wchar_t*, const wchar_t*, size_t); +int wcscoll(wchar_t const*, wchar_t const*); +size_t wcsxfrm(wchar_t*, wchar_t const*, size_t); int wctob(wint_t); -int mbsinit(const mbstate_t*); -wchar_t* wcspbrk(const wchar_t*, const wchar_t*); -wchar_t* wcsstr(const wchar_t*, const wchar_t*); -wchar_t* wmemchr(const wchar_t*, wchar_t, size_t); -wchar_t* wmemcpy(wchar_t*, const wchar_t*, size_t); +int mbsinit(mbstate_t const*); +wchar_t* wcspbrk(wchar_t const*, wchar_t const*); +wchar_t* wcsstr(wchar_t const*, wchar_t const*); +wchar_t* wmemchr(wchar_t const*, wchar_t, size_t); +wchar_t* wmemcpy(wchar_t*, wchar_t const*, size_t); wchar_t* wmemset(wchar_t*, wchar_t, size_t); -wchar_t* wmemmove(wchar_t*, const wchar_t*, size_t); -unsigned long wcstoul(const wchar_t*, wchar_t**, int); -unsigned long long wcstoull(const wchar_t*, wchar_t**, int); -float wcstof(const wchar_t*, wchar_t**); -double wcstod(const wchar_t*, wchar_t**); -long double wcstold(const wchar_t*, wchar_t**); +wchar_t* wmemmove(wchar_t*, wchar_t const*, size_t); +unsigned long wcstoul(wchar_t const*, wchar_t**, int); +unsigned long long wcstoull(wchar_t const*, wchar_t**, int); +float wcstof(wchar_t const*, wchar_t**); +double wcstod(wchar_t const*, wchar_t**); +long double wcstold(wchar_t const*, wchar_t**); int wcwidth(wchar_t); -size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*); -size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*); -int wmemcmp(const wchar_t*, const wchar_t*, size_t); -size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*); -size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*); -size_t wcscspn(const wchar_t* wcs, const wchar_t* reject); -size_t wcsspn(const wchar_t* wcs, const wchar_t* accept); +size_t wcsrtombs(char*, wchar_t const**, size_t, mbstate_t*); +size_t mbsrtowcs(wchar_t*, char const**, size_t, mbstate_t*); +int wmemcmp(wchar_t const*, wchar_t const*, size_t); +size_t wcsnrtombs(char*, wchar_t const**, size_t, size_t, mbstate_t*); +size_t mbsnrtowcs(wchar_t*, char const**, size_t, size_t, mbstate_t*); +size_t wcscspn(wchar_t const* wcs, wchar_t const* reject); +size_t wcsspn(wchar_t const* wcs, wchar_t const* accept); wint_t fgetwc(FILE* stream); wint_t getwc(FILE* stream); @@ -78,24 +78,24 @@ wint_t fputwc(wchar_t wc, FILE* stream); wint_t putwc(wchar_t wc, FILE* stream); wint_t putwchar(wchar_t wc); wchar_t* fgetws(wchar_t* __restrict ws, int n, FILE* __restrict stream); -int fputws(const wchar_t* __restrict ws, FILE* __restrict stream); +int fputws(wchar_t const* __restrict ws, FILE* __restrict stream); wint_t ungetwc(wint_t wc, FILE* stream); int fwide(FILE* stream, int mode); -int wprintf(const wchar_t* __restrict format, ...); -int fwprintf(FILE* __restrict stream, const wchar_t* __restrict format, ...); -int swprintf(wchar_t* __restrict wcs, size_t maxlen, const wchar_t* __restrict format, ...); -int vwprintf(const wchar_t* __restrict format, va_list args); -int vfwprintf(FILE* __restrict stream, const wchar_t* __restrict format, va_list args); -int vswprintf(wchar_t* __restrict wcs, size_t maxlen, const wchar_t* __restrict format, va_list args); +int wprintf(wchar_t const* __restrict format, ...); +int fwprintf(FILE* __restrict stream, wchar_t const* __restrict format, ...); +int swprintf(wchar_t* __restrict wcs, size_t maxlen, wchar_t const* __restrict format, ...); +int vwprintf(wchar_t const* __restrict format, va_list args); +int vfwprintf(FILE* __restrict stream, wchar_t const* __restrict format, va_list args); +int vswprintf(wchar_t* __restrict wcs, size_t maxlen, wchar_t const* __restrict format, va_list args); -int fwscanf(FILE* __restrict stream, const wchar_t* __restrict format, ...); -int swscanf(const wchar_t* __restrict ws, const wchar_t* __restrict format, ...); -int wscanf(const wchar_t* __restrict format, ...); -int vfwscanf(FILE* __restrict stream, const wchar_t* __restrict format, va_list arg); -int vswscanf(const wchar_t* __restrict ws, const wchar_t* __restrict format, va_list arg); -int vwscanf(const wchar_t* __restrict format, va_list arg); +int fwscanf(FILE* __restrict stream, wchar_t const* __restrict format, ...); +int swscanf(wchar_t const* __restrict ws, wchar_t const* __restrict format, ...); +int wscanf(wchar_t const* __restrict format, ...); +int vfwscanf(FILE* __restrict stream, wchar_t const* __restrict format, va_list arg); +int vswscanf(wchar_t const* __restrict ws, wchar_t const* __restrict format, va_list arg); +int vwscanf(wchar_t const* __restrict format, va_list arg); -size_t wcsftime(wchar_t* __restrict wcs, size_t maxsize, const wchar_t* __restrict format, const struct tm* __restrict timeptr); +size_t wcsftime(wchar_t* __restrict wcs, size_t maxsize, wchar_t const* __restrict format, const struct tm* __restrict timeptr); __END_DECLS diff --git a/Userland/Libraries/LibC/wctype.cpp b/Userland/Libraries/LibC/wctype.cpp index c5dfdcda7a..92f2ca77e9 100644 --- a/Userland/Libraries/LibC/wctype.cpp +++ b/Userland/Libraries/LibC/wctype.cpp @@ -136,7 +136,7 @@ int iswctype(wint_t wc, wctype_t charclass) } } -wctype_t wctype(const char* property) +wctype_t wctype(char const* property) { if (strcmp(property, "alnum") == 0) return WCTYPE_ALNUM; @@ -201,7 +201,7 @@ wint_t towctrans(wint_t wc, wctrans_t desc) } } -wctrans_t wctrans(const char* charclass) +wctrans_t wctrans(char const* charclass) { if (strcmp(charclass, "tolower") == 0) return WCTRANS_TOLOWER; diff --git a/Userland/Libraries/LibC/wctype.h b/Userland/Libraries/LibC/wctype.h index 3bf6afa65c..6f08a0b04b 100644 --- a/Userland/Libraries/LibC/wctype.h +++ b/Userland/Libraries/LibC/wctype.h @@ -27,10 +27,10 @@ int iswlower(wint_t wc); int iswupper(wint_t wc); int iswblank(wint_t wc); int iswctype(wint_t, wctype_t); -wctype_t wctype(const char*); +wctype_t wctype(char const*); wint_t towlower(wint_t wc); wint_t towupper(wint_t wc); wint_t towctrans(wint_t, wctrans_t); -wctrans_t wctrans(const char*); +wctrans_t wctrans(char const*); __END_DECLS diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index c38641f7fb..a29d5f77ef 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -148,7 +148,7 @@ void Card::draw(GUI::Painter& painter) const painter.blit(position(), m_upside_down ? *s_background : *m_front, m_front->rect()); } -void Card::clear(GUI::Painter& painter, const Color& background_color) const +void Card::clear(GUI::Painter& painter, Color const& background_color) const { painter.fill_rect({ old_position(), { width, height } }, background_color); } @@ -159,7 +159,7 @@ void Card::save_old_position() m_old_position_valid = true; } -void Card::clear_and_draw(GUI::Painter& painter, const Color& background_color) +void Card::clear_and_draw(GUI::Painter& painter, Color const& background_color) { if (is_old_position_valid()) clear(painter, background_color); diff --git a/Userland/Libraries/LibCards/Card.h b/Userland/Libraries/LibCards/Card.h index 31028bf27f..257751f057 100644 --- a/Userland/Libraries/LibCards/Card.h +++ b/Userland/Libraries/LibCards/Card.h @@ -41,7 +41,7 @@ public: Gfx::IntRect& rect() { return m_rect; } Gfx::IntPoint position() const { return m_rect.location(); } - const Gfx::IntPoint& old_position() const { return m_old_position; } + Gfx::IntPoint const& old_position() const { return m_old_position; } uint8_t value() const { return m_value; }; Suit suit() const { return m_suit; } @@ -59,8 +59,8 @@ public: void save_old_position(); void draw(GUI::Painter&) const; - void clear(GUI::Painter&, const Color& background_color) const; - void clear_and_draw(GUI::Painter&, const Color& background_color); + void clear(GUI::Painter&, Color const& background_color) const; + void clear_and_draw(GUI::Painter&, Color const& background_color); private: Card(Suit suit, uint8_t value); diff --git a/Userland/Libraries/LibCards/CardStack.cpp b/Userland/Libraries/LibCards/CardStack.cpp index 2d65d124ea..7826a3938c 100644 --- a/Userland/Libraries/LibCards/CardStack.cpp +++ b/Userland/Libraries/LibCards/CardStack.cpp @@ -15,7 +15,7 @@ CardStack::CardStack() { } -CardStack::CardStack(const Gfx::IntPoint& position, Type type) +CardStack::CardStack(Gfx::IntPoint const& position, Type type) : m_position(position) , m_type(type) , m_rules(rules_for_type(type)) @@ -25,7 +25,7 @@ CardStack::CardStack(const Gfx::IntPoint& position, Type type) calculate_bounding_box(); } -CardStack::CardStack(const Gfx::IntPoint& position, Type type, NonnullRefPtr<CardStack> associated_stack) +CardStack::CardStack(Gfx::IntPoint const& position, Type type, NonnullRefPtr<CardStack> associated_stack) : m_associated_stack(move(associated_stack)) , m_position(position) , m_type(type) @@ -42,7 +42,7 @@ void CardStack::clear() m_stack_positions.clear(); } -void CardStack::draw(GUI::Painter& painter, const Gfx::Color& background_color) +void CardStack::draw(GUI::Painter& painter, Gfx::Color const& background_color) { auto draw_background_if_empty = [&]() { size_t number_of_moving_cards = 0; @@ -108,7 +108,7 @@ void CardStack::rebound_cards() card.set_position(m_stack_positions.at(card_index++)); } -void CardStack::add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule) +void CardStack::add_all_grabbed_cards(Gfx::IntPoint const& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule) { VERIFY(grabbed.is_empty()); @@ -187,7 +187,7 @@ void CardStack::add_all_grabbed_cards(const Gfx::IntPoint& click_location, Nonnu } } -bool CardStack::is_allowed_to_push(const Card& card, size_t stack_size, MovementRule movement_rule) const +bool CardStack::is_allowed_to_push(Card const& card, size_t stack_size, MovementRule movement_rule) const { if (m_type == Type::Stock || m_type == Type::Waste || m_type == Type::Play) return false; diff --git a/Userland/Libraries/LibCards/CardStack.h b/Userland/Libraries/LibCards/CardStack.h index 82e39f7bf3..7c763daae3 100644 --- a/Userland/Libraries/LibCards/CardStack.h +++ b/Userland/Libraries/LibCards/CardStack.h @@ -31,17 +31,17 @@ public: }; CardStack(); - CardStack(const Gfx::IntPoint& position, Type type); - CardStack(const Gfx::IntPoint& position, Type type, NonnullRefPtr<CardStack> associated_stack); + CardStack(Gfx::IntPoint const& position, Type type); + CardStack(Gfx::IntPoint const& position, Type type, NonnullRefPtr<CardStack> associated_stack); bool is_empty() const { return m_stack.is_empty(); } bool is_focused() const { return m_focused; } Type type() const { return m_type; } - const NonnullRefPtrVector<Card>& stack() const { return m_stack; } + NonnullRefPtrVector<Card> const& stack() const { return m_stack; } size_t count() const { return m_stack.size(); } - const Card& peek() const { return m_stack.last(); } + Card const& peek() const { return m_stack.last(); } Card& peek() { return m_stack.last(); } - const Gfx::IntRect& bounding_box() const { return m_bounding_box; } + Gfx::IntRect const& bounding_box() const { return m_bounding_box; } void set_focused(bool focused) { m_focused = focused; } @@ -50,9 +50,9 @@ public: void move_to_stack(CardStack&); void rebound_cards(); - bool is_allowed_to_push(const Card&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const; - void add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating); - void draw(GUI::Painter&, const Gfx::Color& background_color); + bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const; + void add_all_grabbed_cards(Gfx::IntPoint const& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating); + void draw(GUI::Painter&, Gfx::Color const& background_color); void clear(); private: @@ -125,7 +125,7 @@ struct AK::Formatter<Cards::CardStack> : Formatter<FormatString> { StringBuilder cards; bool first_card = true; - for (const auto& card : stack.stack()) { + for (auto const& card : stack.stack()) { cards.appendff("{}{}", (first_card ? "" : " "), card); first_card = false; } diff --git a/Userland/Libraries/LibChess/Chess.cpp b/Userland/Libraries/LibChess/Chess.cpp index 6d56ecd1f0..60c1ff4d88 100644 --- a/Userland/Libraries/LibChess/Chess.cpp +++ b/Userland/Libraries/LibChess/Chess.cpp @@ -101,7 +101,7 @@ String Move::to_long_algebraic() const return builder.build(); } -Move Move::from_algebraic(StringView algebraic, const Color turn, const Board& board) +Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& board) { String move_string = algebraic; Move move({ 50, 50 }, { 50, 50 }); @@ -143,7 +143,7 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, const Board& b move_string = move_string.substring(1, move_string.length() - 1); } - Square::for_each([&](const Square& square) { + Square::for_each([&](Square const& square) { if (!move_string.is_empty()) { if (board.get_piece(square).type == move.piece.type && board.is_legal(Move(square, move.to), turn)) { if (move_string.length() >= 2) { @@ -326,19 +326,19 @@ String Board::to_fen() const return builder.to_string(); } -Piece Board::get_piece(const Square& square) const +Piece Board::get_piece(Square const& square) const { VERIFY(square.in_bounds()); return m_board[square.rank][square.file]; } -Piece Board::set_piece(const Square& square, const Piece& piece) +Piece Board::set_piece(Square const& square, Piece const& piece) { VERIFY(square.in_bounds()); return m_board[square.rank][square.file] = piece; } -bool Board::is_legal_promotion(const Move& move, Color color) const +bool Board::is_legal_promotion(Move const& move, Color color) const { auto piece = get_piece(move.from); @@ -367,7 +367,7 @@ bool Board::is_legal_promotion(const Move& move, Color color) const return true; } -bool Board::is_legal(const Move& move, Color color) const +bool Board::is_legal(Move const& move, Color color) const { if (color == Color::None) color = turn(); @@ -409,7 +409,7 @@ bool Board::is_legal(const Move& move, Color color) const return true; } -bool Board::is_legal_no_check(const Move& move, Color color) const +bool Board::is_legal_no_check(Move const& move, Color color) const { auto piece = get_piece(move.from); @@ -536,7 +536,7 @@ bool Board::is_legal_no_check(const Move& move, Color color) const bool Board::in_check(Color color) const { Square king_square = { 50, 50 }; - Square::for_each([&](const Square& square) { + Square::for_each([&](Square const& square) { if (get_piece(square) == Piece(color, Type::King)) { king_square = square; return IterationDecision::Break; @@ -545,7 +545,7 @@ bool Board::in_check(Color color) const }); bool check = false; - Square::for_each([&](const Square& square) { + Square::for_each([&](Square const& square) { if (is_legal_no_check({ square, king_square }, opposing_color(color))) { check = true; return IterationDecision::Break; @@ -556,7 +556,7 @@ bool Board::in_check(Color color) const return check; } -bool Board::apply_move(const Move& move, Color color) +bool Board::apply_move(Move const& move, Color color) { if (color == Color::None) color = turn(); @@ -569,7 +569,7 @@ bool Board::apply_move(const Move& move, Color color) return apply_illegal_move(move, color); } -bool Board::apply_illegal_move(const Move& move, Color color) +bool Board::apply_illegal_move(Move const& move, Color color) { auto state = Traits<Board>::hash(*this); auto state_count = 0; @@ -826,7 +826,7 @@ int Board::material_imbalance() const return imbalance; } -bool Board::is_promotion_move(const Move& move, Color color) const +bool Board::is_promotion_move(Move const& move, Color color) const { if (color == Color::None) color = turn(); @@ -846,7 +846,7 @@ bool Board::is_promotion_move(const Move& move, Color color) const return true; } -bool Board::operator==(const Board& other) const +bool Board::operator==(Board const& other) const { bool equal_squares = true; Square::for_each([&](Square sq) { diff --git a/Userland/Libraries/LibChess/Chess.h b/Userland/Libraries/LibChess/Chess.h index e20a683cec..c73bdc5cce 100644 --- a/Userland/Libraries/LibChess/Chess.h +++ b/Userland/Libraries/LibChess/Chess.h @@ -49,7 +49,7 @@ struct Piece { } Color color : 4; Type type : 4; - bool operator==(const Piece& other) const { return color == other.color && type == other.type; } + bool operator==(Piece const& other) const { return color == other.color && type == other.type; } }; constexpr Piece EmptyPiece = { Color::None, Type::None }; @@ -58,12 +58,12 @@ struct Square { i8 rank; // zero indexed; i8 file; Square(StringView name); - Square(const int& rank, const int& file) + Square(int const& rank, int const& file) : rank(rank) , file(file) { } - bool operator==(const Square& other) const { return rank == other.rank && file == other.file; } + bool operator==(Square const& other) const { return rank == other.rank && file == other.file; } template<typename Callback> static void for_each(Callback callback) @@ -94,15 +94,15 @@ struct Move { bool is_ambiguous : 1 = false; Square ambiguous { 50, 50 }; Move(StringView long_algebraic); - Move(const Square& from, const Square& to, const Type& promote_to = Type::None) + Move(Square const& from, Square const& to, Type const& promote_to = Type::None) : from(from) , to(to) , promote_to(promote_to) { } - bool operator==(const Move& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; } + bool operator==(Move const& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; } - static Move from_algebraic(StringView algebraic, const Color turn, const Board& board); + static Move from_algebraic(StringView algebraic, const Color turn, Board const& board); String to_long_algebraic() const; String to_algebraic() const; }; @@ -111,16 +111,16 @@ class Board { public: Board(); - Piece get_piece(const Square&) const; - Piece set_piece(const Square&, const Piece&); + Piece get_piece(Square const&) const; + Piece set_piece(Square const&, Piece const&); - bool is_legal(const Move&, Color color = Color::None) const; + bool is_legal(Move const&, Color color = Color::None) const; bool in_check(Color color) const; - bool is_promotion_move(const Move&, Color color = Color::None) const; + bool is_promotion_move(Move const&, Color color = Color::None) const; - bool apply_move(const Move&, Color color = Color::None); - const Optional<Move>& last_move() const { return m_last_move; } + bool apply_move(Move const&, Color color = Color::None); + Optional<Move> const& last_move() const { return m_last_move; } String to_fen() const; @@ -151,14 +151,14 @@ public: int material_imbalance() const; Color turn() const { return m_turn; } - const Vector<Move>& moves() const { return m_moves; } + Vector<Move> const& moves() const { return m_moves; } - bool operator==(const Board& other) const; + bool operator==(Board const& other) const; private: - bool is_legal_no_check(const Move&, Color color) const; - bool is_legal_promotion(const Move&, Color color) const; - bool apply_illegal_move(const Move&, Color color); + bool is_legal_no_check(Move const&, Color color) const; + bool is_legal_promotion(Move const&, Color color) const; + bool apply_illegal_move(Move const&, Color color); Piece m_board[8][8]; Optional<Move> m_last_move; diff --git a/Userland/Libraries/LibChess/UCICommand.h b/Userland/Libraries/LibChess/UCICommand.h index 33415ae8c5..0b5ae607cb 100644 --- a/Userland/Libraries/LibChess/UCICommand.h +++ b/Userland/Libraries/LibChess/UCICommand.h @@ -109,8 +109,8 @@ public: virtual String to_string() const override; - const String& name() const { return m_name; } - const Optional<String>& value() const { return m_value; } + String const& name() const { return m_name; } + Optional<String> const& value() const { return m_value; } private: String m_name; @@ -119,7 +119,7 @@ private: class PositionCommand : public Command { public: - explicit PositionCommand(const Optional<String>& fen, const Vector<Chess::Move>& moves) + explicit PositionCommand(Optional<String> const& fen, Vector<Chess::Move> const& moves) : Command(Command::Type::Position) , m_fen(fen) , m_moves(moves) @@ -130,8 +130,8 @@ public: virtual String to_string() const override; - const Optional<String>& fen() const { return m_fen; } - const Vector<Chess::Move>& moves() const { return m_moves; } + Optional<String> const& fen() const { return m_fen; } + Vector<Chess::Move> const& moves() const { return m_moves; } private: Optional<String> m_fen; @@ -194,7 +194,7 @@ public: virtual String to_string() const override; Type field_type() const { return m_field_type; } - const String& value() const { return m_value; } + String const& value() const { return m_value; } private: Type m_field_type; @@ -227,7 +227,7 @@ public: class BestMoveCommand : public Command { public: - explicit BestMoveCommand(const Chess::Move& move) + explicit BestMoveCommand(Chess::Move const& move) : Command(Command::Type::BestMove) , m_move(move) { diff --git a/Userland/Libraries/LibChess/UCIEndpoint.cpp b/Userland/Libraries/LibChess/UCIEndpoint.cpp index e1ab9d234b..0c8723b9db 100644 --- a/Userland/Libraries/LibChess/UCIEndpoint.cpp +++ b/Userland/Libraries/LibChess/UCIEndpoint.cpp @@ -21,7 +21,7 @@ Endpoint::Endpoint(NonnullRefPtr<Core::IODevice> in, NonnullRefPtr<Core::IODevic set_in_notifier(); } -void Endpoint::send_command(const Command& command) +void Endpoint::send_command(Command const& command) { dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), String(command.to_string().characters(), Chomp)); m_out->write(command.to_string()); @@ -33,27 +33,27 @@ void Endpoint::event(Core::Event& event) case Command::Type::UCI: return handle_uci(); case Command::Type::Debug: - return handle_debug(static_cast<const DebugCommand&>(event)); + return handle_debug(static_cast<DebugCommand const&>(event)); case Command::Type::IsReady: return handle_uci(); case Command::Type::SetOption: - return handle_setoption(static_cast<const SetOptionCommand&>(event)); + return handle_setoption(static_cast<SetOptionCommand const&>(event)); case Command::Type::Position: - return handle_position(static_cast<const PositionCommand&>(event)); + return handle_position(static_cast<PositionCommand const&>(event)); case Command::Type::Go: - return handle_go(static_cast<const GoCommand&>(event)); + return handle_go(static_cast<GoCommand const&>(event)); case Command::Type::Stop: return handle_stop(); case Command::Type::Id: - return handle_id(static_cast<const IdCommand&>(event)); + return handle_id(static_cast<IdCommand const&>(event)); case Command::Type::UCIOk: return handle_uciok(); case Command::Type::ReadyOk: return handle_readyok(); case Command::Type::BestMove: - return handle_bestmove(static_cast<const BestMoveCommand&>(event)); + return handle_bestmove(static_cast<BestMoveCommand const&>(event)); case Command::Type::Info: - return handle_info(static_cast<const InfoCommand&>(event)); + return handle_info(static_cast<InfoCommand const&>(event)); default: break; } diff --git a/Userland/Libraries/LibChess/UCIEndpoint.h b/Userland/Libraries/LibChess/UCIEndpoint.h index f9843ae8cf..8e99ab979d 100644 --- a/Userland/Libraries/LibChess/UCIEndpoint.h +++ b/Userland/Libraries/LibChess/UCIEndpoint.h @@ -19,19 +19,19 @@ public: virtual ~Endpoint() override = default; virtual void handle_uci() { } - virtual void handle_debug(const DebugCommand&) { } + virtual void handle_debug(DebugCommand const&) { } virtual void handle_isready() { } - virtual void handle_setoption(const SetOptionCommand&) { } - virtual void handle_position(const PositionCommand&) { } - virtual void handle_go(const GoCommand&) { } + virtual void handle_setoption(SetOptionCommand const&) { } + virtual void handle_position(PositionCommand const&) { } + virtual void handle_go(GoCommand const&) { } virtual void handle_stop() { } - virtual void handle_id(const IdCommand&) { } + virtual void handle_id(IdCommand const&) { } virtual void handle_uciok() { } virtual void handle_readyok() { } - virtual void handle_bestmove(const BestMoveCommand&) { } - virtual void handle_info(const InfoCommand&) { } + virtual void handle_bestmove(BestMoveCommand const&) { } + virtual void handle_info(InfoCommand const&) { } - void send_command(const Command&); + void send_command(Command const&); virtual void event(Core::Event&) override; diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index a4e0bcedbe..31a2271572 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -16,7 +16,7 @@ namespace Compress { -const CanonicalCode& CanonicalCode::fixed_literal_codes() +CanonicalCode const& CanonicalCode::fixed_literal_codes() { static CanonicalCode code; static bool initialized = false; @@ -30,7 +30,7 @@ const CanonicalCode& CanonicalCode::fixed_literal_codes() return code; } -const CanonicalCode& CanonicalCode::fixed_distance_codes() +CanonicalCode const& CanonicalCode::fixed_distance_codes() { static CanonicalCode code; static bool initialized = false; @@ -128,7 +128,7 @@ bool DeflateDecompressor::CompressedBlock::try_read_more() if (m_eof == true) return false; - const auto symbol = m_literal_codes.read_symbol(m_decompressor.m_input_stream); + auto const symbol = m_literal_codes.read_symbol(m_decompressor.m_input_stream); if (symbol >= 286) { // invalid deflate literal/length symbol m_decompressor.set_fatal_error(); @@ -147,13 +147,13 @@ bool DeflateDecompressor::CompressedBlock::try_read_more() return false; } - const auto length = m_decompressor.decode_length(symbol); - const auto distance_symbol = m_distance_codes.value().read_symbol(m_decompressor.m_input_stream); + auto const length = m_decompressor.decode_length(symbol); + auto const distance_symbol = m_distance_codes.value().read_symbol(m_decompressor.m_input_stream); if (distance_symbol >= 30) { // invalid deflate distance symbol m_decompressor.set_fatal_error(); return false; } - const auto distance = m_decompressor.decode_distance(distance_symbol); + auto const distance = m_decompressor.decode_distance(distance_symbol); for (size_t idx = 0; idx < length; ++idx) { u8 byte = 0; @@ -180,7 +180,7 @@ bool DeflateDecompressor::UncompressedBlock::try_read_more() if (m_bytes_remaining == 0) return false; - const auto nread = min(m_bytes_remaining, m_decompressor.m_output_stream.remaining_contiguous_space()); + auto const nread = min(m_bytes_remaining, m_decompressor.m_output_stream.remaining_contiguous_space()); m_bytes_remaining -= nread; m_decompressor.m_input_stream >> m_decompressor.m_output_stream.reserve_contiguous_space(nread); @@ -215,7 +215,7 @@ size_t DeflateDecompressor::read(Bytes bytes) break; m_read_final_bock = m_input_stream.read_bit(); - const auto block_type = m_input_stream.read_bits(2); + auto const block_type = m_input_stream.read_bits(2); if (m_input_stream.has_any_error()) { set_fatal_error(); @@ -363,7 +363,7 @@ Optional<ByteBuffer> DeflateDecompressor::decompress_all(ReadonlyBytes bytes) u8 buffer[4096]; while (!deflate_stream.has_any_error() && !deflate_stream.unreliable_eof()) { - const auto nread = deflate_stream.read({ buffer, sizeof(buffer) }); + auto const nread = deflate_stream.read({ buffer, sizeof(buffer) }); output_stream.write_or_error({ buffer, nread }); } @@ -428,7 +428,7 @@ void DeflateDecompressor::decode_codes(CanonicalCode& literal_code, Optional<Can set_fatal_error(); return; } - const auto code_length_code = code_length_code_result.value(); + auto const code_length_code = code_length_code_result.value(); // Next we extract the code lengths of the code that was used to encode the block. @@ -544,7 +544,7 @@ bool DeflateCompressor::write_or_error(ReadonlyBytes bytes) } // Knuth's multiplicative hash on 4 bytes -u16 DeflateCompressor::hash_sequence(const u8* bytes) +u16 DeflateCompressor::hash_sequence(u8 const* bytes) { constexpr const u32 knuth_constant = 2654435761; // shares no common factors with 2^32 return ((bytes[0] | bytes[1] << 8 | bytes[2] << 16 | bytes[3] << 24) * knuth_constant) >> (32 - hash_bits); @@ -617,7 +617,7 @@ ALWAYS_INLINE u8 DeflateCompressor::distance_to_base(u16 distance) } template<size_t Size> -void DeflateCompressor::generate_huffman_lengths(Array<u8, Size>& lengths, const Array<u16, Size>& frequencies, size_t max_bit_length, u16 frequency_cap) +void DeflateCompressor::generate_huffman_lengths(Array<u8, Size>& lengths, Array<u16, Size> const& frequencies, size_t max_bit_length, u16 frequency_cap) { VERIFY((1u << max_bit_length) >= Size); u16 heap_keys[Size]; // Used for O(n) heap construction @@ -773,7 +773,7 @@ void DeflateCompressor::lz77_compress_block() } } -size_t DeflateCompressor::huffman_block_length(const Array<u8, max_huffman_literals>& literal_bit_lengths, const Array<u8, max_huffman_distances>& distance_bit_lengths) +size_t DeflateCompressor::huffman_block_length(Array<u8, max_huffman_literals> const& literal_bit_lengths, Array<u8, max_huffman_distances> const& distance_bit_lengths) { size_t length = 0; @@ -807,7 +807,7 @@ size_t DeflateCompressor::fixed_block_length() return 3 + huffman_block_length(fixed_literal_bit_lengths, fixed_distance_bit_lengths); } -size_t DeflateCompressor::dynamic_block_length(const Array<u8, max_huffman_literals>& literal_bit_lengths, const Array<u8, max_huffman_distances>& distance_bit_lengths, const Array<u8, 19>& code_lengths_bit_lengths, const Array<u16, 19>& code_lengths_frequencies, size_t code_lengths_count) +size_t DeflateCompressor::dynamic_block_length(Array<u8, max_huffman_literals> const& literal_bit_lengths, Array<u8, max_huffman_distances> const& distance_bit_lengths, Array<u8, 19> const& code_lengths_bit_lengths, Array<u16, 19> const& code_lengths_frequencies, size_t code_lengths_count) { // block header + literal code count + distance code count + code length count auto length = 3 + 5 + 5 + 4; @@ -831,7 +831,7 @@ size_t DeflateCompressor::dynamic_block_length(const Array<u8, max_huffman_liter return length + huffman_block_length(literal_bit_lengths, distance_bit_lengths); } -void DeflateCompressor::write_huffman(const CanonicalCode& literal_code, const Optional<CanonicalCode>& distance_code) +void DeflateCompressor::write_huffman(CanonicalCode const& literal_code, Optional<CanonicalCode> const& distance_code) { auto has_distances = distance_code.has_value(); for (size_t i = 0; i < m_pending_symbol_size; i++) { @@ -852,7 +852,7 @@ void DeflateCompressor::write_huffman(const CanonicalCode& literal_code, const O } } -size_t DeflateCompressor::encode_huffman_lengths(const Array<u8, max_huffman_literals + max_huffman_distances>& lengths, size_t lengths_count, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths) +size_t DeflateCompressor::encode_huffman_lengths(Array<u8, max_huffman_literals + max_huffman_distances> const& lengths, size_t lengths_count, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths) { size_t encoded_count = 0; size_t i = 0; @@ -895,7 +895,7 @@ size_t DeflateCompressor::encode_huffman_lengths(const Array<u8, max_huffman_lit return encoded_count; } -size_t DeflateCompressor::encode_block_lengths(const Array<u8, max_huffman_literals>& literal_bit_lengths, const Array<u8, max_huffman_distances>& distance_bit_lengths, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths, size_t& literal_code_count, size_t& distance_code_count) +size_t DeflateCompressor::encode_block_lengths(Array<u8, max_huffman_literals> const& literal_bit_lengths, Array<u8, max_huffman_distances> const& distance_bit_lengths, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths, size_t& literal_code_count, size_t& distance_code_count) { literal_code_count = max_huffman_literals; distance_code_count = max_huffman_distances; @@ -920,7 +920,7 @@ size_t DeflateCompressor::encode_block_lengths(const Array<u8, max_huffman_liter return encode_huffman_lengths(all_lengths, lengths_count, encoded_lengths); } -void DeflateCompressor::write_dynamic_huffman(const CanonicalCode& literal_code, size_t literal_code_count, const Optional<CanonicalCode>& distance_code, size_t distance_code_count, const Array<u8, 19>& code_lengths_bit_lengths, size_t code_length_count, const Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths, size_t encoded_lengths_count) +void DeflateCompressor::write_dynamic_huffman(CanonicalCode const& literal_code, size_t literal_code_count, Optional<CanonicalCode> const& distance_code, size_t distance_code_count, Array<u8, 19> const& code_lengths_bit_lengths, size_t code_length_count, Array<code_length_symbol, max_huffman_literals + max_huffman_distances> const& encoded_lengths, size_t encoded_lengths_count) { m_output_stream.write_bits(literal_code_count - 257, 5); m_output_stream.write_bits(distance_code_count - 1, 5); diff --git a/Userland/Libraries/LibCompress/Deflate.h b/Userland/Libraries/LibCompress/Deflate.h index 9d9b51de8b..85e5a811dd 100644 --- a/Userland/Libraries/LibCompress/Deflate.h +++ b/Userland/Libraries/LibCompress/Deflate.h @@ -22,8 +22,8 @@ public: u32 read_symbol(InputBitStream&) const; void write_symbol(OutputBitStream&, u32) const; - static const CanonicalCode& fixed_literal_codes(); - static const CanonicalCode& fixed_distance_codes(); + static CanonicalCode const& fixed_literal_codes(); + static CanonicalCode const& fixed_distance_codes(); static Optional<CanonicalCode> from_bytes(ReadonlyBytes); @@ -157,7 +157,7 @@ private: Bytes pending_block() { return { m_rolling_window + block_size, block_size }; } // LZ77 Compression - static u16 hash_sequence(const u8* bytes); + static u16 hash_sequence(u8 const* bytes); size_t compare_match_candidate(size_t start, size_t candidate, size_t prev_match_length, size_t max_match_length); size_t find_back_match(size_t start, u16 hash, size_t previous_match_length, size_t max_match_length, size_t& match_position); void lz77_compress_block(); @@ -169,16 +169,16 @@ private: }; static u8 distance_to_base(u16 distance); template<size_t Size> - static void generate_huffman_lengths(Array<u8, Size>& lengths, const Array<u16, Size>& frequencies, size_t max_bit_length, u16 frequency_cap = UINT16_MAX); - size_t huffman_block_length(const Array<u8, max_huffman_literals>& literal_bit_lengths, const Array<u8, max_huffman_distances>& distance_bit_lengths); - void write_huffman(const CanonicalCode& literal_code, const Optional<CanonicalCode>& distance_code); - static size_t encode_huffman_lengths(const Array<u8, max_huffman_literals + max_huffman_distances>& lengths, size_t lengths_count, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths); - size_t encode_block_lengths(const Array<u8, max_huffman_literals>& literal_bit_lengths, const Array<u8, max_huffman_distances>& distance_bit_lengths, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths, size_t& literal_code_count, size_t& distance_code_count); - void write_dynamic_huffman(const CanonicalCode& literal_code, size_t literal_code_count, const Optional<CanonicalCode>& distance_code, size_t distance_code_count, const Array<u8, 19>& code_lengths_bit_lengths, size_t code_length_count, const Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths, size_t encoded_lengths_count); + static void generate_huffman_lengths(Array<u8, Size>& lengths, Array<u16, Size> const& frequencies, size_t max_bit_length, u16 frequency_cap = UINT16_MAX); + size_t huffman_block_length(Array<u8, max_huffman_literals> const& literal_bit_lengths, Array<u8, max_huffman_distances> const& distance_bit_lengths); + void write_huffman(CanonicalCode const& literal_code, Optional<CanonicalCode> const& distance_code); + static size_t encode_huffman_lengths(Array<u8, max_huffman_literals + max_huffman_distances> const& lengths, size_t lengths_count, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths); + size_t encode_block_lengths(Array<u8, max_huffman_literals> const& literal_bit_lengths, Array<u8, max_huffman_distances> const& distance_bit_lengths, Array<code_length_symbol, max_huffman_literals + max_huffman_distances>& encoded_lengths, size_t& literal_code_count, size_t& distance_code_count); + void write_dynamic_huffman(CanonicalCode const& literal_code, size_t literal_code_count, Optional<CanonicalCode> const& distance_code, size_t distance_code_count, Array<u8, 19> const& code_lengths_bit_lengths, size_t code_length_count, Array<code_length_symbol, max_huffman_literals + max_huffman_distances> const& encoded_lengths, size_t encoded_lengths_count); size_t uncompressed_block_length(); size_t fixed_block_length(); - size_t dynamic_block_length(const Array<u8, max_huffman_literals>& literal_bit_lengths, const Array<u8, max_huffman_distances>& distance_bit_lengths, const Array<u8, 19>& code_lengths_bit_lengths, const Array<u16, 19>& code_lengths_frequencies, size_t code_lengths_count); + size_t dynamic_block_length(Array<u8, max_huffman_literals> const& literal_bit_lengths, Array<u8, max_huffman_distances> const& distance_bit_lengths, Array<u8, 19> const& code_lengths_bit_lengths, Array<u16, 19> const& code_lengths_frequencies, size_t code_lengths_count); void flush(); bool m_finished { false }; diff --git a/Userland/Libraries/LibCompress/Gzip.cpp b/Userland/Libraries/LibCompress/Gzip.cpp index f93554d272..924bb7bc9b 100644 --- a/Userland/Libraries/LibCompress/Gzip.cpp +++ b/Userland/Libraries/LibCompress/Gzip.cpp @@ -159,11 +159,11 @@ Optional<String> GzipDecompressor::describe_header(ReadonlyBytes bytes) if (bytes.size() < sizeof(BlockHeader)) return {}; - auto& header = *(reinterpret_cast<const BlockHeader*>(bytes.data())); + auto& header = *(reinterpret_cast<BlockHeader const*>(bytes.data())); if (!header.valid_magic_number() || !header.supported_by_implementation()) return {}; - LittleEndian<u32> original_size = *reinterpret_cast<const u32*>(bytes.offset(bytes.size() - sizeof(u32))); + LittleEndian<u32> original_size = *reinterpret_cast<u32 const*>(bytes.offset(bytes.size() - sizeof(u32))); return String::formatted("last modified: {}, original size {}", Core::DateTime::from_timestamp(header.modification_time).to_string(), (u32)original_size); } @@ -202,7 +202,7 @@ Optional<ByteBuffer> GzipDecompressor::decompress_all(ReadonlyBytes bytes) u8 buffer[4096]; while (!gzip_stream.has_any_error() && !gzip_stream.unreliable_eof()) { - const auto nread = gzip_stream.read({ buffer, sizeof(buffer) }); + auto const nread = gzip_stream.read({ buffer, sizeof(buffer) }); output_stream.write_or_error({ buffer, nread }); } diff --git a/Userland/Libraries/LibCompress/Gzip.h b/Userland/Libraries/LibCompress/Gzip.h index e25b6b0813..c043bcadc4 100644 --- a/Userland/Libraries/LibCompress/Gzip.h +++ b/Userland/Libraries/LibCompress/Gzip.h @@ -68,7 +68,7 @@ private: size_t m_nread { 0 }; }; - const Member& current_member() const { return m_current_member.value(); } + Member const& current_member() const { return m_current_member.value(); } Member& current_member() { return m_current_member.value(); } InputStream& m_input_stream; diff --git a/Userland/Libraries/LibConfig/Client.cpp b/Userland/Libraries/LibConfig/Client.cpp index 7b821523dc..2ad0afcc1d 100644 --- a/Userland/Libraries/LibConfig/Client.cpp +++ b/Userland/Libraries/LibConfig/Client.cpp @@ -96,7 +96,7 @@ void Client::notify_changed_bool_value(String const& domain, String const& group }); } -void Client::notify_removed_key(const String& domain, const String& group, const String& key) +void Client::notify_removed_key(String const& domain, String const& group, String const& key) { Listener::for_each([&](auto& listener) { listener.config_key_was_removed(domain, group, key); diff --git a/Userland/Libraries/LibCore/Account.cpp b/Userland/Libraries/LibCore/Account.cpp index 5d935c7b3a..12e22d3b82 100644 --- a/Userland/Libraries/LibCore/Account.cpp +++ b/Userland/Libraries/LibCore/Account.cpp @@ -38,7 +38,7 @@ static String get_salt() return builder.build(); } -static Vector<gid_t> get_extra_gids(const passwd& pwd) +static Vector<gid_t> get_extra_gids(passwd const& pwd) { StringView username { pwd.pw_name }; Vector<gid_t> extra_gids; @@ -57,7 +57,7 @@ static Vector<gid_t> get_extra_gids(const passwd& pwd) return extra_gids; } -ErrorOr<Account> Account::from_passwd(const passwd& pwd, const spwd& spwd) +ErrorOr<Account> Account::from_passwd(passwd const& pwd, spwd const& spwd) { Account account(pwd, spwd, get_extra_gids(pwd)); endpwent(); @@ -88,7 +88,7 @@ ErrorOr<Account> Account::self([[maybe_unused]] Read options) return Account(*pwd, spwd, extra_gids); } -ErrorOr<Account> Account::from_name(const char* username, [[maybe_unused]] Read options) +ErrorOr<Account> Account::from_name(char const* username, [[maybe_unused]] Read options) { auto pwd = TRY(Core::System::getpwnam(username)); if (!pwd.has_value()) @@ -175,7 +175,7 @@ void Account::delete_password() m_password_hash = ""; } -Account::Account(const passwd& pwd, const spwd& spwd, Vector<gid_t> extra_gids) +Account::Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids) : m_username(pwd.pw_name) , m_password_hash(spwd.sp_pwdp) , m_uid(pwd.pw_uid) diff --git a/Userland/Libraries/LibCore/Account.h b/Userland/Libraries/LibCore/Account.h index decf46ede0..5cbd7253ec 100644 --- a/Userland/Libraries/LibCore/Account.h +++ b/Userland/Libraries/LibCore/Account.h @@ -46,11 +46,11 @@ public: // You must call sync to apply changes. void set_password(SecretString const& password); void set_password_enabled(bool enabled); - void set_home_directory(const char* home_directory) { m_home_directory = home_directory; } + void set_home_directory(char const* home_directory) { m_home_directory = home_directory; } void set_uid(uid_t uid) { m_uid = uid; } void set_gid(gid_t gid) { m_gid = gid; } - void set_shell(const char* shell) { m_shell = shell; } - void set_gecos(const char* gecos) { m_gecos = gecos; } + void set_shell(char const* shell) { m_shell = shell; } + void set_gecos(char const* gecos) { m_gecos = gecos; } void delete_password(); // A null password means that this account was missing from /etc/shadow. @@ -59,17 +59,17 @@ public: uid_t uid() const { return m_uid; } gid_t gid() const { return m_gid; } - const String& gecos() const { return m_gecos; } - const String& home_directory() const { return m_home_directory; } - const String& shell() const { return m_shell; } - const Vector<gid_t>& extra_gids() const { return m_extra_gids; } + String const& gecos() const { return m_gecos; } + String const& home_directory() const { return m_home_directory; } + String const& shell() const { return m_shell; } + Vector<gid_t> const& extra_gids() const { return m_extra_gids; } ErrorOr<void> sync(); private: static ErrorOr<Account> from_passwd(passwd const&, spwd const&); - Account(const passwd& pwd, const spwd& spwd, Vector<gid_t> extra_gids); + Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids); ErrorOr<String> generate_passwd_file() const; #ifndef AK_OS_BSD_GENERIC diff --git a/Userland/Libraries/LibCore/AnonymousBuffer.h b/Userland/Libraries/LibCore/AnonymousBuffer.h index 895bfec464..a0fd5bc76d 100644 --- a/Userland/Libraries/LibCore/AnonymousBuffer.h +++ b/Userland/Libraries/LibCore/AnonymousBuffer.h @@ -24,7 +24,7 @@ public: int fd() const { return m_fd; } size_t size() const { return m_size; } void* data() { return m_data; } - const void* data() const { return m_data; } + void const* data() const { return m_data; } private: AnonymousBufferImpl(int fd, size_t, void*); @@ -74,7 +74,7 @@ private: namespace IPC { -bool encode(Encoder&, const Core::AnonymousBuffer&); +bool encode(Encoder&, Core::AnonymousBuffer const&); ErrorOr<void> decode(Decoder&, Core::AnonymousBuffer&); } diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index a339b8a0bd..ced9d32548 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -16,7 +16,7 @@ #include <stdio.h> #include <string.h> -static Optional<double> convert_to_double(const char* s) +static Optional<double> convert_to_double(char const* s) { char* p; double v = strtod(s, &p); @@ -103,7 +103,7 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha } VERIFY(found_option); - const char* arg = found_option->requires_argument ? optarg : nullptr; + char const* arg = found_option->requires_argument ? optarg : nullptr; if (!found_option->accept_value(arg)) { warnln("\033[31mInvalid value for option \033[1m{}\033[22m\033[0m", found_option->name_for_display()); fail(); @@ -171,7 +171,7 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha for (size_t i = 0; i < m_positional_args.size(); i++) { auto& arg = m_positional_args[i]; for (int j = 0; j < num_values_for_arg[i]; j++) { - const char* value = argv[optind++]; + char const* value = argv[optind++]; if (!arg.accept_value(value)) { warnln("Invalid value for argument {}", arg.name); fail(); @@ -183,7 +183,7 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha return true; } -void ArgsParser::print_usage(FILE* file, const char* argv0) +void ArgsParser::print_usage(FILE* file, char const* argv0) { char const* env_preference = getenv("ARGSPARSER_EMIT_MARKDOWN"); if (env_preference != nullptr && env_preference[0] == '1' && env_preference[1] == 0) { @@ -193,7 +193,7 @@ void ArgsParser::print_usage(FILE* file, const char* argv0) } } -void ArgsParser::print_usage_terminal(FILE* file, const char* argv0) +void ArgsParser::print_usage_terminal(FILE* file, char const* argv0) { out(file, "Usage:\n\t\033[1m{}\033[0m", argv0); @@ -264,7 +264,7 @@ void ArgsParser::print_usage_terminal(FILE* file, const char* argv0) } } -void ArgsParser::print_usage_markdown(FILE* file, const char* argv0) +void ArgsParser::print_usage_markdown(FILE* file, char const* argv0) { outln(file, "## Name\n\n{}", argv0); @@ -347,7 +347,7 @@ void ArgsParser::add_option(Option&& option) m_options.append(move(option)); } -void ArgsParser::add_ignored(const char* long_name, char short_name, bool hidden) +void ArgsParser::add_ignored(char const* long_name, char short_name, bool hidden) { Option option { false, @@ -355,7 +355,7 @@ void ArgsParser::add_ignored(const char* long_name, char short_name, bool hidden long_name, short_name, nullptr, - [](const char*) { + [](char const*) { return true; }, hidden, @@ -363,7 +363,7 @@ void ArgsParser::add_ignored(const char* long_name, char short_name, bool hidden add_option(move(option)); } -void ArgsParser::add_option(bool& value, const char* help_string, const char* long_name, char short_name, bool hidden) +void ArgsParser::add_option(bool& value, char const* help_string, char const* long_name, char short_name, bool hidden) { Option option { false, @@ -371,7 +371,7 @@ void ArgsParser::add_option(bool& value, const char* help_string, const char* lo long_name, short_name, nullptr, - [&value](const char* s) { + [&value](char const* s) { VERIFY(s == nullptr); value = true; return true; @@ -381,7 +381,7 @@ void ArgsParser::add_option(bool& value, const char* help_string, const char* lo add_option(move(option)); } -void ArgsParser::add_option(const char*& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(char const*& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -389,7 +389,7 @@ void ArgsParser::add_option(const char*& value, const char* help_string, const c long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { value = s; return true; }, @@ -398,7 +398,7 @@ void ArgsParser::add_option(const char*& value, const char* help_string, const c add_option(move(option)); } -void ArgsParser::add_option(String& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(String& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -406,7 +406,7 @@ void ArgsParser::add_option(String& value, const char* help_string, const char* long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { value = s; return true; }, @@ -423,7 +423,7 @@ void ArgsParser::add_option(StringView& value, char const* help_string, char con long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { value = s; return true; }, @@ -432,7 +432,7 @@ void ArgsParser::add_option(StringView& value, char const* help_string, char con add_option(move(option)); } -void ArgsParser::add_option(int& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(int& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -440,7 +440,7 @@ void ArgsParser::add_option(int& value, const char* help_string, const char* lon long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { auto opt = StringView(s).to_int(); value = opt.value_or(0); return opt.has_value(); @@ -450,7 +450,7 @@ void ArgsParser::add_option(int& value, const char* help_string, const char* lon add_option(move(option)); } -void ArgsParser::add_option(unsigned& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(unsigned& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -458,7 +458,7 @@ void ArgsParser::add_option(unsigned& value, const char* help_string, const char long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { auto opt = StringView(s).to_uint(); value = opt.value_or(0); return opt.has_value(); @@ -468,7 +468,7 @@ void ArgsParser::add_option(unsigned& value, const char* help_string, const char add_option(move(option)); } -void ArgsParser::add_option(double& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(double& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -476,7 +476,7 @@ void ArgsParser::add_option(double& value, const char* help_string, const char* long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { auto opt = convert_to_double(s); value = opt.value_or(0.0); return opt.has_value(); @@ -486,7 +486,7 @@ void ArgsParser::add_option(double& value, const char* help_string, const char* add_option(move(option)); } -void ArgsParser::add_option(Optional<double>& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(Optional<double>& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -494,7 +494,7 @@ void ArgsParser::add_option(Optional<double>& value, const char* help_string, co long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { value = convert_to_double(s); return value.has_value(); }, @@ -503,7 +503,7 @@ void ArgsParser::add_option(Optional<double>& value, const char* help_string, co add_option(move(option)); } -void ArgsParser::add_option(Optional<size_t>& value, const char* help_string, const char* long_name, char short_name, const char* value_name, bool hidden) +void ArgsParser::add_option(Optional<size_t>& value, char const* help_string, char const* long_name, char short_name, char const* value_name, bool hidden) { Option option { true, @@ -511,7 +511,7 @@ void ArgsParser::add_option(Optional<size_t>& value, const char* help_string, co long_name, short_name, value_name, - [&value](const char* s) { + [&value](char const* s) { value = AK::StringUtils::convert_to_uint<size_t>(s); return value.has_value(); }, @@ -551,14 +551,14 @@ void ArgsParser::add_positional_argument(Arg&& arg) m_positional_args.append(move(arg)); } -void ArgsParser::add_positional_argument(const char*& value, const char* help_string, const char* name, Required required) +void ArgsParser::add_positional_argument(char const*& value, char const* help_string, char const* name, Required required) { Arg arg { help_string, name, required == Required::Yes ? 1 : 0, 1, - [&value](const char* s) { + [&value](char const* s) { value = s; return true; } @@ -566,14 +566,14 @@ void ArgsParser::add_positional_argument(const char*& value, const char* help_st add_positional_argument(move(arg)); } -void ArgsParser::add_positional_argument(String& value, const char* help_string, const char* name, Required required) +void ArgsParser::add_positional_argument(String& value, char const* help_string, char const* name, Required required) { Arg arg { help_string, name, required == Required::Yes ? 1 : 0, 1, - [&value](const char* s) { + [&value](char const* s) { value = s; return true; } @@ -588,7 +588,7 @@ void ArgsParser::add_positional_argument(StringView& value, char const* help_str name, required == Required::Yes ? 1 : 0, 1, - [&value](const char* s) { + [&value](char const* s) { value = s; return true; } @@ -596,14 +596,14 @@ void ArgsParser::add_positional_argument(StringView& value, char const* help_str add_positional_argument(move(arg)); } -void ArgsParser::add_positional_argument(int& value, const char* help_string, const char* name, Required required) +void ArgsParser::add_positional_argument(int& value, char const* help_string, char const* name, Required required) { Arg arg { help_string, name, required == Required::Yes ? 1 : 0, 1, - [&value](const char* s) { + [&value](char const* s) { auto opt = StringView(s).to_int(); value = opt.value_or(0); return opt.has_value(); @@ -612,14 +612,14 @@ void ArgsParser::add_positional_argument(int& value, const char* help_string, co add_positional_argument(move(arg)); } -void ArgsParser::add_positional_argument(unsigned& value, const char* help_string, const char* name, Required required) +void ArgsParser::add_positional_argument(unsigned& value, char const* help_string, char const* name, Required required) { Arg arg { help_string, name, required == Required::Yes ? 1 : 0, 1, - [&value](const char* s) { + [&value](char const* s) { auto opt = StringView(s).to_uint(); value = opt.value_or(0); return opt.has_value(); @@ -628,14 +628,14 @@ void ArgsParser::add_positional_argument(unsigned& value, const char* help_strin add_positional_argument(move(arg)); } -void ArgsParser::add_positional_argument(double& value, const char* help_string, const char* name, Required required) +void ArgsParser::add_positional_argument(double& value, char const* help_string, char const* name, Required required) { Arg arg { help_string, name, required == Required::Yes ? 1 : 0, 1, - [&value](const char* s) { + [&value](char const* s) { auto opt = convert_to_double(s); value = opt.value_or(0.0); return opt.has_value(); @@ -644,14 +644,14 @@ void ArgsParser::add_positional_argument(double& value, const char* help_string, add_positional_argument(move(arg)); } -void ArgsParser::add_positional_argument(Vector<const char*>& values, const char* help_string, const char* name, Required required) +void ArgsParser::add_positional_argument(Vector<char const*>& values, char const* help_string, char const* name, Required required) { Arg arg { help_string, name, required == Required::Yes ? 1 : 0, INT_MAX, - [&values](const char* s) { + [&values](char const* s) { values.append(s); return true; } diff --git a/Userland/Libraries/LibCore/Command.cpp b/Userland/Libraries/LibCore/Command.cpp index 25e48425a6..ab6ea80bef 100644 --- a/Userland/Libraries/LibCore/Command.cpp +++ b/Userland/Libraries/LibCore/Command.cpp @@ -46,13 +46,13 @@ ErrorOr<CommandResult> command(String const& program, Vector<String> const& argu close(stderr_pipe[0]); }); - Vector<const char*> parts = { program.characters() }; - for (const auto& part : arguments) { + Vector<char const*> parts = { program.characters() }; + for (auto const& part : arguments) { parts.append(part.characters()); } parts.append(nullptr); - const char** argv = parts.data(); + char const** argv = parts.data(); posix_spawn_file_actions_t action; posix_spawn_file_actions_init(&action); diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index 50d4153c11..41c1b7f78c 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -89,7 +89,7 @@ String DateTime::to_string(StringView format) const struct tm tm; localtime_r(&m_timestamp, &tm); StringBuilder builder; - const int format_len = format.length(); + int const format_len = format.length(); auto format_time_zone_offset = [&](bool with_separator) { #if defined(__serenity__) @@ -190,20 +190,20 @@ String DateTime::to_string(StringView format) const builder.appendff("{}", tm.tm_wday ? tm.tm_wday : 7); break; case 'U': { - const int wday_of_year_beginning = (tm.tm_wday + 6 * tm.tm_yday) % 7; - const int week_number = (tm.tm_yday + wday_of_year_beginning) / 7; + int const wday_of_year_beginning = (tm.tm_wday + 6 * tm.tm_yday) % 7; + int const week_number = (tm.tm_yday + wday_of_year_beginning) / 7; builder.appendff("{:02}", week_number); break; } case 'V': { - const int wday_of_year_beginning = (tm.tm_wday + 6 + 6 * tm.tm_yday) % 7; + int const wday_of_year_beginning = (tm.tm_wday + 6 + 6 * tm.tm_yday) % 7; int week_number = (tm.tm_yday + wday_of_year_beginning) / 7 + 1; if (wday_of_year_beginning > 3) { if (tm.tm_yday >= 7 - wday_of_year_beginning) --week_number; else { - const int days_of_last_year = days_in_year(tm.tm_year + 1900 - 1); - const int wday_of_last_year_beginning = (wday_of_year_beginning + 6 * days_of_last_year) % 7; + int const days_of_last_year = days_in_year(tm.tm_year + 1900 - 1); + int const wday_of_last_year_beginning = (wday_of_year_beginning + 6 * days_of_last_year) % 7; week_number = (days_of_last_year + wday_of_last_year_beginning) / 7 + 1; if (wday_of_last_year_beginning > 3) --week_number; @@ -216,8 +216,8 @@ String DateTime::to_string(StringView format) const builder.appendff("{}", tm.tm_wday); break; case 'W': { - const int wday_of_year_beginning = (tm.tm_wday + 6 + 6 * tm.tm_yday) % 7; - const int week_number = (tm.tm_yday + wday_of_year_beginning) / 7; + int const wday_of_year_beginning = (tm.tm_wday + 6 + 6 * tm.tm_yday) % 7; + int const week_number = (tm.tm_yday + wday_of_year_beginning) / 7; builder.appendff("{:02}", week_number); break; } @@ -253,7 +253,7 @@ String DateTime::to_string(StringView format) const return builder.build(); } -Optional<DateTime> DateTime::parse(StringView format, const String& string) +Optional<DateTime> DateTime::parse(StringView format, String const& string) { unsigned format_pos = 0; unsigned string_pos = 0; diff --git a/Userland/Libraries/LibCore/DateTime.h b/Userland/Libraries/LibCore/DateTime.h index 41d8a1ad72..f8c35f133d 100644 --- a/Userland/Libraries/LibCore/DateTime.h +++ b/Userland/Libraries/LibCore/DateTime.h @@ -36,9 +36,9 @@ public: static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0); static DateTime now(); static DateTime from_timestamp(time_t); - static Optional<DateTime> parse(StringView format, const String& string); + static Optional<DateTime> parse(StringView format, String const& string); - bool operator<(const DateTime& other) const { return m_timestamp < other.m_timestamp; } + bool operator<(DateTime const& other) const { return m_timestamp < other.m_timestamp; } private: time_t m_timestamp { 0 }; @@ -54,7 +54,7 @@ private: namespace IPC { -bool encode(IPC::Encoder&, const Core::DateTime&); +bool encode(IPC::Encoder&, Core::DateTime const&); ErrorOr<void> decode(IPC::Decoder&, Core::DateTime&); } diff --git a/Userland/Libraries/LibCore/DirIterator.h b/Userland/Libraries/LibCore/DirIterator.h index 6fca1ae502..3fdd3d613c 100644 --- a/Userland/Libraries/LibCore/DirIterator.h +++ b/Userland/Libraries/LibCore/DirIterator.h @@ -28,7 +28,7 @@ public: bool has_error() const { return m_error != 0; } int error() const { return m_error; } - const char* error_string() const { return strerror(m_error); } + char const* error_string() const { return strerror(m_error); } bool has_next(); String next_path(); String next_full_path(); diff --git a/Userland/Libraries/LibCore/Event.cpp b/Userland/Libraries/LibCore/Event.cpp index 37cc05d95c..6faee840f1 100644 --- a/Userland/Libraries/LibCore/Event.cpp +++ b/Userland/Libraries/LibCore/Event.cpp @@ -25,7 +25,7 @@ Object* ChildEvent::child() return nullptr; } -const Object* ChildEvent::child() const +Object const* ChildEvent::child() const { if (auto ref = m_child.strong_ref()) return ref.ptr(); @@ -39,7 +39,7 @@ Object* ChildEvent::insertion_before_child() return nullptr; } -const Object* ChildEvent::insertion_before_child() const +Object const* ChildEvent::insertion_before_child() const { if (auto ref = m_insertion_before_child.strong_ref()) return ref.ptr(); diff --git a/Userland/Libraries/LibCore/Event.h b/Userland/Libraries/LibCore/Event.h index 164580b0c7..fab8095cd9 100644 --- a/Userland/Libraries/LibCore/Event.h +++ b/Userland/Libraries/LibCore/Event.h @@ -115,10 +115,10 @@ public: ~ChildEvent() = default; Object* child(); - const Object* child() const; + Object const* child() const; Object* insertion_before_child(); - const Object* insertion_before_child() const; + Object const* insertion_before_child() const; private: WeakPtr<Object> m_child; diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index 76ad358f7c..c72784da63 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -53,8 +53,8 @@ struct EventLoopTimer { TimerShouldFireWhenNotVisible fire_when_not_visible { TimerShouldFireWhenNotVisible::No }; WeakPtr<Object> owner; - void reload(const Time& now); - bool has_expired(const Time& now) const; + void reload(Time const& now); + bool has_expired(Time const& now) const; }; struct EventLoop::Private { @@ -208,16 +208,16 @@ private: } public: - void send_response(const JsonObject& response) + void send_response(JsonObject const& response) { auto serialized = response.to_string(); u32 length = serialized.length(); // FIXME: Propagate errors - MUST(m_socket->write({ (const u8*)&length, sizeof(length) })); + MUST(m_socket->write({ (u8 const*)&length, sizeof(length) })); MUST(m_socket->write(serialized.bytes())); } - void handle_request(const JsonObject& request) + void handle_request(JsonObject const& request) { auto type = request.get("type").as_string_or({}); @@ -792,12 +792,12 @@ try_select_again: } } -bool EventLoopTimer::has_expired(const Time& now) const +bool EventLoopTimer::has_expired(Time const& now) const { return now > fire_time; } -void EventLoopTimer::reload(const Time& now) +void EventLoopTimer::reload(Time const& now) { fire_time = now + interval; } diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 811a50dd44..8fcef0e41c 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -152,7 +152,7 @@ bool File::looks_like_shared_library() const return File::looks_like_shared_library(m_filename); } -bool File::looks_like_shared_library(const String& filename) +bool File::looks_like_shared_library(String const& filename) { return filename.ends_with(".so"sv) || filename.contains(".so."sv); } diff --git a/Userland/Libraries/LibCore/FileStream.h b/Userland/Libraries/LibCore/FileStream.h index f8462397d7..13f8a1ffbd 100644 --- a/Userland/Libraries/LibCore/FileStream.h +++ b/Userland/Libraries/LibCore/FileStream.h @@ -40,7 +40,7 @@ public: if (has_any_error()) return 0; - const auto buffer = m_file->read(bytes.size()); + auto const buffer = m_file->read(bytes.size()); return buffer.bytes().copy_to(bytes); } diff --git a/Userland/Libraries/LibCore/IODevice.cpp b/Userland/Libraries/LibCore/IODevice.cpp index a0d792e85e..809a6aab58 100644 --- a/Userland/Libraries/LibCore/IODevice.cpp +++ b/Userland/Libraries/LibCore/IODevice.cpp @@ -22,7 +22,7 @@ IODevice::IODevice(Object* parent) { } -const char* IODevice::error_string() const +char const* IODevice::error_string() const { return strerror(m_error); } @@ -142,7 +142,7 @@ ByteBuffer IODevice::read_all() set_eof(true); break; } - data.append((const u8*)read_buffer, nread); + data.append((u8 const*)read_buffer, nread); } auto result = ByteBuffer::copy(data); @@ -166,7 +166,7 @@ String IODevice::read_line(size_t max_size) dbgln("IODevice::read_line: At EOF but there's more than max_size({}) buffered", max_size); return {}; } - auto line = String((const char*)m_buffered_data.data(), m_buffered_data.size(), Chomp); + auto line = String((char const*)m_buffered_data.data(), m_buffered_data.size(), Chomp); m_buffered_data.clear(); return line; } @@ -272,7 +272,7 @@ bool IODevice::truncate(off_t size) return true; } -bool IODevice::write(const u8* data, int size) +bool IODevice::write(u8 const* data, int size) { int rc = ::write(m_fd, data, size); if (rc < 0) { @@ -294,7 +294,7 @@ void IODevice::set_fd(int fd) bool IODevice::write(StringView v) { - return write((const u8*)v.characters_without_null_termination(), v.length()); + return write((u8 const*)v.characters_without_null_termination(), v.length()); } LineIterator::LineIterator(IODevice& device, bool is_end) diff --git a/Userland/Libraries/LibCore/IODevice.h b/Userland/Libraries/LibCore/IODevice.h index 6fb3255155..d98f4ecc42 100644 --- a/Userland/Libraries/LibCore/IODevice.h +++ b/Userland/Libraries/LibCore/IODevice.h @@ -23,7 +23,7 @@ class LineIterator { public: explicit LineIterator(IODevice&, bool is_end = false); - bool operator==(const LineIterator& other) const { return &other == this || (at_end() && other.is_end()) || (other.at_end() && is_end()); } + bool operator==(LineIterator const& other) const { return &other == this || (at_end() && other.is_end()) || (other.at_end() && is_end()); } bool is_end() const { return m_is_end; } bool at_end() const; @@ -81,7 +81,7 @@ public: bool eof() const { return m_eof; } int error() const { return m_error; } - const char* error_string() const; + char const* error_string() const; bool has_error() const { return m_error != 0; } @@ -91,7 +91,7 @@ public: ByteBuffer read_all(); String read_line(size_t max_size = 16384); - bool write(const u8*, int size); + bool write(u8 const*, int size); bool write(StringView); bool truncate(off_t); diff --git a/Userland/Libraries/LibCore/InputBitStream.h b/Userland/Libraries/LibCore/InputBitStream.h index 573f460dbf..be0c8f9cc7 100644 --- a/Userland/Libraries/LibCore/InputBitStream.h +++ b/Userland/Libraries/LibCore/InputBitStream.h @@ -78,7 +78,7 @@ public: nread += 8; m_current_byte.clear(); } else { - const auto bit = (m_current_byte.value() >> (7 - m_bit_offset)) & 1; + auto const bit = (m_current_byte.value() >> (7 - m_bit_offset)) & 1; result <<= 1; result |= bit; ++nread; @@ -87,7 +87,7 @@ public: } } else { // Always take this branch for booleans or u8: there's no purpose in reading more than a single bit - const auto bit = (m_current_byte.value() >> (7 - m_bit_offset)) & 1; + auto const bit = (m_current_byte.value() >> (7 - m_bit_offset)) & 1; if constexpr (IsSame<bool, T>) result = bit; else { diff --git a/Userland/Libraries/LibCore/LocalServer.cpp b/Userland/Libraries/LibCore/LocalServer.cpp index e1f4ab1a51..9bbd878a83 100644 --- a/Userland/Libraries/LibCore/LocalServer.cpp +++ b/Userland/Libraries/LibCore/LocalServer.cpp @@ -61,7 +61,7 @@ void LocalServer::setup_notifier() }; } -bool LocalServer::listen(const String& address) +bool LocalServer::listen(String const& address) { if (m_listening) return false; @@ -92,7 +92,7 @@ bool LocalServer::listen(const String& address) return false; } auto un = un_optional.value(); - rc = ::bind(m_fd, (const sockaddr*)&un, sizeof(un)); + rc = ::bind(m_fd, (sockaddr const*)&un, sizeof(un)); if (rc < 0) { perror("bind"); return false; diff --git a/Userland/Libraries/LibCore/LocalServer.h b/Userland/Libraries/LibCore/LocalServer.h index 209fb0547b..8554ec5937 100644 --- a/Userland/Libraries/LibCore/LocalServer.h +++ b/Userland/Libraries/LibCore/LocalServer.h @@ -19,7 +19,7 @@ public: ErrorOr<void> take_over_from_system_server(String const& path = String()); bool is_listening() const { return m_listening; } - bool listen(const String& address); + bool listen(String const& address); ErrorOr<NonnullOwnPtr<Stream::LocalSocket>> accept(); diff --git a/Userland/Libraries/LibCore/MappedFile.h b/Userland/Libraries/LibCore/MappedFile.h index 7048caf995..d0fbbbd59c 100644 --- a/Userland/Libraries/LibCore/MappedFile.h +++ b/Userland/Libraries/LibCore/MappedFile.h @@ -24,7 +24,7 @@ public: ~MappedFile(); void* data() { return m_data; } - const void* data() const { return m_data; } + void const* data() const { return m_data; } size_t size() const { return m_size; } diff --git a/Userland/Libraries/LibCore/MemoryStream.h b/Userland/Libraries/LibCore/MemoryStream.h index 5eeb066acf..465da44f9f 100644 --- a/Userland/Libraries/LibCore/MemoryStream.h +++ b/Userland/Libraries/LibCore/MemoryStream.h @@ -68,7 +68,7 @@ public: virtual ErrorOr<size_t> write(ReadonlyBytes bytes) override { // FIXME: Can this not error? - 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; } diff --git a/Userland/Libraries/LibCore/MimeData.cpp b/Userland/Libraries/LibCore/MimeData.cpp index 6e57cee162..ae94d041f9 100644 --- a/Userland/Libraries/LibCore/MimeData.cpp +++ b/Userland/Libraries/LibCore/MimeData.cpp @@ -31,7 +31,7 @@ Vector<URL> MimeData::urls() const return urls; } -void MimeData::set_urls(const Vector<URL>& urls) +void MimeData::set_urls(Vector<URL> const& urls) { StringBuilder builder; for (auto& url : urls) { @@ -46,7 +46,7 @@ String MimeData::text() const return String::copy(m_data.get("text/plain").value_or({})); } -void MimeData::set_text(const String& text) +void MimeData::set_text(String const& text) { set_data("text/plain", text.to_byte_buffer()); } diff --git a/Userland/Libraries/LibCore/MimeData.h b/Userland/Libraries/LibCore/MimeData.h index d3f6b05df8..f94d6b61c9 100644 --- a/Userland/Libraries/LibCore/MimeData.h +++ b/Userland/Libraries/LibCore/MimeData.h @@ -20,27 +20,27 @@ class MimeData : public Object { public: virtual ~MimeData() = default; - ByteBuffer data(const String& mime_type) const { return m_data.get(mime_type).value_or({}); } - void set_data(const String& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); } + ByteBuffer data(String const& mime_type) const { return m_data.get(mime_type).value_or({}); } + void set_data(String const& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); } - bool has_format(const String& mime_type) const { return m_data.contains(mime_type); } + bool has_format(String const& mime_type) const { return m_data.contains(mime_type); } Vector<String> formats() const; // Convenience helpers for "text/plain" bool has_text() const { return has_format("text/plain"); } String text() const; - void set_text(const String&); + void set_text(String const&); // Convenience helpers for "text/uri-list" bool has_urls() const { return has_format("text/uri-list"); } Vector<URL> urls() const; - void set_urls(const Vector<URL>&); + void set_urls(Vector<URL> const&); - const HashMap<String, ByteBuffer>& all_data() const { return m_data; } + HashMap<String, ByteBuffer> const& all_data() const { return m_data; } private: MimeData() = default; - explicit MimeData(const HashMap<String, ByteBuffer>& data) + explicit MimeData(HashMap<String, ByteBuffer> const& data) : m_data(data) { } diff --git a/Userland/Libraries/LibCore/NetworkJob.cpp b/Userland/Libraries/LibCore/NetworkJob.cpp index 9c031f4f39..8a18f85002 100644 --- a/Userland/Libraries/LibCore/NetworkJob.cpp +++ b/Userland/Libraries/LibCore/NetworkJob.cpp @@ -69,7 +69,7 @@ void NetworkJob::did_progress(Optional<u32> total_size, u32 downloaded) on_progress(total_size, downloaded); } -const char* to_string(NetworkJob::Error error) +char const* to_string(NetworkJob::Error error) { switch (error) { case NetworkJob::Error::ProtocolFailed: diff --git a/Userland/Libraries/LibCore/NetworkJob.h b/Userland/Libraries/LibCore/NetworkJob.h index 84bdc2dbc4..878dc33db8 100644 --- a/Userland/Libraries/LibCore/NetworkJob.h +++ b/Userland/Libraries/LibCore/NetworkJob.h @@ -28,7 +28,7 @@ public: virtual ~NetworkJob() override = default; // Could fire twice, after Headers and after Trailers! - Function<void(const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> response_code)> on_headers_received; + Function<void(HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received; Function<void(bool success)> on_finish; Function<void(Optional<u32>, u32)> on_progress; @@ -36,7 +36,7 @@ public: bool has_error() const { return m_error != Error::None; } Error error() const { return m_error; } NetworkResponse* response() { return m_response.ptr(); } - const NetworkResponse* response() const { return m_response.ptr(); } + NetworkResponse const* response() const { return m_response.ptr(); } enum class ShutdownMode { DetachFromSocket, @@ -66,7 +66,7 @@ private: Error m_error { Error::None }; }; -const char* to_string(NetworkJob::Error); +char const* to_string(NetworkJob::Error); } diff --git a/Userland/Libraries/LibCore/Object.cpp b/Userland/Libraries/LibCore/Object.cpp index 62f9d54939..f0c5dcf1be 100644 --- a/Userland/Libraries/LibCore/Object.cpp +++ b/Userland/Libraries/LibCore/Object.cpp @@ -198,7 +198,7 @@ bool Object::set_property(String const& name, JsonValue const& value) return it->value->set(value); } -bool Object::is_ancestor_of(const Object& other) const +bool Object::is_ancestor_of(Object const& other) const { if (&other == this) return false; @@ -247,7 +247,7 @@ void Object::decrement_inspector_count(Badge<InspectorServerConnection>) did_end_inspection(); } -void Object::register_property(const String& name, Function<JsonValue()> getter, Function<bool(const JsonValue&)> setter) +void Object::register_property(String const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter) { m_properties.set(name, make<Property>(name, move(getter), move(setter))); } @@ -271,7 +271,7 @@ ObjectClassRegistration::ObjectClassRegistration(StringView class_name, Function object_classes().set(class_name, this); } -bool ObjectClassRegistration::is_derived_from(const ObjectClassRegistration& base_class) const +bool ObjectClassRegistration::is_derived_from(ObjectClassRegistration const& base_class) const { if (&base_class == this) return true; @@ -280,14 +280,14 @@ bool ObjectClassRegistration::is_derived_from(const ObjectClassRegistration& bas return m_parent_class->is_derived_from(base_class); } -void ObjectClassRegistration::for_each(Function<void(const ObjectClassRegistration&)> callback) +void ObjectClassRegistration::for_each(Function<void(ObjectClassRegistration const&)> callback) { for (auto& it : object_classes()) { callback(*it.value); } } -const ObjectClassRegistration* ObjectClassRegistration::find(StringView class_name) +ObjectClassRegistration const* ObjectClassRegistration::find(StringView class_name) { return object_classes().get(class_name).value_or(nullptr); } diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index c5511b3b8e..bad2ae50de 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -45,12 +45,12 @@ public: ~ObjectClassRegistration() = default; StringView class_name() const { return m_class_name; } - const ObjectClassRegistration* parent_class() const { return m_parent_class; } + ObjectClassRegistration const* parent_class() const { return m_parent_class; } RefPtr<Object> construct() const { return m_factory(); } - bool is_derived_from(const ObjectClassRegistration& base_class) const; + bool is_derived_from(ObjectClassRegistration const& base_class) const; - static void for_each(Function<void(const ObjectClassRegistration&)>); - static const ObjectClassRegistration* find(StringView class_name); + static void for_each(Function<void(ObjectClassRegistration const&)>); + static ObjectClassRegistration const* find(StringView class_name); private: StringView m_class_name; @@ -98,11 +98,11 @@ public: virtual StringView class_name() const = 0; - const String& name() const { return m_name; } + String const& name() const { return m_name; } void set_name(String name) { m_name = move(name); } NonnullRefPtrVector<Object>& children() { return m_children; } - const NonnullRefPtrVector<Object>& children() const { return m_children; } + NonnullRefPtrVector<Object> const& children() const { return m_children; } template<typename Callback> void for_each_child(Callback callback) @@ -117,15 +117,15 @@ public: void for_each_child_of_type(Callback callback) requires IsBaseOf<Object, T>; template<typename T> - T* find_child_of_type_named(const String&) requires IsBaseOf<Object, T>; + T* find_child_of_type_named(String const&) requires IsBaseOf<Object, T>; template<typename T> - T* find_descendant_of_type_named(const String&) requires IsBaseOf<Object, T>; + T* find_descendant_of_type_named(String const&) requires IsBaseOf<Object, T>; - bool is_ancestor_of(const Object&) const; + bool is_ancestor_of(Object const&) const; Object* parent() { return m_parent; } - const Object* parent() const { return m_parent; } + Object const* parent() const { return m_parent; } void start_timer(int ms, TimerShouldFireWhenNotVisible = TimerShouldFireWhenNotVisible::No); void stop_timer(); @@ -146,9 +146,9 @@ public: void save_to(JsonObject&); - bool set_property(String const& name, const JsonValue& value); + bool set_property(String const& name, JsonValue const& value); JsonValue property(String const& name) const; - const HashMap<String, NonnullOwnPtr<Property>>& properties() const { return m_properties; } + HashMap<String, NonnullOwnPtr<Property>> const& properties() const { return m_properties; } static IntrusiveList<&Object::m_all_objects_list_node>& all_objects(); @@ -186,7 +186,7 @@ public: protected: explicit Object(Object* parent = nullptr); - void register_property(const String& name, Function<JsonValue()> getter, Function<bool(const JsonValue&)> setter = nullptr); + void register_property(String const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr); virtual void event(Core::Event&); @@ -213,7 +213,7 @@ private: template<> struct AK::Formatter<Core::Object> : AK::Formatter<FormatString> { - ErrorOr<void> format(FormatBuilder& builder, const Core::Object& value) + ErrorOr<void> format(FormatBuilder& builder, Core::Object const& value) { return AK::Formatter<FormatString>::format(builder, "{}({})", value.class_name(), &value); } @@ -231,7 +231,7 @@ inline void Object::for_each_child_of_type(Callback callback) requires IsBaseOf< } template<typename T> -T* Object::find_child_of_type_named(const String& name) requires IsBaseOf<Object, T> +T* Object::find_child_of_type_named(String const& name) requires IsBaseOf<Object, T> { T* found_child = nullptr; for_each_child_of_type<T>([&](auto& child) { diff --git a/Userland/Libraries/LibCore/Property.cpp b/Userland/Libraries/LibCore/Property.cpp index 16443a0171..0d9f66dbab 100644 --- a/Userland/Libraries/LibCore/Property.cpp +++ b/Userland/Libraries/LibCore/Property.cpp @@ -9,7 +9,7 @@ namespace Core { -Property::Property(String name, Function<JsonValue()> getter, Function<bool(const JsonValue&)> setter) +Property::Property(String name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter) : m_name(move(name)) , m_getter(move(getter)) , m_setter(move(setter)) diff --git a/Userland/Libraries/LibCore/Property.h b/Userland/Libraries/LibCore/Property.h index 8370bdf5a4..1588379b2c 100644 --- a/Userland/Libraries/LibCore/Property.h +++ b/Userland/Libraries/LibCore/Property.h @@ -16,10 +16,10 @@ class Property { AK_MAKE_NONCOPYABLE(Property); public: - Property(String name, Function<JsonValue()> getter, Function<bool(const JsonValue&)> setter = nullptr); + Property(String name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr); ~Property() = default; - bool set(const JsonValue& value) + bool set(JsonValue const& value) { if (!m_setter) return false; @@ -28,13 +28,13 @@ public: JsonValue get() const { return m_getter(); } - const String& name() const { return m_name; } + String const& name() const { return m_name; } bool is_readonly() const { return !m_setter; } private: String m_name; Function<JsonValue()> m_getter; - Function<bool(const JsonValue&)> m_setter; + Function<bool(JsonValue const&)> m_setter; }; } diff --git a/Userland/Libraries/LibCore/SecretString.h b/Userland/Libraries/LibCore/SecretString.h index 865542ff7c..f6440eb285 100644 --- a/Userland/Libraries/LibCore/SecretString.h +++ b/Userland/Libraries/LibCore/SecretString.h @@ -21,7 +21,7 @@ public: [[nodiscard]] bool is_empty() const { return m_secure_buffer.is_empty(); } [[nodiscard]] size_t length() const { return m_secure_buffer.size(); } - [[nodiscard]] char const* characters() const { return reinterpret_cast<const char*>(m_secure_buffer.data()); } + [[nodiscard]] char const* characters() const { return reinterpret_cast<char const*>(m_secure_buffer.data()); } [[nodiscard]] StringView view() const { return { characters(), length() }; } SecretString() = default; diff --git a/Userland/Libraries/LibCore/SocketAddress.h b/Userland/Libraries/LibCore/SocketAddress.h index b575ff339d..faf17c36f0 100644 --- a/Userland/Libraries/LibCore/SocketAddress.h +++ b/Userland/Libraries/LibCore/SocketAddress.h @@ -25,20 +25,20 @@ public: }; SocketAddress() = default; - SocketAddress(const IPv4Address& address) + SocketAddress(IPv4Address const& address) : m_type(Type::IPv4) , m_ipv4_address(address) { } - SocketAddress(const IPv4Address& address, u16 port) + SocketAddress(IPv4Address const& address, u16 port) : m_type(Type::IPv4) , m_ipv4_address(address) , m_port(port) { } - static SocketAddress local(const String& address) + static SocketAddress local(String const& address) { SocketAddress addr; addr.m_type = Type::Local; diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 00fdfb7f6e..b5e6290c30 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -30,7 +30,7 @@ # include <linux/memfd.h> # include <sys/syscall.h> -static int memfd_create(const char* name, unsigned int flags) +static int memfd_create(char const* name, unsigned int flags) { return syscall(SYS_memfd_create, name, flags); } diff --git a/Userland/Libraries/LibCore/SystemServerTakeover.cpp b/Userland/Libraries/LibCore/SystemServerTakeover.cpp index 3f134663ca..a1dfe9e401 100644 --- a/Userland/Libraries/LibCore/SystemServerTakeover.cpp +++ b/Userland/Libraries/LibCore/SystemServerTakeover.cpp @@ -17,7 +17,7 @@ static void parse_sockets_from_system_server() VERIFY(!s_overtaken_sockets_parsed); constexpr auto socket_takeover = "SOCKET_TAKEOVER"; - const char* sockets = getenv(socket_takeover); + char const* sockets = getenv(socket_takeover); if (!sockets) { s_overtaken_sockets_parsed = true; return; diff --git a/Userland/Libraries/LibCore/UDPServer.cpp b/Userland/Libraries/LibCore/UDPServer.cpp index 47a07fdf07..729b640de6 100644 --- a/Userland/Libraries/LibCore/UDPServer.cpp +++ b/Userland/Libraries/LibCore/UDPServer.cpp @@ -38,7 +38,7 @@ UDPServer::~UDPServer() ::close(m_fd); } -bool UDPServer::bind(const IPv4Address& address, u16 port) +bool UDPServer::bind(IPv4Address const& address, u16 port) { if (m_bound) return false; @@ -46,7 +46,7 @@ bool UDPServer::bind(const IPv4Address& address, u16 port) auto saddr = SocketAddress(address, port); auto in = saddr.to_sockaddr_in(); - if (::bind(m_fd, (const sockaddr*)&in, sizeof(in)) != 0) { + if (::bind(m_fd, (sockaddr const*)&in, sizeof(in)) != 0) { perror("UDPServer::bind"); return false; } diff --git a/Userland/Libraries/LibCore/UDPServer.h b/Userland/Libraries/LibCore/UDPServer.h index 453cf43056..50ac61ee31 100644 --- a/Userland/Libraries/LibCore/UDPServer.h +++ b/Userland/Libraries/LibCore/UDPServer.h @@ -22,7 +22,7 @@ public: bool is_bound() const { return m_bound; } - bool bind(const IPv4Address& address, u16 port); + bool bind(IPv4Address const& address, u16 port); ByteBuffer receive(size_t size, sockaddr_in& from); ByteBuffer receive(size_t size) { diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp index fa4515f8f7..f063e30c80 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.cpp +++ b/Userland/Libraries/LibCoredump/Backtrace.cpp @@ -41,7 +41,7 @@ ELFObjectInfo const* Backtrace::object_info_for_region(Reader const& coredump, M return info_ptr; } -Backtrace::Backtrace(const Reader& coredump, const ELF::Core::ThreadInfo& thread_info, Function<void(size_t, size_t)> on_progress) +Backtrace::Backtrace(Reader const& coredump, const ELF::Core::ThreadInfo& thread_info, Function<void(size_t, size_t)> on_progress) : m_thread_info(move(thread_info)) { #if ARCH(I386) @@ -92,7 +92,7 @@ Backtrace::Backtrace(const Reader& coredump, const ELF::Core::ThreadInfo& thread } } -void Backtrace::add_entry(const Reader& coredump, FlatPtr ip) +void Backtrace::add_entry(Reader const& coredump, FlatPtr ip) { auto ip_region = coredump.region_containing(ip); if (!ip_region.has_value()) { diff --git a/Userland/Libraries/LibCoredump/Backtrace.h b/Userland/Libraries/LibCoredump/Backtrace.h index d06bad1167..d112f110c5 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.h +++ b/Userland/Libraries/LibCoredump/Backtrace.h @@ -38,14 +38,14 @@ public: String to_string(bool color = false) const; }; - Backtrace(const Reader&, const ELF::Core::ThreadInfo&, Function<void(size_t, size_t)> on_progress = {}); + Backtrace(Reader const&, const ELF::Core::ThreadInfo&, Function<void(size_t, size_t)> on_progress = {}); ~Backtrace() = default; ELF::Core::ThreadInfo const& thread_info() const { return m_thread_info; } Vector<Entry> const& entries() const { return m_entries; } private: - void add_entry(const Reader&, FlatPtr ip); + void add_entry(Reader const&, FlatPtr ip); ELFObjectInfo const* object_info_for_region(Reader const&, MemoryRegionInfo const&); bool m_skip_loader_so { false }; diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp index 445acd353c..e010abab58 100644 --- a/Userland/Libraries/LibCoredump/Reader.cpp +++ b/Userland/Libraries/LibCoredump/Reader.cpp @@ -77,7 +77,7 @@ Optional<ByteBuffer> Reader::decompress_coredump(ReadonlyBytes raw_coredump) return bytebuffer.release_value(); } -Reader::NotesEntryIterator::NotesEntryIterator(const u8* notes_data) +Reader::NotesEntryIterator::NotesEntryIterator(u8 const* notes_data) : m_current(bit_cast<const ELF::Core::NotesEntry*>(notes_data)) , start(notes_data) { @@ -103,22 +103,22 @@ void Reader::NotesEntryIterator::next() VERIFY(!at_end()); switch (type()) { case ELF::Core::NotesEntryHeader::Type::ProcessInfo: { - const auto* current = bit_cast<const ELF::Core::ProcessInfo*>(m_current); + auto const* current = bit_cast<const ELF::Core::ProcessInfo*>(m_current); m_current = bit_cast<const ELF::Core::NotesEntry*>(current->json_data + strlen(current->json_data) + 1); break; } case ELF::Core::NotesEntryHeader::Type::ThreadInfo: { - const auto* current = bit_cast<const ELF::Core::ThreadInfo*>(m_current); + auto const* current = bit_cast<const ELF::Core::ThreadInfo*>(m_current); m_current = bit_cast<const ELF::Core::NotesEntry*>(current + 1); break; } case ELF::Core::NotesEntryHeader::Type::MemoryRegionInfo: { - const auto* current = bit_cast<const ELF::Core::MemoryRegionInfo*>(m_current); + auto const* current = bit_cast<const ELF::Core::MemoryRegionInfo*>(m_current); m_current = bit_cast<const ELF::Core::NotesEntry*>(current->region_name + strlen(current->region_name) + 1); break; } case ELF::Core::NotesEntryHeader::Type::Metadata: { - const auto* current = bit_cast<const ELF::Core::Metadata*>(m_current); + auto const* current = bit_cast<const ELF::Core::Metadata*>(m_current); m_current = bit_cast<const ELF::Core::NotesEntry*>(current->json_data + strlen(current->json_data) + 1); break; } @@ -139,7 +139,7 @@ Optional<FlatPtr> Reader::peek_memory(FlatPtr address) const return {}; FlatPtr offset_in_region = address - region->region_start; - auto* region_data = bit_cast<const u8*>(image().program_header(region->program_header_index).raw_data()); + auto* region_data = bit_cast<u8 const*>(image().program_header(region->program_header_index).raw_data()); FlatPtr value { 0 }; ByteReader::load(region_data + offset_in_region, value); return value; @@ -148,7 +148,7 @@ Optional<FlatPtr> Reader::peek_memory(FlatPtr address) const const JsonObject Reader::process_info() const { const ELF::Core::ProcessInfo* process_info_notes_entry = nullptr; - NotesEntryIterator it(bit_cast<const u8*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); + NotesEntryIterator it(bit_cast<u8 const*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); for (; !it.at_end(); it.next()) { if (it.type() != ELF::Core::NotesEntryHeader::Type::ProcessInfo) continue; @@ -182,7 +182,7 @@ Optional<MemoryRegionInfo> Reader::first_region_for_object(StringView object_nam Optional<MemoryRegionInfo> Reader::region_containing(FlatPtr address) const { Optional<MemoryRegionInfo> ret; - for_each_memory_region_info([&ret, address](const auto& region_info) { + for_each_memory_region_info([&ret, address](auto const& region_info) { if (region_info.region_start <= address && region_info.region_end >= address) { ret = region_info; return IterationDecision::Break; @@ -247,7 +247,7 @@ Vector<String> Reader::process_environment() const HashMap<String, String> Reader::metadata() const { const ELF::Core::Metadata* metadata_notes_entry = nullptr; - NotesEntryIterator it(bit_cast<const u8*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); + NotesEntryIterator it(bit_cast<u8 const*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); for (; !it.at_end(); it.next()) { if (it.type() != ELF::Core::NotesEntryHeader::Type::Metadata) continue; @@ -268,7 +268,7 @@ HashMap<String, String> Reader::metadata() const return metadata; } -const Reader::LibraryData* Reader::library_containing(FlatPtr address) const +Reader::LibraryData const* Reader::library_containing(FlatPtr address) const { static HashMap<String, OwnPtr<LibraryData>> cached_libs; auto region = region_containing(address); diff --git a/Userland/Libraries/LibCoredump/Reader.h b/Userland/Libraries/LibCoredump/Reader.h index 536ecfb009..8f13f74f70 100644 --- a/Userland/Libraries/LibCoredump/Reader.h +++ b/Userland/Libraries/LibCoredump/Reader.h @@ -69,7 +69,7 @@ public: NonnullRefPtr<Core::MappedFile> file; ELF::Image lib_elf; }; - const LibraryData* library_containing(FlatPtr address) const; + LibraryData const* library_containing(FlatPtr address) const; String resolve_object_path(StringView object_name) const; @@ -89,7 +89,7 @@ private: class NotesEntryIterator { public: - NotesEntryIterator(const u8* notes_data); + NotesEntryIterator(u8 const* notes_data); ELF::Core::NotesEntryHeader::Type type() const; const ELF::Core::NotesEntry* current() const; @@ -99,7 +99,7 @@ private: private: const ELF::Core::NotesEntry* m_current { nullptr }; - const u8* start { nullptr }; + u8 const* start { nullptr }; }; // Private as we don't need anyone poking around in this JsonObject @@ -122,7 +122,7 @@ private: template<typename Func> void Reader::for_each_memory_region_info(Func func) const { - NotesEntryIterator it(bit_cast<const u8*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); + NotesEntryIterator it(bit_cast<u8 const*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); for (; !it.at_end(); it.next()) { if (it.type() != ELF::Core::NotesEntryHeader::Type::MemoryRegionInfo) continue; @@ -138,7 +138,7 @@ void Reader::for_each_memory_region_info(Func func) const raw_memory_region_info.region_start, raw_memory_region_info.region_end, raw_memory_region_info.program_header_index, - { bit_cast<const char*>(raw_data.offset_pointer(raw_data.size())) }, + { bit_cast<char const*>(raw_data.offset_pointer(raw_data.size())) }, }; IterationDecision decision = func(memory_region_info); if (decision == IterationDecision::Break) @@ -149,12 +149,12 @@ void Reader::for_each_memory_region_info(Func func) const template<typename Func> void Reader::for_each_thread_info(Func func) const { - NotesEntryIterator it(bit_cast<const u8*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); + NotesEntryIterator it(bit_cast<u8 const*>(m_coredump_image.program_header(m_notes_segment_index).raw_data())); for (; !it.at_end(); it.next()) { if (it.type() != ELF::Core::NotesEntryHeader::Type::ThreadInfo) continue; ELF::Core::ThreadInfo thread_info; - ByteReader::load(bit_cast<const u8*>(it.current()), thread_info); + ByteReader::load(bit_cast<u8 const*>(it.current()), thread_info); IterationDecision decision = func(thread_info); if (decision == IterationDecision::Break) diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index f07e09d252..53ff3cfe2d 100644 --- a/Userland/Libraries/LibCpp/AST.cpp +++ b/Userland/Libraries/LibCpp/AST.cpp @@ -23,7 +23,7 @@ void ASTNode::dump(FILE* output, size_t indent) const void TranslationUnit::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); - for (const auto& child : m_declarations) { + for (auto const& child : m_declarations) { child.dump(output, indent + 1); } } @@ -45,7 +45,7 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const } print_indent(output, indent + 1); outln(output, "("); - for (const auto& arg : m_parameters) { + for (auto const& arg : m_parameters) { arg.dump(output, indent + 1); } print_indent(output, indent + 1); @@ -155,7 +155,7 @@ void FunctionDefinition::dump(FILE* output, size_t indent) const ASTNode::dump(output, indent); print_indent(output, indent); outln(output, "{{"); - for (const auto& statement : m_statements) { + for (auto const& statement : m_statements) { statement.dump(output, indent + 1); } print_indent(output, indent); @@ -200,7 +200,7 @@ void BinaryExpression::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case BinaryOp::Addition: op_string = "+"; @@ -272,7 +272,7 @@ void AssignmentExpression::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case AssignmentOp::Assignment: op_string = "="; @@ -296,7 +296,7 @@ void FunctionCall::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); m_callee->dump(output, indent + 1); - for (const auto& arg : m_arguments) { + for (auto const& arg : m_arguments) { arg.dump(output, indent + 1); } } @@ -349,7 +349,7 @@ void UnaryExpression::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case UnaryOp::BitwiseNot: op_string = "~"; @@ -449,7 +449,7 @@ NonnullRefPtrVector<Declaration> Statement::declarations() const { if (is_declaration()) { NonnullRefPtrVector<Declaration> vec; - const auto& decl = static_cast<const Declaration&>(*this); + auto const& decl = static_cast<Declaration const&>(*this); vec.empend(const_cast<Declaration&>(decl)); return vec; } @@ -607,7 +607,7 @@ void Constructor::dump(FILE* output, size_t indent) const outln(output, "C'tor"); print_indent(output, indent + 1); outln(output, "("); - for (const auto& arg : parameters()) { + for (auto const& arg : parameters()) { arg.dump(output, indent + 1); } print_indent(output, indent + 1); @@ -623,7 +623,7 @@ void Destructor::dump(FILE* output, size_t indent) const outln(output, "D'tor"); print_indent(output, indent + 1); outln(output, "("); - for (const auto& arg : parameters()) { + for (auto const& arg : parameters()) { arg.dump(output, indent + 1); } print_indent(output, indent + 1); diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h index 259ef63e4e..c2c772aa33 100644 --- a/Userland/Libraries/LibCpp/AST.h +++ b/Userland/Libraries/LibCpp/AST.h @@ -47,11 +47,11 @@ public: VERIFY(m_end.has_value()); return m_end.value(); } - const FlyString& filename() const + FlyString const& filename() const { return m_filename; } - void set_end(const Position& end) { m_end = end; } + void set_end(Position const& end) { m_end = end; } void set_parent(ASTNode& parent) { m_parent = &parent; } virtual NonnullRefPtrVector<Declaration> declarations() const { return {}; } @@ -66,7 +66,7 @@ public: virtual bool is_dummy_node() const { return false; } protected: - ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : m_parent(parent) , m_start(start) , m_end(end) @@ -89,7 +89,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; } - TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : ASTNode(parent, start, end, filename) { } @@ -108,7 +108,7 @@ public: virtual NonnullRefPtrVector<Declaration> declarations() const override; protected: - Statement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Statement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : ASTNode(parent, start, end, filename) { } @@ -127,12 +127,12 @@ public: virtual bool is_namespace() const { return false; } virtual bool is_enum() const { return false; } bool is_member() const { return parent() != nullptr && parent()->is_declaration() && verify_cast<Declaration>(parent())->is_struct_or_class(); } - const Name* name() const { return m_name; } + Name const* name() const { return m_name; } StringView full_name() const; void set_name(RefPtr<Name> name) { m_name = move(name); } protected: - Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -146,7 +146,7 @@ class InvalidDeclaration : public Declaration { public: virtual ~InvalidDeclaration() override = default; virtual StringView class_name() const override { return "InvalidDeclaration"sv; } - InvalidDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + InvalidDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Declaration(parent, start, end, filename) { } @@ -162,19 +162,19 @@ public: virtual bool is_destructor() const { return false; } RefPtr<FunctionDefinition> definition() { return m_definition; } - FunctionDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + FunctionDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Declaration(parent, start, end, filename) { } virtual NonnullRefPtrVector<Declaration> declarations() const override; - const Vector<StringView>& qualifiers() const { return m_qualifiers; } - void set_qualifiers(const Vector<StringView>& qualifiers) { m_qualifiers = qualifiers; } - const Type* return_type() const { return m_return_type.ptr(); } - void set_return_type(const RefPtr<Type>& return_type) { m_return_type = return_type; } - const NonnullRefPtrVector<Parameter>& parameters() const { return m_parameters; } - void set_parameters(const NonnullRefPtrVector<Parameter>& parameters) { m_parameters = parameters; } - const FunctionDefinition* definition() const { return m_definition.ptr(); } + Vector<StringView> const& qualifiers() const { return m_qualifiers; } + void set_qualifiers(Vector<StringView> const& qualifiers) { m_qualifiers = qualifiers; } + Type const* return_type() const { return m_return_type.ptr(); } + void set_return_type(RefPtr<Type> const& return_type) { m_return_type = return_type; } + NonnullRefPtrVector<Parameter> const& parameters() const { return m_parameters; } + void set_parameters(NonnullRefPtrVector<Parameter> const& parameters) { m_parameters = parameters; } + FunctionDefinition const* definition() const { return m_definition.ptr(); } void set_definition(RefPtr<FunctionDefinition>&& definition) { m_definition = move(definition); } private: @@ -190,10 +190,10 @@ public: virtual bool is_variable_or_parameter_declaration() const override { return true; } void set_type(RefPtr<Type>&& type) { m_type = move(type); } - const Type* type() const { return m_type.ptr(); } + Type const* type() const { return m_type.ptr(); } protected: - VariableOrParameterDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + VariableOrParameterDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Declaration(parent, start, end, filename) { } @@ -208,7 +208,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_parameter() const override { return true; } - Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, RefPtr<Name> name) + Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, RefPtr<Name> name) : VariableOrParameterDeclaration(parent, start, end, filename) { m_name = name; @@ -237,7 +237,7 @@ public: void set_qualifiers(Vector<StringView>&& qualifiers) { m_qualifiers = move(qualifiers); } protected: - Type(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Type(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : ASTNode(parent, start, end, filename) { } @@ -254,12 +254,12 @@ public: virtual String to_string() const override; virtual bool is_named_type() const override { return true; } - NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Type(parent, start, end, filename) { } - const Name* name() const { return m_name.ptr(); } + Name const* name() const { return m_name.ptr(); } void set_name(RefPtr<Name>&& name) { m_name = move(name); } private: @@ -273,12 +273,12 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual String to_string() const override; - Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Type(parent, start, end, filename) { } - const Type* pointee() const { return m_pointee.ptr(); } + Type const* pointee() const { return m_pointee.ptr(); } void set_pointee(RefPtr<Type>&& pointee) { m_pointee = move(pointee); } private: @@ -297,13 +297,13 @@ public: Rvalue, }; - Reference(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, Kind kind) + Reference(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, Kind kind) : Type(parent, start, end, filename) , m_kind(kind) { } - const Type* referenced_type() const { return m_referenced_type.ptr(); } + Type const* referenced_type() const { return m_referenced_type.ptr(); } void set_referenced_type(RefPtr<Type>&& pointee) { m_referenced_type = move(pointee); } Kind kind() const { return m_kind; } @@ -319,7 +319,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual String to_string() const override; - FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Type(parent, start, end, filename) { } @@ -338,7 +338,7 @@ public: virtual StringView class_name() const override { return "FunctionDefinition"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : ASTNode(parent, start, end, filename) { } @@ -355,7 +355,7 @@ class InvalidStatement : public Statement { public: virtual ~InvalidStatement() override = default; virtual StringView class_name() const override { return "InvalidStatement"sv; } - InvalidStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + InvalidStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -367,7 +367,7 @@ public: virtual StringView class_name() const override { return "Expression"sv; } protected: - Expression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Expression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -377,7 +377,7 @@ class InvalidExpression : public Expression { public: virtual ~InvalidExpression() override = default; virtual StringView class_name() const override { return "InvalidExpression"sv; } - InvalidExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + InvalidExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -389,14 +389,14 @@ public: virtual StringView class_name() const override { return "VariableDeclaration"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : VariableOrParameterDeclaration(parent, start, end, filename) { } virtual bool is_variable_declaration() const override { return true; } - const Expression* initial_value() const { return m_initial_value; } + Expression const* initial_value() const { return m_initial_value; } void set_initial_value(RefPtr<Expression>&& initial_value) { m_initial_value = move(initial_value); } private: @@ -409,12 +409,12 @@ public: virtual StringView class_name() const override { return "Identifier"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StringView name) + Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StringView name) : Expression(parent, start, end, filename) , m_name(name) { } - Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Identifier(parent, start, end, filename, {}) { } @@ -436,13 +436,13 @@ public: virtual bool is_name() const override { return true; } virtual bool is_templatized() const { return false; } - Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } virtual StringView full_name() const; - const Identifier* name() const { return m_name.ptr(); } + Identifier const* name() const { return m_name.ptr(); } void set_name(RefPtr<Identifier>&& name) { m_name = move(name); } NonnullRefPtrVector<Identifier> const& scope() const { return m_scope; } void set_scope(NonnullRefPtrVector<Identifier> scope) { m_scope = move(scope); } @@ -461,7 +461,7 @@ public: virtual bool is_templatized() const override { return true; } virtual StringView full_name() const override; - TemplatizedName(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + TemplatizedName(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Name(parent, start, end, filename) { } @@ -479,7 +479,7 @@ public: virtual StringView class_name() const override { return "NumericLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - NumericLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StringView value) + NumericLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StringView value) : Expression(parent, start, end, filename) , m_value(value) { @@ -495,7 +495,7 @@ public: virtual StringView class_name() const override { return "NullPointerLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -507,7 +507,7 @@ public: virtual StringView class_name() const override { return "BooleanLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - BooleanLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, bool value) + BooleanLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, bool value) : Expression(parent, start, end, filename) , m_value(value) { @@ -541,7 +541,7 @@ enum class BinaryOp { class BinaryExpression : public Expression { public: - BinaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + BinaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -571,7 +571,7 @@ enum class AssignmentOp { class AssignmentExpression : public Expression { public: - AssignmentExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + AssignmentExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -582,9 +582,9 @@ public: AssignmentOp op() const { return m_op; } void set_op(AssignmentOp op) { m_op = op; } - const Expression* lhs() const { return m_lhs; } + Expression const* lhs() const { return m_lhs; } void set_lhs(RefPtr<Expression>&& e) { m_lhs = move(e); } - const Expression* rhs() const { return m_rhs; } + Expression const* rhs() const { return m_rhs; } void set_rhs(RefPtr<Expression>&& e) { m_rhs = move(e); } private: @@ -595,7 +595,7 @@ private: class FunctionCall : public Expression { public: - FunctionCall(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + FunctionCall(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -605,7 +605,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_function_call() const override { return true; } - const Expression* callee() const { return m_callee.ptr(); } + Expression const* callee() const { return m_callee.ptr(); } void set_callee(RefPtr<Expression>&& callee) { m_callee = move(callee); } void add_argument(NonnullRefPtr<Expression>&& arg) { m_arguments.append(move(arg)); } @@ -618,7 +618,7 @@ private: class StringLiteral final : public Expression { public: - StringLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + StringLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -639,13 +639,13 @@ public: virtual ~ReturnStatement() override = default; virtual StringView class_name() const override { return "ReturnStatement"sv; } - ReturnStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + ReturnStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - const Expression* value() const { return m_value.ptr(); } + Expression const* value() const { return m_value.ptr(); } void set_value(RefPtr<Expression>&& value) { m_value = move(value); } private: @@ -659,7 +659,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_enum() const override { return true; } - EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Declaration(parent, start, end, filename) { } @@ -696,7 +696,7 @@ public: Class }; - StructOrClassDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StructOrClassDeclaration::Type type) + StructOrClassDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StructOrClassDeclaration::Type type) : Declaration(parent, start, end, filename) , m_type(type) { @@ -722,7 +722,7 @@ enum class UnaryOp { class UnaryExpression : public Expression { public: - UnaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + UnaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -741,7 +741,7 @@ private: class MemberExpression : public Expression { public: - MemberExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + MemberExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -751,9 +751,9 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_member_expression() const override { return true; } - const Expression* object() const { return m_object.ptr(); } + Expression const* object() const { return m_object.ptr(); } void set_object(RefPtr<Expression>&& object) { m_object = move(object); } - const Expression* property() const { return m_property.ptr(); } + Expression const* property() const { return m_property.ptr(); } void set_property(RefPtr<Expression>&& property) { m_property = move(property); } private: @@ -763,7 +763,7 @@ private: class ForStatement : public Statement { public: - ForStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + ForStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -778,7 +778,7 @@ public: void set_test(RefPtr<Expression>&& test) { m_test = move(test); } void set_update(RefPtr<Expression>&& update) { m_update = move(update); } void set_body(RefPtr<Statement>&& body) { m_body = move(body); } - const Statement* body() const { return m_body.ptr(); } + Statement const* body() const { return m_body.ptr(); } private: RefPtr<VariableDeclaration> m_init; @@ -789,7 +789,7 @@ private: class BlockStatement final : public Statement { public: - BlockStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + BlockStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -808,7 +808,7 @@ private: class Comment final : public Statement { public: - Comment(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Comment(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -819,7 +819,7 @@ public: class IfStatement : public Statement { public: - IfStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + IfStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Statement(parent, start, end, filename) { } @@ -833,8 +833,8 @@ public: void set_then_statement(RefPtr<Statement>&& then) { m_then = move(then); } void set_else_statement(RefPtr<Statement>&& _else) { m_else = move(_else); } - const Statement* then_statement() const { return m_then.ptr(); } - const Statement* else_statement() const { return m_else.ptr(); } + Statement const* then_statement() const { return m_then.ptr(); } + Statement const* else_statement() const { return m_else.ptr(); } private: RefPtr<Expression> m_predicate; @@ -849,7 +849,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_namespace() const override { return true; } - NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Declaration(parent, start, end, filename) { } @@ -863,7 +863,7 @@ private: class CppCastExpression : public Expression { public: - CppCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + CppCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -884,7 +884,7 @@ private: class CStyleCastExpression : public Expression { public: - CStyleCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + CStyleCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -903,7 +903,7 @@ private: class SizeofExpression : public Expression { public: - SizeofExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + SizeofExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -920,7 +920,7 @@ private: class BracedInitList : public Expression { public: - BracedInitList(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + BracedInitList(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : Expression(parent, start, end, filename) { } @@ -937,7 +937,7 @@ private: class DummyAstNode : public ASTNode { public: - DummyAstNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + DummyAstNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : ASTNode(parent, start, end, filename) { } @@ -953,7 +953,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_constructor() const override { return true; } - Constructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Constructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : FunctionDeclaration(parent, start, end, filename) { } @@ -966,7 +966,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_destructor() const override { return true; } - Destructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename) + Destructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename) : FunctionDeclaration(parent, start, end, filename) { } diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index 0a0e9bb7e0..9cb3e65de5 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -864,12 +864,12 @@ void Parser::load_state() m_state = m_saved_states.take_last(); } -StringView Parser::text_of_token(const Cpp::Token& token) const +StringView Parser::text_of_token(Cpp::Token const& token) const { return token.text(); } -String Parser::text_of_node(const ASTNode& node) const +String Parser::text_of_node(ASTNode const& node) const { return text_in_range(node.start(), node.end()); } @@ -969,7 +969,7 @@ Optional<size_t> Parser::index_of_node_at(Position pos) const VERIFY(m_saved_states.is_empty()); Optional<size_t> match_node_index; - auto node_span = [](const ASTNode& node) { + auto node_span = [](ASTNode const& node) { VERIFY(node.end().line >= node.start().line); VERIFY((node.end().line > node.start().line) || (node.end().column >= node.start().column)); return Position { node.end().line - node.start().line, node.start().line != node.end().line ? 0 : node.end().column - node.start().column }; @@ -1106,7 +1106,7 @@ NonnullRefPtr<EnumDeclaration> Parser::parse_enum_declaration(ASTNode& parent) return enum_decl; } -Token Parser::consume_keyword(const String& keyword) +Token Parser::consume_keyword(String const& keyword) { auto token = consume(); if (token.type() != Token::Type::Keyword) { @@ -1120,7 +1120,7 @@ Token Parser::consume_keyword(const String& keyword) return token; } -bool Parser::match_keyword(const String& keyword) +bool Parser::match_keyword(String const& keyword) { auto token = peek(); if (token.type() != Token::Type::Keyword) { diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h index 5ef0f36d08..e9054a376c 100644 --- a/Userland/Libraries/LibCpp/Parser.h +++ b/Userland/Libraries/LibCpp/Parser.h @@ -29,11 +29,11 @@ public: Optional<Token> token_at(Position) const; Optional<size_t> index_of_token_at(Position) const; RefPtr<const TranslationUnit> root_node() const { return m_root_node; } - String text_of_node(const ASTNode&) const; - StringView text_of_token(const Cpp::Token& token) const; + String text_of_node(ASTNode const&) const; + StringView text_of_token(Cpp::Token const& token) const; void print_tokens() const; Vector<Token> const& tokens() const { return m_tokens; } - const Vector<String>& errors() const { return m_errors; } + Vector<String> const& errors() const { return m_errors; } struct TodoEntry { String content; @@ -71,7 +71,7 @@ private: bool match_literal(); bool match_unary_expression(); bool match_boolean_literal(); - bool match_keyword(const String&); + bool match_keyword(String const&); bool match_block_statement(); bool match_namespace_declaration(); bool match_template_arguments(); @@ -130,7 +130,7 @@ private: bool match(Token::Type); Token consume(Token::Type); Token consume(); - Token consume_keyword(const String&); + Token consume_keyword(String const&); Token peek(size_t offset = 0) const; Optional<Token> peek(Token::Type) const; Position position() const; @@ -149,7 +149,7 @@ private: template<class T, class... Args> NonnullRefPtr<T> - create_ast_node(ASTNode& parent, const Position& start, Optional<Position> end, Args&&... args) + create_ast_node(ASTNode& parent, Position const& start, Optional<Position> end, Args&&... args) { auto node = adopt_ref(*new T(&parent, start, end, m_filename, forward<Args>(args)...)); @@ -163,7 +163,7 @@ private: } NonnullRefPtr<TranslationUnit> - create_root_ast_node(const Position& start, Position end) + create_root_ast_node(Position const& start, Position end) { auto node = adopt_ref(*new TranslationUnit(nullptr, start, end, m_filename)); m_nodes.append(node); diff --git a/Userland/Libraries/LibCpp/Preprocessor.cpp b/Userland/Libraries/LibCpp/Preprocessor.cpp index 330bef1e14..0f956f5c96 100644 --- a/Userland/Libraries/LibCpp/Preprocessor.cpp +++ b/Userland/Libraries/LibCpp/Preprocessor.cpp @@ -12,7 +12,7 @@ #include <ctype.h> namespace Cpp { -Preprocessor::Preprocessor(const String& filename, StringView program) +Preprocessor::Preprocessor(String const& filename, StringView program) : m_filename(filename) , m_program(program) { diff --git a/Userland/Libraries/LibCpp/Preprocessor.h b/Userland/Libraries/LibCpp/Preprocessor.h index 92e5ce5dc4..0452ea3581 100644 --- a/Userland/Libraries/LibCpp/Preprocessor.h +++ b/Userland/Libraries/LibCpp/Preprocessor.h @@ -20,7 +20,7 @@ namespace Cpp { class Preprocessor { public: - explicit Preprocessor(const String& filename, StringView program); + explicit Preprocessor(String const& filename, StringView program); Vector<Token> process_and_lex(); Vector<StringView> included_paths() const { return m_included_paths; } diff --git a/Userland/Libraries/LibCpp/Token.cpp b/Userland/Libraries/LibCpp/Token.cpp index 481ca0e42e..71f7bc768b 100644 --- a/Userland/Libraries/LibCpp/Token.cpp +++ b/Userland/Libraries/LibCpp/Token.cpp @@ -9,19 +9,19 @@ namespace Cpp { -bool Position::operator<(const Position& other) const +bool Position::operator<(Position const& other) const { return line < other.line || (line == other.line && column < other.column); } -bool Position::operator>(const Position& other) const +bool Position::operator>(Position const& other) const { return !(*this < other) && !(*this == other); } -bool Position::operator==(const Position& other) const +bool Position::operator==(Position const& other) const { return line == other.line && column == other.column; } -bool Position::operator<=(const Position& other) const +bool Position::operator<=(Position const& other) const { return !(*this > other); } diff --git a/Userland/Libraries/LibCpp/Token.h b/Userland/Libraries/LibCpp/Token.h index f4de7fbfcf..c592a924cb 100644 --- a/Userland/Libraries/LibCpp/Token.h +++ b/Userland/Libraries/LibCpp/Token.h @@ -83,10 +83,10 @@ struct Position { size_t line { 0 }; size_t column { 0 }; - bool operator<(const Position&) const; - bool operator<=(const Position&) const; - bool operator>(const Position&) const; - bool operator==(const Position&) const; + bool operator<(Position const&) const; + bool operator<=(Position const&) const; + bool operator>(Position const&) const; + bool operator==(Position const&) const; }; struct Token { @@ -96,7 +96,7 @@ struct Token { #undef __TOKEN }; - Token(Type type, const Position& start, const Position& end, StringView text) + Token(Type type, Position const& start, Position const& end, StringView text) : m_type(type) , m_start(start) , m_end(end) @@ -104,7 +104,7 @@ struct Token { { } - static const char* type_to_string(Type t) + static char const* type_to_string(Type t) { switch (t) { #define __TOKEN(x) \ @@ -119,11 +119,11 @@ struct Token { String to_string() const; String type_as_string() const; - const Position& start() const { return m_start; } - const Position& end() const { return m_end; } + Position const& start() const { return m_start; } + Position const& end() const { return m_end; } - void set_start(const Position& other) { m_start = other; } - void set_end(const Position& other) { m_end = other; } + void set_start(Position const& other) { m_start = other; } + void set_end(Position const& other) { m_end = other; } Type type() const { return m_type; } StringView text() const { return m_text; } diff --git a/Userland/Libraries/LibCrypt/crypt.cpp b/Userland/Libraries/LibCrypt/crypt.cpp index c952a74d07..9823ef980e 100644 --- a/Userland/Libraries/LibCrypt/crypt.cpp +++ b/Userland/Libraries/LibCrypt/crypt.cpp @@ -15,7 +15,7 @@ extern "C" { static struct crypt_data crypt_data; -char* crypt(const char* key, const char* salt) +char* crypt(char const* key, char const* salt) { crypt_data.initialized = true; return crypt_r(key, salt, &crypt_data); @@ -24,7 +24,7 @@ char* crypt(const char* key, const char* salt) static constexpr size_t crypt_salt_max = 16; static constexpr size_t sha_string_length = 44; -char* crypt_r(const char* key, const char* salt, struct crypt_data* data) +char* crypt_r(char const* key, char const* salt, struct crypt_data* data) { if (!data->initialized) { errno = EINVAL; @@ -33,7 +33,7 @@ char* crypt_r(const char* key, const char* salt, struct crypt_data* data) if (salt[0] == '$') { if (salt[1] == '5') { - const char* salt_value = salt + 3; + char const* salt_value = salt + 3; size_t salt_len = min(strcspn(salt_value, "$"), crypt_salt_max); size_t header_len = salt_len + 3; @@ -46,7 +46,7 @@ char* crypt_r(const char* key, const char* salt, struct crypt_data* data) Crypto::Hash::SHA256 sha; sha.update(key); - sha.update((const u8*)salt_value, salt_len); + sha.update((u8 const*)salt_value, salt_len); auto digest = sha.digest(); auto string = encode_base64(ReadonlyBytes(digest.immutable_data(), digest.data_length())); diff --git a/Userland/Libraries/LibCrypt/crypt.h b/Userland/Libraries/LibCrypt/crypt.h index c51744a666..0a304ac047 100644 --- a/Userland/Libraries/LibCrypt/crypt.h +++ b/Userland/Libraries/LibCrypt/crypt.h @@ -22,7 +22,7 @@ struct crypt_data { char result[65]; }; -char* crypt(const char* key, const char* salt); -char* crypt_r(const char* key, const char* salt, struct crypt_data* data); +char* crypt(char const* key, char const* salt); +char* crypt_r(char const* key, char const* salt, struct crypt_data* data); __END_DECLS diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.cpp b/Userland/Libraries/LibCrypto/Authentication/GHash.cpp index de06e63087..396da9b53f 100644 --- a/Userland/Libraries/LibCrypto/Authentication/GHash.cpp +++ b/Userland/Libraries/LibCrypto/Authentication/GHash.cpp @@ -12,12 +12,12 @@ namespace { -static u32 to_u32(const u8* b) +static u32 to_u32(u8 const* b) { return AK::convert_between_host_and_big_endian(ByteReader::load32(b)); } -static void to_u8s(u8* b, const u32* w) +static void to_u8s(u8* b, u32 const* w) { for (auto i = 0; i < 4; ++i) { ByteReader::store(b + i * 4, AK::convert_between_host_and_big_endian(w[i])); diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.h b/Userland/Libraries/LibCrypto/Authentication/GHash.h index 0bfc8274cd..21b6039d5d 100644 --- a/Userland/Libraries/LibCrypto/Authentication/GHash.h +++ b/Userland/Libraries/LibCrypto/Authentication/GHash.h @@ -24,7 +24,7 @@ struct GHashDigest { constexpr static size_t Size = 16; u8 data[Size]; - const u8* immutable_data() const { return data; } + u8 const* immutable_data() const { return data; } size_t data_length() { return Size; } }; @@ -33,7 +33,7 @@ public: using TagType = GHashDigest; template<size_t N> - explicit GHash(const char (&key)[N]) + explicit GHash(char const (&key)[N]) : GHash({ key, N }) { } diff --git a/Userland/Libraries/LibCrypto/Authentication/HMAC.h b/Userland/Libraries/LibCrypto/Authentication/HMAC.h index 8c80602dbe..29c9ce1300 100644 --- a/Userland/Libraries/LibCrypto/Authentication/HMAC.h +++ b/Userland/Libraries/LibCrypto/Authentication/HMAC.h @@ -39,23 +39,23 @@ public: reset(); } - TagType process(const u8* message, size_t length) + TagType process(u8 const* message, size_t length) { reset(); update(message, length); return digest(); } - void update(const u8* message, size_t length) + void update(u8 const* message, size_t length) { m_inner_hasher.update(message, length); } TagType process(ReadonlyBytes span) { return process(span.data(), span.size()); } - TagType process(StringView string) { return process((const u8*)string.characters_without_null_termination(), string.length()); } + TagType process(StringView string) { return process((u8 const*)string.characters_without_null_termination(), string.length()); } void update(ReadonlyBytes span) { return update(span.data(), span.size()); } - void update(StringView string) { return update((const u8*)string.characters_without_null_termination(), string.length()); } + void update(StringView string) { return update((u8 const*)string.characters_without_null_termination(), string.length()); } TagType digest() { @@ -84,7 +84,7 @@ public: #endif private: - void derive_key(const u8* key, size_t length) + void derive_key(u8 const* key, size_t length) { auto block_size = m_inner_hasher.block_size(); // Note: The block size of all the current hash functions is 512 bits. diff --git a/Userland/Libraries/LibCrypto/BigInt/Algorithms/BitwiseOperations.cpp b/Userland/Libraries/LibCrypto/BigInt/Algorithms/BitwiseOperations.cpp index 55bcbb44e8..2003e4896c 100644 --- a/Userland/Libraries/LibCrypto/BigInt/Algorithms/BitwiseOperations.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/Algorithms/BitwiseOperations.cpp @@ -32,7 +32,7 @@ FLATTEN void UnsignedBigIntegerAlgorithms::bitwise_or_without_allocation( return; } - const UnsignedBigInteger *shorter, *longer; + UnsignedBigInteger const *shorter, *longer; if (left.length() < right.length()) { shorter = &left; longer = &right; @@ -71,7 +71,7 @@ FLATTEN void UnsignedBigIntegerAlgorithms::bitwise_and_without_allocation( return; } - const UnsignedBigInteger *shorter, *longer; + UnsignedBigInteger const *shorter, *longer; if (left.length() < right.length()) { shorter = &left; longer = &right; @@ -110,7 +110,7 @@ FLATTEN void UnsignedBigIntegerAlgorithms::bitwise_xor_without_allocation( return; } - const UnsignedBigInteger *shorter, *longer; + UnsignedBigInteger const *shorter, *longer; if (left.length() < right.length()) { shorter = &left; longer = &right; diff --git a/Userland/Libraries/LibCrypto/BigInt/Algorithms/SimpleOperations.cpp b/Userland/Libraries/LibCrypto/BigInt/Algorithms/SimpleOperations.cpp index bf8e784180..78ac298c61 100644 --- a/Userland/Libraries/LibCrypto/BigInt/Algorithms/SimpleOperations.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/Algorithms/SimpleOperations.cpp @@ -17,8 +17,8 @@ void UnsignedBigIntegerAlgorithms::add_without_allocation( UnsignedBigInteger const& right, UnsignedBigInteger& output) { - const UnsignedBigInteger* const longer = (left.length() > right.length()) ? &left : &right; - const UnsignedBigInteger* const shorter = (longer == &right) ? &left : &right; + UnsignedBigInteger const* const longer = (left.length() > right.length()) ? &left : &right; + UnsignedBigInteger const* const shorter = (longer == &right) ? &left : &right; output.set_to(*longer); add_into_accumulator_without_allocation(output, *shorter); diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp index e95102cb84..da24f95b31 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp @@ -9,7 +9,7 @@ namespace Crypto { -SignedBigInteger SignedBigInteger::import_data(const u8* ptr, size_t length) +SignedBigInteger SignedBigInteger::import_data(u8 const* ptr, size_t length) { bool sign = *ptr; auto unsigned_data = UnsignedBigInteger::import_data(ptr + 1, length - 1); @@ -71,7 +71,7 @@ double SignedBigInteger::to_double() const return -unsigned_value; } -FLATTEN SignedBigInteger SignedBigInteger::plus(const SignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::plus(SignedBigInteger const& other) const { // If both are of the same sign, just add the unsigned data and return. if (m_sign == other.m_sign) @@ -81,7 +81,7 @@ FLATTEN SignedBigInteger SignedBigInteger::plus(const SignedBigInteger& other) c return m_sign ? other.minus(this->m_unsigned_data) : minus(other.m_unsigned_data); } -FLATTEN SignedBigInteger SignedBigInteger::minus(const SignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::minus(SignedBigInteger const& other) const { // If the signs are different, convert the op to an addition. if (m_sign != other.m_sign) { @@ -120,7 +120,7 @@ FLATTEN SignedBigInteger SignedBigInteger::minus(const SignedBigInteger& other) return SignedBigInteger { 0 }; } -FLATTEN SignedBigInteger SignedBigInteger::plus(const UnsignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::plus(UnsignedBigInteger const& other) const { if (m_sign) { if (other < m_unsigned_data) @@ -132,7 +132,7 @@ FLATTEN SignedBigInteger SignedBigInteger::plus(const UnsignedBigInteger& other) return { m_unsigned_data.plus(other), false }; } -FLATTEN SignedBigInteger SignedBigInteger::minus(const UnsignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::minus(UnsignedBigInteger const& other) const { if (m_sign) return { m_unsigned_data.plus(m_unsigned_data), true }; @@ -167,7 +167,7 @@ FLATTEN SignedDivisionResult SignedBigInteger::divided_by(UnsignedBigInteger con }; } -FLATTEN SignedBigInteger SignedBigInteger::bitwise_or(const SignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::bitwise_or(SignedBigInteger const& other) const { // See bitwise_and() for derivations. if (!is_negative() && !other.is_negative()) @@ -191,7 +191,7 @@ FLATTEN SignedBigInteger SignedBigInteger::bitwise_or(const SignedBigInteger& ot return { unsigned_value().minus(1).bitwise_and(other.unsigned_value().minus(1)).plus(1), true }; } -FLATTEN SignedBigInteger SignedBigInteger::bitwise_and(const SignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::bitwise_and(SignedBigInteger const& other) const { if (!is_negative() && !other.is_negative()) return { unsigned_value().bitwise_and(other.unsigned_value()), false }; @@ -229,33 +229,33 @@ FLATTEN SignedBigInteger SignedBigInteger::bitwise_and(const SignedBigInteger& o return { unsigned_value().minus(1).bitwise_or(other.unsigned_value().minus(1)).plus(1), true }; } -FLATTEN SignedBigInteger SignedBigInteger::bitwise_xor(const SignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::bitwise_xor(SignedBigInteger const& other) const { return bitwise_or(other).minus(bitwise_and(other)); } -bool SignedBigInteger::operator==(const UnsignedBigInteger& other) const +bool SignedBigInteger::operator==(UnsignedBigInteger const& other) const { if (m_sign) return false; return m_unsigned_data == other; } -bool SignedBigInteger::operator!=(const UnsignedBigInteger& other) const +bool SignedBigInteger::operator!=(UnsignedBigInteger const& other) const { if (m_sign) return true; return m_unsigned_data != other; } -bool SignedBigInteger::operator<(const UnsignedBigInteger& other) const +bool SignedBigInteger::operator<(UnsignedBigInteger const& other) const { if (m_sign) return true; return m_unsigned_data < other; } -bool SignedBigInteger::operator>(const UnsignedBigInteger& other) const +bool SignedBigInteger::operator>(UnsignedBigInteger const& other) const { return *this != other && !(*this < other); } @@ -265,13 +265,13 @@ FLATTEN SignedBigInteger SignedBigInteger::shift_left(size_t num_bits) const return SignedBigInteger { m_unsigned_data.shift_left(num_bits), m_sign }; } -FLATTEN SignedBigInteger SignedBigInteger::multiplied_by(const SignedBigInteger& other) const +FLATTEN SignedBigInteger SignedBigInteger::multiplied_by(SignedBigInteger const& other) const { bool result_sign = m_sign ^ other.m_sign; return { m_unsigned_data.multiplied_by(other.m_unsigned_data), result_sign }; } -FLATTEN SignedDivisionResult SignedBigInteger::divided_by(const SignedBigInteger& divisor) const +FLATTEN SignedDivisionResult SignedBigInteger::divided_by(SignedBigInteger const& divisor) const { // Aa / Bb -> (A^B)q, Ar bool result_sign = m_sign ^ divisor.m_sign; @@ -292,7 +292,7 @@ void SignedBigInteger::set_bit_inplace(size_t bit_index) m_unsigned_data.set_bit_inplace(bit_index); } -bool SignedBigInteger::operator==(const SignedBigInteger& other) const +bool SignedBigInteger::operator==(SignedBigInteger const& other) const { if (is_invalid() != other.is_invalid()) return false; @@ -303,12 +303,12 @@ bool SignedBigInteger::operator==(const SignedBigInteger& other) const return m_sign == other.m_sign && m_unsigned_data == other.m_unsigned_data; } -bool SignedBigInteger::operator!=(const SignedBigInteger& other) const +bool SignedBigInteger::operator!=(SignedBigInteger const& other) const { return !(*this == other); } -bool SignedBigInteger::operator<(const SignedBigInteger& other) const +bool SignedBigInteger::operator<(SignedBigInteger const& other) const { if (m_sign ^ other.m_sign) return m_sign; @@ -319,24 +319,24 @@ bool SignedBigInteger::operator<(const SignedBigInteger& other) const return m_unsigned_data < other.m_unsigned_data; } -bool SignedBigInteger::operator<=(const SignedBigInteger& other) const +bool SignedBigInteger::operator<=(SignedBigInteger const& other) const { return *this < other || *this == other; } -bool SignedBigInteger::operator>(const SignedBigInteger& other) const +bool SignedBigInteger::operator>(SignedBigInteger const& other) const { return *this != other && !(*this < other); } -bool SignedBigInteger::operator>=(const SignedBigInteger& other) const +bool SignedBigInteger::operator>=(SignedBigInteger const& other) const { return !(*this < other); } } -ErrorOr<void> AK::Formatter<Crypto::SignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::SignedBigInteger& value) +ErrorOr<void> AK::Formatter<Crypto::SignedBigInteger>::format(FormatBuilder& fmtbuilder, Crypto::SignedBigInteger const& value) { if (value.is_negative()) TRY(fmtbuilder.put_string("-")); diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h index 5b5468a728..e39e37b038 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h @@ -45,8 +45,8 @@ public: return { UnsignedBigInteger::create_invalid(), false }; } - static SignedBigInteger import_data(StringView data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); } - static SignedBigInteger import_data(const u8* ptr, size_t length); + static SignedBigInteger import_data(StringView data) { return import_data((u8 const*)data.characters_without_null_termination(), data.length()); } + static SignedBigInteger import_data(u8 const* ptr, size_t length); static SignedBigInteger create_from(i64 value) { @@ -69,8 +69,8 @@ public: u64 to_u64() const; double to_double() const; - const UnsignedBigInteger& unsigned_value() const { return m_unsigned_data; } - const Vector<u32, STARTING_WORD_SIZE> words() const { return m_unsigned_data.words(); } + UnsignedBigInteger const& unsigned_value() const { return m_unsigned_data; } + Vector<u32, STARTING_WORD_SIZE> const words() const { return m_unsigned_data.words(); } bool is_negative() const { return m_sign; } void negate() @@ -90,7 +90,7 @@ public: m_unsigned_data.set_to((u32)other); m_sign = other < 0; } - void set_to(const SignedBigInteger& other) + void set_to(SignedBigInteger const& other) { m_unsigned_data.set_to(other.m_unsigned_data); m_sign = other.m_sign; @@ -107,36 +107,36 @@ public: size_t length() const { return m_unsigned_data.length() + 1; } size_t trimmed_length() const { return m_unsigned_data.trimmed_length() + 1; }; - SignedBigInteger plus(const SignedBigInteger& other) const; - SignedBigInteger minus(const SignedBigInteger& other) const; - SignedBigInteger bitwise_or(const SignedBigInteger& other) const; - SignedBigInteger bitwise_and(const SignedBigInteger& other) const; - SignedBigInteger bitwise_xor(const SignedBigInteger& other) const; + SignedBigInteger plus(SignedBigInteger const& other) const; + SignedBigInteger minus(SignedBigInteger const& other) const; + SignedBigInteger bitwise_or(SignedBigInteger const& other) const; + SignedBigInteger bitwise_and(SignedBigInteger const& other) const; + SignedBigInteger bitwise_xor(SignedBigInteger const& other) const; SignedBigInteger bitwise_not() const; SignedBigInteger shift_left(size_t num_bits) const; - SignedBigInteger multiplied_by(const SignedBigInteger& other) const; - SignedDivisionResult divided_by(const SignedBigInteger& divisor) const; + SignedBigInteger multiplied_by(SignedBigInteger const& other) const; + SignedDivisionResult divided_by(SignedBigInteger const& divisor) const; - SignedBigInteger plus(const UnsignedBigInteger& other) const; - SignedBigInteger minus(const UnsignedBigInteger& other) const; - SignedBigInteger multiplied_by(const UnsignedBigInteger& other) const; - SignedDivisionResult divided_by(const UnsignedBigInteger& divisor) const; + SignedBigInteger plus(UnsignedBigInteger const& other) const; + SignedBigInteger minus(UnsignedBigInteger const& other) const; + SignedBigInteger multiplied_by(UnsignedBigInteger const& other) const; + SignedDivisionResult divided_by(UnsignedBigInteger const& divisor) const; u32 hash() const; void set_bit_inplace(size_t bit_index); - bool operator==(const SignedBigInteger& other) const; - bool operator!=(const SignedBigInteger& other) const; - bool operator<(const SignedBigInteger& other) const; - bool operator<=(const SignedBigInteger& other) const; - bool operator>(const SignedBigInteger& other) const; - bool operator>=(const SignedBigInteger& other) const; + bool operator==(SignedBigInteger const& other) const; + bool operator!=(SignedBigInteger const& other) const; + bool operator<(SignedBigInteger const& other) const; + bool operator<=(SignedBigInteger const& other) const; + bool operator>(SignedBigInteger const& other) const; + bool operator>=(SignedBigInteger const& other) const; - bool operator==(const UnsignedBigInteger& other) const; - bool operator!=(const UnsignedBigInteger& other) const; - bool operator<(const UnsignedBigInteger& other) const; - bool operator>(const UnsignedBigInteger& other) const; + bool operator==(UnsignedBigInteger const& other) const; + bool operator!=(UnsignedBigInteger const& other) const; + bool operator<(UnsignedBigInteger const& other) const; + bool operator>(UnsignedBigInteger const& other) const; private: void ensure_sign_is_valid() @@ -162,7 +162,7 @@ struct AK::Formatter<Crypto::SignedBigInteger> : AK::Formatter<Crypto::UnsignedB }; inline Crypto::SignedBigInteger -operator""_sbigint(const char* string, size_t length) +operator""_sbigint(char const* string, size_t length) { return Crypto::SignedBigInteger::from_base(10, { string, length }); } diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index a8082721d1..b47b0f05ec 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp @@ -13,7 +13,7 @@ namespace Crypto { -UnsignedBigInteger::UnsignedBigInteger(const u8* ptr, size_t length) +UnsignedBigInteger::UnsignedBigInteger(u8 const* ptr, size_t length) { m_words.resize_and_keep_capacity((length + sizeof(u32) - 1) / sizeof(u32)); size_t in = length, out = 0; @@ -136,7 +136,7 @@ void UnsignedBigInteger::set_to(UnsignedBigInteger::Word other) m_cached_hash = 0; } -void UnsignedBigInteger::set_to(const UnsignedBigInteger& other) +void UnsignedBigInteger::set_to(UnsignedBigInteger const& other) { m_is_invalid = other.m_is_invalid; m_words.resize_and_keep_capacity(other.m_words.size()); @@ -195,7 +195,7 @@ size_t UnsignedBigInteger::one_based_index_of_highest_set_bit() const return index; } -FLATTEN UnsignedBigInteger UnsignedBigInteger::plus(const UnsignedBigInteger& other) const +FLATTEN UnsignedBigInteger UnsignedBigInteger::plus(UnsignedBigInteger const& other) const { UnsignedBigInteger result; @@ -204,7 +204,7 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::plus(const UnsignedBigInteger& ot return result; } -FLATTEN UnsignedBigInteger UnsignedBigInteger::minus(const UnsignedBigInteger& other) const +FLATTEN UnsignedBigInteger UnsignedBigInteger::minus(UnsignedBigInteger const& other) const { UnsignedBigInteger result; @@ -213,7 +213,7 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::minus(const UnsignedBigInteger& o return result; } -FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_or(const UnsignedBigInteger& other) const +FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_or(UnsignedBigInteger const& other) const { UnsignedBigInteger result; @@ -222,7 +222,7 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_or(const UnsignedBigInteg return result; } -FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_and(const UnsignedBigInteger& other) const +FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_and(UnsignedBigInteger const& other) const { UnsignedBigInteger result; @@ -231,7 +231,7 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_and(const UnsignedBigInte return result; } -FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_xor(const UnsignedBigInteger& other) const +FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_xor(UnsignedBigInteger const& other) const { UnsignedBigInteger result; @@ -260,7 +260,7 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::shift_left(size_t num_bits) const return output; } -FLATTEN UnsignedBigInteger UnsignedBigInteger::multiplied_by(const UnsignedBigInteger& other) const +FLATTEN UnsignedBigInteger UnsignedBigInteger::multiplied_by(UnsignedBigInteger const& other) const { UnsignedBigInteger result; UnsignedBigInteger temp_shift_result; @@ -272,7 +272,7 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::multiplied_by(const UnsignedBigIn return result; } -FLATTEN UnsignedDivisionResult UnsignedBigInteger::divided_by(const UnsignedBigInteger& divisor) const +FLATTEN UnsignedDivisionResult UnsignedBigInteger::divided_by(UnsignedBigInteger const& divisor) const { UnsignedBigInteger quotient; UnsignedBigInteger remainder; @@ -299,7 +299,7 @@ u32 UnsignedBigInteger::hash() const if (m_cached_hash != 0) return m_cached_hash; - return m_cached_hash = string_hash((const char*)m_words.data(), sizeof(Word) * m_words.size()); + return m_cached_hash = string_hash((char const*)m_words.data(), sizeof(Word) * m_words.size()); } void UnsignedBigInteger::set_bit_inplace(size_t bit_index) @@ -318,7 +318,7 @@ void UnsignedBigInteger::set_bit_inplace(size_t bit_index) m_cached_hash = 0; } -bool UnsignedBigInteger::operator==(const UnsignedBigInteger& other) const +bool UnsignedBigInteger::operator==(UnsignedBigInteger const& other) const { if (is_invalid() != other.is_invalid()) return false; @@ -331,12 +331,12 @@ bool UnsignedBigInteger::operator==(const UnsignedBigInteger& other) const return !__builtin_memcmp(m_words.data(), other.words().data(), length * (BITS_IN_WORD / 8)); } -bool UnsignedBigInteger::operator!=(const UnsignedBigInteger& other) const +bool UnsignedBigInteger::operator!=(UnsignedBigInteger const& other) const { return !(*this == other); } -bool UnsignedBigInteger::operator<(const UnsignedBigInteger& other) const +bool UnsignedBigInteger::operator<(UnsignedBigInteger const& other) const { auto length = trimmed_length(); auto other_length = other.trimmed_length(); @@ -360,7 +360,7 @@ bool UnsignedBigInteger::operator<(const UnsignedBigInteger& other) const return false; } -bool UnsignedBigInteger::operator>(const UnsignedBigInteger& other) const +bool UnsignedBigInteger::operator>(UnsignedBigInteger const& other) const { return *this != other && !(*this < other); } @@ -372,7 +372,7 @@ bool UnsignedBigInteger::operator>=(UnsignedBigInteger const& other) const } -ErrorOr<void> AK::Formatter<Crypto::UnsignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::UnsignedBigInteger& value) +ErrorOr<void> AK::Formatter<Crypto::UnsignedBigInteger>::format(FormatBuilder& fmtbuilder, Crypto::UnsignedBigInteger const& value) { if (value.is_invalid()) return Formatter<StringView>::format(fmtbuilder, "invalid"); diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h index 36cb4c1707..4a2c4878d5 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h +++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h @@ -30,14 +30,14 @@ public: { } - explicit UnsignedBigInteger(const u8* ptr, size_t length); + explicit UnsignedBigInteger(u8 const* ptr, size_t length); UnsignedBigInteger() = default; static UnsignedBigInteger create_invalid(); - static UnsignedBigInteger import_data(StringView data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); } - static UnsignedBigInteger import_data(const u8* ptr, size_t length) + static UnsignedBigInteger import_data(StringView data) { return import_data((u8 const*)data.characters_without_null_termination(), data.length()); } + static UnsignedBigInteger import_data(u8 const* ptr, size_t length) { return UnsignedBigInteger(ptr, length); } @@ -60,11 +60,11 @@ public: u64 to_u64() const; double to_double() const; - const Vector<Word, STARTING_WORD_SIZE>& words() const { return m_words; } + Vector<Word, STARTING_WORD_SIZE> const& words() const { return m_words; } void set_to_0(); void set_to(Word other); - void set_to(const UnsignedBigInteger& other); + void set_to(UnsignedBigInteger const& other); void invalidate() { @@ -86,24 +86,24 @@ public: size_t one_based_index_of_highest_set_bit() const; - UnsignedBigInteger plus(const UnsignedBigInteger& other) const; - UnsignedBigInteger minus(const UnsignedBigInteger& other) const; - UnsignedBigInteger bitwise_or(const UnsignedBigInteger& other) const; - UnsignedBigInteger bitwise_and(const UnsignedBigInteger& other) const; - UnsignedBigInteger bitwise_xor(const UnsignedBigInteger& other) const; + UnsignedBigInteger plus(UnsignedBigInteger const& other) const; + UnsignedBigInteger minus(UnsignedBigInteger const& other) const; + UnsignedBigInteger bitwise_or(UnsignedBigInteger const& other) const; + UnsignedBigInteger bitwise_and(UnsignedBigInteger const& other) const; + UnsignedBigInteger bitwise_xor(UnsignedBigInteger const& other) const; UnsignedBigInteger bitwise_not_fill_to_one_based_index(size_t) const; UnsignedBigInteger shift_left(size_t num_bits) const; - UnsignedBigInteger multiplied_by(const UnsignedBigInteger& other) const; - UnsignedDivisionResult divided_by(const UnsignedBigInteger& divisor) const; + UnsignedBigInteger multiplied_by(UnsignedBigInteger const& other) const; + UnsignedDivisionResult divided_by(UnsignedBigInteger const& divisor) const; u32 hash() const; void set_bit_inplace(size_t bit_index); - bool operator==(const UnsignedBigInteger& other) const; - bool operator!=(const UnsignedBigInteger& other) const; - bool operator<(const UnsignedBigInteger& other) const; - bool operator>(const UnsignedBigInteger& other) const; + bool operator==(UnsignedBigInteger const& other) const; + bool operator!=(UnsignedBigInteger const& other) const; + bool operator<(UnsignedBigInteger const& other) const; + bool operator>(UnsignedBigInteger const& other) const; bool operator>=(UnsignedBigInteger const& other) const; private: @@ -133,7 +133,7 @@ struct AK::Formatter<Crypto::UnsignedBigInteger> : Formatter<StringView> { }; inline Crypto::UnsignedBigInteger -operator""_bigint(const char* string, size_t length) +operator""_bigint(char const* string, size_t length) { return Crypto::UnsignedBigInteger::from_base(10, { string, length }); } diff --git a/Userland/Libraries/LibCrypto/Cipher/AES.cpp b/Userland/Libraries/LibCrypto/Cipher/AES.cpp index 989134d456..b853599f88 100644 --- a/Userland/Libraries/LibCrypto/Cipher/AES.cpp +++ b/Userland/Libraries/LibCrypto/Cipher/AES.cpp @@ -197,13 +197,13 @@ void AESCipherKey::expand_decrypt_key(ReadonlyBytes user_key, size_t bits) } } -void AESCipher::encrypt_block(const AESCipherBlock& in, AESCipherBlock& out) +void AESCipher::encrypt_block(AESCipherBlock const& in, AESCipherBlock& out) { u32 s0, s1, s2, s3, t0, t1, t2, t3; size_t r { 0 }; - const auto& dec_key = key(); - const auto* round_keys = dec_key.round_keys(); + auto const& dec_key = key(); + auto const* round_keys = dec_key.round_keys(); s0 = get_key(in.bytes().offset_pointer(0)) ^ round_keys[0]; s1 = get_key(in.bytes().offset_pointer(4)) ^ round_keys[1]; @@ -289,13 +289,13 @@ void AESCipher::encrypt_block(const AESCipherBlock& in, AESCipherBlock& out) // clang-format on } -void AESCipher::decrypt_block(const AESCipherBlock& in, AESCipherBlock& out) +void AESCipher::decrypt_block(AESCipherBlock const& in, AESCipherBlock& out) { u32 s0, s1, s2, s3, t0, t1, t2, t3; size_t r { 0 }; - const auto& dec_key = key(); - const auto* round_keys = dec_key.round_keys(); + auto const& dec_key = key(); + auto const* round_keys = dec_key.round_keys(); s0 = get_key(in.bytes().offset_pointer(0)) ^ round_keys[0]; s1 = get_key(in.bytes().offset_pointer(4)) ^ round_keys[1]; diff --git a/Userland/Libraries/LibCrypto/Cipher/AES.h b/Userland/Libraries/LibCrypto/Cipher/AES.h index dd92484d59..4aa94bf6dd 100644 --- a/Userland/Libraries/LibCrypto/Cipher/AES.h +++ b/Userland/Libraries/LibCrypto/Cipher/AES.h @@ -28,7 +28,7 @@ public: : CipherBlock(mode) { } - AESCipherBlock(const u8* data, size_t length, PaddingMode mode = PaddingMode::CMS) + AESCipherBlock(u8 const* data, size_t length, PaddingMode mode = PaddingMode::CMS) : AESCipherBlock(mode) { CipherBlock::overwrite(data, length); @@ -40,7 +40,7 @@ public: virtual Bytes bytes() override { return Bytes { m_data, sizeof(m_data) }; } virtual void overwrite(ReadonlyBytes) override; - virtual void overwrite(const u8* data, size_t size) override { overwrite({ data, size }); } + virtual void overwrite(u8 const* data, size_t size) override { overwrite({ data, size }); } virtual void apply_initialization_vector(ReadonlyBytes ivec) override { @@ -68,9 +68,9 @@ struct AESCipherKey : public CipherKey { String to_string() const; #endif - const u32* round_keys() const + u32 const* round_keys() const { - return (const u32*)m_rd_keys; + return (u32 const*)m_rd_keys; } AESCipherKey(ReadonlyBytes user_key, size_t key_bits, Intent intent) @@ -114,11 +114,11 @@ public: { } - virtual const AESCipherKey& key() const override { return m_key; }; + virtual AESCipherKey const& key() const override { return m_key; }; virtual AESCipherKey& key() override { return m_key; }; - virtual void encrypt_block(const BlockType& in, BlockType& out) override; - virtual void decrypt_block(const BlockType& in, BlockType& out) override; + virtual void encrypt_block(BlockType const& in, BlockType& out) override; + virtual void decrypt_block(BlockType const& in, BlockType& out) override; #ifndef KERNEL virtual String class_name() const override diff --git a/Userland/Libraries/LibCrypto/Cipher/Cipher.h b/Userland/Libraries/LibCrypto/Cipher/Cipher.h index 88178a1f38..644dd1353a 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Cipher.h +++ b/Userland/Libraries/LibCrypto/Cipher/Cipher.h @@ -43,7 +43,7 @@ public: virtual ReadonlyBytes bytes() const = 0; virtual void overwrite(ReadonlyBytes) = 0; - virtual void overwrite(const u8* data, size_t size) { overwrite({ data, size }); } + virtual void overwrite(u8 const* data, size_t size) { overwrite({ data, size }); } virtual void apply_initialization_vector(ReadonlyBytes ivec) = 0; @@ -102,15 +102,15 @@ public: { } - virtual const KeyType& key() const = 0; + virtual KeyType const& key() const = 0; virtual KeyType& key() = 0; constexpr static size_t block_size() { return BlockType::block_size(); } PaddingMode padding_mode() const { return m_padding_mode; } - virtual void encrypt_block(const BlockType& in, BlockType& out) = 0; - virtual void decrypt_block(const BlockType& in, BlockType& out) = 0; + virtual void encrypt_block(BlockType const& in, BlockType& out) = 0; + virtual void decrypt_block(BlockType const& in, BlockType& out) = 0; #ifndef KERNEL virtual String class_name() const = 0; diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h index 979ca281ed..3639282bf8 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h @@ -99,7 +99,7 @@ public: // FIXME: Add back the default intent parameter once clang-11 is the default in GitHub Actions. // Once added back, remove the parameter where it's constructed in get_random_bytes in Kernel/Random.h. template<typename KeyType, typename... Args> - explicit constexpr CTR(const KeyType& user_key, size_t key_bits, Intent, Args... args) + explicit constexpr CTR(KeyType const& user_key, size_t key_bits, Intent, Args... args) : Mode<T>(user_key, key_bits, Intent::Encryption, args...) { } @@ -126,7 +126,7 @@ public: this->encrypt_or_stream(&in, out, ivec, ivec_out); } - void key_stream(Bytes& out, const Bytes& ivec = {}, Bytes* ivec_out = nullptr) + void key_stream(Bytes& out, Bytes const& ivec = {}, Bytes* ivec_out = nullptr) { this->encrypt_or_stream(nullptr, out, ivec, ivec_out); } @@ -144,7 +144,7 @@ private: protected: constexpr static IncrementFunctionType increment {}; - void encrypt_or_stream(const ReadonlyBytes* in, Bytes& out, ReadonlyBytes ivec, Bytes* ivec_out = nullptr) + void encrypt_or_stream(ReadonlyBytes const* in, Bytes& out, ReadonlyBytes ivec, Bytes* ivec_out = nullptr) { size_t length; if (in) { diff --git a/Userland/Libraries/LibCrypto/Hash/HashFunction.h b/Userland/Libraries/LibCrypto/Hash/HashFunction.h index ff73aa6e61..3d875ff5db 100644 --- a/Userland/Libraries/LibCrypto/Hash/HashFunction.h +++ b/Userland/Libraries/LibCrypto/Hash/HashFunction.h @@ -19,7 +19,7 @@ struct Digest { constexpr static size_t Size = DigestS / 8; u8 data[Size]; - [[nodiscard]] ALWAYS_INLINE const u8* immutable_data() const { return data; } + [[nodiscard]] ALWAYS_INLINE u8 const* immutable_data() const { return data; } [[nodiscard]] ALWAYS_INLINE size_t data_length() const { return Size; } [[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const { return { immutable_data(), data_length() }; } @@ -39,12 +39,12 @@ public: constexpr static size_t block_size() { return BlockSize; } constexpr static size_t digest_size() { return DigestSize; } - virtual void update(const u8*, size_t) = 0; + virtual void update(u8 const*, size_t) = 0; void update(Bytes buffer) { update(buffer.data(), buffer.size()); } void update(ReadonlyBytes buffer) { update(buffer.data(), buffer.size()); } - void update(const ByteBuffer& buffer) { update(buffer.data(), buffer.size()); } - void update(StringView string) { update((const u8*)string.characters_without_null_termination(), string.length()); } + void update(ByteBuffer const& buffer) { update(buffer.data(), buffer.size()); } + void update(StringView string) { update((u8 const*)string.characters_without_null_termination(), string.length()); } virtual DigestType peek() = 0; virtual DigestType digest() = 0; diff --git a/Userland/Libraries/LibCrypto/Hash/HashManager.h b/Userland/Libraries/LibCrypto/Hash/HashManager.h index 10628bc52c..834823bf5f 100644 --- a/Userland/Libraries/LibCrypto/Hash/HashManager.h +++ b/Userland/Libraries/LibCrypto/Hash/HashManager.h @@ -59,25 +59,25 @@ struct MultiHashDigestVariant { { } - [[nodiscard]] const u8* immutable_data() const + [[nodiscard]] u8 const* immutable_data() const { return m_digest.visit( - [&](const Empty&) -> const u8* { VERIFY_NOT_REACHED(); }, - [&](const auto& value) { return value.immutable_data(); }); + [&](Empty const&) -> u8 const* { VERIFY_NOT_REACHED(); }, + [&](auto const& value) { return value.immutable_data(); }); } [[nodiscard]] size_t data_length() const { return m_digest.visit( - [&](const Empty&) -> size_t { VERIFY_NOT_REACHED(); }, - [&](const auto& value) { return value.data_length(); }); + [&](Empty const&) -> size_t { VERIFY_NOT_REACHED(); }, + [&](auto const& value) { return value.data_length(); }); } [[nodiscard]] ReadonlyBytes bytes() const { return m_digest.visit( - [&](const Empty&) -> ReadonlyBytes { VERIFY_NOT_REACHED(); }, - [&](const auto& value) { return value.bytes(); }); + [&](Empty const&) -> ReadonlyBytes { VERIFY_NOT_REACHED(); }, + [&](auto const& value) { return value.bytes(); }); } using DigestVariant = Variant<Empty, MD5::DigestType, SHA1::DigestType, SHA256::DigestType, SHA384::DigestType, SHA512::DigestType>; @@ -93,7 +93,7 @@ public: m_pre_init_buffer = ByteBuffer(); } - Manager(const Manager& other) // NOT a copy constructor! + Manager(Manager const& other) // NOT a copy constructor! { m_pre_init_buffer = ByteBuffer(); // will not be used initialize(other.m_kind); @@ -113,15 +113,15 @@ public: inline size_t digest_size() const { return m_algorithm.visit( - [&](const Empty&) -> size_t { return 0; }, - [&](const auto& hash) { return hash.digest_size(); }); + [&](Empty const&) -> size_t { return 0; }, + [&](auto const& hash) { return hash.digest_size(); }); } inline size_t block_size() const { return m_algorithm.visit( - [&](const Empty&) -> size_t { return 0; }, - [&](const auto& hash) { return hash.block_size(); }); + [&](Empty const&) -> size_t { return 0; }, + [&](auto const& hash) { return hash.block_size(); }); } inline void initialize(HashKind kind) @@ -154,7 +154,7 @@ public: } } - virtual void update(const u8* data, size_t length) override + virtual void update(u8 const* data, size_t length) override { auto size = m_pre_init_buffer.size(); if (size) { @@ -195,8 +195,8 @@ public: virtual String class_name() const override { return m_algorithm.visit( - [&](const Empty&) -> String { return "UninitializedHashManager"; }, - [&](const auto& hash) { return hash.class_name(); }); + [&](Empty const&) -> String { return "UninitializedHashManager"; }, + [&](auto const& hash) { return hash.class_name(); }); } #endif diff --git a/Userland/Libraries/LibCrypto/Hash/MD5.cpp b/Userland/Libraries/LibCrypto/Hash/MD5.cpp index e698021cff..72cb516d0c 100644 --- a/Userland/Libraries/LibCrypto/Hash/MD5.cpp +++ b/Userland/Libraries/LibCrypto/Hash/MD5.cpp @@ -48,7 +48,7 @@ static constexpr void round_4(u32& a, u32 b, u32 c, u32 d, u32 x, u32 s, u32 ac) namespace Crypto { namespace Hash { -void MD5::update(const u8* input, size_t length) +void MD5::update(u8 const* input, size_t length) { auto index = (u32)(m_count[0] >> 3) & 0x3f; size_t offset { 0 }; @@ -101,7 +101,7 @@ MD5::DigestType MD5::peek() return digest; } -void MD5::encode(const u32* from, u8* to, size_t length) +void MD5::encode(u32 const* from, u8* to, size_t length) { for (size_t i = 0, j = 0; j < length; ++i, j += 4) { to[j] = (u8)(from[i] & 0xff); @@ -111,13 +111,13 @@ void MD5::encode(const u32* from, u8* to, size_t length) } } -void MD5::decode(const u8* from, u32* to, size_t length) +void MD5::decode(u8 const* from, u32* to, size_t length) { for (size_t i = 0, j = 0; j < length; ++i, j += 4) to[i] = (((u32)from[j]) | (((u32)from[j + 1]) << 8) | (((u32)from[j + 2]) << 16) | (((u32)from[j + 3]) << 24)); } -void MD5::transform(const u8* block) +void MD5::transform(u8 const* block) { auto a = m_A; auto b = m_B; diff --git a/Userland/Libraries/LibCrypto/Hash/MD5.h b/Userland/Libraries/LibCrypto/Hash/MD5.h index 9c55b38b86..087ae022bd 100644 --- a/Userland/Libraries/LibCrypto/Hash/MD5.h +++ b/Userland/Libraries/LibCrypto/Hash/MD5.h @@ -52,7 +52,7 @@ class MD5 final : public HashFunction<512, 128> { public: using HashFunction::update; - virtual void update(const u8*, size_t) override; + virtual void update(u8 const*, size_t) override; virtual DigestType digest() override; virtual DigestType peek() override; @@ -63,15 +63,15 @@ public: } #endif - inline static DigestType hash(const u8* data, size_t length) + inline static DigestType hash(u8 const* data, size_t length) { MD5 md5; md5.update(data, length); return md5.digest(); } - inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); } - inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); } + inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); } + inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } inline virtual void reset() override { m_A = MD5Constants::init_A; @@ -86,10 +86,10 @@ public: } private: - inline void transform(const u8*); + inline void transform(u8 const*); - static void encode(const u32* from, u8* to, size_t length); - static void decode(const u8* from, u32* to, size_t length); + static void encode(u32 const* from, u8* to, size_t length); + static void decode(u8 const* from, u32* to, size_t length); u32 m_A { MD5Constants::init_A }, m_B { MD5Constants::init_B }, m_C { MD5Constants::init_C }, m_D { MD5Constants::init_D }; u32 m_count[2] { 0, 0 }; diff --git a/Userland/Libraries/LibCrypto/Hash/SHA1.cpp b/Userland/Libraries/LibCrypto/Hash/SHA1.cpp index edb699d708..6202225a8b 100644 --- a/Userland/Libraries/LibCrypto/Hash/SHA1.cpp +++ b/Userland/Libraries/LibCrypto/Hash/SHA1.cpp @@ -17,11 +17,11 @@ static constexpr auto ROTATE_LEFT(u32 value, size_t bits) return (value << bits) | (value >> (32 - bits)); } -inline void SHA1::transform(const u8* data) +inline void SHA1::transform(u8 const* data) { u32 blocks[80]; for (size_t i = 0; i < 16; ++i) - blocks[i] = AK::convert_between_host_and_network_endian(((const u32*)data)[i]); + blocks[i] = AK::convert_between_host_and_network_endian(((u32 const*)data)[i]); // w[i] = (w[i-3] xor w[i-8] xor w[i-14] xor w[i-16]) leftrotate 1 for (size_t i = 16; i < Rounds; ++i) @@ -67,7 +67,7 @@ inline void SHA1::transform(const u8* data) secure_zero(blocks, 16 * sizeof(u32)); } -void SHA1::update(const u8* message, size_t length) +void SHA1::update(u8 const* message, size_t length) { for (size_t i = 0; i < length; ++i) { if (m_data_length == BlockSize) { diff --git a/Userland/Libraries/LibCrypto/Hash/SHA1.h b/Userland/Libraries/LibCrypto/Hash/SHA1.h index 8fcbfc7f56..200cc1f509 100644 --- a/Userland/Libraries/LibCrypto/Hash/SHA1.h +++ b/Userland/Libraries/LibCrypto/Hash/SHA1.h @@ -37,20 +37,20 @@ public: reset(); } - virtual void update(const u8*, size_t) override; + virtual void update(u8 const*, size_t) override; virtual DigestType digest() override; virtual DigestType peek() override; - inline static DigestType hash(const u8* data, size_t length) + inline static DigestType hash(u8 const* data, size_t length) { SHA1 sha; sha.update(data, length); return sha.digest(); } - inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); } - inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); } + inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); } + inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL virtual String class_name() const override @@ -68,7 +68,7 @@ public: } private: - inline void transform(const u8*); + inline void transform(u8 const*); u8 m_data_buffer[BlockSize] {}; size_t m_data_length { 0 }; diff --git a/Userland/Libraries/LibCrypto/Hash/SHA2.cpp b/Userland/Libraries/LibCrypto/Hash/SHA2.cpp index 85a4a0dd87..6876e1e2b5 100644 --- a/Userland/Libraries/LibCrypto/Hash/SHA2.cpp +++ b/Userland/Libraries/LibCrypto/Hash/SHA2.cpp @@ -25,7 +25,7 @@ constexpr static auto EP1(u64 x) { return ROTRIGHT(x, 14) ^ ROTRIGHT(x, 18) ^ RO constexpr static auto SIGN0(u64 x) { return ROTRIGHT(x, 1) ^ ROTRIGHT(x, 8) ^ (x >> 7); } constexpr static auto SIGN1(u64 x) { return ROTRIGHT(x, 19) ^ ROTRIGHT(x, 61) ^ (x >> 6); } -inline void SHA256::transform(const u8* data) +inline void SHA256::transform(u8 const* data) { u32 m[64]; @@ -66,7 +66,7 @@ inline void SHA256::transform(const u8* data) m_state[7] += h; } -void SHA256::update(const u8* message, size_t length) +void SHA256::update(u8 const* message, size_t length) { for (size_t i = 0; i < length; ++i) { if (m_data_length == BlockSize) { @@ -142,7 +142,7 @@ SHA256::DigestType SHA256::peek() return digest; } -inline void SHA384::transform(const u8* data) +inline void SHA384::transform(u8 const* data) { u64 m[80]; @@ -184,7 +184,7 @@ inline void SHA384::transform(const u8* data) m_state[7] += h; } -void SHA384::update(const u8* message, size_t length) +void SHA384::update(u8 const* message, size_t length) { for (size_t i = 0; i < length; ++i) { if (m_data_length == BlockSize) { @@ -267,7 +267,7 @@ SHA384::DigestType SHA384::peek() return digest; } -inline void SHA512::transform(const u8* data) +inline void SHA512::transform(u8 const* data) { u64 m[80]; @@ -308,7 +308,7 @@ inline void SHA512::transform(const u8* data) m_state[7] += h; } -void SHA512::update(const u8* message, size_t length) +void SHA512::update(u8 const* message, size_t length) { for (size_t i = 0; i < length; ++i) { if (m_data_length == BlockSize) { diff --git a/Userland/Libraries/LibCrypto/Hash/SHA2.h b/Userland/Libraries/LibCrypto/Hash/SHA2.h index b9cb3315dd..9cc4433140 100644 --- a/Userland/Libraries/LibCrypto/Hash/SHA2.h +++ b/Userland/Libraries/LibCrypto/Hash/SHA2.h @@ -85,20 +85,20 @@ public: reset(); } - virtual void update(const u8*, size_t) override; + virtual void update(u8 const*, size_t) override; virtual DigestType digest() override; virtual DigestType peek() override; - inline static DigestType hash(const u8* data, size_t length) + inline static DigestType hash(u8 const* data, size_t length) { SHA256 sha; sha.update(data, length); return sha.digest(); } - inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); } - inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); } + inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); } + inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL virtual String class_name() const override @@ -116,7 +116,7 @@ public: } private: - inline void transform(const u8*); + inline void transform(u8 const*); u8 m_data_buffer[BlockSize] {}; size_t m_data_length { 0 }; @@ -137,20 +137,20 @@ public: reset(); } - virtual void update(const u8*, size_t) override; + virtual void update(u8 const*, size_t) override; virtual DigestType digest() override; virtual DigestType peek() override; - inline static DigestType hash(const u8* data, size_t length) + inline static DigestType hash(u8 const* data, size_t length) { SHA384 sha; sha.update(data, length); return sha.digest(); } - inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); } - inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); } + inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); } + inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL virtual String class_name() const override @@ -168,7 +168,7 @@ public: } private: - inline void transform(const u8*); + inline void transform(u8 const*); u8 m_data_buffer[BlockSize] {}; size_t m_data_length { 0 }; @@ -189,20 +189,20 @@ public: reset(); } - virtual void update(const u8*, size_t) override; + virtual void update(u8 const*, size_t) override; virtual DigestType digest() override; virtual DigestType peek() override; - inline static DigestType hash(const u8* data, size_t length) + inline static DigestType hash(u8 const* data, size_t length) { SHA512 sha; sha.update(data, length); return sha.digest(); } - inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); } - inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); } + inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); } + inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL virtual String class_name() const override @@ -220,7 +220,7 @@ public: } private: - inline void transform(const u8*); + inline void transform(u8 const*); u8 m_data_buffer[BlockSize] {}; size_t m_data_length { 0 }; diff --git a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp index 4aa33b015d..b44e6cac0c 100644 --- a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp +++ b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp @@ -11,7 +11,7 @@ namespace Crypto { namespace NumberTheory { -UnsignedBigInteger ModularInverse(const UnsignedBigInteger& a_, const UnsignedBigInteger& b) +UnsignedBigInteger ModularInverse(UnsignedBigInteger const& a_, UnsignedBigInteger const& b) { if (b == 1) return { 1 }; @@ -32,7 +32,7 @@ UnsignedBigInteger ModularInverse(const UnsignedBigInteger& a_, const UnsignedBi return result; } -UnsignedBigInteger ModularPower(const UnsignedBigInteger& b, const UnsignedBigInteger& e, const UnsignedBigInteger& m) +UnsignedBigInteger ModularPower(UnsignedBigInteger const& b, UnsignedBigInteger const& e, UnsignedBigInteger const& m) { if (m == 1) return 0; @@ -68,7 +68,7 @@ UnsignedBigInteger ModularPower(const UnsignedBigInteger& b, const UnsignedBigIn return result; } -UnsignedBigInteger GCD(const UnsignedBigInteger& a, const UnsignedBigInteger& b) +UnsignedBigInteger GCD(UnsignedBigInteger const& a, UnsignedBigInteger const& b) { UnsignedBigInteger temp_a { a }; UnsignedBigInteger temp_b { b }; @@ -85,7 +85,7 @@ UnsignedBigInteger GCD(const UnsignedBigInteger& a, const UnsignedBigInteger& b) return output; } -UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b) +UnsignedBigInteger LCM(UnsignedBigInteger const& a, UnsignedBigInteger const& b) { UnsignedBigInteger temp_a { a }; UnsignedBigInteger temp_b { b }; @@ -113,7 +113,7 @@ UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b) return output; } -static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInteger, 256>& tests) +static bool MR_primality_test(UnsignedBigInteger n, Vector<UnsignedBigInteger, 256> const& tests) { // Written using Wikipedia: // https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Miller%E2%80%93Rabin_test @@ -158,7 +158,7 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte return true; // "probably prime" } -UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBigInteger& max_excluded) +UnsignedBigInteger random_number(UnsignedBigInteger const& min, UnsignedBigInteger const& max_excluded) { VERIFY(min < max_excluded); auto range = max_excluded.minus(min); @@ -181,7 +181,7 @@ UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBi return divmod.remainder.plus(min); } -bool is_probably_prime(const UnsignedBigInteger& p) +bool is_probably_prime(UnsignedBigInteger const& p) { // Is it a small number? if (p < 49) { diff --git a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.h b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.h index 3f6f04f0a0..b77d2c0db4 100644 --- a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.h +++ b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.h @@ -12,14 +12,14 @@ namespace Crypto { namespace NumberTheory { -UnsignedBigInteger ModularInverse(const UnsignedBigInteger& a_, const UnsignedBigInteger& b); -UnsignedBigInteger ModularPower(const UnsignedBigInteger& b, const UnsignedBigInteger& e, const UnsignedBigInteger& m); +UnsignedBigInteger ModularInverse(UnsignedBigInteger const& a_, UnsignedBigInteger const& b); +UnsignedBigInteger ModularPower(UnsignedBigInteger const& b, UnsignedBigInteger const& e, UnsignedBigInteger const& m); // Note: This function _will_ generate extremely huge numbers, and in doing so, // it will allocate and free a lot of memory! // Please use |ModularPower| if your use-case is modexp. template<typename IntegerType> -static IntegerType Power(const IntegerType& b, const IntegerType& e) +static IntegerType Power(IntegerType const& b, IntegerType const& e) { IntegerType ep { e }; IntegerType base { b }; @@ -39,11 +39,11 @@ static IntegerType Power(const IntegerType& b, const IntegerType& e) return exp; } -UnsignedBigInteger GCD(const UnsignedBigInteger& a, const UnsignedBigInteger& b); -UnsignedBigInteger LCM(const UnsignedBigInteger& a, const UnsignedBigInteger& b); +UnsignedBigInteger GCD(UnsignedBigInteger const& a, UnsignedBigInteger const& b); +UnsignedBigInteger LCM(UnsignedBigInteger const& a, UnsignedBigInteger const& b); -UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBigInteger& max_excluded); -bool is_probably_prime(const UnsignedBigInteger& p); +UnsignedBigInteger random_number(UnsignedBigInteger const& min, UnsignedBigInteger const& max_excluded); +bool is_probably_prime(UnsignedBigInteger const& p); UnsignedBigInteger random_big_prime(size_t bits); } diff --git a/Userland/Libraries/LibCrypto/PK/Code/Code.h b/Userland/Libraries/LibCrypto/PK/Code/Code.h index 3300129ac7..6835c4d7b5 100644 --- a/Userland/Libraries/LibCrypto/PK/Code/Code.h +++ b/Userland/Libraries/LibCrypto/PK/Code/Code.h @@ -24,7 +24,7 @@ public: virtual void encode(ReadonlyBytes in, ByteBuffer& out, size_t em_bits) = 0; virtual VerificationConsistency verify(ReadonlyBytes msg, ReadonlyBytes emsg, size_t em_bits) = 0; - const HashFunction& hasher() const { return m_hasher; } + HashFunction const& hasher() const { return m_hasher; } HashFunction& hasher() { return m_hasher; } protected: diff --git a/Userland/Libraries/LibCrypto/PK/RSA.cpp b/Userland/Libraries/LibCrypto/PK/RSA.cpp index 15f257fc29..bc532d5ffa 100644 --- a/Userland/Libraries/LibCrypto/PK/RSA.cpp +++ b/Userland/Libraries/LibCrypto/PK/RSA.cpp @@ -56,7 +56,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes der) bool has_read_error = false; - const auto check_if_pkcs8_rsa_key = [&] { + auto const check_if_pkcs8_rsa_key = [&] { // see if it's a sequence: auto tag_result = decoder.peek(); if (tag_result.is_error()) { diff --git a/Userland/Libraries/LibCrypto/PK/RSA.h b/Userland/Libraries/LibCrypto/PK/RSA.h index 0134728093..9884ae0610 100644 --- a/Userland/Libraries/LibCrypto/PK/RSA.h +++ b/Userland/Libraries/LibCrypto/PK/RSA.h @@ -31,8 +31,8 @@ public: { } - const Integer& modulus() const { return m_modulus; } - const Integer& public_exponent() const { return m_public_exponent; } + Integer const& modulus() const { return m_modulus; } + Integer const& public_exponent() const { return m_public_exponent; } size_t length() const { return m_length; } void set_length(size_t length) { m_length = length; } @@ -62,9 +62,9 @@ public: RSAPrivateKey() = default; - const Integer& modulus() const { return m_modulus; } - const Integer& private_exponent() const { return m_private_exponent; } - const Integer& public_exponent() const { return m_public_exponent; } + Integer const& modulus() const { return m_modulus; } + Integer const& private_exponent() const { return m_private_exponent; } + Integer const& public_exponent() const { return m_public_exponent; } size_t length() const { return m_length; } void set_length(size_t length) { m_length = length; } @@ -135,7 +135,7 @@ public: { } - RSA(const ByteBuffer& publicKeyPEM, const ByteBuffer& privateKeyPEM) + RSA(ByteBuffer const& publicKeyPEM, ByteBuffer const& privateKeyPEM) { import_public_key(publicKeyPEM); import_private_key(privateKeyPEM); @@ -176,8 +176,8 @@ public: void import_public_key(ReadonlyBytes, bool pem = true); void import_private_key(ReadonlyBytes, bool pem = true); - const PrivateKeyType& private_key() const { return m_private_key; } - const PublicKeyType& public_key() const { return m_public_key; } + PrivateKeyType const& private_key() const { return m_private_key; } + PublicKeyType const& public_key() const { return m_public_key; } }; template<typename HashFunction> diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index c0dc9b1905..6cf6a90cf1 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -142,7 +142,7 @@ Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source } Optional<SourcePositionAndAddress> result; - for (const auto& line_entry : m_sorted_lines) { + for (auto const& line_entry : m_sorted_lines) { if (!line_entry.file.ends_with(file_path)) continue; @@ -159,12 +159,12 @@ Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source return result; } -NonnullOwnPtrVector<DebugInfo::VariableInfo> DebugInfo::get_variables_in_current_scope(const PtraceRegisters& regs) const +NonnullOwnPtrVector<DebugInfo::VariableInfo> DebugInfo::get_variables_in_current_scope(PtraceRegisters const& regs) const { NonnullOwnPtrVector<DebugInfo::VariableInfo> variables; // TODO: We can store the scopes in a better data structure - for (const auto& scope : m_scopes) { + for (auto const& scope : m_scopes) { FlatPtr ip; #if ARCH(I386) ip = regs.eip; @@ -174,7 +174,7 @@ NonnullOwnPtrVector<DebugInfo::VariableInfo> DebugInfo::get_variables_in_current if (ip - m_base_address < scope.address_low || ip - m_base_address >= scope.address_high) continue; - for (const auto& die_entry : scope.dies_of_variables) { + for (auto const& die_entry : scope.dies_of_variables) { auto variable_info = create_variable_info(die_entry, regs); if (!variable_info) continue; @@ -357,7 +357,7 @@ String DebugInfo::name_of_containing_function(FlatPtr address) const Optional<DebugInfo::VariablesScope> DebugInfo::get_containing_function(FlatPtr address) const { - for (const auto& scope : m_scopes) { + for (auto const& scope : m_scopes) { if (!scope.is_function || address < scope.address_low || address >= scope.address_high) continue; return scope; @@ -368,7 +368,7 @@ Optional<DebugInfo::VariablesScope> DebugInfo::get_containing_function(FlatPtr a Vector<DebugInfo::SourcePosition> DebugInfo::source_lines_in_scope(VariablesScope const& scope) const { Vector<DebugInfo::SourcePosition> source_lines; - for (const auto& line : m_sorted_lines) { + for (auto const& line : m_sorted_lines) { if (line.address < scope.address_low) continue; diff --git a/Userland/Libraries/LibDebug/DebugInfo.h b/Userland/Libraries/LibDebug/DebugInfo.h index 6a8d12b20d..43493c3313 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.h +++ b/Userland/Libraries/LibDebug/DebugInfo.h @@ -71,7 +71,7 @@ public: union { u32 as_u32; u32 as_i32; - const char* as_string; + char const* as_string; } constant_data { 0 }; Dwarf::EntryTag type_tag; @@ -107,22 +107,22 @@ public: FlatPtr address; }; - Optional<SourcePositionAndAddress> get_address_from_source_position(const String& file, size_t line) const; + Optional<SourcePositionAndAddress> get_address_from_source_position(String const& file, size_t line) const; String name_of_containing_function(FlatPtr address) const; - Vector<SourcePosition> source_lines_in_scope(const VariablesScope&) const; + Vector<SourcePosition> source_lines_in_scope(VariablesScope const&) const; Optional<VariablesScope> get_containing_function(FlatPtr address) const; private: void prepare_variable_scopes(); void prepare_lines(); - void parse_scopes_impl(const Dwarf::DIE& die); - OwnPtr<VariableInfo> create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters&, u32 address_offset = 0) const; - static bool is_variable_tag_supported(const Dwarf::EntryTag& tag); - void add_type_info_to_variable(const Dwarf::DIE& type_die, const PtraceRegisters& regs, DebugInfo::VariableInfo* parent_variable) const; + void parse_scopes_impl(Dwarf::DIE const& die); + OwnPtr<VariableInfo> create_variable_info(Dwarf::DIE const& variable_die, PtraceRegisters const&, u32 address_offset = 0) const; + static bool is_variable_tag_supported(Dwarf::EntryTag const& tag); + void add_type_info_to_variable(Dwarf::DIE const& type_die, PtraceRegisters const& regs, DebugInfo::VariableInfo* parent_variable) const; - Optional<Dwarf::LineProgram::DirectoryAndFile> get_source_path_of_inline(const Dwarf::DIE&) const; - Optional<uint32_t> get_line_of_inline(const Dwarf::DIE&) const; + Optional<Dwarf::LineProgram::DirectoryAndFile> get_source_path_of_inline(Dwarf::DIE const&) const; + Optional<uint32_t> get_line_of_inline(Dwarf::DIE const&) const; ELF::Image const& m_elf; String m_source_root; diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp index f9d5515ed4..de990e6220 100644 --- a/Userland/Libraries/LibDebug/DebugSession.cpp +++ b/Userland/Libraries/LibDebug/DebugSession.cpp @@ -29,12 +29,12 @@ DebugSession::~DebugSession() if (m_is_debuggee_dead) return; - for (const auto& bp : m_breakpoints) { + for (auto const& bp : m_breakpoints) { disable_breakpoint(bp.key); } m_breakpoints.clear(); - for (const auto& wp : m_watchpoints) { + for (auto const& wp : m_watchpoints) { disable_watchpoint(wp.key); } m_watchpoints.clear(); @@ -46,8 +46,8 @@ DebugSession::~DebugSession() void DebugSession::for_each_loaded_library(Function<IterationDecision(LoadedLibrary const&)> func) const { - for (const auto& lib_name : m_loaded_libraries.keys()) { - const auto& lib = *m_loaded_libraries.get(lib_name).value(); + for (auto const& lib_name : m_loaded_libraries.keys()) { + auto const& lib = *m_loaded_libraries.get(lib_name).value(); if (func(lib) == IterationDecision::Break) break; } @@ -80,11 +80,11 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(String const& command, auto parts = command.split(' '); VERIFY(!parts.is_empty()); - const char** args = bit_cast<const char**>(calloc(parts.size() + 1, sizeof(const char*))); + char const** args = bit_cast<char const**>(calloc(parts.size() + 1, sizeof(char const*))); for (size_t i = 0; i < parts.size(); i++) { args[i] = parts[i].characters(); } - const char** envp = bit_cast<const char**>(calloc(2, sizeof(const char*))); + char const** envp = bit_cast<char const**>(calloc(2, sizeof(char const*))); // This causes loader to stop on a breakpoint before jumping to the entry point of the program. envp[0] = "_LOADER_BREAKPOINT=1"; int rc = execvpe(args[0], const_cast<char**>(args), const_cast<char**>(envp)); diff --git a/Userland/Libraries/LibDebug/Dwarf/AttributeValue.h b/Userland/Libraries/LibDebug/Dwarf/AttributeValue.h index 9343328abf..c46979c877 100644 --- a/Userland/Libraries/LibDebug/Dwarf/AttributeValue.h +++ b/Userland/Libraries/LibDebug/Dwarf/AttributeValue.h @@ -36,7 +36,7 @@ public: FlatPtr as_addr() const; u64 as_unsigned() const { return m_data.as_unsigned; } i64 as_signed() const { return m_data.as_signed; } - const char* as_string() const; + char const* as_string() const; bool as_bool() const { return m_data.as_bool; } ReadonlyBytes as_raw_bytes() const { return m_data.as_raw_bytes; } @@ -46,7 +46,7 @@ private: FlatPtr as_addr; u64 as_unsigned; i64 as_signed; - const char* as_string; // points to bytes in the memory mapped elf image + char const* as_string; // points to bytes in the memory mapped elf image bool as_bool; ReadonlyBytes as_raw_bytes; } m_data {}; diff --git a/Userland/Libraries/LibDebug/Dwarf/DIE.cpp b/Userland/Libraries/LibDebug/Dwarf/DIE.cpp index 4c1c271c5b..1577d98fd7 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DIE.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/DIE.cpp @@ -54,7 +54,7 @@ Optional<AttributeValue> DIE::get_attribute(Attribute const& attribute) const auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code); VERIFY(abbreviation_info); - for (const auto& attribute_spec : abbreviation_info->attribute_specifications) { + for (auto const& attribute_spec : abbreviation_info->attribute_specifications) { auto value = m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit); if (attribute_spec.attribute == attribute) { return value; diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp index 57b3991c10..23f7596019 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp @@ -77,7 +77,7 @@ void DwarfInfo::populate_compilation_units() } AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t implicit_const_value, - InputMemoryStream& debug_info_stream, const CompilationUnit* unit) const + InputMemoryStream& debug_info_stream, CompilationUnit const* unit) const { AttributeValue value; value.m_form = form; @@ -98,7 +98,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im value.m_type = AttributeValue::Type::String; auto strings_data = debug_strings_data(); - value.m_data.as_string = bit_cast<const char*>(strings_data.offset_pointer(offset)); + value.m_data.as_string = bit_cast<char const*>(strings_data.offset_pointer(offset)); break; } case AttributeDataForm::Data1: { @@ -199,7 +199,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im debug_info_stream >> str; VERIFY(!debug_info_stream.has_any_error()); value.m_type = AttributeValue::Type::String; - value.m_data.as_string = bit_cast<const char*>(debug_info_data().offset_pointer(str_offset)); + value.m_data.as_string = bit_cast<char const*>(debug_info_data().offset_pointer(str_offset)); break; } case AttributeDataForm::Block1: { @@ -241,7 +241,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im value.m_type = AttributeValue::Type::String; auto strings_data = debug_line_strings_data(); - value.m_data.as_string = bit_cast<const char*>(strings_data.offset_pointer(offset)); + value.m_data.as_string = bit_cast<char const*>(strings_data.offset_pointer(offset)); break; } case AttributeDataForm::ImplicitConst: { diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h index 3e9375801b..ac2ec7e2e5 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h @@ -39,7 +39,7 @@ public: void for_each_compilation_unit(Callback) const; AttributeValue get_attribute_value(AttributeDataForm form, ssize_t implicit_const_value, - InputMemoryStream& debug_info_stream, const CompilationUnit* unit = nullptr) const; + InputMemoryStream& debug_info_stream, CompilationUnit const* unit = nullptr) const; Optional<DIE> get_die_at_address(FlatPtr) const; @@ -89,7 +89,7 @@ private: template<typename Callback> void DwarfInfo::for_each_compilation_unit(Callback callback) const { - for (const auto& unit : m_compilation_units) { + for (auto const& unit : m_compilation_units) { callback(unit); } } diff --git a/Userland/Libraries/LibDebug/ProcessInspector.cpp b/Userland/Libraries/LibDebug/ProcessInspector.cpp index c006b2094f..bf07ff3dab 100644 --- a/Userland/Libraries/LibDebug/ProcessInspector.cpp +++ b/Userland/Libraries/LibDebug/ProcessInspector.cpp @@ -9,10 +9,10 @@ namespace Debug { -const LoadedLibrary* ProcessInspector::library_at(FlatPtr address) const +LoadedLibrary const* ProcessInspector::library_at(FlatPtr address) const { - const LoadedLibrary* result = nullptr; - for_each_loaded_library([&result, address](const auto& lib) { + LoadedLibrary const* result = nullptr; + for_each_loaded_library([&result, address](auto const& lib) { if (address >= lib.base_address && address < lib.base_address + lib.debug_info->elf().size()) { result = &lib; return IterationDecision::Break; diff --git a/Userland/Libraries/LibDebug/ProcessInspector.h b/Userland/Libraries/LibDebug/ProcessInspector.h index 315d3e520f..00672ae111 100644 --- a/Userland/Libraries/LibDebug/ProcessInspector.h +++ b/Userland/Libraries/LibDebug/ProcessInspector.h @@ -22,7 +22,7 @@ public: virtual void set_registers(PtraceRegisters const&) = 0; virtual void for_each_loaded_library(Function<IterationDecision(LoadedLibrary const&)>) const = 0; - const LoadedLibrary* library_at(FlatPtr address) const; + LoadedLibrary const* library_at(FlatPtr address) const; struct SymbolicationResult { String library_name; String symbol; diff --git a/Userland/Libraries/LibDesktop/AppFile.h b/Userland/Libraries/LibDesktop/AppFile.h index 98f3af6cf0..a9f10da6fa 100644 --- a/Userland/Libraries/LibDesktop/AppFile.h +++ b/Userland/Libraries/LibDesktop/AppFile.h @@ -15,7 +15,7 @@ namespace Desktop { class AppFile : public RefCounted<AppFile> { public: - static constexpr const char* APP_FILES_DIRECTORY = "/res/apps"; + static constexpr char const* APP_FILES_DIRECTORY = "/res/apps"; static NonnullRefPtr<AppFile> get_for_app(StringView app_name); static NonnullRefPtr<AppFile> open(StringView path); static void for_each(Function<void(NonnullRefPtr<AppFile>)>, StringView directory = APP_FILES_DIRECTORY); diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index 62da78b5ac..fc32bb1951 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -14,7 +14,7 @@ namespace Desktop { -auto Launcher::Details::from_details_str(const String& details_str) -> NonnullRefPtr<Details> +auto Launcher::Details::from_details_str(String const& details_str) -> NonnullRefPtr<Details> { auto details = adopt_ref(*new Details); auto json = JsonValue::from_string(details_str).release_value_but_fixme_should_propagate_errors(); @@ -87,12 +87,12 @@ ErrorOr<void> Launcher::seal_allowlist() return {}; } -bool Launcher::open(const URL& url, const String& handler_name) +bool Launcher::open(const URL& url, String const& handler_name) { return connection().open_url(url, handler_name); } -bool Launcher::open(const URL& url, const Details& details) +bool Launcher::open(const URL& url, Details const& details) { VERIFY(details.launcher_type != LauncherType::Application); // Launcher should not be used to execute arbitrary applications return open(url, details.executable); diff --git a/Userland/Libraries/LibDesktop/Launcher.h b/Userland/Libraries/LibDesktop/Launcher.h index c62764a011..1a9229e0b1 100644 --- a/Userland/Libraries/LibDesktop/Launcher.h +++ b/Userland/Libraries/LibDesktop/Launcher.h @@ -28,7 +28,7 @@ public: String executable; LauncherType launcher_type { LauncherType::Default }; - static NonnullRefPtr<Details> from_details_str(const String&); + static NonnullRefPtr<Details> from_details_str(String const&); }; static void ensure_connection(); @@ -36,8 +36,8 @@ public: static ErrorOr<void> add_allowed_handler_with_any_url(String const& handler); static ErrorOr<void> add_allowed_handler_with_only_specific_urls(String const& handler, Vector<URL> const&); static ErrorOr<void> seal_allowlist(); - static bool open(const URL&, const String& handler_name = {}); - static bool open(const URL&, const Details& details); + static bool open(const URL&, String const& handler_name = {}); + static bool open(const URL&, Details const& details); static Vector<String> get_handlers_for_url(const URL&); static NonnullRefPtrVector<Details> get_handlers_with_details_for_url(const URL&); }; diff --git a/Userland/Libraries/LibDiff/Format.cpp b/Userland/Libraries/LibDiff/Format.cpp index ee28282183..1e1718ada0 100644 --- a/Userland/Libraries/LibDiff/Format.cpp +++ b/Userland/Libraries/LibDiff/Format.cpp @@ -10,12 +10,12 @@ #include <AK/Vector.h> namespace Diff { -String generate_only_additions(const String& text) +String generate_only_additions(String const& text) { auto lines = text.split('\n', true); // Keep empty StringBuilder builder; builder.appendff("@@ -0,0 +1,{} @@\n", lines.size()); - for (const auto& line : lines) { + for (auto const& line : lines) { builder.appendff("+{}\n", line); } return builder.to_string(); diff --git a/Userland/Libraries/LibDiff/Format.h b/Userland/Libraries/LibDiff/Format.h index e0570392ff..888b19555e 100644 --- a/Userland/Libraries/LibDiff/Format.h +++ b/Userland/Libraries/LibDiff/Format.h @@ -9,5 +9,5 @@ #include <AK/String.h> namespace Diff { -String generate_only_additions(const String&); +String generate_only_additions(String const&); }; diff --git a/Userland/Libraries/LibDiff/Hunks.cpp b/Userland/Libraries/LibDiff/Hunks.cpp index fe526045aa..babe53628c 100644 --- a/Userland/Libraries/LibDiff/Hunks.cpp +++ b/Userland/Libraries/LibDiff/Hunks.cpp @@ -8,7 +8,7 @@ #include <AK/Debug.h> namespace Diff { -Vector<Hunk> parse_hunks(const String& diff) +Vector<Hunk> parse_hunks(String const& diff) { Vector<String> diff_lines = diff.split('\n'); if (diff_lines.is_empty()) @@ -58,15 +58,15 @@ Vector<Hunk> parse_hunks(const String& diff) } if constexpr (HUNKS_DEBUG) { - for (const auto& hunk : hunks) { + for (auto const& hunk : hunks) { dbgln("Hunk location:"); dbgln(" orig: {}", hunk.original_start_line); dbgln(" target: {}", hunk.target_start_line); dbgln(" removed:"); - for (const auto& line : hunk.removed_lines) + for (auto const& line : hunk.removed_lines) dbgln("- {}", line); dbgln(" added:"); - for (const auto& line : hunk.added_lines) + for (auto const& line : hunk.added_lines) dbgln("+ {}", line); } } @@ -74,14 +74,14 @@ Vector<Hunk> parse_hunks(const String& diff) return hunks; } -HunkLocation parse_hunk_location(const String& location_line) +HunkLocation parse_hunk_location(String const& location_line) { size_t char_index = 0; struct StartAndLength { size_t start { 0 }; size_t length { 0 }; }; - auto parse_start_and_length_pair = [](const String& raw) { + auto parse_start_and_length_pair = [](String const& raw) { auto index_of_separator = raw.find(',').value(); auto start = raw.substring(0, index_of_separator).to_uint().value(); auto length = raw.substring(index_of_separator + 1, raw.length() - index_of_separator - 1).to_uint().value(); diff --git a/Userland/Libraries/LibDiff/Hunks.h b/Userland/Libraries/LibDiff/Hunks.h index dafd61bc1e..63050c12f0 100644 --- a/Userland/Libraries/LibDiff/Hunks.h +++ b/Userland/Libraries/LibDiff/Hunks.h @@ -32,6 +32,6 @@ struct Hunk { Vector<String> added_lines; }; -Vector<Hunk> parse_hunks(const String& diff); -HunkLocation parse_hunk_location(const String& location_line); +Vector<Hunk> parse_hunks(String const& diff); +HunkLocation parse_hunk_location(String const& location_line); }; diff --git a/Userland/Libraries/LibDl/dlfcn.cpp b/Userland/Libraries/LibDl/dlfcn.cpp index 077f62a101..ae1e18fe00 100644 --- a/Userland/Libraries/LibDl/dlfcn.cpp +++ b/Userland/Libraries/LibDl/dlfcn.cpp @@ -14,7 +14,7 @@ __thread char* s_dlerror_text = NULL; __thread bool s_dlerror_retrieved = false; -static void store_error(const String& error) +static void store_error(String const& error) { free(s_dlerror_text); s_dlerror_text = strdup(error.characters()); @@ -41,7 +41,7 @@ char* dlerror() return const_cast<char*>(s_dlerror_text); } -void* dlopen(const char* filename, int flags) +void* dlopen(char const* filename, int flags) { auto result = __dlopen(filename, flags); if (result.is_error()) { @@ -51,7 +51,7 @@ void* dlopen(const char* filename, int flags) return result.value(); } -void* dlsym(void* handle, const char* symbol_name) +void* dlsym(void* handle, char const* symbol_name) { auto result = __dlsym(handle, symbol_name); if (result.is_error()) { diff --git a/Userland/Libraries/LibDl/dlfcn.h b/Userland/Libraries/LibDl/dlfcn.h index b8ab808793..99f2c68e67 100644 --- a/Userland/Libraries/LibDl/dlfcn.h +++ b/Userland/Libraries/LibDl/dlfcn.h @@ -17,16 +17,16 @@ __BEGIN_DECLS #define RTLD_LOCAL 16 typedef struct __Dl_info { - const char* dli_fname; + char const* dli_fname; void* dli_fbase; - const char* dli_sname; + char const* dli_sname; void* dli_saddr; } Dl_info; int dlclose(void*); char* dlerror(void); -void* dlopen(const char*, int); -void* dlsym(void*, const char*); +void* dlopen(char const*, int); +void* dlsym(void*, char const*); int dladdr(void*, Dl_info*); __END_DECLS diff --git a/Userland/Libraries/LibDl/dlfcn_integration.h b/Userland/Libraries/LibDl/dlfcn_integration.h index aa4642d4f3..bf5a20ae60 100644 --- a/Userland/Libraries/LibDl/dlfcn_integration.h +++ b/Userland/Libraries/LibDl/dlfcn_integration.h @@ -28,8 +28,8 @@ struct __Dl_info; typedef struct __Dl_info Dl_info; typedef Result<void, DlErrorMessage> (*DlCloseFunction)(void*); -typedef Result<void*, DlErrorMessage> (*DlOpenFunction)(const char*, int); -typedef Result<void*, DlErrorMessage> (*DlSymFunction)(void*, const char*); +typedef Result<void*, DlErrorMessage> (*DlOpenFunction)(char const*, int); +typedef Result<void*, DlErrorMessage> (*DlSymFunction)(void*, char const*); typedef Result<void, DlErrorMessage> (*DlAddrFunction)(void*, Dl_info*); extern "C" { diff --git a/Userland/Libraries/LibEDID/EDID.cpp b/Userland/Libraries/LibEDID/EDID.cpp index 599df45a45..1c5a9ca772 100644 --- a/Userland/Libraries/LibEDID/EDID.cpp +++ b/Userland/Libraries/LibEDID/EDID.cpp @@ -319,7 +319,7 @@ T Parser::read_host(T const* field) const template<typename T> requires(IsIntegral<T> && sizeof(T) > 1) T Parser::read_le(T const* field) - const +const { static_assert(sizeof(T) > 1); return AK::convert_between_host_and_little_endian(read_host(field)); @@ -327,7 +327,7 @@ requires(IsIntegral<T> && sizeof(T) > 1) T Parser::read_le(T const* field) template<typename T> requires(IsIntegral<T> && sizeof(T) > 1) T Parser::read_be(T const* field) - const +const { static_assert(sizeof(T) > 1); return AK::convert_between_host_and_big_endian(read_host(field)); diff --git a/Userland/Libraries/LibEDID/EDID.h b/Userland/Libraries/LibEDID/EDID.h index 18ac90336f..b70b4b9b9b 100644 --- a/Userland/Libraries/LibEDID/EDID.h +++ b/Userland/Libraries/LibEDID/EDID.h @@ -438,11 +438,11 @@ private: template<typename T> requires(IsIntegral<T> && sizeof(T) > 1) T read_le(T const*) - const; + const; template<typename T> requires(IsIntegral<T> && sizeof(T) > 1) T read_be(T const*) - const; + const; Definitions::EDID const& raw_edid() const; ErrorOr<IterationDecision> for_each_display_descriptor(Function<IterationDecision(u8, Definitions::DisplayDescriptor const&)>) const; diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index 66ce35adf3..b4d5033997 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.cpp +++ b/Userland/Libraries/LibELF/DynamicLinker.cpp @@ -56,8 +56,8 @@ static bool s_do_breakpoint_trap_before_entry { false }; static StringView s_ld_library_path; static Result<void, DlErrorMessage> __dlclose(void* handle); -static Result<void*, DlErrorMessage> __dlopen(const char* filename, int flags); -static Result<void*, DlErrorMessage> __dlsym(void* handle, const char* symbol_name); +static Result<void*, DlErrorMessage> __dlopen(char const* filename, int flags); +static Result<void*, DlErrorMessage> __dlsym(void* handle, char const* symbol_name); static Result<void, DlErrorMessage> __dladdr(void* addr, Dl_info* info); Optional<DynamicObject::SymbolLookupResult> DynamicLinker::lookup_global_symbol(StringView name) @@ -84,7 +84,7 @@ static String get_library_name(String path) return LexicalPath::basename(move(path)); } -static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(const String& filename, int fd) +static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(String const& filename, int fd) { auto result = ELF::DynamicLoader::try_create(fd, filename); if (result.is_error()) { @@ -139,7 +139,7 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> map_library(String c return DlErrorMessage { String::formatted("Could not find required shared library: {}", name) }; } -static Vector<String> get_dependencies(const String& name) +static Vector<String> get_dependencies(String const& name) { auto lib = s_loaders.get(name).value(); Vector<String> dependencies; @@ -152,13 +152,13 @@ static Vector<String> get_dependencies(const String& name) return dependencies; } -static Result<void, DlErrorMessage> map_dependencies(const String& name) +static Result<void, DlErrorMessage> map_dependencies(String const& name) { dbgln_if(DYNAMIC_LOAD_DEBUG, "mapping dependencies for: {}", name); auto const& parent_object = (*s_loaders.get(name))->dynamic_object(); - for (const auto& needed_name : get_dependencies(name)) { + for (auto const& needed_name : get_dependencies(name)) { dbgln_if(DYNAMIC_LOAD_DEBUG, "needed library: {}", needed_name.characters()); String library_name = get_library_name(needed_name); @@ -180,7 +180,7 @@ static Result<void, DlErrorMessage> map_dependencies(const String& name) static void allocate_tls() { s_total_tls_size = 0; - for (const auto& data : s_loaders) { + for (auto const& data : s_loaders) { dbgln_if(DYNAMIC_LOAD_DEBUG, "{}: TLS Size: {}", data.key, data.value->tls_size_of_current_object()); s_total_tls_size += data.value->tls_size_of_current_object(); } @@ -198,7 +198,7 @@ static void allocate_tls() auto& initial_tls_data = initial_tls_data_result.value(); // Initialize TLS data - for (const auto& entry : s_loaders) { + for (auto const& entry : s_loaders) { entry.value->copy_initial_tls_data_into(initial_tls_data); } @@ -277,7 +277,7 @@ static void initialize_libc(DynamicObject& libc) } template<typename Callback> -static void for_each_unfinished_dependency_of(const String& name, HashTable<String>& seen_names, bool first, bool skip_global_objects, Callback callback) +static void for_each_unfinished_dependency_of(String const& name, HashTable<String>& seen_names, bool first, bool skip_global_objects, Callback callback) { if (!s_loaders.contains(name)) return; @@ -289,13 +289,13 @@ static void for_each_unfinished_dependency_of(const String& name, HashTable<Stri return; seen_names.set(name); - for (const auto& needed_name : get_dependencies(name)) + for (auto const& needed_name : get_dependencies(name)) for_each_unfinished_dependency_of(get_library_name(needed_name), seen_names, false, skip_global_objects, callback); callback(*s_loaders.get(name).value()); } -static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(const String& name, bool skip_global_objects) +static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(String const& name, bool skip_global_objects) { HashTable<String> seen_names; NonnullRefPtrVector<DynamicLoader> loaders; @@ -305,7 +305,7 @@ static NonnullRefPtrVector<DynamicLoader> collect_loaders_for_library(const Stri return loaders; } -static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> load_main_library(const String& name, int flags, bool skip_global_objects) +static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> load_main_library(String const& name, int flags, bool skip_global_objects) { auto main_library_loader = *s_loaders.get(name); auto main_library_object = main_library_loader->map(); @@ -333,7 +333,7 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> load_main_library(co if (loader.filename() == "libsystem.so"sv) { VERIFY(!loader.text_segments().is_empty()); - for (const auto& segment : loader.text_segments()) { + for (auto const& segment : loader.text_segments()) { if (syscall(SC_msyscall, segment.address().get())) { VERIFY_NOT_REACHED(); } @@ -367,7 +367,7 @@ static Result<void, DlErrorMessage> __dlclose(void* handle) return {}; } -static Optional<DlErrorMessage> verify_tls_for_dlopen(const DynamicLoader& loader) +static Optional<DlErrorMessage> verify_tls_for_dlopen(DynamicLoader const& loader) { if (loader.tls_size_of_current_object() == 0) return {}; @@ -396,7 +396,7 @@ static Optional<DlErrorMessage> verify_tls_for_dlopen(const DynamicLoader& loade return DlErrorMessage("Using dlopen() with libraries that have non-zeroed TLS is currently not supported"); } -static Result<void*, DlErrorMessage> __dlopen(const char* filename, int flags) +static Result<void*, DlErrorMessage> __dlopen(char const* filename, int flags) { // FIXME: RTLD_NOW and RTLD_LOCAL are not supported flags &= ~RTLD_NOW; @@ -451,7 +451,7 @@ static Result<void*, DlErrorMessage> __dlopen(const char* filename, int flags) return *object; } -static Result<void*, DlErrorMessage> __dlsym(void* handle, const char* symbol_name) +static Result<void*, DlErrorMessage> __dlsym(void* handle, char const* symbol_name) { dbgln_if(DYNAMIC_LOAD_DEBUG, "__dlsym: {}, {}", handle, symbol_name); diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index 2ea5e16df6..63bad18311 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -26,7 +26,7 @@ #include <unistd.h> #ifndef __serenity__ -static void* mmap_with_name(void* addr, size_t length, int prot, int flags, int fd, off_t offset, const char*) +static void* mmap_with_name(void* addr, size_t length, int prot, int flags, int fd, off_t offset, char const*) { return mmap(addr, length, prot, flags, fd, offset); } @@ -86,7 +86,7 @@ DynamicLoader::~DynamicLoader() } } -const DynamicObject& DynamicLoader::dynamic_object() const +DynamicObject const& DynamicLoader::dynamic_object() const { if (!m_cached_dynamic_object) { VirtualAddress dynamic_section_address; @@ -238,7 +238,7 @@ void DynamicLoader::load_stage_4() void DynamicLoader::do_lazy_relocations() { - for (const auto& relocation : m_unresolved_relocations) { + for (auto const& relocation : m_unresolved_relocations) { if (auto res = do_relocation(relocation, ShouldInitializeWeak::Yes); res != RelocationResult::Success) { dbgln("Loader.so: {} unresolved symbol '{}'", m_filename, relocation.symbol().name()); VERIFY_NOT_REACHED(); @@ -256,7 +256,7 @@ void DynamicLoader::load_program_headers() VirtualAddress dynamic_region_desired_vaddr; - m_elf_image.for_each_program_header([&](const Image::ProgramHeader& program_header) { + m_elf_image.for_each_program_header([&](Image::ProgramHeader const& program_header) { ProgramHeaderRegion region {}; region.set_program_header(program_header.raw_header()); if (region.is_tls_template()) { @@ -555,7 +555,7 @@ ssize_t DynamicLoader::negative_offset_from_tls_block_end(ssize_t tls_offset, si void DynamicLoader::copy_initial_tls_data_into(ByteBuffer& buffer) const { - const u8* tls_data = nullptr; + u8 const* tls_data = nullptr; size_t tls_size_in_image = 0; m_elf_image.for_each_program_header([this, &tls_data, &tls_size_in_image](ELF::Image::ProgramHeader program_header) { diff --git a/Userland/Libraries/LibELF/DynamicLoader.h b/Userland/Libraries/LibELF/DynamicLoader.h index 23ef8ff5c9..db3ab6cfba 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.h +++ b/Userland/Libraries/LibELF/DynamicLoader.h @@ -45,7 +45,7 @@ public: static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> try_create(int fd, String filename); ~DynamicLoader(); - const String& filename() const { return m_filename; } + String const& filename() const { return m_filename; } bool is_valid() const { return m_valid; } @@ -74,7 +74,7 @@ public: void for_each_needed_library(F) const; VirtualAddress base_address() const { return m_base_address; } - const Vector<LoadedSegment> text_segments() const { return m_text_segments; } + Vector<LoadedSegment> const text_segments() const { return m_text_segments; } bool is_dynamic() const { return m_elf_image.is_dynamic(); } static Optional<DynamicObject::SymbolLookupResult> lookup_symbol(const ELF::DynamicObject::Symbol&); @@ -129,7 +129,7 @@ private: Success = 1, ResolveLater = 2, }; - RelocationResult do_relocation(const DynamicObject::Relocation&, ShouldInitializeWeak should_initialize_weak); + RelocationResult do_relocation(DynamicObject::Relocation const&, ShouldInitializeWeak should_initialize_weak); void do_relr_relocations(); size_t calculate_tls_size() const; ssize_t negative_offset_from_tls_block_end(ssize_t tls_offset, size_t value_of_symbol) const; diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index 22ec378e7d..ad1e5b1c4f 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -16,7 +16,7 @@ namespace ELF { -DynamicObject::DynamicObject(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address) +DynamicObject::DynamicObject(String const& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address) : m_filename(filename) , m_base_address(base_address) , m_dynamic_address(dynamic_section_address) @@ -44,7 +44,7 @@ void DynamicObject::dump() const builder.append("\nd_tag tag_name value\n"); size_t num_dynamic_sections = 0; - for_each_dynamic_entry([&](const DynamicObject::DynamicEntry& entry) { + for_each_dynamic_entry([&](DynamicObject::DynamicEntry const& entry) { String name_field = String::formatted("({})", name_for_dtag(entry.tag())); builder.appendff("{:#08x} {:17} {:#08x}\n", entry.tag(), name_field, entry.val()); num_dynamic_sections++; @@ -64,7 +64,7 @@ void DynamicObject::dump() const void DynamicObject::parse() { - for_each_dynamic_entry([&](const DynamicEntry& entry) { + for_each_dynamic_entry([&](DynamicEntry const& entry) { switch (entry.tag()) { case DT_INIT: m_init_offset = entry.ptr() - m_elf_base_address.get(); @@ -294,7 +294,7 @@ auto DynamicObject::HashSection::lookup_gnu_symbol(StringView name, u32 hash_val using BloomWord = FlatPtr; constexpr size_t bloom_word_size = sizeof(BloomWord) * 8; - const u32* hash_table_begin = (u32*)address().as_ptr(); + u32 const* hash_table_begin = (u32*)address().as_ptr(); const size_t num_buckets = hash_table_begin[0]; const size_t num_omitted_symbols = hash_table_begin[1]; @@ -303,9 +303,9 @@ auto DynamicObject::HashSection::lookup_gnu_symbol(StringView name, u32 hash_val const u32 num_maskwords_bitmask = num_maskwords - 1; const u32 shift2 = hash_table_begin[3]; - const BloomWord* bloom_words = (BloomWord const*)&hash_table_begin[4]; - const u32* const buckets = (u32 const*)&bloom_words[num_maskwords]; - const u32* const chains = &buckets[num_buckets]; + BloomWord const* bloom_words = (BloomWord const*)&hash_table_begin[4]; + u32 const* const buckets = (u32 const*)&bloom_words[num_maskwords]; + u32 const* const chains = &buckets[num_buckets]; BloomWord hash1 = hash_value; BloomWord hash2 = hash1 >> shift2; @@ -317,7 +317,7 @@ auto DynamicObject::HashSection::lookup_gnu_symbol(StringView name, u32 hash_val size_t current_sym = buckets[hash1 % num_buckets]; if (current_sym == 0) return {}; - const u32* current_chain = &chains[current_sym - num_omitted_symbols]; + u32 const* current_chain = &chains[current_sym - num_omitted_symbols]; for (hash1 &= ~1;; ++current_sym) { hash2 = *(current_chain++); @@ -336,12 +336,12 @@ auto DynamicObject::HashSection::lookup_gnu_symbol(StringView name, u32 hash_val StringView DynamicObject::symbol_string_table_string(ElfW(Word) index) const { - return StringView { (const char*)base_address().offset(m_string_table_offset + index).as_ptr() }; + return StringView { (char const*)base_address().offset(m_string_table_offset + index).as_ptr() }; } -const char* DynamicObject::raw_symbol_string_table_string(ElfW(Word) index) const +char const* DynamicObject::raw_symbol_string_table_string(ElfW(Word) index) const { - return (const char*)base_address().offset(m_string_table_offset + index).as_ptr(); + return (char const*)base_address().offset(m_string_table_offset + index).as_ptr(); } DynamicObject::InitializationFunction DynamicObject::init_section_function() const @@ -350,7 +350,7 @@ DynamicObject::InitializationFunction DynamicObject::init_section_function() con return (InitializationFunction)init_section().address().as_ptr(); } -const char* DynamicObject::name_for_dtag(ElfW(Sword) d_tag) +char const* DynamicObject::name_for_dtag(ElfW(Sword) d_tag) { switch (d_tag) { case DT_NULL: @@ -463,7 +463,7 @@ auto DynamicObject::lookup_symbol(StringView name) const -> Optional<SymbolLooku return lookup_symbol(HashSymbol { name }); } -auto DynamicObject::lookup_symbol(const HashSymbol& symbol) const -> Optional<SymbolLookupResult> +auto DynamicObject::lookup_symbol(HashSymbol const& symbol) const -> Optional<SymbolLookupResult> { auto result = hash_section().lookup_symbol(symbol); if (!result.has_value()) @@ -474,7 +474,7 @@ auto DynamicObject::lookup_symbol(const HashSymbol& symbol) const -> Optional<Sy return SymbolLookupResult { symbol_result.value(), symbol_result.size(), symbol_result.address(), symbol_result.bind(), this }; } -NonnullRefPtr<DynamicObject> DynamicObject::create(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address) +NonnullRefPtr<DynamicObject> DynamicObject::create(String const& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address) { return adopt_ref(*new DynamicObject(filename, base_address, dynamic_section_address)); } diff --git a/Userland/Libraries/LibELF/DynamicObject.h b/Userland/Libraries/LibELF/DynamicObject.h index 19c277977c..6161a6c568 100644 --- a/Userland/Libraries/LibELF/DynamicObject.h +++ b/Userland/Libraries/LibELF/DynamicObject.h @@ -20,8 +20,8 @@ namespace ELF { class DynamicObject : public RefCounted<DynamicObject> { public: - static NonnullRefPtr<DynamicObject> create(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address); - static const char* name_for_dtag(ElfW(Sword) d_tag); + static NonnullRefPtr<DynamicObject> create(String const& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address); + static char const* name_for_dtag(ElfW(Sword) d_tag); ~DynamicObject(); void dump() const; @@ -52,7 +52,7 @@ public: class Symbol { public: - Symbol(const DynamicObject& dynamic, unsigned index, const ElfW(Sym) & sym) + Symbol(DynamicObject const& dynamic, unsigned index, const ElfW(Sym) & sym) : m_dynamic(dynamic) , m_sym(sym) , m_index(index) @@ -60,7 +60,7 @@ public: } StringView name() const { return m_dynamic.symbol_string_table_string(m_sym.st_name); } - const char* raw_name() const { return m_dynamic.raw_symbol_string_table_string(m_sym.st_name); } + char const* raw_name() const { return m_dynamic.raw_symbol_string_table_string(m_sym.st_name); } unsigned section_index() const { return m_sym.st_shndx; } FlatPtr value() const { return m_sym.st_value; } size_t size() const { return m_sym.st_size; } @@ -90,17 +90,17 @@ public: return m_dynamic.base_address().offset(value()); return VirtualAddress { value() }; } - const DynamicObject& object() const { return m_dynamic; } + DynamicObject const& object() const { return m_dynamic; } private: - const DynamicObject& m_dynamic; + DynamicObject const& m_dynamic; const ElfW(Sym) & m_sym; - const unsigned m_index; + unsigned const m_index; }; class Section { public: - Section(const DynamicObject& dynamic, unsigned section_offset, unsigned section_size_bytes, unsigned entry_size, StringView name) + Section(DynamicObject const& dynamic, unsigned section_offset, unsigned section_size_bytes, unsigned entry_size, StringView name) : m_dynamic(dynamic) , m_section_offset(section_offset) , m_section_size_bytes(section_size_bytes) @@ -126,7 +126,7 @@ public: protected: friend class RelocationSection; friend class HashSection; - const DynamicObject& m_dynamic; + DynamicObject const& m_dynamic; unsigned m_section_offset; unsigned m_section_size_bytes; unsigned m_entry_size; @@ -135,7 +135,7 @@ public: class RelocationSection : public Section { public: - explicit RelocationSection(const Section& section, bool addend_used) + explicit RelocationSection(Section const& section, bool addend_used) : Section(section.m_dynamic, section.m_section_offset, section.m_section_size_bytes, section.m_entry_size, section.m_name) , m_addend_used(addend_used) { @@ -150,12 +150,12 @@ public: void for_each_relocation(F func) const; private: - const bool m_addend_used; + bool const m_addend_used; }; class Relocation { public: - Relocation(const DynamicObject& dynamic, const ElfW(Rela) & rel, unsigned offset_in_section, bool addend_used) + Relocation(DynamicObject const& dynamic, const ElfW(Rela) & rel, unsigned offset_in_section, bool addend_used) : m_dynamic(dynamic) , m_rel(rel) , m_offset_in_section(offset_in_section) @@ -200,10 +200,10 @@ public: [[nodiscard]] DynamicObject const& dynamic_object() const { return m_dynamic; } private: - const DynamicObject& m_dynamic; + DynamicObject const& m_dynamic; const ElfW(Rela) & m_rel; - const unsigned m_offset_in_section; - const bool m_addend_used; + unsigned const m_offset_in_section; + bool const m_addend_used; }; enum class HashType { @@ -230,13 +230,13 @@ public: class HashSection : public Section { public: - HashSection(const Section& section, HashType hash_type) + HashSection(Section const& section, HashType hash_type) : Section(section.m_dynamic, section.m_section_offset, section.m_section_size_bytes, section.m_entry_size, section.m_name) , m_hash_type(hash_type) { } - Optional<Symbol> lookup_symbol(const HashSymbol& symbol) const + Optional<Symbol> lookup_symbol(HashSymbol const& symbol) const { if (m_hash_type == HashType::SYSV) return lookup_sysv_symbol(symbol.name(), symbol.sysv_hash()); @@ -286,7 +286,7 @@ public: VirtualAddress plt_got_base_address() const { return m_base_address.offset(m_procedure_linkage_table_offset.value()); } VirtualAddress base_address() const { return m_base_address; } - const String& filename() const { return m_filename; } + String const& filename() const { return m_filename; } StringView rpath() const { return m_has_rpath ? symbol_string_table_string(m_rpath_index) : StringView {}; } StringView runpath() const { return m_has_runpath ? symbol_string_table_string(m_runpath_index) : StringView {}; } @@ -326,7 +326,7 @@ public: }; Optional<SymbolLookupResult> lookup_symbol(StringView name) const; - Optional<SymbolLookupResult> lookup_symbol(const HashSymbol& symbol) const; + Optional<SymbolLookupResult> lookup_symbol(HashSymbol const& symbol) const; // Will be called from _fixup_plt_entry, as part of the PLT trampoline VirtualAddress patch_plt_entry(u32 relocation_offset); @@ -336,10 +336,10 @@ public: void* symbol_for_name(StringView name); private: - explicit DynamicObject(const String& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address); + explicit DynamicObject(String const& filename, VirtualAddress base_address, VirtualAddress dynamic_section_address); StringView symbol_string_table_string(ElfW(Word)) const; - const char* raw_symbol_string_table_string(ElfW(Word)) const; + char const* raw_symbol_string_table_string(ElfW(Word)) const; void parse(); String m_filename; @@ -403,7 +403,7 @@ template<IteratorFunction<DynamicObject::Relocation&> F> inline void DynamicObject::RelocationSection::for_each_relocation(F func) const { for (unsigned i = 0; i < relocation_count(); ++i) { - const auto reloc = relocation(i); + auto const reloc = relocation(i); if (reloc.type() == 0) continue; if (func(reloc) == IterationDecision::Break) diff --git a/Userland/Libraries/LibELF/Image.cpp b/Userland/Libraries/LibELF/Image.cpp index e8e9a6f568..694a7721f3 100644 --- a/Userland/Libraries/LibELF/Image.cpp +++ b/Userland/Libraries/LibELF/Image.cpp @@ -26,7 +26,7 @@ Image::Image(ReadonlyBytes bytes, bool verbose_logging) parse(); } -Image::Image(const u8* buffer, size_t size, bool verbose_logging) +Image::Image(u8 const* buffer, size_t size, bool verbose_logging) : Image(ReadonlyBytes { buffer, size }, verbose_logging) { } @@ -69,7 +69,7 @@ void Image::dump() const dbgln(" phnum: {}", header().e_phnum); dbgln(" shstrndx: {}", header().e_shstrndx); - for_each_program_header([&](const ProgramHeader& program_header) { + for_each_program_header([&](ProgramHeader const& program_header) { dbgln(" Program Header {}: {{", program_header.index()); dbgln(" type: {:x}", program_header.type()); dbgln(" offset: {:x}", program_header.offset()); @@ -78,7 +78,7 @@ void Image::dump() const }); for (unsigned i = 0; i < header().e_shnum; ++i) { - const auto& section = this->section(i); + auto const& section = this->section(i); dbgln(" Section {}: {{", i); dbgln(" name: {}", section.name()); dbgln(" type: {:x}", section.type()); @@ -90,7 +90,7 @@ void Image::dump() const dbgln("Symbol count: {} (table is {})", symbol_count(), m_symbol_table_section_index); for (unsigned i = 1; i < symbol_count(); ++i) { - const auto& sym = symbol(i); + auto const& sym = symbol(i); dbgln("Symbol @{}:", i); dbgln(" Name: {}", sym.name()); dbgln(" In section: {}", section_index_to_string(sym.section_index())); @@ -187,10 +187,10 @@ StringView Image::table_string(unsigned offset) const return table_string(m_string_table_section_index, offset); } -const char* Image::raw_data(unsigned offset) const +char const* Image::raw_data(unsigned offset) const { VERIFY(offset < m_size); // Callers must check indices into raw_data()'s result are also in bounds. - return reinterpret_cast<const char*>(m_buffer) + offset; + return reinterpret_cast<char const*>(m_buffer) + offset; } const ElfW(Ehdr) & Image::header() const @@ -361,7 +361,7 @@ StringView Image::Symbol::raw_data() const Optional<Image::Symbol> Image::find_demangled_function(StringView name) const { Optional<Image::Symbol> found; - for_each_symbol([&](const Image::Symbol& symbol) { + for_each_symbol([&](Image::Symbol const& symbol) { if (symbol.type() != STT_FUNC) return IterationDecision::Continue; if (symbol.is_undefined()) @@ -416,7 +416,7 @@ Optional<Image::Symbol> Image::find_symbol(FlatPtr address, u32* out_offset) con NEVER_INLINE void Image::sort_symbols() const { m_sorted_symbols.ensure_capacity(symbol_count()); - for_each_symbol([this](const auto& symbol) { + for_each_symbol([this](auto const& symbol) { m_sorted_symbols.append({ symbol.value(), symbol.name(), {}, symbol }); }); quick_sort(m_sorted_symbols, [](auto& a, auto& b) { diff --git a/Userland/Libraries/LibELF/Image.h b/Userland/Libraries/LibELF/Image.h index 7811463cc5..7af308a810 100644 --- a/Userland/Libraries/LibELF/Image.h +++ b/Userland/Libraries/LibELF/Image.h @@ -21,18 +21,18 @@ namespace ELF { class Image { public: explicit Image(ReadonlyBytes, bool verbose_logging = true); - explicit Image(const u8*, size_t, bool verbose_logging = true); + explicit Image(u8 const*, size_t, bool verbose_logging = true); ~Image() = default; void dump() const; bool is_valid() const { return m_valid; } bool parse(); - bool is_within_image(const void* address, size_t size) const + bool is_within_image(void const* address, size_t size) const { if (address < m_buffer) return false; - if (((const u8*)address + size) > m_buffer + m_size) + if (((u8 const*)address + size) > m_buffer + m_size) return false; return true; } @@ -44,7 +44,7 @@ public: class Symbol { public: - Symbol(const Image& image, unsigned index, const ElfW(Sym) & sym) + Symbol(Image const& image, unsigned index, const ElfW(Sym) & sym) : m_image(image) , m_sym(sym) , m_index(index) @@ -79,14 +79,14 @@ public: StringView raw_data() const; private: - const Image& m_image; + Image const& m_image; const ElfW(Sym) & m_sym; - const unsigned m_index; + unsigned const m_index; }; class ProgramHeader { public: - ProgramHeader(const Image& image, unsigned program_header_index) + ProgramHeader(Image const& image, unsigned program_header_index) : m_image(image) , m_program_header(image.program_header_internal(program_header_index)) , m_program_header_index(program_header_index) @@ -105,18 +105,18 @@ public: bool is_readable() const { return flags() & PF_R; } bool is_writable() const { return flags() & PF_W; } bool is_executable() const { return flags() & PF_X; } - const char* raw_data() const { return m_image.raw_data(m_program_header.p_offset); } + char const* raw_data() const { return m_image.raw_data(m_program_header.p_offset); } ElfW(Phdr) raw_header() const { return m_program_header; } private: - const Image& m_image; + Image const& m_image; const ElfW(Phdr) & m_program_header; unsigned m_program_header_index { 0 }; }; class Section { public: - Section(const Image& image, unsigned sectionIndex) + Section(Image const& image, unsigned sectionIndex) : m_image(image) , m_section_header(image.section_header(sectionIndex)) , m_section_index(sectionIndex) @@ -131,7 +131,7 @@ public: size_t entry_size() const { return m_section_header.sh_entsize; } size_t entry_count() const { return !entry_size() ? 0 : size() / entry_size(); } FlatPtr address() const { return m_section_header.sh_addr; } - const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); } + char const* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); } ReadonlyBytes bytes() const { return { raw_data(), size() }; } Optional<RelocationSection> relocations() const; auto flags() const { return m_section_header.sh_flags; } @@ -140,14 +140,14 @@ public: protected: friend class RelocationSection; - const Image& m_image; + Image const& m_image; const ElfW(Shdr) & m_section_header; unsigned m_section_index; }; class RelocationSection : public Section { public: - explicit RelocationSection(const Section& section) + explicit RelocationSection(Section const& section) : Section(section.m_image, section.m_section_index) { } @@ -160,7 +160,7 @@ public: class Relocation { public: - Relocation(const Image& image, const ElfW(Rel) & rel) + Relocation(Image const& image, const ElfW(Rel) & rel) : m_image(image) , m_rel(rel) { @@ -188,7 +188,7 @@ public: } private: - const Image& m_image; + Image const& m_image; const ElfW(Rel) & m_rel; }; @@ -243,7 +243,7 @@ public: Optional<Image::Symbol> find_symbol(FlatPtr address, u32* offset = nullptr) const; private: - const char* raw_data(unsigned offset) const; + char const* raw_data(unsigned offset) const; const ElfW(Ehdr) & header() const; const ElfW(Shdr) & section_header(unsigned) const; const ElfW(Phdr) & program_header_internal(unsigned) const; @@ -252,7 +252,7 @@ private: StringView section_index_to_string(unsigned index) const; StringView table_string(unsigned table_index, unsigned offset) const; - const u8* m_buffer { nullptr }; + u8 const* m_buffer { nullptr }; size_t m_size { 0 }; bool m_verbose_logging { true }; bool m_valid { false }; diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index ce37953258..696ae07cce 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -484,26 +484,26 @@ GLAPI void glClearStencil(GLint s); GLAPI void glColor3d(GLdouble r, GLdouble g, GLdouble b); GLAPI void glColor3dv(GLdouble const* v); GLAPI void glColor3f(GLfloat r, GLfloat g, GLfloat b); -GLAPI void glColor3fv(const GLfloat* v); +GLAPI void glColor3fv(GLfloat const* v); GLAPI void glColor3ub(GLubyte r, GLubyte g, GLubyte b); GLAPI void glColor3ubv(GLubyte const* v); GLAPI void glColor4b(GLbyte r, GLbyte g, GLbyte b, GLbyte a); GLAPI void glColor4dv(GLdouble const* v); GLAPI void glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); -GLAPI void glColor4fv(const GLfloat* v); +GLAPI void glColor4fv(GLfloat const* v); GLAPI void glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a); -GLAPI void glColor4ubv(const GLubyte* v); +GLAPI void glColor4ubv(GLubyte const* v); GLAPI void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GLAPI void glColorMaterial(GLenum face, GLenum mode); -GLAPI void glDeleteTextures(GLsizei n, const GLuint* textures); +GLAPI void glDeleteTextures(GLsizei n, GLuint const* textures); GLAPI void glEnd(); GLAPI void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal); GLAPI void glGenTextures(GLsizei n, GLuint* textures); GLAPI GLenum glGetError(); GLAPI GLubyte* glGetString(GLenum name); GLAPI void glLoadIdentity(); -GLAPI void glLoadMatrixd(const GLdouble* matrix); -GLAPI void glLoadMatrixf(const GLfloat* matrix); +GLAPI void glLoadMatrixd(GLdouble const* matrix); +GLAPI void glLoadMatrixf(GLfloat const* matrix); GLAPI void glMatrixMode(GLenum mode); GLAPI void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal); GLAPI void glPushMatrix(); @@ -517,29 +517,29 @@ GLAPI void glScalef(GLfloat x, GLfloat y, GLfloat z); GLAPI void glTranslated(GLdouble x, GLdouble y, GLdouble z); GLAPI void glTranslatef(GLfloat x, GLfloat y, GLfloat z); GLAPI void glVertex2d(GLdouble x, GLdouble y); -GLAPI void glVertex2dv(const GLdouble* v); +GLAPI void glVertex2dv(GLdouble const* v); GLAPI void glVertex2f(GLfloat x, GLfloat y); -GLAPI void glVertex2fv(const GLfloat* v); +GLAPI void glVertex2fv(GLfloat const* v); GLAPI void glVertex2i(GLint x, GLint y); -GLAPI void glVertex2iv(const GLint* v); +GLAPI void glVertex2iv(GLint const* v); GLAPI void glVertex2s(GLshort x, GLshort y); -GLAPI void glVertex2sv(const GLshort* v); +GLAPI void glVertex2sv(GLshort const* v); GLAPI void glVertex3d(GLdouble x, GLdouble y, GLdouble z); -GLAPI void glVertex3dv(const GLdouble* v); +GLAPI void glVertex3dv(GLdouble const* v); GLAPI void glVertex3f(GLfloat x, GLfloat y, GLfloat z); -GLAPI void glVertex3fv(const GLfloat* v); +GLAPI void glVertex3fv(GLfloat const* v); GLAPI void glVertex3i(GLint x, GLint y, GLint z); -GLAPI void glVertex3iv(const GLint* v); +GLAPI void glVertex3iv(GLint const* v); GLAPI void glVertex3s(GLshort x, GLshort y, GLshort z); -GLAPI void glVertex3sv(const GLshort* v); +GLAPI void glVertex3sv(GLshort const* v); GLAPI void glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void glVertex4dv(const GLdouble* v); +GLAPI void glVertex4dv(GLdouble const* v); GLAPI void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void glVertex4fv(const GLfloat* v); +GLAPI void glVertex4fv(GLfloat const* v); GLAPI void glVertex4i(GLint x, GLint y, GLint z, GLint w); -GLAPI void glVertex4iv(const GLint* v); +GLAPI void glVertex4iv(GLint const* v); GLAPI void glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void glVertex4sv(const GLshort* v); +GLAPI void glVertex4sv(GLshort const* v); GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void glEnable(GLenum cap); GLAPI void glDisable(GLenum cap); @@ -566,7 +566,7 @@ GLAPI void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum GLAPI void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid const* data); GLAPI void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const* data); GLAPI void glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid const* data); -GLAPI void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* data); +GLAPI void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid const* data); GLAPI void glTexCoord1f(GLfloat s); GLAPI void glTexCoord1fv(GLfloat const* v); GLAPI void glTexCoord2d(GLdouble s, GLdouble t); @@ -577,7 +577,7 @@ GLAPI void glTexCoord2i(GLint s, GLint t); GLAPI void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r); GLAPI void glTexCoord3fv(GLfloat const* v); GLAPI void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void glTexCoord4fv(const GLfloat* v); +GLAPI void glTexCoord4fv(GLfloat const* v); GLAPI void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); GLAPI void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t); GLAPI void glTexParameteri(GLenum target, GLenum pname, GLint param); @@ -602,12 +602,12 @@ GLAPI void glDisableClientState(GLenum cap); GLAPI void glClientActiveTextureARB(GLenum target); GLAPI void glClientActiveTexture(GLenum target); -GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer); -GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer); -GLAPI void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void* pointer); +GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, void const* pointer); +GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, void const* pointer); +GLAPI void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void const* pointer); GLAPI void glDrawArrays(GLenum mode, GLint first, GLsizei count); -GLAPI void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices); -GLAPI void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data); +GLAPI void glDrawElements(GLenum mode, GLsizei count, GLenum type, void const* indices); +GLAPI void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data); GLAPI void glDepthRange(GLdouble nearVal, GLdouble farVal); GLAPI void glDepthFunc(GLenum func); GLAPI void glPolygonMode(GLenum face, GLenum mode); diff --git a/Userland/Libraries/LibGL/GLColor.cpp b/Userland/Libraries/LibGL/GLColor.cpp index a3b50c3fc1..4eb277c919 100644 --- a/Userland/Libraries/LibGL/GLColor.cpp +++ b/Userland/Libraries/LibGL/GLColor.cpp @@ -26,7 +26,7 @@ void glColor3f(GLfloat r, GLfloat g, GLfloat b) g_gl_context->gl_color(r, g, b, 1.0); } -void glColor3fv(const GLfloat* v) +void glColor3fv(GLfloat const* v) { g_gl_context->gl_color(v[0], v[1], v[2], 1.0); } @@ -60,7 +60,7 @@ void glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) g_gl_context->gl_color(r, g, b, a); } -void glColor4fv(const GLfloat* v) +void glColor4fv(GLfloat const* v) { g_gl_context->gl_color(v[0], v[1], v[2], v[3]); } @@ -70,7 +70,7 @@ void glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) g_gl_context->gl_color(r / 255.0, g / 255.0, b / 255.0, a / 255.0); } -void glColor4ubv(const GLubyte* v) +void glColor4ubv(GLubyte const* v) { g_gl_context->gl_color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0); } diff --git a/Userland/Libraries/LibGL/GLContext.cpp b/Userland/Libraries/LibGL/GLContext.cpp index 0c0246f25d..f57c6f99b5 100644 --- a/Userland/Libraries/LibGL/GLContext.cpp +++ b/Userland/Libraries/LibGL/GLContext.cpp @@ -471,7 +471,7 @@ void GLContext::gl_load_identity() *m_current_matrix = FloatMatrix4x4::identity(); } -void GLContext::gl_load_matrix(const FloatMatrix4x4& matrix) +void GLContext::gl_load_matrix(FloatMatrix4x4 const& matrix) { APPEND_TO_CALL_LIST_WITH_ARG_AND_RETURN_IF_NEEDED(gl_load_matrix, matrix); RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); @@ -859,7 +859,7 @@ void GLContext::gl_gen_textures(GLsizei n, GLuint* textures) } } -void GLContext::gl_delete_textures(GLsizei n, const GLuint* textures) +void GLContext::gl_delete_textures(GLsizei n, GLuint const* textures) { RETURN_WITH_ERROR_IF(n < 0, GL_INVALID_VALUE); RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); @@ -1070,8 +1070,7 @@ void GLContext::invoke_list(size_t list_index) for (auto& entry : listing.entries) { entry.function.visit([&](auto& function) { entry.arguments.visit([&](auto& arguments) { - auto apply = [&]<typename... Args>(Args && ... args) - { + auto apply = [&]<typename... Args>(Args&&... args) { if constexpr (requires { (this->*function)(forward<Args>(args)...); }) (this->*function)(forward<Args>(args)...); }; @@ -1987,7 +1986,7 @@ void GLContext::gl_client_active_texture(GLenum target) m_client_active_texture = target - GL_TEXTURE0; } -void GLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) +void GLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer) { RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); RETURN_WITH_ERROR_IF(!(size == 2 || size == 3 || size == 4), GL_INVALID_VALUE); @@ -1997,7 +1996,7 @@ void GLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const m_client_vertex_pointer = { .size = size, .type = type, .stride = stride, .pointer = pointer }; } -void GLContext::gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) +void GLContext::gl_color_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer) { RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); RETURN_WITH_ERROR_IF(!(size == 3 || size == 4), GL_INVALID_VALUE); @@ -2015,7 +2014,7 @@ void GLContext::gl_color_pointer(GLint size, GLenum type, GLsizei stride, const m_client_color_pointer = { .size = size, .type = type, .stride = stride, .pointer = pointer }; } -void GLContext::gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) +void GLContext::gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer) { RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); RETURN_WITH_ERROR_IF(!(size == 1 || size == 2 || size == 3 || size == 4), GL_INVALID_VALUE); @@ -2117,7 +2116,7 @@ void GLContext::gl_draw_arrays(GLenum mode, GLint first, GLsizei count) gl_end(); } -void GLContext::gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const void* indices) +void GLContext::gl_draw_elements(GLenum mode, GLsizei count, GLenum type, void const* indices) { APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_draw_elements, mode, count, type, indices); RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); @@ -2147,13 +2146,13 @@ void GLContext::gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const int i = 0; switch (type) { case GL_UNSIGNED_BYTE: - i = reinterpret_cast<const GLubyte*>(indices)[index]; + i = reinterpret_cast<GLubyte const*>(indices)[index]; break; case GL_UNSIGNED_SHORT: - i = reinterpret_cast<const GLushort*>(indices)[index]; + i = reinterpret_cast<GLushort const*>(indices)[index]; break; case GL_UNSIGNED_INT: - i = reinterpret_cast<const GLuint*>(indices)[index]; + i = reinterpret_cast<GLuint const*>(indices)[index]; break; } @@ -2184,7 +2183,7 @@ void GLContext::gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const gl_end(); } -void GLContext::gl_draw_pixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data) +void GLContext::gl_draw_pixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data) { APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_draw_pixels, width, height, format, type, data); @@ -2335,7 +2334,7 @@ void GLContext::gl_depth_func(GLenum func) // General helper function to read arbitrary vertex attribute data into a float array void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& attrib, int index, float* elements) { - auto byte_ptr = reinterpret_cast<const char*>(attrib.pointer); + auto byte_ptr = reinterpret_cast<char const*>(attrib.pointer); auto normalize = attrib.normalize; size_t stride = attrib.stride; @@ -2345,7 +2344,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLbyte) * attrib.size; for (int i = 0; i < attrib.size; i++) { - elements[i] = *(reinterpret_cast<const GLbyte*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLbyte const*>(byte_ptr + stride * index) + i); if (normalize) elements[i] /= 0x80; } @@ -2356,7 +2355,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLubyte) * attrib.size; for (int i = 0; i < attrib.size; i++) { - elements[i] = *(reinterpret_cast<const GLubyte*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLubyte const*>(byte_ptr + stride * index) + i); if (normalize) elements[i] /= 0xff; } @@ -2367,7 +2366,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLshort) * attrib.size; for (int i = 0; i < attrib.size; i++) { - elements[i] = *(reinterpret_cast<const GLshort*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLshort const*>(byte_ptr + stride * index) + i); if (normalize) elements[i] /= 0x8000; } @@ -2378,7 +2377,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLushort) * attrib.size; for (int i = 0; i < attrib.size; i++) { - elements[i] = *(reinterpret_cast<const GLushort*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLushort const*>(byte_ptr + stride * index) + i); if (normalize) elements[i] /= 0xffff; } @@ -2389,7 +2388,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLint) * attrib.size; for (int i = 0; i < attrib.size; i++) { - elements[i] = *(reinterpret_cast<const GLint*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLint const*>(byte_ptr + stride * index) + i); if (normalize) elements[i] /= 0x80000000; } @@ -2400,7 +2399,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLuint) * attrib.size; for (int i = 0; i < attrib.size; i++) { - elements[i] = *(reinterpret_cast<const GLuint*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLuint const*>(byte_ptr + stride * index) + i); if (normalize) elements[i] /= 0xffffffff; } @@ -2411,7 +2410,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLfloat) * attrib.size; for (int i = 0; i < attrib.size; i++) - elements[i] = *(reinterpret_cast<const GLfloat*>(byte_ptr + stride * index) + i); + elements[i] = *(reinterpret_cast<GLfloat const*>(byte_ptr + stride * index) + i); break; } case GL_DOUBLE: { @@ -2419,7 +2418,7 @@ void GLContext::read_from_vertex_attribute_pointer(VertexAttribPointer const& at stride = sizeof(GLdouble) * attrib.size; for (int i = 0; i < attrib.size; i++) - elements[i] = static_cast<float>(*(reinterpret_cast<const GLdouble*>(byte_ptr + stride * index) + i)); + elements[i] = static_cast<float>(*(reinterpret_cast<GLdouble const*>(byte_ptr + stride * index) + i)); break; } } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index c4704973fb..394ee8216e 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -57,14 +57,14 @@ public: void gl_clear_depth(GLdouble depth); void gl_clear_stencil(GLint s); void gl_color(GLdouble r, GLdouble g, GLdouble b, GLdouble a); - void gl_delete_textures(GLsizei n, const GLuint* textures); + void gl_delete_textures(GLsizei n, GLuint const* textures); void gl_end(); void gl_frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val); void gl_gen_textures(GLsizei n, GLuint* textures); GLenum gl_get_error(); GLubyte* gl_get_string(GLenum name); void gl_load_identity(); - void gl_load_matrix(const FloatMatrix4x4& matrix); + void gl_load_matrix(FloatMatrix4x4 const& matrix); void gl_matrix_mode(GLenum mode); void gl_ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val); void gl_push_matrix(); @@ -110,12 +110,12 @@ public: void gl_enable_client_state(GLenum cap); void gl_disable_client_state(GLenum cap); void gl_client_active_texture(GLenum target); - void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer); - void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer); - void gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer); + void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer); + void gl_color_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer); + void gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer); void gl_draw_arrays(GLenum mode, GLint first, GLsizei count); - void gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const void* indices); - void gl_draw_pixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data); + void gl_draw_elements(GLenum mode, GLsizei count, GLenum type, void const* indices); + void gl_draw_pixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data); void gl_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void gl_get_booleanv(GLenum pname, GLboolean* data); void gl_get_doublev(GLenum pname, GLdouble* params); @@ -419,7 +419,7 @@ private: GLenum type { GL_FLOAT }; bool normalize { true }; GLsizei stride { 0 }; - const void* pointer { 0 }; + void const* pointer { 0 }; }; static void read_from_vertex_attribute_pointer(VertexAttribPointer const&, int index, float* elements); diff --git a/Userland/Libraries/LibGL/GLDraw.cpp b/Userland/Libraries/LibGL/GLDraw.cpp index f484dc49d2..9d16e42f44 100644 --- a/Userland/Libraries/LibGL/GLDraw.cpp +++ b/Userland/Libraries/LibGL/GLDraw.cpp @@ -15,7 +15,7 @@ void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLflo g_gl_context->gl_bitmap(width, height, xorig, yorig, xmove, ymove, bitmap); } -void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data) +void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data) { g_gl_context->gl_draw_pixels(width, height, format, type, data); } diff --git a/Userland/Libraries/LibGL/GLTexture.cpp b/Userland/Libraries/LibGL/GLTexture.cpp index 73c8d1af46..adf43b416f 100644 --- a/Userland/Libraries/LibGL/GLTexture.cpp +++ b/Userland/Libraries/LibGL/GLTexture.cpp @@ -15,29 +15,29 @@ void glGenTextures(GLsizei n, GLuint* textures) g_gl_context->gl_gen_textures(n, textures); } -void glDeleteTextures(GLsizei n, const GLuint* textures) +void glDeleteTextures(GLsizei n, GLuint const* textures) { g_gl_context->gl_delete_textures(n, textures); } -void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid* data) +void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid const* data) { dbgln("glTexImage1D({:#x}, {}, {:#x}, {}, {}, {:#x}, {:#x}, {:p}): unimplemented", target, level, internalFormat, width, border, format, type, data); TODO(); } -void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data) +void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const* data) { g_gl_context->gl_tex_image_2d(target, level, internalFormat, width, height, border, format, type, data); } -void glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* data) +void glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid const* data) { dbgln("glTexImage3D({:#x}, {}, {:#x}, {}, {}, {}, {}, {:#x}, {:#x}, {:p}): unimplemented", target, level, internalFormat, width, height, depth, border, format, type, data); TODO(); } -void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* data) +void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid const* data) { g_gl_context->gl_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, type, data); } diff --git a/Userland/Libraries/LibGL/GLVert.cpp b/Userland/Libraries/LibGL/GLVert.cpp index a0a40e9082..1005a7f875 100644 --- a/Userland/Libraries/LibGL/GLVert.cpp +++ b/Userland/Libraries/LibGL/GLVert.cpp @@ -25,7 +25,7 @@ void glVertex2d(GLdouble x, GLdouble y) g_gl_context->gl_vertex(x, y, 0.0, 1.0); } -void glVertex2dv(const GLdouble* v) +void glVertex2dv(GLdouble const* v) { g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0); } @@ -35,7 +35,7 @@ void glVertex2f(GLfloat x, GLfloat y) g_gl_context->gl_vertex(x, y, 0.0, 1.0); } -void glVertex2fv(const GLfloat* v) +void glVertex2fv(GLfloat const* v) { g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0); } @@ -45,7 +45,7 @@ void glVertex2i(GLint x, GLint y) g_gl_context->gl_vertex(x, y, 0.0, 1.0); } -void glVertex2iv(const GLint* v) +void glVertex2iv(GLint const* v) { g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0); } @@ -55,7 +55,7 @@ void glVertex2s(GLshort x, GLshort y) g_gl_context->gl_vertex(x, y, 0.0, 1.0); } -void glVertex2sv(const GLshort* v) +void glVertex2sv(GLshort const* v) { g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0); } @@ -65,7 +65,7 @@ void glVertex3d(GLdouble x, GLdouble y, GLdouble z) g_gl_context->gl_vertex(x, y, z, 1.0); } -void glVertex3dv(const GLdouble* v) +void glVertex3dv(GLdouble const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0); } @@ -75,7 +75,7 @@ void glVertex3f(GLfloat x, GLfloat y, GLfloat z) g_gl_context->gl_vertex(x, y, z, 1.0); } -void glVertex3fv(const GLfloat* v) +void glVertex3fv(GLfloat const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0); } @@ -85,7 +85,7 @@ void glVertex3i(GLint x, GLint y, GLint z) g_gl_context->gl_vertex(x, y, z, 1.0); } -void glVertex3iv(const GLint* v) +void glVertex3iv(GLint const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0); } @@ -95,7 +95,7 @@ void glVertex3s(GLshort x, GLshort y, GLshort z) g_gl_context->gl_vertex(x, y, z, 1.0); } -void glVertex3sv(const GLshort* v) +void glVertex3sv(GLshort const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0); } @@ -105,7 +105,7 @@ void glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) g_gl_context->gl_vertex(x, y, z, w); } -void glVertex4dv(const GLdouble* v) +void glVertex4dv(GLdouble const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]); } @@ -115,7 +115,7 @@ void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) g_gl_context->gl_vertex(x, y, z, w); } -void glVertex4fv(const GLfloat* v) +void glVertex4fv(GLfloat const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]); } @@ -125,7 +125,7 @@ void glVertex4i(GLint x, GLint y, GLint z, GLint w) g_gl_context->gl_vertex(x, y, z, w); } -void glVertex4iv(const GLint* v) +void glVertex4iv(GLint const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]); } @@ -135,7 +135,7 @@ void glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w) g_gl_context->gl_vertex(x, y, z, w); } -void glVertex4sv(const GLshort* v) +void glVertex4sv(GLshort const* v) { g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]); } @@ -190,7 +190,7 @@ void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) g_gl_context->gl_tex_coord(s, t, r, q); } -void glTexCoord4fv(const GLfloat* v) +void glTexCoord4fv(GLfloat const* v) { g_gl_context->gl_tex_coord(v[0], v[1], v[2], v[3]); } diff --git a/Userland/Libraries/LibGL/GLVertexArrays.cpp b/Userland/Libraries/LibGL/GLVertexArrays.cpp index 46a3a8d2a9..3dea1ade54 100644 --- a/Userland/Libraries/LibGL/GLVertexArrays.cpp +++ b/Userland/Libraries/LibGL/GLVertexArrays.cpp @@ -9,17 +9,17 @@ extern GL::GLContext* g_gl_context; -void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer) +void glVertexPointer(GLint size, GLenum type, GLsizei stride, void const* pointer) { g_gl_context->gl_vertex_pointer(size, type, stride, pointer); } -void glColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer) +void glColorPointer(GLint size, GLenum type, GLsizei stride, void const* pointer) { g_gl_context->gl_color_pointer(size, type, stride, pointer); } -void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void* pointer) +void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void const* pointer) { g_gl_context->gl_tex_coord_pointer(size, type, stride, pointer); } @@ -29,7 +29,7 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) g_gl_context->gl_draw_arrays(mode, first, count); } -void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) +void glDrawElements(GLenum mode, GLsizei count, GLenum type, void const* indices) { g_gl_context->gl_draw_elements(mode, count, type, indices); } diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index c0ae44b967..a2d1fdb23a 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -17,7 +17,7 @@ namespace GUI { -AboutDialog::AboutDialog(StringView name, const Gfx::Bitmap* icon, Window* parent_window, StringView version) +AboutDialog::AboutDialog(StringView name, Gfx::Bitmap const* icon, Window* parent_window, StringView version) : Dialog(parent_window) , m_name(name) , m_icon(icon) diff --git a/Userland/Libraries/LibGUI/AboutDialog.h b/Userland/Libraries/LibGUI/AboutDialog.h index 4fb3ac3ee4..a6b5a724e0 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.h +++ b/Userland/Libraries/LibGUI/AboutDialog.h @@ -17,7 +17,7 @@ class AboutDialog final : public Dialog { public: virtual ~AboutDialog() override = default; - static void show(StringView name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const Gfx::Bitmap* window_icon = nullptr, StringView version = Core::Version::SERENITY_VERSION) + static void show(StringView name, Gfx::Bitmap const* icon = nullptr, Window* parent_window = nullptr, Gfx::Bitmap const* window_icon = nullptr, StringView version = Core::Version::SERENITY_VERSION) { auto dialog = AboutDialog::construct(name, icon, parent_window, version); if (window_icon) @@ -26,7 +26,7 @@ public: } private: - AboutDialog(StringView name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, StringView version = Core::Version::SERENITY_VERSION); + AboutDialog(StringView name, Gfx::Bitmap const* icon = nullptr, Window* parent_window = nullptr, StringView version = Core::Version::SERENITY_VERSION); String m_name; RefPtr<Gfx::Bitmap> m_icon; diff --git a/Userland/Libraries/LibGUI/AbstractButton.cpp b/Userland/Libraries/LibGUI/AbstractButton.cpp index 4697c490b0..be77913634 100644 --- a/Userland/Libraries/LibGUI/AbstractButton.cpp +++ b/Userland/Libraries/LibGUI/AbstractButton.cpp @@ -218,7 +218,7 @@ void AbstractButton::keyup_event(KeyEvent& event) Widget::keyup_event(event); } -void AbstractButton::paint_text(Painter& painter, const Gfx::IntRect& rect, const Gfx::Font& font, Gfx::TextAlignment text_alignment, Gfx::TextWrapping text_wrapping) +void AbstractButton::paint_text(Painter& painter, Gfx::IntRect const& rect, Gfx::Font const& font, Gfx::TextAlignment text_alignment, Gfx::TextWrapping text_wrapping) { auto clipped_rect = rect.intersected(this->rect()); diff --git a/Userland/Libraries/LibGUI/AbstractButton.h b/Userland/Libraries/LibGUI/AbstractButton.h index 40c3b71d56..0a29c8b9fc 100644 --- a/Userland/Libraries/LibGUI/AbstractButton.h +++ b/Userland/Libraries/LibGUI/AbstractButton.h @@ -21,7 +21,7 @@ public: Function<void(bool)> on_checked; void set_text(String); - const String& text() const { return m_text; } + String const& text() const { return m_text; } bool is_exclusive() const { return m_exclusive; } void set_exclusive(bool b) { m_exclusive = b; } @@ -54,7 +54,7 @@ protected: virtual void focusout_event(GUI::FocusEvent&) override; virtual void change_event(Event&) override; - void paint_text(Painter&, const Gfx::IntRect&, const Gfx::Font&, Gfx::TextAlignment, Gfx::TextWrapping = Gfx::TextWrapping::DontWrap); + void paint_text(Painter&, Gfx::IntRect const&, Gfx::Font const&, Gfx::TextAlignment, Gfx::TextWrapping = Gfx::TextWrapping::DontWrap); private: String m_text; diff --git a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp index b1a022f1a9..30e55ca91b 100644 --- a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp +++ b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp @@ -146,7 +146,7 @@ void AbstractScrollableWidget::update_scrollbar_ranges() m_vertical_scrollbar->set_page_step(visible_content_rect().height() - m_vertical_scrollbar->step()); } -void AbstractScrollableWidget::set_content_size(const Gfx::IntSize& size) +void AbstractScrollableWidget::set_content_size(Gfx::IntSize const& size) { if (m_content_size == size) return; @@ -154,7 +154,7 @@ void AbstractScrollableWidget::set_content_size(const Gfx::IntSize& size) update_scrollbar_ranges(); } -void AbstractScrollableWidget::set_size_occupied_by_fixed_elements(const Gfx::IntSize& size) +void AbstractScrollableWidget::set_size_occupied_by_fixed_elements(Gfx::IntSize const& size) { if (m_size_occupied_by_fixed_elements == size) return; @@ -191,14 +191,14 @@ Gfx::IntRect AbstractScrollableWidget::visible_content_rect() const return rect; } -void AbstractScrollableWidget::scroll_into_view(const Gfx::IntRect& rect, Orientation orientation) +void AbstractScrollableWidget::scroll_into_view(Gfx::IntRect const& rect, Orientation orientation) { if (orientation == Orientation::Vertical) return scroll_into_view(rect, false, true); return scroll_into_view(rect, true, false); } -void AbstractScrollableWidget::scroll_into_view(const Gfx::IntRect& rect, bool scroll_horizontally, bool scroll_vertically) +void AbstractScrollableWidget::scroll_into_view(Gfx::IntRect const& rect, bool scroll_horizontally, bool scroll_vertically) { auto visible_content_rect = this->visible_content_rect(); if (visible_content_rect.contains(rect)) @@ -255,7 +255,7 @@ void AbstractScrollableWidget::set_automatic_scrolling_timer(bool active) } } -Gfx::IntPoint AbstractScrollableWidget::automatic_scroll_delta_from_position(const Gfx::IntPoint& pos) const +Gfx::IntPoint AbstractScrollableWidget::automatic_scroll_delta_from_position(Gfx::IntPoint const& pos) const { Gfx::IntPoint delta { 0, 0 }; @@ -280,7 +280,7 @@ Gfx::IntRect AbstractScrollableWidget::widget_inner_rect() const return rect; } -Gfx::IntPoint AbstractScrollableWidget::to_content_position(const Gfx::IntPoint& widget_position) const +Gfx::IntPoint AbstractScrollableWidget::to_content_position(Gfx::IntPoint const& widget_position) const { auto content_position = widget_position; content_position.translate_by(horizontal_scrollbar().value(), vertical_scrollbar().value()); @@ -288,7 +288,7 @@ Gfx::IntPoint AbstractScrollableWidget::to_content_position(const Gfx::IntPoint& return content_position; } -Gfx::IntPoint AbstractScrollableWidget::to_widget_position(const Gfx::IntPoint& content_position) const +Gfx::IntPoint AbstractScrollableWidget::to_widget_position(Gfx::IntPoint const& content_position) const { auto widget_position = content_position; widget_position.translate_by(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); diff --git a/Userland/Libraries/LibGUI/AbstractScrollableWidget.h b/Userland/Libraries/LibGUI/AbstractScrollableWidget.h index fdc3ff5d12..54a79b7db7 100644 --- a/Userland/Libraries/LibGUI/AbstractScrollableWidget.h +++ b/Userland/Libraries/LibGUI/AbstractScrollableWidget.h @@ -33,8 +33,8 @@ public: return viewport_rect; } - void scroll_into_view(const Gfx::IntRect&, Orientation); - void scroll_into_view(const Gfx::IntRect&, bool scroll_horizontally, bool scroll_vertically); + void scroll_into_view(Gfx::IntRect const&, Orientation); + void scroll_into_view(Gfx::IntRect const&, bool scroll_horizontally, bool scroll_vertically); void set_scrollbars_enabled(bool); bool is_scrollbars_enabled() const { return m_scrollbars_enabled; } @@ -43,17 +43,17 @@ public: Gfx::IntSize excess_size() const; Scrollbar& vertical_scrollbar() { return *m_vertical_scrollbar; } - const Scrollbar& vertical_scrollbar() const { return *m_vertical_scrollbar; } + Scrollbar const& vertical_scrollbar() const { return *m_vertical_scrollbar; } Scrollbar& horizontal_scrollbar() { return *m_horizontal_scrollbar; } - const Scrollbar& horizontal_scrollbar() const { return *m_horizontal_scrollbar; } + Scrollbar const& horizontal_scrollbar() const { return *m_horizontal_scrollbar; } Widget& corner_widget() { return *m_corner_widget; } - const Widget& corner_widget() const { return *m_corner_widget; } + Widget const& corner_widget() const { return *m_corner_widget; } void scroll_to_top(); void scroll_to_bottom(); void set_automatic_scrolling_timer(bool active); - virtual Gfx::IntPoint automatic_scroll_delta_from_position(const Gfx::IntPoint&) const; + virtual Gfx::IntPoint automatic_scroll_delta_from_position(Gfx::IntPoint const&) const; int width_occupied_by_vertical_scrollbar() const; int height_occupied_by_horizontal_scrollbar() const; @@ -63,11 +63,11 @@ public: void set_should_hide_unnecessary_scrollbars(bool b) { m_should_hide_unnecessary_scrollbars = b; } bool should_hide_unnecessary_scrollbars() const { return m_should_hide_unnecessary_scrollbars; } - Gfx::IntPoint to_content_position(const Gfx::IntPoint& widget_position) const; - Gfx::IntPoint to_widget_position(const Gfx::IntPoint& content_position) const; + Gfx::IntPoint to_content_position(Gfx::IntPoint const& widget_position) const; + Gfx::IntPoint to_widget_position(Gfx::IntPoint const& content_position) const; - Gfx::IntRect to_content_rect(const Gfx::IntRect& widget_rect) const { return { to_content_position(widget_rect.location()), widget_rect.size() }; } - Gfx::IntRect to_widget_rect(const Gfx::IntRect& content_rect) const { return { to_widget_position(content_rect.location()), content_rect.size() }; } + Gfx::IntRect to_content_rect(Gfx::IntRect const& widget_rect) const { return { to_content_position(widget_rect.location()), widget_rect.size() }; } + Gfx::IntRect to_widget_rect(Gfx::IntRect const& content_rect) const { return { to_widget_position(content_rect.location()), content_rect.size() }; } protected: AbstractScrollableWidget(); @@ -75,8 +75,8 @@ protected: virtual void resize_event(ResizeEvent&) override; virtual void mousewheel_event(MouseEvent&) override; virtual void did_scroll() { } - void set_content_size(const Gfx::IntSize&); - void set_size_occupied_by_fixed_elements(const Gfx::IntSize&); + void set_content_size(Gfx::IntSize const&); + void set_size_occupied_by_fixed_elements(Gfx::IntSize const&); virtual void on_automatic_scrolling_timer_fired() {}; int autoscroll_threshold() const { return m_autoscroll_threshold; } diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp index 68db013f4c..bc29dadf82 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.cpp +++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp @@ -219,7 +219,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event) AbstractView::mousedown_event(event); } -ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& position, bool& is_toggle) const +ModelIndex AbstractTableView::index_at_event_position(Gfx::IntPoint const& position, bool& is_toggle) const { is_toggle = false; if (!model()) @@ -239,7 +239,7 @@ ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& posit return {}; } -ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& position) const +ModelIndex AbstractTableView::index_at_event_position(Gfx::IntPoint const& position) const { bool is_toggle; auto index = index_at_event_position(position, is_toggle); @@ -269,7 +269,7 @@ void AbstractTableView::move_cursor_relative(int vertical_steps, int horizontal_ } } -void AbstractTableView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) +void AbstractTableView::scroll_into_view(ModelIndex const& index, bool scroll_horizontally, bool scroll_vertically) { Gfx::IntRect rect; switch (selection_behavior()) { @@ -321,12 +321,12 @@ Gfx::IntRect AbstractTableView::content_rect(int row, int column) const return { row_rect.x() + x, row_rect.y(), column_width(column) + horizontal_padding() * 2, row_height() }; } -Gfx::IntRect AbstractTableView::content_rect(const ModelIndex& index) const +Gfx::IntRect AbstractTableView::content_rect(ModelIndex const& index) const { return content_rect(index.row(), index.column()); } -Gfx::IntRect AbstractTableView::content_rect_minus_scrollbars(const ModelIndex& index) const +Gfx::IntRect AbstractTableView::content_rect_minus_scrollbars(ModelIndex const& index) const { auto naive_content_rect = content_rect(index.row(), index.column()); return { naive_content_rect.x() - horizontal_scrollbar().value(), naive_content_rect.y() - vertical_scrollbar().value(), naive_content_rect.width(), naive_content_rect.height() }; @@ -340,7 +340,7 @@ Gfx::IntRect AbstractTableView::row_rect(int item_index) const row_height() }; } -Gfx::IntPoint AbstractTableView::adjusted_position(const Gfx::IntPoint& position) const +Gfx::IntPoint AbstractTableView::adjusted_position(Gfx::IntPoint const& position) const { return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); } @@ -469,7 +469,7 @@ bool AbstractTableView::is_navigation(GUI::KeyEvent& event) } } -Gfx::IntPoint AbstractTableView::automatic_scroll_delta_from_position(const Gfx::IntPoint& pos) const +Gfx::IntPoint AbstractTableView::automatic_scroll_delta_from_position(Gfx::IntPoint const& pos) const { if (pos.y() > column_header().height() + autoscroll_threshold()) return AbstractScrollableWidget::automatic_scroll_delta_from_position(pos); diff --git a/Userland/Libraries/LibGUI/AbstractTableView.h b/Userland/Libraries/LibGUI/AbstractTableView.h index 74de744560..30afb19a82 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.h +++ b/Userland/Libraries/LibGUI/AbstractTableView.h @@ -19,7 +19,7 @@ public: virtual ~TableCellPaintingDelegate() = default; virtual bool should_paint(ModelIndex const&) { return true; } - virtual void paint(Painter&, const Gfx::IntRect&, const Gfx::Palette&, const ModelIndex&) = 0; + virtual void paint(Painter&, Gfx::IntRect const&, Gfx::Palette const&, ModelIndex const&) = 0; }; class AbstractTableView : public AbstractView { @@ -52,23 +52,23 @@ public: void set_column_painting_delegate(int column, OwnPtr<TableCellPaintingDelegate>); - Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const; + Gfx::IntPoint adjusted_position(Gfx::IntPoint const&) const; - virtual Gfx::IntRect content_rect(const ModelIndex&) const override; - Gfx::IntRect content_rect_minus_scrollbars(const ModelIndex&) const; + virtual Gfx::IntRect content_rect(ModelIndex const&) const override; + Gfx::IntRect content_rect_minus_scrollbars(ModelIndex const&) const; Gfx::IntRect content_rect(int row, int column) const; Gfx::IntRect row_rect(int item_index) const; virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const override; - virtual void scroll_into_view(const ModelIndex&, bool scroll_horizontally = true, bool scroll_vertically = true) override; - void scroll_into_view(const ModelIndex& index, Orientation orientation) + virtual void scroll_into_view(ModelIndex const&, bool scroll_horizontally = true, bool scroll_vertically = true) override; + void scroll_into_view(ModelIndex const& index, Orientation orientation) { scroll_into_view(index, orientation == Gfx::Orientation::Horizontal, orientation == Gfx::Orientation::Vertical); } - virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const; - virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; + virtual ModelIndex index_at_event_position(Gfx::IntPoint const&, bool& is_toggle) const; + virtual ModelIndex index_at_event_position(Gfx::IntPoint const&) const override; virtual void select_all() override; @@ -78,10 +78,10 @@ public: virtual void did_scroll() override; HeaderView& column_header() { return *m_column_header; } - const HeaderView& column_header() const { return *m_column_header; } + HeaderView const& column_header() const { return *m_column_header; } HeaderView& row_header() { return *m_row_header; } - const HeaderView& row_header() const { return *m_row_header; } + HeaderView const& row_header() const { return *m_row_header; } virtual void model_did_update(unsigned flags) override; @@ -94,7 +94,7 @@ protected: virtual void keydown_event(KeyEvent&) override; virtual void resize_event(ResizeEvent&) override; - virtual void toggle_index(const ModelIndex&) { } + virtual void toggle_index(ModelIndex const&) { } void update_content_size(); virtual void auto_resize_column(int column); @@ -106,7 +106,7 @@ protected: void move_cursor_relative(int vertical_steps, int horizontal_steps, SelectionUpdate); - virtual Gfx::IntPoint automatic_scroll_delta_from_position(const Gfx::IntPoint& pos) const override; + virtual Gfx::IntPoint automatic_scroll_delta_from_position(Gfx::IntPoint const& pos) const override; private: void layout_headers(); diff --git a/Userland/Libraries/LibGUI/AbstractZoomPanWidget.cpp b/Userland/Libraries/LibGUI/AbstractZoomPanWidget.cpp index 03247bd670..0957ad587d 100644 --- a/Userland/Libraries/LibGUI/AbstractZoomPanWidget.cpp +++ b/Userland/Libraries/LibGUI/AbstractZoomPanWidget.cpp @@ -185,7 +185,7 @@ void AbstractZoomPanWidget::set_scale_bounds(float min_scale, float max_scale) void AbstractZoomPanWidget::fit_content_to_rect(Gfx::IntRect const& viewport_rect, FitType type) { - const float border_ratio = 0.95f; + float const border_ratio = 0.95f; auto image_size = m_original_rect.size(); auto height_ratio = floorf(border_ratio * viewport_rect.height()) / image_size.height(); auto width_ratio = floorf(border_ratio * viewport_rect.width()) / image_size.width(); diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 8191798993..4eceaa6fbd 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -23,22 +23,22 @@ NonnullRefPtr<Action> Action::create(String text, RefPtr<Gfx::Bitmap> icon, Func return adopt_ref(*new Action(move(text), move(icon), move(callback), parent)); } -NonnullRefPtr<Action> Action::create(String text, const Shortcut& shortcut, Function<void(Action&)> callback, Core::Object* parent) +NonnullRefPtr<Action> Action::create(String text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, move(callback), parent)); } -NonnullRefPtr<Action> Action::create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent) +NonnullRefPtr<Action> Action::create(String text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(callback), parent)); } -NonnullRefPtr<Action> Action::create(String text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent) +NonnullRefPtr<Action> Action::create(String text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent)); } -NonnullRefPtr<Action> Action::create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent) +NonnullRefPtr<Action> Action::create(String text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(icon), move(callback), parent)); } @@ -53,12 +53,12 @@ NonnullRefPtr<Action> Action::create_checkable(String text, RefPtr<Gfx::Bitmap> return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true)); } -NonnullRefPtr<Action> Action::create_checkable(String text, const Shortcut& shortcut, Function<void(Action&)> callback, Core::Object* parent) +NonnullRefPtr<Action> Action::create_checkable(String text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true)); } -NonnullRefPtr<Action> Action::create_checkable(String text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent) +NonnullRefPtr<Action> Action::create_checkable(String text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent, true)); } @@ -73,17 +73,17 @@ Action::Action(String text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> on { } -Action::Action(String text, const Shortcut& shortcut, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable) +Action::Action(String text, Shortcut const& shortcut, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable) : Action(move(text), shortcut, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable) { } -Action::Action(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable) +Action::Action(String text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable) : Action(move(text), shortcut, alternate_shortcut, nullptr, move(on_activation_callback), parent, checkable) { } -Action::Action(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable) +Action::Action(String text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable) : Core::Object(parent) , on_activation(move(on_activation_callback)) , m_text(move(text)) @@ -217,7 +217,7 @@ void Action::set_group(Badge<ActionGroup>, ActionGroup* group) m_action_group = AK::make_weak_ptr_if_nonnull(group); } -void Action::set_icon(const Gfx::Bitmap* icon) +void Action::set_icon(Gfx::Bitmap const* icon) { m_icon = icon; } diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index b1eca83b7a..bf2b5376d4 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -23,7 +23,7 @@ namespace GUI { namespace CommonActions { -NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent = nullptr); +NonnullRefPtr<Action> make_about_action(String const& app_name, Icon const& app_icon, Window* parent = nullptr); NonnullRefPtr<Action> make_open_action(Function<void(Action&)>, Core::Object* parent = nullptr); NonnullRefPtr<Action> make_save_action(Function<void(Action&)>, Core::Object* parent = nullptr); NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)>, Core::Object* parent = nullptr); @@ -65,14 +65,14 @@ public: }; static NonnullRefPtr<Action> create(String text, Function<void(Action&)> callback, Core::Object* parent = nullptr); static NonnullRefPtr<Action> create(String text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); - static NonnullRefPtr<Action> create(String text, const Shortcut& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr); - static NonnullRefPtr<Action> create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr); - static NonnullRefPtr<Action> create(String text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); - static NonnullRefPtr<Action> create(String text, const Shortcut& shortcut, const Shortcut& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); + static NonnullRefPtr<Action> create(String text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr); + static NonnullRefPtr<Action> create(String text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr); + static NonnullRefPtr<Action> create(String text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); + static NonnullRefPtr<Action> create(String text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); static NonnullRefPtr<Action> create_checkable(String text, Function<void(Action&)> callback, Core::Object* parent = nullptr); static NonnullRefPtr<Action> create_checkable(String text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); - static NonnullRefPtr<Action> create_checkable(String text, const Shortcut& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr); - static NonnullRefPtr<Action> create_checkable(String text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); + static NonnullRefPtr<Action> create_checkable(String text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr); + static NonnullRefPtr<Action> create_checkable(String text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr); virtual ~Action() override; @@ -84,10 +84,10 @@ public: Shortcut const& shortcut() const { return m_shortcut; } Shortcut const& alternate_shortcut() const { return m_alternate_shortcut; } - const Gfx::Bitmap* icon() const { return m_icon.ptr(); } - void set_icon(const Gfx::Bitmap*); + Gfx::Bitmap const* icon() const { return m_icon.ptr(); } + void set_icon(Gfx::Bitmap const*); - const Core::Object* activator() const { return m_activator.ptr(); } + Core::Object const* activator() const { return m_activator.ptr(); } Core::Object* activator() { return m_activator.ptr(); } Function<void(Action&)> on_activation; @@ -116,16 +116,16 @@ public: void register_menu_item(Badge<MenuItem>, MenuItem&); void unregister_menu_item(Badge<MenuItem>, MenuItem&); - const ActionGroup* group() const { return m_action_group.ptr(); } + ActionGroup const* group() const { return m_action_group.ptr(); } void set_group(Badge<ActionGroup>, ActionGroup*); HashTable<MenuItem*> menu_items() const { return m_menu_items; } private: Action(String, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); - Action(String, const Shortcut&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); - Action(String, const Shortcut&, const Shortcut&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); - Action(String, const Shortcut&, const Shortcut&, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(String, Shortcut const&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(String, Shortcut const&, Shortcut const&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(String, Shortcut const&, Shortcut const&, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); Action(String, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false); template<typename Callback> diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 1ab1ad8bec..96427ecc0b 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -24,7 +24,7 @@ class Application::TooltipWindow final : public Window { C_OBJECT(TooltipWindow); public: - void set_tooltip(const String& tooltip) + void set_tooltip(String const& tooltip) { m_label->set_text(Gfx::parse_ampersand_string(tooltip)); int tooltip_width = m_label->min_width() + 10; @@ -136,7 +136,7 @@ void Application::unregister_global_shortcut_action(Badge<Action>, Action& actio m_global_shortcut_actions.remove(action.alternate_shortcut()); } -Action* Application::action_for_key_event(const KeyEvent& event) +Action* Application::action_for_key_event(KeyEvent const& event) { auto it = m_global_shortcut_actions.find(Shortcut(event.modifiers(), (KeyCode)event.key())); if (it == m_global_shortcut_actions.end()) @@ -144,7 +144,7 @@ Action* Application::action_for_key_event(const KeyEvent& event) return (*it).value; } -void Application::show_tooltip(String tooltip, const Widget* tooltip_source_widget) +void Application::show_tooltip(String tooltip, Widget const* tooltip_source_widget) { m_tooltip_source_widget = tooltip_source_widget; if (!m_tooltip_window) { @@ -163,7 +163,7 @@ void Application::show_tooltip(String tooltip, const Widget* tooltip_source_widg } } -void Application::show_tooltip_immediately(String tooltip, const Widget* tooltip_source_widget) +void Application::show_tooltip_immediately(String tooltip, Widget const* tooltip_source_widget) { m_tooltip_source_widget = tooltip_source_widget; if (!m_tooltip_window) { @@ -206,7 +206,7 @@ void Application::set_system_palette(Core::AnonymousBuffer& buffer) m_palette = m_system_palette; } -void Application::set_palette(const Palette& palette) +void Application::set_palette(Palette const& palette) { m_palette = palette.impl(); } @@ -221,7 +221,7 @@ void Application::request_tooltip_show() VERIFY(m_tooltip_window); Gfx::IntRect desktop_rect = Desktop::the().rect(); - const int margin = 30; + int const margin = 30; Gfx::IntPoint adjusted_pos = ConnectionToWindowServer::the().get_global_cursor_position(); adjusted_pos.translate_by(0, 18); @@ -271,7 +271,7 @@ void Application::set_pending_drop_widget(Widget* widget) m_pending_drop_widget->update(); } -void Application::set_drag_hovered_widget_impl(Widget* widget, const Gfx::IntPoint& position, Vector<String> mime_types) +void Application::set_drag_hovered_widget_impl(Widget* widget, Gfx::IntPoint const& position, Vector<String> mime_types) { if (widget == m_drag_hovered_widget) return; diff --git a/Userland/Libraries/LibGUI/Application.h b/Userland/Libraries/LibGUI/Application.h index f4f594d6fd..68466bb39a 100644 --- a/Userland/Libraries/LibGUI/Application.h +++ b/Userland/Libraries/LibGUI/Application.h @@ -33,13 +33,13 @@ public: int exec(); void quit(int = 0); - Action* action_for_key_event(const KeyEvent&); + Action* action_for_key_event(KeyEvent const&); void register_global_shortcut_action(Badge<Action>, Action&); void unregister_global_shortcut_action(Badge<Action>, Action&); - void show_tooltip(String, const Widget* tooltip_source_widget); - void show_tooltip_immediately(String, const Widget* tooltip_source_widget); + void show_tooltip(String, Widget const* tooltip_source_widget); + void show_tooltip_immediately(String, Widget const* tooltip_source_widget); void hide_tooltip(); Widget* tooltip_source_widget() { return m_tooltip_source_widget; }; @@ -49,11 +49,11 @@ public: void did_create_window(Badge<Window>); void did_delete_last_window(Badge<Window>); - const String& invoked_as() const { return m_invoked_as; } - const Vector<String>& args() const { return m_args; } + String const& invoked_as() const { return m_invoked_as; } + Vector<String> const& args() const { return m_args; } Gfx::Palette palette() const; - void set_palette(const Gfx::Palette&); + void set_palette(Gfx::Palette const&); void set_system_palette(Core::AnonymousBuffer&); @@ -64,18 +64,18 @@ public: Core::EventLoop& event_loop() { return *m_event_loop; } Window* active_window() { return m_active_window; } - const Window* active_window() const { return m_active_window; } + Window const* active_window() const { return m_active_window; } void window_did_become_active(Badge<Window>, Window&); void window_did_become_inactive(Badge<Window>, Window&); Widget* drag_hovered_widget() { return m_drag_hovered_widget.ptr(); } - const Widget* drag_hovered_widget() const { return m_drag_hovered_widget.ptr(); } + Widget const* drag_hovered_widget() const { return m_drag_hovered_widget.ptr(); } Widget* pending_drop_widget() { return m_pending_drop_widget.ptr(); } - const Widget* pending_drop_widget() const { return m_pending_drop_widget.ptr(); } + Widget const* pending_drop_widget() const { return m_pending_drop_widget.ptr(); } - void set_drag_hovered_widget(Badge<Window>, Widget* widget, const Gfx::IntPoint& position = {}, Vector<String> mime_types = {}) + void set_drag_hovered_widget(Badge<Window>, Widget* widget, Gfx::IntPoint const& position = {}, Vector<String> mime_types = {}) { set_drag_hovered_widget_impl(widget, position, move(mime_types)); } @@ -98,7 +98,7 @@ private: void request_tooltip_show(); void tooltip_hide_timer_did_fire(); - void set_drag_hovered_widget_impl(Widget*, const Gfx::IntPoint& = {}, Vector<String> = {}); + void set_drag_hovered_widget_impl(Widget*, Gfx::IntPoint const& = {}, Vector<String> = {}); void set_pending_drop_widget(Widget*); OwnPtr<Core::EventLoop> m_event_loop; diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index 82a46800f2..400aff8471 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -219,12 +219,12 @@ AutocompleteProvider::Entry::HideAutocompleteAfterApplying AutocompleteBox::appl return hide_when_done; } -bool AutocompleteProvider::Declaration::operator==(const AutocompleteProvider::Declaration& other) const +bool AutocompleteProvider::Declaration::operator==(AutocompleteProvider::Declaration const& other) const { return name == other.name && position == other.position && type == other.type && scope == other.scope; } -bool AutocompleteProvider::ProjectLocation::operator==(const ProjectLocation& other) const +bool AutocompleteProvider::ProjectLocation::operator==(ProjectLocation const& other) const { return file == other.file && line == other.line && column == other.column; } diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.h b/Userland/Libraries/LibGUI/AutocompleteProvider.h index a6acd00ccd..0475436046 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.h +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.h @@ -45,7 +45,7 @@ public: size_t line { 0 }; size_t column { 0 }; - bool operator==(const ProjectLocation&) const; + bool operator==(ProjectLocation const&) const; }; enum class DeclarationType { @@ -64,7 +64,7 @@ public: DeclarationType type; String scope; - bool operator==(const Declaration&) const; + bool operator==(Declaration const&) const; }; virtual void provide_completions(Function<void(Vector<Entry>)>) = 0; @@ -102,7 +102,7 @@ public: size_t end_line { 0 }; size_t end_column { 0 }; - static constexpr const char* type_to_string(SemanticType t) + static constexpr char const* type_to_string(SemanticType t) { switch (t) { #define __SEMANTIC(x) \ diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp index 3cf593c470..c274935c32 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp @@ -101,7 +101,7 @@ void Breadcrumbbar::append_segment(String text, Gfx::Bitmap const* icon, String auto icon_width = icon ? icon->width() : 0; auto icon_padding = icon ? 4 : 0; - const int max_button_width = 100; + int const max_button_width = 100; auto button_width = min(button_text_width + icon_width + icon_padding + 16, max_button_width); auto shrunken_width = icon_width + icon_padding + (icon ? 4 : 16); diff --git a/Userland/Libraries/LibGUI/Button.h b/Userland/Libraries/LibGUI/Button.h index 73c4102a81..5e1cb76a84 100644 --- a/Userland/Libraries/LibGUI/Button.h +++ b/Userland/Libraries/LibGUI/Button.h @@ -23,7 +23,7 @@ public: void set_icon(RefPtr<Gfx::Bitmap>); void set_icon_from_path(String const&); - const Gfx::Bitmap* icon() const { return m_icon.ptr(); } + Gfx::Bitmap const* icon() const { return m_icon.ptr(); } Gfx::Bitmap* icon() { return m_icon.ptr(); } void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; } diff --git a/Userland/Libraries/LibGUI/Calendar.cpp b/Userland/Libraries/LibGUI/Calendar.cpp index cd3cbbca3b..922e030255 100644 --- a/Userland/Libraries/LibGUI/Calendar.cpp +++ b/Userland/Libraries/LibGUI/Calendar.cpp @@ -17,10 +17,10 @@ REGISTER_WIDGET(GUI, Calendar); namespace GUI { -static const auto extra_large_font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular36.font"); -static const auto large_font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font"); -static const auto medium_font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonRegular14.font"); -static const auto small_font = Gfx::BitmapFont::load_from_file("/res/fonts/KaticaRegular10.font"); +static auto const extra_large_font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular36.font"); +static auto const large_font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font"); +static auto const medium_font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonRegular14.font"); +static auto const small_font = Gfx::BitmapFont::load_from_file("/res/fonts/KaticaRegular10.font"); Calendar::Calendar(Core::DateTime date_time, Mode mode) : m_selected_date(date_time) @@ -75,7 +75,7 @@ void Calendar::resize_event(GUI::ResizeEvent& event) set_show_year(false); - const int GRID_LINES = 6; + int const GRID_LINES = 6; int tile_width = (m_event_size.width() - GRID_LINES) / 7; int width_remainder = (m_event_size.width() - GRID_LINES) % 7; int y_offset = is_showing_days_of_the_week() ? 16 : 0; @@ -124,10 +124,10 @@ void Calendar::resize_event(GUI::ResizeEvent& event) set_show_month_and_year(false); - const int VERT_GRID_LINES = 27; - const int HORI_GRID_LINES = 15; - const int THREADING = 3; - const int MONTH_TITLE = 19; + int const VERT_GRID_LINES = 27; + int const HORI_GRID_LINES = 15; + int const THREADING = 3; + int const MONTH_TITLE = 19; int tile_width = (m_event_size.width() - VERT_GRID_LINES) / 28; int width_remainder = (m_event_size.width() - VERT_GRID_LINES) % 28; int y_offset = is_showing_year() ? 22 : 0; diff --git a/Userland/Libraries/LibGUI/ColumnsView.cpp b/Userland/Libraries/LibGUI/ColumnsView.cpp index 67ba0bce1b..ce1cbef995 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.cpp +++ b/Userland/Libraries/LibGUI/ColumnsView.cpp @@ -156,7 +156,7 @@ void ColumnsView::paint_event(PaintEvent& event) } } -void ColumnsView::push_column(const ModelIndex& parent_index) +void ColumnsView::push_column(ModelIndex const& parent_index) { VERIFY(model()); @@ -206,7 +206,7 @@ void ColumnsView::update_column_sizes() set_content_size({ total_width, total_height }); } -ModelIndex ColumnsView::index_at_event_position(const Gfx::IntPoint& a_position) const +ModelIndex ColumnsView::index_at_event_position(Gfx::IntPoint const& a_position) const { if (!model()) return {}; @@ -306,7 +306,7 @@ void ColumnsView::move_cursor(CursorMovement movement, SelectionUpdate selection set_cursor(new_index, selection_update); } -Gfx::IntRect ColumnsView::content_rect(const ModelIndex& index) const +Gfx::IntRect ColumnsView::content_rect(ModelIndex const& index) const { if (!index.is_valid()) return {}; diff --git a/Userland/Libraries/LibGUI/ColumnsView.h b/Userland/Libraries/LibGUI/ColumnsView.h index 3f37463106..f0d1ffea14 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.h +++ b/Userland/Libraries/LibGUI/ColumnsView.h @@ -18,14 +18,14 @@ public: int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } - virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; - virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + virtual ModelIndex index_at_event_position(Gfx::IntPoint const&) const override; + virtual Gfx::IntRect content_rect(ModelIndex const&) const override; virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const&) const override; private: ColumnsView(); virtual ~ColumnsView() override = default; - void push_column(const ModelIndex& parent_index); + void push_column(ModelIndex const& parent_index); void update_column_sizes(); int item_height() const { return 18; } diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 294461fc45..4f82b9fea3 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -145,7 +145,7 @@ void ComboBox::set_editor_placeholder(StringView placeholder) m_editor->set_placeholder(placeholder); } -const String& ComboBox::editor_placeholder() const +String const& ComboBox::editor_placeholder() const { return m_editor->placeholder(); } @@ -170,7 +170,7 @@ void ComboBox::navigate_relative(int delta) on_change(m_editor->text(), current_selected); } -void ComboBox::selection_updated(const ModelIndex& index) +void ComboBox::selection_updated(ModelIndex const& index) { if (index.is_valid()) m_selected_index = index; @@ -274,7 +274,7 @@ String ComboBox::text() const return m_editor->text(); } -void ComboBox::set_text(const String& text) +void ComboBox::set_text(String const& text) { m_editor->set_text(text); } @@ -292,7 +292,7 @@ Model* ComboBox::model() return m_list_view->model(); } -const Model* ComboBox::model() const +Model const* ComboBox::model() const { return m_list_view->model(); } diff --git a/Userland/Libraries/LibGUI/ComboBox.h b/Userland/Libraries/LibGUI/ComboBox.h index 4db98b30e9..07955c3f7b 100644 --- a/Userland/Libraries/LibGUI/ComboBox.h +++ b/Userland/Libraries/LibGUI/ComboBox.h @@ -21,14 +21,14 @@ public: virtual ~ComboBox() override; String text() const; - void set_text(const String&); + void set_text(String const&); void open(); void close(); void select_all(); Model* model(); - const Model* model() const; + Model const* model() const; void set_model(NonnullRefPtr<Model>); size_t selected_index() const; @@ -41,9 +41,9 @@ public: void set_model_column(int); void set_editor_placeholder(StringView placeholder); - const String& editor_placeholder() const; + String const& editor_placeholder() const; - Function<void(const String&, const ModelIndex&)> on_change; + Function<void(String const&, ModelIndex const&)> on_change; Function<void()> on_return_pressed; protected: @@ -51,7 +51,7 @@ protected: virtual void resize_event(ResizeEvent&) override; private: - void selection_updated(const ModelIndex&); + void selection_updated(ModelIndex const&); void navigate(AbstractView::CursorMovement); void navigate_relative(int); diff --git a/Userland/Libraries/LibGUI/CommonActions.cpp b/Userland/Libraries/LibGUI/CommonActions.cpp index 27c3e8cfb8..4255ca6ad8 100644 --- a/Userland/Libraries/LibGUI/CommonActions.cpp +++ b/Userland/Libraries/LibGUI/CommonActions.cpp @@ -15,7 +15,7 @@ namespace GUI { namespace CommonActions { -NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent) +NonnullRefPtr<Action> make_about_action(String const& app_name, Icon const& app_icon, Window* parent) { auto weak_parent = AK::make_weak_ptr_if_nonnull<Window>(parent); auto action = Action::create(String::formatted("&About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) { diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp index 29d1f10b7f..a06a32f7b4 100644 --- a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp +++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp @@ -36,7 +36,7 @@ static void initialize_if_needed() s_initialized = true; } -void CommonLocationsProvider::load_from_json(const String& json_path) +void CommonLocationsProvider::load_from_json(String const& json_path) { auto file = Core::File::construct(json_path); if (!file->open(Core::OpenMode::ReadOnly)) { @@ -69,7 +69,7 @@ void CommonLocationsProvider::load_from_json(const String& json_path) s_initialized = true; } -const Vector<CommonLocationsProvider::CommonLocation>& CommonLocationsProvider::common_locations() +Vector<CommonLocationsProvider::CommonLocation> const& CommonLocationsProvider::common_locations() { initialize_if_needed(); return s_common_locations; diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.h b/Userland/Libraries/LibGUI/CommonLocationsProvider.h index 813439195d..0de400a83e 100644 --- a/Userland/Libraries/LibGUI/CommonLocationsProvider.h +++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.h @@ -20,8 +20,8 @@ public: String path; }; - static void load_from_json(const String& json_path); - static const Vector<CommonLocation>& common_locations(); + static void load_from_json(String const& json_path); + static Vector<CommonLocation> const& common_locations(); }; } diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowMangerServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowMangerServer.cpp index 006e41d02b..e5b8e482d9 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowMangerServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowMangerServer.cpp @@ -27,7 +27,7 @@ void ConnectionToWindowMangerServer::window_state_changed(i32 wm_id, i32 client_ Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, workspace_row, workspace_column, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress)); } -void ConnectionToWindowMangerServer::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size) +void ConnectionToWindowMangerServer::applet_area_size_changed(i32 wm_id, Gfx::IntSize const& size) { if (auto* window = Window::from_window_id(wm_id)) Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size)); diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp index d7cb7517e9..93c49ae504 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp @@ -68,7 +68,7 @@ void ConnectionToWindowServer::update_system_theme(Core::AnonymousBuffer const& }); } -void ConnectionToWindowServer::update_system_fonts(const String& default_font_query, const String& fixed_width_font_query) +void ConnectionToWindowServer::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query) { Gfx::FontDatabase::set_default_font_query(default_font_query); Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query); diff --git a/Userland/Libraries/LibGUI/Desktop.cpp b/Userland/Libraries/LibGUI/Desktop.cpp index f962a005c9..74e443557c 100644 --- a/Userland/Libraries/LibGUI/Desktop.cpp +++ b/Userland/Libraries/LibGUI/Desktop.cpp @@ -22,7 +22,7 @@ Desktop& Desktop::the() return s_the; } -void Desktop::did_receive_screen_rects(Badge<ConnectionToWindowServer>, const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index, unsigned workspace_rows, unsigned workspace_columns) +void Desktop::did_receive_screen_rects(Badge<ConnectionToWindowServer>, Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index, unsigned workspace_rows, unsigned workspace_columns) { m_main_screen_index = main_screen_index; m_rects = rects; diff --git a/Userland/Libraries/LibGUI/Desktop.h b/Userland/Libraries/LibGUI/Desktop.h index 82f5143fb3..952977997f 100644 --- a/Userland/Libraries/LibGUI/Desktop.h +++ b/Userland/Libraries/LibGUI/Desktop.h @@ -35,7 +35,7 @@ public: bool set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<String> path); Gfx::IntRect rect() const { return m_bounding_rect; } - const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; } + Vector<Gfx::IntRect, 4> const& rects() const { return m_rects; } size_t main_screen_index() const { return m_main_screen_index; } unsigned workspace_rows() const { return m_workspace_rows; } @@ -43,7 +43,7 @@ public: int taskbar_height() const { return TaskbarWindow::taskbar_height(); } - void did_receive_screen_rects(Badge<ConnectionToWindowServer>, const Vector<Gfx::IntRect, 4>&, size_t, unsigned, unsigned); + void did_receive_screen_rects(Badge<ConnectionToWindowServer>, Vector<Gfx::IntRect, 4> const&, size_t, unsigned, unsigned); template<typename F> void on_receive_screen_rects(F&& callback) diff --git a/Userland/Libraries/LibGUI/DragOperation.cpp b/Userland/Libraries/LibGUI/DragOperation.cpp index 839b1f8aef..349c230246 100644 --- a/Userland/Libraries/LibGUI/DragOperation.cpp +++ b/Userland/Libraries/LibGUI/DragOperation.cpp @@ -73,20 +73,20 @@ void DragOperation::notify_cancelled(Badge<ConnectionToWindowServer>) s_current_drag_operation->done(Outcome::Cancelled); } -void DragOperation::set_text(const String& text) +void DragOperation::set_text(String const& text) { if (!m_mime_data) m_mime_data = Core::MimeData::construct(); m_mime_data->set_text(text); } -void DragOperation::set_bitmap(const Gfx::Bitmap* bitmap) +void DragOperation::set_bitmap(Gfx::Bitmap const* bitmap) { if (!m_mime_data) m_mime_data = Core::MimeData::construct(); if (bitmap) m_mime_data->set_data("image/x-raw-bitmap", bitmap->serialize_to_byte_buffer()); } -void DragOperation::set_data(const String& data_type, const String& data) +void DragOperation::set_data(String const& data_type, String const& data) { if (!m_mime_data) m_mime_data = Core::MimeData::construct(); diff --git a/Userland/Libraries/LibGUI/DragOperation.h b/Userland/Libraries/LibGUI/DragOperation.h index 647e728d7c..b9419af34e 100644 --- a/Userland/Libraries/LibGUI/DragOperation.h +++ b/Userland/Libraries/LibGUI/DragOperation.h @@ -27,9 +27,9 @@ public: virtual ~DragOperation() override = default; void set_mime_data(RefPtr<Core::MimeData> mime_data) { m_mime_data = move(mime_data); } - void set_text(const String& text); - void set_bitmap(const Gfx::Bitmap* bitmap); - void set_data(const String& data_type, const String& data); + void set_text(String const& text); + void set_bitmap(Gfx::Bitmap const* bitmap); + void set_data(String const& data_type, String const& data); Outcome exec(); Outcome outcome() const { return m_outcome; } diff --git a/Userland/Libraries/LibGUI/EditingEngine.cpp b/Userland/Libraries/LibGUI/EditingEngine.cpp index 0141ffee11..34f6f56e69 100644 --- a/Userland/Libraries/LibGUI/EditingEngine.cpp +++ b/Userland/Libraries/LibGUI/EditingEngine.cpp @@ -33,7 +33,7 @@ void EditingEngine::detach() m_editor = nullptr; } -bool EditingEngine::on_key(const KeyEvent& event) +bool EditingEngine::on_key(KeyEvent const& event) { if (event.key() == KeyCode::Key_Left) { if (!event.shift() && m_editor->selection().is_valid()) { @@ -268,7 +268,7 @@ void EditingEngine::move_to_logical_line_end() m_editor->set_cursor({ m_editor->cursor().line(), m_editor->current_line().length() }); } -void EditingEngine::move_one_up(const KeyEvent& event) +void EditingEngine::move_one_up(KeyEvent const& event) { if (m_editor->cursor().line() > 0 || m_editor->is_wrapping_enabled()) { if (event.ctrl() && event.shift()) { @@ -288,7 +288,7 @@ void EditingEngine::move_one_up(const KeyEvent& event) } }; -void EditingEngine::move_one_down(const KeyEvent& event) +void EditingEngine::move_one_down(KeyEvent const& event) { if (m_editor->cursor().line() < (m_editor->line_count() - 1) || m_editor->is_wrapping_enabled()) { if (event.ctrl() && event.shift()) { @@ -406,7 +406,7 @@ TextPosition EditingEngine::find_beginning_of_next_word() for (size_t column_index = 0; column_index < lines.at(line_index).length(); column_index++) { if (line_index == cursor.line() && column_index < cursor.column()) continue; - const u32* line_chars = line.view().code_points(); + u32 const* line_chars = line.view().code_points(); const u32 current_char = line_chars[column_index]; if (started_on_punct && is_vim_alphanumeric(current_char)) { @@ -470,7 +470,7 @@ TextPosition EditingEngine::find_end_of_next_word() if (line_index == cursor.line() && column_index < cursor.column()) continue; - const u32* line_chars = line.view().code_points(); + u32 const* line_chars = line.view().code_points(); const u32 current_char = line_chars[column_index]; if (column_index == lines.at(line_index).length() - 1 && !is_first_iteration && (is_vim_alphanumeric(current_char) || is_vim_punctuation(current_char))) @@ -526,7 +526,7 @@ TextPosition EditingEngine::find_end_of_previous_word() if (line_index == cursor.line() && column_index > cursor.column()) continue; - const u32* line_chars = line.view().code_points(); + u32 const* line_chars = line.view().code_points(); const u32 current_char = line_chars[column_index]; if (started_on_punct && is_vim_alphanumeric(current_char)) { @@ -591,7 +591,7 @@ TextPosition EditingEngine::find_beginning_of_previous_word() continue; } - const u32* line_chars = line.view().code_points(); + u32 const* line_chars = line.view().code_points(); const u32 current_char = line_chars[column_index]; if (column_index == 0 && !is_first_iteration && (is_vim_alphanumeric(current_char) || is_vim_punctuation(current_char))) { diff --git a/Userland/Libraries/LibGUI/EditingEngine.h b/Userland/Libraries/LibGUI/EditingEngine.h index 3b0e617cc7..bef68b2200 100644 --- a/Userland/Libraries/LibGUI/EditingEngine.h +++ b/Userland/Libraries/LibGUI/EditingEngine.h @@ -40,7 +40,7 @@ public: return *m_editor.unsafe_ptr(); } - virtual bool on_key(const KeyEvent& event); + virtual bool on_key(KeyEvent const& event); bool is_regular() const { return engine_type() == EngineType::Regular; } bool is_vim() const { return engine_type() == EngineType::Vim; } @@ -52,8 +52,8 @@ protected: void move_one_left(); void move_one_right(); - void move_one_up(const KeyEvent& event); - void move_one_down(const KeyEvent& event); + void move_one_up(KeyEvent const& event); + void move_one_down(KeyEvent const& event); void move_to_previous_span(); void move_to_next_span(); void move_to_logical_line_beginning(); diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.h b/Userland/Libraries/LibGUI/EmojiInputDialog.h index 739c09abb2..e291887ecd 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.h +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.h @@ -14,7 +14,7 @@ class EmojiInputDialog final : public Dialog { C_OBJECT(EmojiInputDialog); public: - const String& selected_emoji_text() const { return m_selected_emoji_text; } + String const& selected_emoji_text() const { return m_selected_emoji_text; } private: virtual void event(Core::Event&) override; diff --git a/Userland/Libraries/LibGUI/Event.cpp b/Userland/Libraries/LibGUI/Event.cpp index 414e21576d..88c8089702 100644 --- a/Userland/Libraries/LibGUI/Event.cpp +++ b/Userland/Libraries/LibGUI/Event.cpp @@ -12,7 +12,7 @@ namespace GUI { -DropEvent::DropEvent(const Gfx::IntPoint& position, const String& text, NonnullRefPtr<Core::MimeData> mime_data) +DropEvent::DropEvent(Gfx::IntPoint const& position, String const& text, NonnullRefPtr<Core::MimeData> mime_data) : Event(Event::Drop) , m_position(position) , m_text(text) diff --git a/Userland/Libraries/LibGUI/Event.h b/Userland/Libraries/LibGUI/Event.h index 90cae6e922..a0b013b0c1 100644 --- a/Userland/Libraries/LibGUI/Event.h +++ b/Userland/Libraries/LibGUI/Event.h @@ -133,13 +133,13 @@ private: class WMAppletAreaSizeChangedEvent : public WMEvent { public: - explicit WMAppletAreaSizeChangedEvent(const Gfx::IntSize& size) + explicit WMAppletAreaSizeChangedEvent(Gfx::IntSize const& size) : WMEvent(Event::Type::WM_AppletAreaSizeChanged, 0, 0) , m_size(size) { } - const Gfx::IntSize& size() const { return m_size; } + Gfx::IntSize const& size() const { return m_size; } private: Gfx::IntSize m_size; @@ -155,7 +155,7 @@ public: class WMWindowStateChangedEvent : public WMEvent { public: - WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, StringView title, const Gfx::IntRect& rect, unsigned workspace_row, unsigned workspace_column, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress) + WMWindowStateChangedEvent(int client_id, int window_id, int parent_client_id, int parent_window_id, StringView title, Gfx::IntRect const& rect, unsigned workspace_row, unsigned workspace_column, bool is_active, bool is_modal, WindowType window_type, bool is_minimized, bool is_frameless, Optional<int> progress) : WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id) , m_parent_client_id(parent_client_id) , m_parent_window_id(parent_window_id) @@ -174,8 +174,8 @@ public: int parent_client_id() const { return m_parent_client_id; } int parent_window_id() const { return m_parent_window_id; } - const String& title() const { return m_title; } - const Gfx::IntRect& rect() const { return m_rect; } + String const& title() const { return m_title; } + Gfx::IntRect const& rect() const { return m_rect; } bool is_active() const { return m_active; } bool is_modal() const { return m_modal; } WindowType window_type() const { return m_window_type; } @@ -202,13 +202,13 @@ private: class WMWindowRectChangedEvent : public WMEvent { public: - WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::IntRect& rect) + WMWindowRectChangedEvent(int client_id, int window_id, Gfx::IntRect const& rect) : WMEvent(Event::Type::WM_WindowRectChanged, client_id, window_id) , m_rect(rect) { } - const Gfx::IntRect& rect() const { return m_rect; } + Gfx::IntRect const& rect() const { return m_rect; } private: Gfx::IntRect m_rect; @@ -216,13 +216,13 @@ private: class WMWindowIconBitmapChangedEvent : public WMEvent { public: - WMWindowIconBitmapChangedEvent(int client_id, int window_id, const Gfx::Bitmap* bitmap) + WMWindowIconBitmapChangedEvent(int client_id, int window_id, Gfx::Bitmap const* bitmap) : WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id) , m_bitmap(move(bitmap)) { } - const Gfx::Bitmap* bitmap() const { return m_bitmap; } + Gfx::Bitmap const* bitmap() const { return m_bitmap; } private: RefPtr<Gfx::Bitmap> m_bitmap; @@ -241,8 +241,8 @@ public: unsigned current_column() const { return m_current_column; } private: - const unsigned m_current_row; - const unsigned m_current_column; + unsigned const m_current_row; + unsigned const m_current_column; }; class WMKeymapChangedEvent : public WMEvent { @@ -268,8 +268,8 @@ public: { } - const Vector<Gfx::IntRect, 32>& rects() const { return m_rects; } - const Gfx::IntSize& window_size() const { return m_window_size; } + Vector<Gfx::IntRect, 32> const& rects() const { return m_rects; } + Gfx::IntSize const& window_size() const { return m_window_size; } private: Vector<Gfx::IntRect, 32> m_rects; @@ -278,15 +278,15 @@ private: class PaintEvent final : public Event { public: - explicit PaintEvent(const Gfx::IntRect& rect, const Gfx::IntSize& window_size = {}) + explicit PaintEvent(Gfx::IntRect const& rect, Gfx::IntSize const& window_size = {}) : Event(Event::Paint) , m_rect(rect) , m_window_size(window_size) { } - const Gfx::IntRect& rect() const { return m_rect; } - const Gfx::IntSize& window_size() const { return m_window_size; } + Gfx::IntRect const& rect() const { return m_rect; } + Gfx::IntSize const& window_size() const { return m_window_size; } private: Gfx::IntRect m_rect; @@ -295,13 +295,13 @@ private: class ResizeEvent final : public Event { public: - explicit ResizeEvent(const Gfx::IntSize& size) + explicit ResizeEvent(Gfx::IntSize const& size) : Event(Event::Resize) , m_size(size) { } - const Gfx::IntSize& size() const { return m_size; } + Gfx::IntSize const& size() const { return m_size; } private: Gfx::IntSize m_size; @@ -309,15 +309,15 @@ private: class ContextMenuEvent final : public Event { public: - explicit ContextMenuEvent(const Gfx::IntPoint& position, const Gfx::IntPoint& screen_position) + explicit ContextMenuEvent(Gfx::IntPoint const& position, Gfx::IntPoint const& screen_position) : Event(Event::ContextMenu) , m_position(position) , m_screen_position(screen_position) { } - const Gfx::IntPoint& position() const { return m_position; } - const Gfx::IntPoint& screen_position() const { return m_screen_position; } + Gfx::IntPoint const& position() const { return m_position; } + Gfx::IntPoint const& screen_position() const { return m_screen_position; } private: Gfx::IntPoint m_position; @@ -401,7 +401,7 @@ private: class MouseEvent final : public Event { public: - MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x, int wheel_delta_y, int wheel_raw_delta_x, int wheel_raw_delta_y) + MouseEvent(Type type, Gfx::IntPoint const& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x, int wheel_delta_y, int wheel_raw_delta_x, int wheel_raw_delta_y) : Event(type) , m_position(position) , m_buttons(buttons) @@ -414,7 +414,7 @@ public: { } - const Gfx::IntPoint& position() const { return m_position; } + Gfx::IntPoint const& position() const { return m_position; } int x() const { return m_position.x(); } int y() const { return m_position.y(); } MouseButton button() const { return m_button; } @@ -442,15 +442,15 @@ private: class DragEvent final : public Event { public: - DragEvent(Type type, const Gfx::IntPoint& position, Vector<String> mime_types) + DragEvent(Type type, Gfx::IntPoint const& position, Vector<String> mime_types) : Event(type) , m_position(position) , m_mime_types(move(mime_types)) { } - const Gfx::IntPoint& position() const { return m_position; } - const Vector<String>& mime_types() const { return m_mime_types; } + Gfx::IntPoint const& position() const { return m_position; } + Vector<String> const& mime_types() const { return m_mime_types; } private: Gfx::IntPoint m_position; @@ -459,13 +459,13 @@ private: class DropEvent final : public Event { public: - DropEvent(const Gfx::IntPoint&, const String& text, NonnullRefPtr<Core::MimeData> mime_data); + DropEvent(Gfx::IntPoint const&, String const& text, NonnullRefPtr<Core::MimeData> mime_data); ~DropEvent() = default; - const Gfx::IntPoint& position() const { return m_position; } - const String& text() const { return m_text; } - const Core::MimeData& mime_data() const { return m_mime_data; } + Gfx::IntPoint const& position() const { return m_position; } + String const& text() const { return m_text; } + Core::MimeData const& mime_data() const { return m_mime_data; } private: Gfx::IntPoint m_position; @@ -491,14 +491,14 @@ public: class ScreenRectsChangeEvent final : public Event { public: - explicit ScreenRectsChangeEvent(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index) + explicit ScreenRectsChangeEvent(Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index) : Event(Type::ScreenRectsChange) , m_rects(rects) , m_main_screen_index(main_screen_index) { } - const Vector<Gfx::IntRect, 4>& rects() const { return m_rects; } + Vector<Gfx::IntRect, 4> const& rects() const { return m_rects; } size_t main_screen_index() const { return m_main_screen_index; } private: diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp index 821af95491..495cae5b3f 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.cpp +++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp @@ -129,7 +129,7 @@ Icon FileIconProvider::filetype_image_icon() return s_filetype_image_icon; } -Icon FileIconProvider::icon_for_path(const String& path) +Icon FileIconProvider::icon_for_path(String const& path) { struct stat stat; if (::stat(path.characters(), &stat) < 0) @@ -137,7 +137,7 @@ Icon FileIconProvider::icon_for_path(const String& path) return icon_for_path(path, stat.st_mode); } -Icon FileIconProvider::icon_for_executable(const String& path) +Icon FileIconProvider::icon_for_executable(String const& path) { static HashMap<String, Icon> app_icon_cache; @@ -167,7 +167,7 @@ Icon FileIconProvider::icon_for_executable(const String& path) return s_executable_icon; } - auto image = ELF::Image((const u8*)mapped_file->data(), mapped_file->size()); + auto image = ELF::Image((u8 const*)mapped_file->data(), mapped_file->size()); if (!image.is_valid()) { app_icon_cache.set(path, s_executable_icon); return s_executable_icon; @@ -176,7 +176,7 @@ Icon FileIconProvider::icon_for_executable(const String& path) // If any of the required sections are missing then use the defaults Icon icon; struct IconSection { - const char* section_name; + char const* section_name; int image_size; }; @@ -186,7 +186,7 @@ Icon FileIconProvider::icon_for_executable(const String& path) }; bool had_error = false; - for (const auto& icon_section : icon_sections) { + for (auto const& icon_section : icon_sections) { auto section = image.lookup_section(icon_section.section_name); RefPtr<Gfx::Bitmap> bitmap; @@ -217,7 +217,7 @@ Icon FileIconProvider::icon_for_executable(const String& path) return icon; } -Icon FileIconProvider::icon_for_path(const String& path, mode_t mode) +Icon FileIconProvider::icon_for_path(String const& path, mode_t mode) { initialize_if_needed(); if (path == "/") diff --git a/Userland/Libraries/LibGUI/FileIconProvider.h b/Userland/Libraries/LibGUI/FileIconProvider.h index afd3c44202..89aa8a3709 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.h +++ b/Userland/Libraries/LibGUI/FileIconProvider.h @@ -14,9 +14,9 @@ namespace GUI { class FileIconProvider { public: - static Icon icon_for_path(const String&, mode_t); - static Icon icon_for_path(const String&); - static Icon icon_for_executable(const String&); + static Icon icon_for_path(String const&, mode_t); + static Icon icon_for_path(String const&); + static Icon icon_for_executable(String const&); static Icon filetype_image_icon(); static Icon directory_icon(); diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index 4d7001cab7..20333b91f0 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -32,7 +32,7 @@ namespace GUI { -Optional<String> FilePicker::get_open_filepath(Window* parent_window, const String& window_title, StringView path, bool folder, ScreenPosition screen_position) +Optional<String> FilePicker::get_open_filepath(Window* parent_window, String const& window_title, StringView path, bool folder, ScreenPosition screen_position) { auto picker = FilePicker::construct(parent_window, folder ? Mode::OpenFolder : Mode::Open, "", path, screen_position); @@ -50,7 +50,7 @@ Optional<String> FilePicker::get_open_filepath(Window* parent_window, const Stri return {}; } -Optional<String> FilePicker::get_save_filepath(Window* parent_window, const String& title, const String& extension, StringView path, ScreenPosition screen_position) +Optional<String> FilePicker::get_save_filepath(Window* parent_window, String const& title, String const& extension, StringView path, ScreenPosition screen_position) { auto picker = FilePicker::construct(parent_window, Mode::Save, String::formatted("{}.{}", title, extension), path, screen_position); @@ -115,7 +115,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St }; auto open_parent_directory_action = Action::create( - "Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png").release_value_but_fixme_should_propagate_errors(), [this](const Action&) { + "Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png").release_value_but_fixme_should_propagate_errors(), [this](Action const&) { set_path(String::formatted("{}/..", m_model->root_path())); }, this); @@ -129,7 +129,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St toolbar.add_separator(); auto mkdir_action = Action::create( - "New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [this](const Action&) { + "New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [this](Action const&) { String value; if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value)); @@ -286,7 +286,7 @@ void FilePicker::on_file_return() done(ExecOK); } -void FilePicker::set_path(const String& path) +void FilePicker::set_path(String const& path) { if (access(path.characters(), R_OK | X_OK) == -1) { GUI::MessageBox::show(this, String::formatted("Could not open '{}':\n{}", path, strerror(errno)), "Error", GUI::MessageBox::Type::Error); diff --git a/Userland/Libraries/LibGUI/FilePicker.h b/Userland/Libraries/LibGUI/FilePicker.h index 1152e95f4a..441cfeaefa 100644 --- a/Userland/Libraries/LibGUI/FilePicker.h +++ b/Userland/Libraries/LibGUI/FilePicker.h @@ -28,8 +28,8 @@ public: Save }; - static Optional<String> get_open_filepath(Window* parent_window, const String& window_title = {}, StringView path = Core::StandardPaths::home_directory(), bool folder = false, ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent); - static Optional<String> get_save_filepath(Window* parent_window, const String& title, const String& extension, StringView path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent); + static Optional<String> get_open_filepath(Window* parent_window, String const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), bool folder = false, ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent); + static Optional<String> get_save_filepath(Window* parent_window, String const& title, String const& extension, StringView path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent); virtual ~FilePicker() override; @@ -38,7 +38,7 @@ public: private: void on_file_return(); - void set_path(const String&); + void set_path(String const&); // ^GUI::ModelClient virtual void model_did_update(unsigned) override; diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h index 6fd6c9baf4..a796c93a84 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.h +++ b/Userland/Libraries/LibGUI/FileSystemModel.h @@ -110,7 +110,7 @@ public: String full_path(ModelIndex const&) const; ModelIndex index(String path, int column) const; - void update_node_on_selection(ModelIndex const&, const bool); + void update_node_on_selection(ModelIndex const&, bool const); ModelIndex m_previously_selected_index {}; Node const& node(ModelIndex const& index) const; diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index 6def60e8f4..bba820f0c9 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -18,7 +18,7 @@ namespace GUI { -FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, bool fixed_width_only) +FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, bool fixed_width_only) : Dialog(parent_window) , m_fixed_width_only(fixed_width_only) { @@ -170,7 +170,7 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, boo set_font(current_font); } -void FontPicker::set_font(const Gfx::Font* font) +void FontPicker::set_font(Gfx::Font const* font) { if (m_font == font) return; diff --git a/Userland/Libraries/LibGUI/FontPicker.h b/Userland/Libraries/LibGUI/FontPicker.h index a40a28f168..376bcfa881 100644 --- a/Userland/Libraries/LibGUI/FontPicker.h +++ b/Userland/Libraries/LibGUI/FontPicker.h @@ -20,14 +20,14 @@ public: virtual ~FontPicker() override = default; RefPtr<Gfx::Font> font() const { return m_font; } - void set_font(const Gfx::Font*); + void set_font(Gfx::Font const*); private: - FontPicker(Window* parent_window = nullptr, const Gfx::Font* current_font = nullptr, bool fixed_width_only = false); + FontPicker(Window* parent_window = nullptr, Gfx::Font const* current_font = nullptr, bool fixed_width_only = false); void update_font(); - const bool m_fixed_width_only; + bool const m_fixed_width_only; RefPtr<Gfx::Font> m_font; diff --git a/Userland/Libraries/LibGUI/Frame.h b/Userland/Libraries/LibGUI/Frame.h index 5bd7ead299..91c1f42241 100644 --- a/Userland/Libraries/LibGUI/Frame.h +++ b/Userland/Libraries/LibGUI/Frame.h @@ -28,7 +28,7 @@ public: Gfx::FrameShape frame_shape() const { return m_shape; } void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } - Gfx::IntRect frame_inner_rect_for_size(const Gfx::IntSize& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; } + Gfx::IntRect frame_inner_rect_for_size(Gfx::IntSize const& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; } Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); } virtual Gfx::IntRect children_clip_rect() const override; diff --git a/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.cpp b/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.cpp index 41c9de0446..b6a262f8e5 100644 --- a/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.cpp @@ -11,7 +11,7 @@ namespace GUI::GML { -static Syntax::TextStyle style_for_token_type(const Gfx::Palette& palette, Token::Type type) +static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, Token::Type type) { switch (type) { case Token::Type::LeftCurly: @@ -38,7 +38,7 @@ bool SyntaxHighlighter::is_identifier(u64 token) const return ini_token == Token::Type::Identifier; } -void SyntaxHighlighter::rehighlight(const Palette& palette) +void SyntaxHighlighter::rehighlight(Palette const& palette) { auto text = m_client->get_text(); Lexer lexer(text); diff --git a/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.h b/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.h index 0c2961e90a..7a660a73c4 100644 --- a/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.h +++ b/Userland/Libraries/LibGUI/GML/SyntaxHighlighter.h @@ -19,7 +19,7 @@ public: virtual bool is_identifier(u64) const override; virtual Syntax::Language language() const override { return Syntax::Language::GML; } - virtual void rehighlight(const Palette&) override; + virtual void rehighlight(Palette const&) override; protected: virtual Vector<MatchingTokenPair> matching_token_pairs_impl() const override; diff --git a/Userland/Libraries/LibGUI/GitCommitSyntaxHighlighter.cpp b/Userland/Libraries/LibGUI/GitCommitSyntaxHighlighter.cpp index abc597861c..e531479730 100644 --- a/Userland/Libraries/LibGUI/GitCommitSyntaxHighlighter.cpp +++ b/Userland/Libraries/LibGUI/GitCommitSyntaxHighlighter.cpp @@ -10,7 +10,7 @@ #include <LibGfx/Palette.h> namespace GUI { -static Syntax::TextStyle style_for_token_type(const Gfx::Palette& palette, GitCommitToken::Type type) +static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, GitCommitToken::Type type) { switch (type) { case GitCommitToken::Type::Comment: diff --git a/Userland/Libraries/LibGUI/HeaderView.cpp b/Userland/Libraries/LibGUI/HeaderView.cpp index 0eacc7e284..590035b2f9 100644 --- a/Userland/Libraries/LibGUI/HeaderView.cpp +++ b/Userland/Libraries/LibGUI/HeaderView.cpp @@ -433,7 +433,7 @@ Model* HeaderView::model() return m_table_view.model(); } -const Model* HeaderView::model() const +Model const* HeaderView::model() const { return m_table_view.model(); } diff --git a/Userland/Libraries/LibGUI/HeaderView.h b/Userland/Libraries/LibGUI/HeaderView.h index 89c98ede6d..333761b743 100644 --- a/Userland/Libraries/LibGUI/HeaderView.h +++ b/Userland/Libraries/LibGUI/HeaderView.h @@ -21,7 +21,7 @@ public: Gfx::Orientation orientation() const { return m_orientation; } Model* model(); - const Model* model() const; + Model const* model() const; void set_section_size(int section, int size); int section_size(int section) const; diff --git a/Userland/Libraries/LibGUI/Icon.cpp b/Userland/Libraries/LibGUI/Icon.cpp index aa592bc624..1a3af61faf 100644 --- a/Userland/Libraries/LibGUI/Icon.cpp +++ b/Userland/Libraries/LibGUI/Icon.cpp @@ -16,12 +16,12 @@ Icon::Icon() { } -Icon::Icon(const IconImpl& impl) +Icon::Icon(IconImpl const& impl) : m_impl(const_cast<IconImpl&>(impl)) { } -Icon::Icon(const Icon& other) +Icon::Icon(Icon const& other) : m_impl(other.m_impl) { } @@ -46,14 +46,14 @@ Icon::Icon(RefPtr<Gfx::Bitmap>&& bitmap1, RefPtr<Gfx::Bitmap>&& bitmap2) } } -const Gfx::Bitmap* IconImpl::bitmap_for_size(int size) const +Gfx::Bitmap const* IconImpl::bitmap_for_size(int size) const { auto it = m_bitmaps.find(size); if (it != m_bitmaps.end()) return it->value.ptr(); int best_diff_so_far = INT32_MAX; - const Gfx::Bitmap* best_fit = nullptr; + Gfx::Bitmap const* best_fit = nullptr; for (auto& it : m_bitmaps) { int abs_diff = abs(it.key - size); if (abs_diff < best_diff_so_far) { diff --git a/Userland/Libraries/LibGUI/Icon.h b/Userland/Libraries/LibGUI/Icon.h index a8592082d5..b11cbcf42b 100644 --- a/Userland/Libraries/LibGUI/Icon.h +++ b/Userland/Libraries/LibGUI/Icon.h @@ -20,7 +20,7 @@ public: static NonnullRefPtr<IconImpl> create() { return adopt_ref(*new IconImpl); } ~IconImpl() = default; - const Gfx::Bitmap* bitmap_for_size(int) const; + Gfx::Bitmap const* bitmap_for_size(int) const; void set_bitmap_for_size(int, RefPtr<Gfx::Bitmap>&&); Vector<int> sizes() const @@ -41,24 +41,24 @@ public: Icon(); explicit Icon(RefPtr<Gfx::Bitmap>&&); explicit Icon(RefPtr<Gfx::Bitmap>&&, RefPtr<Gfx::Bitmap>&&); - explicit Icon(const IconImpl&); - Icon(const Icon&); + explicit Icon(IconImpl const&); + Icon(Icon const&); ~Icon() = default; static Icon default_icon(StringView); static ErrorOr<Icon> try_create_default_icon(StringView); - Icon& operator=(const Icon& other) + Icon& operator=(Icon const& other) { if (this != &other) m_impl = other.m_impl; return *this; } - const Gfx::Bitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); } + Gfx::Bitmap const* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); } void set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } - const IconImpl& impl() const { return *m_impl; } + IconImpl const& impl() const { return *m_impl; } Vector<int> sizes() const { return m_impl->sizes(); } diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 1d6717d210..991ef68017 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -40,7 +40,7 @@ void IconView::select_all() } } -void IconView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) +void IconView::scroll_into_view(ModelIndex const& index, bool scroll_horizontally, bool scroll_vertically) { if (!index.is_valid()) return; @@ -106,7 +106,7 @@ auto IconView::get_item_data(int item_index) const -> ItemData& return item_data; } -auto IconView::item_data_from_content_position(const Gfx::IntPoint& content_position) const -> ItemData* +auto IconView::item_data_from_content_position(Gfx::IntPoint const& content_position) const -> ItemData* { if (!m_visual_row_count || !m_visual_column_count) return nullptr; @@ -195,7 +195,7 @@ Gfx::IntRect IconView::item_rect(int item_index) const }; } -ModelIndex IconView::index_at_event_position(const Gfx::IntPoint& position) const +ModelIndex IconView::index_at_event_position(Gfx::IntPoint const& position) const { VERIFY(model()); auto adjusted_position = to_content_position(position); @@ -244,7 +244,7 @@ void IconView::mouseup_event(MouseEvent& event) AbstractView::mouseup_event(event); } -bool IconView::update_rubber_banding(const Gfx::IntPoint& input_position) +bool IconView::update_rubber_banding(Gfx::IntPoint const& input_position) { auto adjusted_position = to_content_position(input_position.constrained(widget_inner_rect())); if (m_rubber_band_current != adjusted_position) { @@ -378,7 +378,7 @@ Gfx::IntRect IconView::editing_rect(ModelIndex const& index) const return editing_rect; } -void IconView::editing_widget_did_change(const ModelIndex& index) +void IconView::editing_widget_did_change(ModelIndex const& index) { if (m_editing_delegate->value().is_string()) { auto text_width = font_for_index(index)->width(m_editing_delegate->value().as_string()); @@ -389,7 +389,7 @@ void IconView::editing_widget_did_change(const ModelIndex& index) } Gfx::IntRect -IconView::paint_invalidation_rect(const ModelIndex& index) const +IconView::paint_invalidation_rect(ModelIndex const& index) const { if (!index.is_valid()) return {}; @@ -397,7 +397,7 @@ IconView::paint_invalidation_rect(const ModelIndex& index) const return item_data.rect(true); } -void IconView::did_change_hovered_index(const ModelIndex& old_index, const ModelIndex& new_index) +void IconView::did_change_hovered_index(ModelIndex const& old_index, ModelIndex const& new_index) { AbstractView::did_change_hovered_index(old_index, new_index); if (old_index.is_valid()) @@ -406,7 +406,7 @@ void IconView::did_change_hovered_index(const ModelIndex& old_index, const Model get_item_rects(new_index.row(), get_item_data(new_index.row()), font_for_index(new_index)); } -void IconView::did_change_cursor_index(const ModelIndex& old_index, const ModelIndex& new_index) +void IconView::did_change_cursor_index(ModelIndex const& old_index, ModelIndex const& new_index) { AbstractView::did_change_cursor_index(old_index, new_index); if (old_index.is_valid()) @@ -415,7 +415,7 @@ void IconView::did_change_cursor_index(const ModelIndex& old_index, const ModelI get_item_rects(new_index.row(), get_item_data(new_index.row()), font_for_index(new_index)); } -void IconView::get_item_rects(int item_index, ItemData& item_data, const Gfx::Font& font) const +void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font const& font) const { auto item_rect = this->item_rect(item_index); item_data.icon_rect = Gfx::IntRect(0, 0, 32, 32).centered_within(item_rect); @@ -589,7 +589,7 @@ void IconView::did_update_selection() // Selection was modified externally, we need to synchronize our cache do_clear_selection(); - selection().for_each_index([&](const ModelIndex& index) { + selection().for_each_index([&](ModelIndex const& index) { if (index.is_valid()) { auto item_index = model_index_to_item_index(index); if ((size_t)item_index < m_item_data_cache.size()) @@ -639,7 +639,7 @@ void IconView::add_selection(ItemData& item_data) AbstractView::add_selection(item_data.index); } -void IconView::add_selection(const ModelIndex& new_index) +void IconView::add_selection(ModelIndex const& new_index) { TemporaryChange change(m_changing_selection, true); auto item_index = model_index_to_item_index(new_index); @@ -654,7 +654,7 @@ void IconView::toggle_selection(ItemData& item_data) remove_item_selection(item_data); } -void IconView::toggle_selection(const ModelIndex& new_index) +void IconView::toggle_selection(ModelIndex const& new_index) { TemporaryChange change(m_changing_selection, true); auto item_index = model_index_to_item_index(new_index); @@ -684,7 +684,7 @@ void IconView::remove_item_selection(ItemData& item_data) AbstractView::remove_selection(item_data.index); } -void IconView::set_selection(const ModelIndex& new_index) +void IconView::set_selection(ModelIndex const& new_index) { TemporaryChange change(m_changing_selection, true); do_clear_selection(); @@ -775,7 +775,7 @@ void IconView::set_flow_direction(FlowDirection flow_direction) } template<typename Function> -inline IterationDecision IconView::for_each_item_intersecting_rect(const Gfx::IntRect& rect, Function f) const +inline IterationDecision IconView::for_each_item_intersecting_rect(Gfx::IntRect const& rect, Function f) const { VERIFY(model()); if (rect.is_empty()) @@ -814,7 +814,7 @@ inline IterationDecision IconView::for_each_item_intersecting_rect(const Gfx::In } template<typename Function> -inline IterationDecision IconView::for_each_item_intersecting_rects(const Vector<Gfx::IntRect>& rects, Function f) const +inline IterationDecision IconView::for_each_item_intersecting_rects(Vector<Gfx::IntRect> const& rects, Function f) const { for (auto& rect : rects) { auto decision = for_each_item_intersecting_rect(rect, f); diff --git a/Userland/Libraries/LibGUI/IconView.h b/Userland/Libraries/LibGUI/IconView.h index 787d21cb1a..e94a994f62 100644 --- a/Userland/Libraries/LibGUI/IconView.h +++ b/Userland/Libraries/LibGUI/IconView.h @@ -29,7 +29,7 @@ public: int horizontal_padding() const { return m_horizontal_padding; } - virtual void scroll_into_view(const ModelIndex&, bool scroll_horizontally = true, bool scroll_vertically = true) override; + virtual void scroll_into_view(ModelIndex const&, bool scroll_horizontally = true, bool scroll_vertically = true) override; Gfx::IntSize effective_item_size() const { return m_effective_item_size; } @@ -39,8 +39,8 @@ public: int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } - virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; - virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + virtual ModelIndex index_at_event_position(Gfx::IntPoint const&) const override; + virtual Gfx::IntRect content_rect(ModelIndex const&) const override; virtual Gfx::IntRect editing_rect(ModelIndex const&) const override; virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const&) const override; @@ -56,9 +56,9 @@ private: virtual void mousedown_event(MouseEvent&) override; virtual void mousemove_event(MouseEvent&) override; virtual void mouseup_event(MouseEvent&) override; - virtual void did_change_hovered_index(const ModelIndex& old_index, const ModelIndex& new_index) override; - virtual void did_change_cursor_index(const ModelIndex& old_index, const ModelIndex& new_index) override; - virtual void editing_widget_did_change(const ModelIndex& index) override; + virtual void did_change_hovered_index(ModelIndex const& old_index, ModelIndex const& new_index) override; + virtual void did_change_cursor_index(ModelIndex const& old_index, ModelIndex const& new_index) override; + virtual void editing_widget_did_change(ModelIndex const& index) override; virtual void move_cursor(CursorMovement, SelectionUpdate) override; @@ -87,13 +87,13 @@ private: Gfx::IntRect hot_icon_rect() const { return icon_rect.inflated(10, 10); } Gfx::IntRect hot_text_rect() const { return text_rect.inflated(2, 2); } - bool is_intersecting(const Gfx::IntRect& rect) const + bool is_intersecting(Gfx::IntRect const& rect) const { VERIFY(valid); return hot_icon_rect().intersects(rect) || hot_text_rect().intersects(rect); } - bool is_containing(const Gfx::IntPoint& point) const + bool is_containing(Gfx::IntPoint const& point) const { VERIFY(valid); return hot_icon_rect().contains(point) || hot_text_rect().contains(point); @@ -108,12 +108,12 @@ private: }; template<typename Function> - IterationDecision for_each_item_intersecting_rect(const Gfx::IntRect&, Function) const; + IterationDecision for_each_item_intersecting_rect(Gfx::IntRect const&, Function) const; template<typename Function> - IterationDecision for_each_item_intersecting_rects(const Vector<Gfx::IntRect>&, Function) const; + IterationDecision for_each_item_intersecting_rects(Vector<Gfx::IntRect> const&, Function) const; - void column_row_from_content_position(const Gfx::IntPoint& content_position, int& row, int& column) const + void column_row_from_content_position(Gfx::IntPoint const& content_position, int& row, int& column) const { row = max(0, min(m_visual_row_count - 1, content_position.y() / effective_item_size().height())); column = max(0, min(m_visual_column_count - 1, content_position.x() / effective_item_size().width())); @@ -123,12 +123,12 @@ private: Gfx::IntRect item_rect(int item_index) const; void update_content_size(); void update_item_rects(int item_index, ItemData& item_data) const; - void get_item_rects(int item_index, ItemData& item_data, const Gfx::Font&) const; - bool update_rubber_banding(const Gfx::IntPoint&); + void get_item_rects(int item_index, ItemData& item_data, Gfx::Font const&) const; + bool update_rubber_banding(Gfx::IntPoint const&); int items_per_page() const; void rebuild_item_cache() const; - int model_index_to_item_index(const ModelIndex& model_index) const + int model_index_to_item_index(ModelIndex const& model_index) const { VERIFY(model_index.row() < item_count()); return model_index.row(); @@ -136,12 +136,12 @@ private: virtual void did_update_selection() override; virtual void clear_selection() override; - virtual void add_selection(const ModelIndex& new_index) override; - virtual void set_selection(const ModelIndex& new_index) override; - virtual void toggle_selection(const ModelIndex& new_index) override; + virtual void add_selection(ModelIndex const& new_index) override; + virtual void set_selection(ModelIndex const& new_index) override; + virtual void toggle_selection(ModelIndex const& new_index) override; ItemData& get_item_data(int) const; - ItemData* item_data_from_content_position(const Gfx::IntPoint&) const; + ItemData* item_data_from_content_position(Gfx::IntPoint const&) const; void do_clear_selection(); bool do_add_selection(ItemData&); void add_selection(ItemData&); diff --git a/Userland/Libraries/LibGUI/ImageWidget.cpp b/Userland/Libraries/LibGUI/ImageWidget.cpp index c59620db91..27667a21d1 100644 --- a/Userland/Libraries/LibGUI/ImageWidget.cpp +++ b/Userland/Libraries/LibGUI/ImageWidget.cpp @@ -28,7 +28,7 @@ ImageWidget::ImageWidget(StringView) REGISTER_BOOL_PROPERTY("should_stretch", should_stretch, set_should_stretch); } -void ImageWidget::set_bitmap(const Gfx::Bitmap* bitmap) +void ImageWidget::set_bitmap(Gfx::Bitmap const* bitmap) { if (m_bitmap == bitmap) return; diff --git a/Userland/Libraries/LibGUI/ImageWidget.h b/Userland/Libraries/LibGUI/ImageWidget.h index e0fb19838d..80669ee51b 100644 --- a/Userland/Libraries/LibGUI/ImageWidget.h +++ b/Userland/Libraries/LibGUI/ImageWidget.h @@ -18,7 +18,7 @@ class ImageWidget : public Frame { public: virtual ~ImageWidget() override = default; - void set_bitmap(const Gfx::Bitmap*); + void set_bitmap(Gfx::Bitmap const*); Gfx::Bitmap* bitmap() { return m_bitmap.ptr(); } Gfx::Bitmap const* bitmap() const { return m_bitmap.ptr(); } diff --git a/Userland/Libraries/LibGUI/JsonArrayModel.cpp b/Userland/Libraries/LibGUI/JsonArrayModel.cpp index 51b8ff9632..40435417b7 100644 --- a/Userland/Libraries/LibGUI/JsonArrayModel.cpp +++ b/Userland/Libraries/LibGUI/JsonArrayModel.cpp @@ -59,7 +59,7 @@ bool JsonArrayModel::store() return true; } -bool JsonArrayModel::add(const Vector<JsonValue>&& values) +bool JsonArrayModel::add(Vector<JsonValue> const&& values) { VERIFY(values.size() == m_fields.size()); JsonObject obj; @@ -108,7 +108,7 @@ bool JsonArrayModel::remove(int row) return true; } -Variant JsonArrayModel::data(const ModelIndex& index, ModelRole role) const +Variant JsonArrayModel::data(ModelIndex const& index, ModelRole role) const { auto& field_spec = m_fields[index.column()]; auto& object = m_array.at(index.row()).as_object(); @@ -142,7 +142,7 @@ Variant JsonArrayModel::data(const ModelIndex& index, ModelRole role) const return {}; } -void JsonArrayModel::set_json_path(const String& json_path) +void JsonArrayModel::set_json_path(String const& json_path) { if (m_json_path == json_path) return; diff --git a/Userland/Libraries/LibGUI/JsonArrayModel.h b/Userland/Libraries/LibGUI/JsonArrayModel.h index fcdb4ecfd3..62107a02bd 100644 --- a/Userland/Libraries/LibGUI/JsonArrayModel.h +++ b/Userland/Libraries/LibGUI/JsonArrayModel.h @@ -16,7 +16,7 @@ namespace GUI { class JsonArrayModel final : public Model { public: struct FieldSpec { - FieldSpec(const String& a_column_name, Gfx::TextAlignment a_text_alignment, Function<Variant(const JsonObject&)>&& a_massage_for_display, Function<Variant(const JsonObject&)>&& a_massage_for_sort = {}, Function<Variant(const JsonObject&)>&& a_massage_for_custom = {}) + FieldSpec(String const& a_column_name, Gfx::TextAlignment a_text_alignment, Function<Variant(JsonObject const&)>&& a_massage_for_display, Function<Variant(JsonObject const&)>&& a_massage_for_sort = {}, Function<Variant(JsonObject const&)>&& a_massage_for_custom = {}) : column_name(a_column_name) , text_alignment(a_text_alignment) , massage_for_display(move(a_massage_for_display)) @@ -25,7 +25,7 @@ public: { } - FieldSpec(const String& a_json_field_name, const String& a_column_name, Gfx::TextAlignment a_text_alignment) + FieldSpec(String const& a_json_field_name, String const& a_column_name, Gfx::TextAlignment a_text_alignment) : json_field_name(a_json_field_name) , column_name(a_column_name) , text_alignment(a_text_alignment) @@ -35,35 +35,35 @@ public: String json_field_name; String column_name; Gfx::TextAlignment text_alignment; - Function<Variant(const JsonObject&)> massage_for_display; - Function<Variant(const JsonObject&)> massage_for_sort; - Function<Variant(const JsonObject&)> massage_for_custom; + Function<Variant(JsonObject const&)> massage_for_display; + Function<Variant(JsonObject const&)> massage_for_sort; + Function<Variant(JsonObject const&)> massage_for_custom; }; - static NonnullRefPtr<JsonArrayModel> create(const String& json_path, Vector<FieldSpec>&& fields) + static NonnullRefPtr<JsonArrayModel> create(String const& json_path, Vector<FieldSpec>&& fields) { return adopt_ref(*new JsonArrayModel(json_path, move(fields))); } virtual ~JsonArrayModel() override = default; - virtual int row_count(const ModelIndex& = ModelIndex()) const override { return m_array.size(); } - virtual int column_count(const ModelIndex& = ModelIndex()) const override { return m_fields.size(); } + virtual int row_count(ModelIndex const& = ModelIndex()) const override { return m_array.size(); } + virtual int column_count(ModelIndex const& = ModelIndex()) const override { return m_fields.size(); } virtual String column_name(int column) const override { return m_fields[column].column_name; } - virtual Variant data(const ModelIndex&, ModelRole = ModelRole::Display) const override; + virtual Variant data(ModelIndex const&, ModelRole = ModelRole::Display) const override; virtual void invalidate() override; virtual void update(); - const String& json_path() const { return m_json_path; } - void set_json_path(const String& json_path); + String const& json_path() const { return m_json_path; } + void set_json_path(String const& json_path); - bool add(const Vector<JsonValue>&& fields); + bool add(Vector<JsonValue> const&& fields); bool set(int row, Vector<JsonValue>&& fields); bool remove(int row); bool store(); private: - JsonArrayModel(const String& json_path, Vector<FieldSpec>&& fields) + JsonArrayModel(String const& json_path, Vector<FieldSpec>&& fields) : m_json_path(json_path) , m_fields(move(fields)) { diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp index 8745611ed2..d41237803a 100644 --- a/Userland/Libraries/LibGUI/Label.cpp +++ b/Userland/Libraries/LibGUI/Label.cpp @@ -43,7 +43,7 @@ void Label::set_autosize(bool autosize) size_to_fit(); } -void Label::set_icon(const Gfx::Bitmap* icon) +void Label::set_icon(Gfx::Bitmap const* icon) { if (m_icon == icon) return; diff --git a/Userland/Libraries/LibGUI/Label.h b/Userland/Libraries/LibGUI/Label.h index 97e4493ddc..dac18da10b 100644 --- a/Userland/Libraries/LibGUI/Label.h +++ b/Userland/Libraries/LibGUI/Label.h @@ -22,9 +22,9 @@ public: String text() const { return m_text; } void set_text(String); - void set_icon(const Gfx::Bitmap*); + void set_icon(Gfx::Bitmap const*); void set_icon_from_path(String const&); - const Gfx::Bitmap* icon() const { return m_icon.ptr(); } + Gfx::Bitmap const* icon() const { return m_icon.ptr(); } Gfx::Bitmap* icon() { return m_icon.ptr(); } Gfx::TextAlignment text_alignment() const { return m_text_alignment; } diff --git a/Userland/Libraries/LibGUI/Layout.cpp b/Userland/Libraries/LibGUI/Layout.cpp index 3c54efda78..807b26446a 100644 --- a/Userland/Libraries/LibGUI/Layout.cpp +++ b/Userland/Libraries/LibGUI/Layout.cpp @@ -140,7 +140,7 @@ void Layout::set_spacing(int spacing) m_owner->notify_layout_changed({}); } -void Layout::set_margins(const Margins& margins) +void Layout::set_margins(Margins const& margins) { if (m_margins == margins) return; diff --git a/Userland/Libraries/LibGUI/Layout.h b/Userland/Libraries/LibGUI/Layout.h index cd2fa5f23b..ef9a01f0cf 100644 --- a/Userland/Libraries/LibGUI/Layout.h +++ b/Userland/Libraries/LibGUI/Layout.h @@ -53,8 +53,8 @@ public: void notify_adopted(Badge<Widget>, Widget&); void notify_disowned(Badge<Widget>, Widget&); - const Margins& margins() const { return m_margins; } - void set_margins(const Margins&); + Margins const& margins() const { return m_margins; } + void set_margins(Margins const&); int spacing() const { return m_spacing; } void set_spacing(int); diff --git a/Userland/Libraries/LibGUI/ListView.cpp b/Userland/Libraries/LibGUI/ListView.cpp index fecd4b8d80..ab66cc9a1d 100644 --- a/Userland/Libraries/LibGUI/ListView.cpp +++ b/Userland/Libraries/LibGUI/ListView.cpp @@ -69,12 +69,12 @@ Gfx::IntRect ListView::content_rect(int row) const return { 0, row * item_height(), content_width(), item_height() }; } -Gfx::IntRect ListView::content_rect(const ModelIndex& index) const +Gfx::IntRect ListView::content_rect(ModelIndex const& index) const { return content_rect(index.row()); } -ModelIndex ListView::index_at_event_position(const Gfx::IntPoint& point) const +ModelIndex ListView::index_at_event_position(Gfx::IntPoint const& point) const { VERIFY(model()); @@ -87,7 +87,7 @@ ModelIndex ListView::index_at_event_position(const Gfx::IntPoint& point) const return {}; } -Gfx::IntPoint ListView::adjusted_position(const Gfx::IntPoint& position) const +Gfx::IntPoint ListView::adjusted_position(Gfx::IntPoint const& position) const { return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); } @@ -255,7 +255,7 @@ void ListView::move_cursor(CursorMovement movement, SelectionUpdate selection_up set_cursor(new_index, selection_update); } -void ListView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) +void ListView::scroll_into_view(ModelIndex const& index, bool scroll_horizontally, bool scroll_vertically) { if (!model()) return; diff --git a/Userland/Libraries/LibGUI/ListView.h b/Userland/Libraries/LibGUI/ListView.h index 3edbfece64..0f471e927f 100644 --- a/Userland/Libraries/LibGUI/ListView.h +++ b/Userland/Libraries/LibGUI/ListView.h @@ -26,12 +26,12 @@ public: int horizontal_padding() const { return m_horizontal_padding; } int vertical_padding() const { return m_vertical_padding; } - virtual void scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) override; + virtual void scroll_into_view(ModelIndex const& index, bool scroll_horizontally, bool scroll_vertically) override; - Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const; + Gfx::IntPoint adjusted_position(Gfx::IntPoint const&) const; - virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; - virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + virtual ModelIndex index_at_event_position(Gfx::IntPoint const&) const override; + virtual Gfx::IntRect content_rect(ModelIndex const&) const override; int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } diff --git a/Userland/Libraries/LibGUI/Margins.h b/Userland/Libraries/LibGUI/Margins.h index 71232a0bec..f1a3405cad 100644 --- a/Userland/Libraries/LibGUI/Margins.h +++ b/Userland/Libraries/LibGUI/Margins.h @@ -65,7 +65,7 @@ public: void set_bottom(int value) { m_bottom = value; } void set_left(int value) { m_left = value; } - bool operator==(const Margins& other) const + bool operator==(Margins const& other) const { return m_left == other.m_left && m_top == other.m_top diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index 340c0b211e..7363688f57 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -42,7 +42,7 @@ Menu::~Menu() unrealize_menu(); } -void Menu::set_icon(const Gfx::Bitmap* icon) +void Menu::set_icon(Gfx::Bitmap const* icon) { m_icon = icon; } @@ -110,13 +110,13 @@ void Menu::add_separator() MUST(try_add_separator()); } -void Menu::realize_if_needed(const RefPtr<Action>& default_action) +void Menu::realize_if_needed(RefPtr<Action> const& default_action) { if (m_menu_id == -1 || m_current_default_action.ptr() != default_action) realize_menu(default_action); } -void Menu::popup(const Gfx::IntPoint& screen_position, const RefPtr<Action>& default_action) +void Menu::popup(Gfx::IntPoint const& screen_position, RefPtr<Action> const& default_action) { realize_if_needed(default_action); ConnectionToWindowServer::the().async_popup_menu(m_menu_id, screen_position); diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h index 2d60d51c38..79c7000e35 100644 --- a/Userland/Libraries/LibGUI/Menu.h +++ b/Userland/Libraries/LibGUI/Menu.h @@ -26,9 +26,9 @@ public: static Menu* from_menu_id(int); int menu_id() const { return m_menu_id; } - const String& name() const { return m_name; } - const Gfx::Bitmap* icon() const { return m_icon.ptr(); } - void set_icon(const Gfx::Bitmap*); + String const& name() const { return m_name; } + Gfx::Bitmap const* icon() const { return m_icon.ptr(); } + void set_icon(Gfx::Bitmap const*); Action* action_at(size_t); @@ -41,7 +41,7 @@ public: Menu& add_submenu(String name); void remove_all_actions(); - void popup(const Gfx::IntPoint& screen_position, const RefPtr<Action>& default_action = nullptr); + void popup(Gfx::IntPoint const& screen_position, RefPtr<Action> const& default_action = nullptr); void dismiss(); void visibility_did_change(Badge<ConnectionToWindowServer>, bool visible); @@ -61,7 +61,7 @@ private: int realize_menu(RefPtr<Action> default_action = nullptr); void unrealize_menu(); - void realize_if_needed(const RefPtr<Action>& default_action); + void realize_if_needed(RefPtr<Action> const& default_action); void realize_menu_item(MenuItem&, int item_id); diff --git a/Userland/Libraries/LibGUI/MenuItem.h b/Userland/Libraries/LibGUI/MenuItem.h index 7e5fd1c8ff..c98cb94abb 100644 --- a/Userland/Libraries/LibGUI/MenuItem.h +++ b/Userland/Libraries/LibGUI/MenuItem.h @@ -29,12 +29,12 @@ public: Type type() const { return m_type; } - const Action* action() const { return m_action.ptr(); } + Action const* action() const { return m_action.ptr(); } Action* action() { return m_action.ptr(); } unsigned identifier() const { return m_identifier; } Menu* submenu() { return m_submenu.ptr(); } - const Menu* submenu() const { return m_submenu.ptr(); } + Menu const* submenu() const { return m_submenu.ptr(); } bool is_checkable() const { return m_checkable; } void set_checkable(bool checkable) { m_checkable = checkable; } diff --git a/Userland/Libraries/LibGUI/ModelEditingDelegate.h b/Userland/Libraries/LibGUI/ModelEditingDelegate.h index e02a61efaa..56a1ee5307 100644 --- a/Userland/Libraries/LibGUI/ModelEditingDelegate.h +++ b/Userland/Libraries/LibGUI/ModelEditingDelegate.h @@ -22,7 +22,7 @@ public: virtual ~ModelEditingDelegate() = default; - void bind(Model& model, const ModelIndex& index) + void bind(Model& model, ModelIndex const& index) { if (m_model.ptr() == &model && m_index == index) return; @@ -32,7 +32,7 @@ public: } Widget* widget() { return m_widget; } - const Widget* widget() const { return m_widget; } + Widget const* widget() const { return m_widget; } Function<void()> on_commit; Function<void()> on_rollback; @@ -63,7 +63,7 @@ protected: on_change(); } - const ModelIndex& index() const { return m_index; } + ModelIndex const& index() const { return m_index; } private: RefPtr<Model> m_model; @@ -92,7 +92,7 @@ public: }; return textbox; } - virtual Variant value() const override { return static_cast<const TextBox*>(widget())->text(); } + virtual Variant value() const override { return static_cast<TextBox const*>(widget())->text(); } virtual void set_value(Variant const& value, SelectionBehavior selection_behavior) override { auto& textbox = static_cast<TextBox&>(*widget()); diff --git a/Userland/Libraries/LibGUI/ModelIndex.cpp b/Userland/Libraries/LibGUI/ModelIndex.cpp index e095764d4d..a9d3f82910 100644 --- a/Userland/Libraries/LibGUI/ModelIndex.cpp +++ b/Userland/Libraries/LibGUI/ModelIndex.cpp @@ -19,7 +19,7 @@ Variant ModelIndex::data(ModelRole role) const return model()->data(*this, role); } -bool ModelIndex::is_parent_of(const ModelIndex& child) const +bool ModelIndex::is_parent_of(ModelIndex const& child) const { auto current_index = child.parent(); while (current_index.is_valid()) { diff --git a/Userland/Libraries/LibGUI/ModelIndex.h b/Userland/Libraries/LibGUI/ModelIndex.h index 07743383a5..c143f49ac1 100644 --- a/Userland/Libraries/LibGUI/ModelIndex.h +++ b/Userland/Libraries/LibGUI/ModelIndex.h @@ -26,19 +26,19 @@ public: void* internal_data() const { return m_internal_data; } ModelIndex parent() const; - bool is_parent_of(const ModelIndex&) const; + bool is_parent_of(ModelIndex const&) const; - bool operator==(const ModelIndex& other) const + bool operator==(ModelIndex const& other) const { return m_model == other.m_model && m_row == other.m_row && m_column == other.m_column && m_internal_data == other.m_internal_data; } - bool operator!=(const ModelIndex& other) const + bool operator!=(ModelIndex const& other) const { return !(*this == other); } - const Model* model() const { return m_model; } + Model const* model() const { return m_model; } Variant data(ModelRole = ModelRole::Display) const; @@ -46,7 +46,7 @@ public: ModelIndex sibling_at_column(int column) const; private: - ModelIndex(const Model& model, int row, int column, void* internal_data) + ModelIndex(Model const& model, int row, int column, void* internal_data) : m_model(&model) , m_row(row) , m_column(column) @@ -54,7 +54,7 @@ private: { } - const Model* m_model { nullptr }; + Model const* m_model { nullptr }; int m_row { -1 }; int m_column { -1 }; void* m_internal_data { nullptr }; diff --git a/Userland/Libraries/LibGUI/ModelSelection.cpp b/Userland/Libraries/LibGUI/ModelSelection.cpp index 825384c280..8e11c3f423 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.cpp +++ b/Userland/Libraries/LibGUI/ModelSelection.cpp @@ -16,7 +16,7 @@ void ModelSelection::remove_all_matching(Function<bool(ModelIndex const&)> filte notify_selection_changed(); } -void ModelSelection::set(const ModelIndex& index) +void ModelSelection::set(ModelIndex const& index) { VERIFY(index.is_valid()); if (m_indices.size() == 1 && m_indices.contains(index)) @@ -26,14 +26,14 @@ void ModelSelection::set(const ModelIndex& index) notify_selection_changed(); } -void ModelSelection::add(const ModelIndex& index) +void ModelSelection::add(ModelIndex const& index) { VERIFY(index.is_valid()); if (m_indices.set(index) == AK::HashSetResult::InsertedNewEntry) notify_selection_changed(); } -void ModelSelection::add_all(const Vector<ModelIndex>& indices) +void ModelSelection::add_all(Vector<ModelIndex> const& indices) { { TemporaryChange notify_change { m_disable_notify, true }; @@ -45,7 +45,7 @@ void ModelSelection::add_all(const Vector<ModelIndex>& indices) notify_selection_changed(); } -void ModelSelection::toggle(const ModelIndex& index) +void ModelSelection::toggle(ModelIndex const& index) { VERIFY(index.is_valid()); if (m_indices.contains(index)) @@ -55,7 +55,7 @@ void ModelSelection::toggle(const ModelIndex& index) notify_selection_changed(); } -bool ModelSelection::remove(const ModelIndex& index) +bool ModelSelection::remove(ModelIndex const& index) { VERIFY(index.is_valid()); if (!m_indices.contains(index)) diff --git a/Userland/Libraries/LibGUI/ModelSelection.h b/Userland/Libraries/LibGUI/ModelSelection.h index 85305246be..b89d632012 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.h +++ b/Userland/Libraries/LibGUI/ModelSelection.h @@ -27,7 +27,7 @@ public: int size() const { return m_indices.size(); } bool is_empty() const { return m_indices.is_empty(); } - bool contains(const ModelIndex& index) const { return m_indices.contains(index); } + bool contains(ModelIndex const& index) const { return m_indices.contains(index); } bool contains_row(int row) const { for (auto& index : m_indices) { @@ -37,11 +37,11 @@ public: return false; } - void set(const ModelIndex&); - void add(const ModelIndex&); - void add_all(const Vector<ModelIndex>&); - void toggle(const ModelIndex&); - bool remove(const ModelIndex&); + void set(ModelIndex const&); + void add(ModelIndex const&); + void add_all(Vector<ModelIndex> const&); + void toggle(ModelIndex const&); + bool remove(ModelIndex const&); void clear(); template<typename Callback> diff --git a/Userland/Libraries/LibGUI/MultiView.h b/Userland/Libraries/LibGUI/MultiView.h index a4436fe08d..3bcf52623f 100644 --- a/Userland/Libraries/LibGUI/MultiView.h +++ b/Userland/Libraries/LibGUI/MultiView.h @@ -23,10 +23,10 @@ public: void refresh(); Function<void()> on_selection_change; - Function<void(const ModelIndex&)> on_activation; - Function<void(const ModelIndex&)> on_selection; - Function<void(const ModelIndex&, const ContextMenuEvent&)> on_context_menu_request; - Function<void(const ModelIndex&, const DropEvent&)> on_drop; + Function<void(ModelIndex const&)> on_activation; + Function<void(ModelIndex const&)> on_selection; + Function<void(ModelIndex const&, ContextMenuEvent const&)> on_context_menu_request; + Function<void(ModelIndex const&, DropEvent const&)> on_drop; enum ViewMode { Invalid, @@ -58,7 +58,7 @@ public: } } - const ModelSelection& selection() const { return const_cast<MultiView&>(*this).current_view().selection(); } + ModelSelection const& selection() const { return const_cast<MultiView&>(*this).current_view().selection(); } ModelSelection& selection() { return current_view().selection(); } template<typename Callback> @@ -70,7 +70,7 @@ public: } Model* model() { return m_model; } - const Model* model() const { return m_model; } + Model const* model() const { return m_model; } void set_model(RefPtr<Model>); diff --git a/Userland/Libraries/LibGUI/Notification.h b/Userland/Libraries/LibGUI/Notification.h index c5d94aaccc..5f695597b6 100644 --- a/Userland/Libraries/LibGUI/Notification.h +++ b/Userland/Libraries/LibGUI/Notification.h @@ -21,22 +21,22 @@ class Notification : public Core::Object { public: virtual ~Notification() override; - const String& text() const { return m_text; } - void set_text(const String& text) + String const& text() const { return m_text; } + void set_text(String const& text) { m_text_dirty = true; m_text = text; } - const String& title() const { return m_title; } - void set_title(const String& title) + String const& title() const { return m_title; } + void set_title(String const& title) { m_title_dirty = true; m_title = title; } - const Gfx::Bitmap* icon() const { return m_icon; } - void set_icon(const Gfx::Bitmap* icon) + Gfx::Bitmap const* icon() const { return m_icon; } + void set_icon(Gfx::Bitmap const* icon) { m_icon_dirty = true; m_icon = icon; diff --git a/Userland/Libraries/LibGUI/OpacitySlider.cpp b/Userland/Libraries/LibGUI/OpacitySlider.cpp index 59cb22d2fa..cb8aff8d79 100644 --- a/Userland/Libraries/LibGUI/OpacitySlider.cpp +++ b/Userland/Libraries/LibGUI/OpacitySlider.cpp @@ -95,7 +95,7 @@ void OpacitySlider::paint_event(PaintEvent& event) Gfx::StylePainter::paint_frame(painter, rect(), palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); } -int OpacitySlider::value_at(const Gfx::IntPoint& position) const +int OpacitySlider::value_at(Gfx::IntPoint const& position) const { auto inner_rect = frame_inner_rect(); if (position.x() < inner_rect.left()) diff --git a/Userland/Libraries/LibGUI/OpacitySlider.h b/Userland/Libraries/LibGUI/OpacitySlider.h index e4ab0560be..3c09c95c89 100644 --- a/Userland/Libraries/LibGUI/OpacitySlider.h +++ b/Userland/Libraries/LibGUI/OpacitySlider.h @@ -29,7 +29,7 @@ private: Gfx::IntRect frame_inner_rect() const; - int value_at(const Gfx::IntPoint&) const; + int value_at(Gfx::IntPoint const&) const; bool m_dragging { false }; }; diff --git a/Userland/Libraries/LibGUI/ProcessChooser.cpp b/Userland/Libraries/LibGUI/ProcessChooser.cpp index 94c3e4781d..2a55fbee53 100644 --- a/Userland/Libraries/LibGUI/ProcessChooser.cpp +++ b/Userland/Libraries/LibGUI/ProcessChooser.cpp @@ -15,7 +15,7 @@ namespace GUI { -ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, const Gfx::Bitmap* window_icon, GUI::Window* parent_window) +ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, Gfx::Bitmap const* window_icon, GUI::Window* parent_window) : Dialog(parent_window) , m_window_title(window_title) , m_button_label(button_label) @@ -44,7 +44,7 @@ ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, m_process_model = process_model; - m_table_view->on_activation = [this](const ModelIndex& index) { set_pid_from_index_and_close(index); }; + m_table_view->on_activation = [this](ModelIndex const& index) { set_pid_from_index_and_close(index); }; auto& button_container = widget.add<GUI::Widget>(); button_container.set_fixed_height(30); @@ -99,7 +99,7 @@ ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, }; } -void ProcessChooser::set_pid_from_index_and_close(const ModelIndex& index) +void ProcessChooser::set_pid_from_index_and_close(ModelIndex const& index) { m_pid = index.data(GUI::ModelRole::Custom).as_i32(); done(ExecOK); diff --git a/Userland/Libraries/LibGUI/ProcessChooser.h b/Userland/Libraries/LibGUI/ProcessChooser.h index 23e3363a0e..e9467e5e1f 100644 --- a/Userland/Libraries/LibGUI/ProcessChooser.h +++ b/Userland/Libraries/LibGUI/ProcessChooser.h @@ -22,9 +22,9 @@ public: pid_t pid() const { return m_pid; } private: - ProcessChooser(StringView window_title = "Process Chooser", StringView button_label = "Select", const Gfx::Bitmap* window_icon = nullptr, GUI::Window* parent_window = nullptr); + ProcessChooser(StringView window_title = "Process Chooser", StringView button_label = "Select", Gfx::Bitmap const* window_icon = nullptr, GUI::Window* parent_window = nullptr); - void set_pid_from_index_and_close(const ModelIndex&); + void set_pid_from_index_and_close(ModelIndex const&); pid_t m_pid { 0 }; diff --git a/Userland/Libraries/LibGUI/RegularEditingEngine.cpp b/Userland/Libraries/LibGUI/RegularEditingEngine.cpp index ff69f2dd74..347e42007b 100644 --- a/Userland/Libraries/LibGUI/RegularEditingEngine.cpp +++ b/Userland/Libraries/LibGUI/RegularEditingEngine.cpp @@ -15,7 +15,7 @@ CursorWidth RegularEditingEngine::cursor_width() const return CursorWidth::NARROW; } -bool RegularEditingEngine::on_key(const KeyEvent& event) +bool RegularEditingEngine::on_key(KeyEvent const& event) { if (EditingEngine::on_key(event)) return true; @@ -34,7 +34,7 @@ bool RegularEditingEngine::on_key(const KeyEvent& event) return false; } -static int strcmp_utf32(const u32* s1, const u32* s2, size_t n) +static int strcmp_utf32(u32 const* s1, u32 const* s2, size_t n) { while (n-- > 0) { if (*s1++ != *s2++) diff --git a/Userland/Libraries/LibGUI/RegularEditingEngine.h b/Userland/Libraries/LibGUI/RegularEditingEngine.h index 308bb353bc..82f0088b86 100644 --- a/Userland/Libraries/LibGUI/RegularEditingEngine.h +++ b/Userland/Libraries/LibGUI/RegularEditingEngine.h @@ -15,7 +15,7 @@ class RegularEditingEngine final : public EditingEngine { public: virtual CursorWidth cursor_width() const override; - virtual bool on_key(const KeyEvent& event) override; + virtual bool on_key(KeyEvent const& event) override; private: void sort_selected_lines(); diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp index 214ffe0401..85cc26eb50 100644 --- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp +++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp @@ -83,7 +83,7 @@ void ScrollableContainerWidget::set_widget(GUI::Widget* widget) update_widget_position(); } -bool ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)) +bool ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)) { if (is<GUI::GML::GMLFile>(ast.ptr())) return load_from_gml_ast(static_ptr_cast<GUI::GML::GMLFile>(ast)->main_class(), unregistered_child_handler); diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.h b/Userland/Libraries/LibGUI/ScrollableContainerWidget.h index 36c2cd734c..3064af9866 100644 --- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.h +++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.h @@ -28,7 +28,7 @@ protected: private: void update_widget_size(); void update_widget_position(); - virtual bool load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)) override; + virtual bool load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)) override; ScrollableContainerWidget(); diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp index ebb0499cb0..5843649dc1 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.cpp +++ b/Userland/Libraries/LibGUI/Scrollbar.cpp @@ -352,7 +352,7 @@ void Scrollbar::set_automatic_scrolling_active(bool active, Component pressed_co } } -void Scrollbar::scroll_by_page(const Gfx::IntPoint& click_position) +void Scrollbar::scroll_by_page(Gfx::IntPoint const& click_position) { float range_size = max() - min(); float available = scrubbable_range_in_pixels(); @@ -368,7 +368,7 @@ void Scrollbar::scroll_by_page(const Gfx::IntPoint& click_position) } } -void Scrollbar::scroll_to_position(const Gfx::IntPoint& click_position) +void Scrollbar::scroll_to_position(Gfx::IntPoint const& click_position) { float range_size = max() - min(); float available = scrubbable_range_in_pixels(); @@ -378,7 +378,7 @@ void Scrollbar::scroll_to_position(const Gfx::IntPoint& click_position) set_target_value(min() + rel_x_or_y * range_size); } -Scrollbar::Component Scrollbar::component_at_position(const Gfx::IntPoint& position) +Scrollbar::Component Scrollbar::component_at_position(Gfx::IntPoint const& position) { if (scrubber_rect().contains(position)) return Component::Scrubber; diff --git a/Userland/Libraries/LibGUI/Scrollbar.h b/Userland/Libraries/LibGUI/Scrollbar.h index 0f6115055c..51aa86aea2 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.h +++ b/Userland/Libraries/LibGUI/Scrollbar.h @@ -79,10 +79,10 @@ private: void on_automatic_scrolling_timer_fired(); void set_automatic_scrolling_active(bool, Component); - void scroll_to_position(const Gfx::IntPoint&); - void scroll_by_page(const Gfx::IntPoint&); + void scroll_to_position(Gfx::IntPoint const&); + void scroll_by_page(Gfx::IntPoint const&); - Component component_at_position(const Gfx::IntPoint&); + Component component_at_position(Gfx::IntPoint const&); void update_animated_scroll(); diff --git a/Userland/Libraries/LibGUI/Shortcut.h b/Userland/Libraries/LibGUI/Shortcut.h index 52d90a6f2d..856260e5d8 100644 --- a/Userland/Libraries/LibGUI/Shortcut.h +++ b/Userland/Libraries/LibGUI/Shortcut.h @@ -30,7 +30,7 @@ public: KeyCode key() const { return m_key; } String to_string() const; - bool operator==(const Shortcut& other) const + bool operator==(Shortcut const& other) const { return m_modifiers == other.m_modifiers && m_key == other.m_key; diff --git a/Userland/Libraries/LibGUI/Slider.cpp b/Userland/Libraries/LibGUI/Slider.cpp index b090f63c90..6ee7edc879 100644 --- a/Userland/Libraries/LibGUI/Slider.cpp +++ b/Userland/Libraries/LibGUI/Slider.cpp @@ -85,7 +85,7 @@ void Slider::mousedown_event(MouseEvent& event) return; } - const auto mouse_offset = event.position().primary_offset_for_orientation(orientation()); + auto const mouse_offset = event.position().primary_offset_for_orientation(orientation()); if (jump_to_cursor()) { float normalized_mouse_offset = 0.0f; diff --git a/Userland/Libraries/LibGUI/StackWidget.h b/Userland/Libraries/LibGUI/StackWidget.h index 0f9dc7170b..ad57814c2e 100644 --- a/Userland/Libraries/LibGUI/StackWidget.h +++ b/Userland/Libraries/LibGUI/StackWidget.h @@ -17,7 +17,7 @@ public: virtual ~StackWidget() override = default; Widget* active_widget() { return m_active_widget.ptr(); } - const Widget* active_widget() const { return m_active_widget.ptr(); } + Widget const* active_widget() const { return m_active_widget.ptr(); } void set_active_widget(Widget*); Function<void(Widget*)> on_active_widget_change; diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index 26e7a9f90e..c855b76d62 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -141,7 +141,7 @@ void TabWidget::resize_event(ResizeEvent& event) m_active_widget->set_relative_rect(child_rect_for_size(event.size())); } -Gfx::IntRect TabWidget::child_rect_for_size(const Gfx::IntSize& size) const +Gfx::IntRect TabWidget::child_rect_for_size(Gfx::IntSize const& size) const { Gfx::IntRect rect; switch (m_tab_position) { @@ -401,7 +401,7 @@ Gfx::IntRect TabWidget::close_button_rect(size_t index) const return close_button_rect; } -int TabWidget::TabData::width(const Gfx::Font& font) const +int TabWidget::TabData::width(Gfx::Font const& font) const { auto width = 16 + font.width(title) + (icon ? (16 + 4) : 0); // NOTE: This needs to always be an odd number, because the button rect @@ -553,7 +553,7 @@ void TabWidget::set_tab_title(Widget& tab, StringView title) } } -void TabWidget::set_tab_icon(Widget& tab, const Gfx::Bitmap* icon) +void TabWidget::set_tab_icon(Widget& tab, Gfx::Bitmap const* icon) { for (auto& t : m_tabs) { if (t.widget == &tab) { diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h index c3a793374d..d723f3417b 100644 --- a/Userland/Libraries/LibGUI/TabWidget.h +++ b/Userland/Libraries/LibGUI/TabWidget.h @@ -28,7 +28,7 @@ public: Optional<size_t> active_tab_index() const; Widget* active_widget() { return m_active_widget.ptr(); } - const Widget* active_widget() const { return m_active_widget.ptr(); } + Widget const* active_widget() const { return m_active_widget.ptr(); } void set_active_widget(Widget*); void set_tab_index(int); @@ -62,7 +62,7 @@ public: void remove_all_tabs_except(Widget& tab); void set_tab_title(Widget& tab, StringView title); - void set_tab_icon(Widget& tab, const Gfx::Bitmap*); + void set_tab_icon(Widget& tab, Gfx::Bitmap const*); void activate_next_tab(); void activate_previous_tab(); @@ -86,7 +86,7 @@ public: Function<void(Widget&)> on_change; Function<void(Widget&)> on_middle_click; Function<void(Widget&)> on_tab_close_click; - Function<void(Widget&, const ContextMenuEvent&)> on_context_menu_request; + Function<void(Widget&, ContextMenuEvent const&)> on_context_menu_request; Function<void(Widget&)> on_double_click; protected: @@ -104,7 +104,7 @@ protected: virtual void doubleclick_event(MouseEvent&) override; private: - Gfx::IntRect child_rect_for_size(const Gfx::IntSize&) const; + Gfx::IntRect child_rect_for_size(Gfx::IntSize const&) const; Gfx::IntRect button_rect(size_t index) const; Gfx::IntRect close_button_rect(size_t index) const; Gfx::IntRect bar_rect() const; @@ -116,7 +116,7 @@ private: RefPtr<Widget> m_active_widget; struct TabData { - int width(const Gfx::Font&) const; + int width(Gfx::Font const&) const; String title; RefPtr<Gfx::Bitmap> icon; Widget* widget { nullptr }; diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index 8466107f80..6ffe48be38 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -171,7 +171,7 @@ void TextDocumentLine::clear(TextDocument& document) document.update_views({}); } -void TextDocumentLine::set_text(TextDocument& document, const Vector<u32> text) +void TextDocumentLine::set_text(TextDocument& document, Vector<u32> const text) { m_text = move(text); document.update_views({}); @@ -194,7 +194,7 @@ bool TextDocumentLine::set_text(TextDocument& document, StringView text) return true; } -void TextDocumentLine::append(TextDocument& document, const u32* code_points, size_t length) +void TextDocumentLine::append(TextDocument& document, u32 const* code_points, size_t length) { if (length == 0) return; @@ -313,7 +313,7 @@ void TextDocument::notify_did_change() m_regex_needs_update = true; } -void TextDocument::set_all_cursors(const TextPosition& position) +void TextDocument::set_all_cursors(TextPosition const& position) { if (m_client_notifications_enabled) { for (auto* client : m_clients) @@ -333,7 +333,7 @@ String TextDocument::text() const return builder.to_string(); } -String TextDocument::text_in_range(const TextRange& a_range) const +String TextDocument::text_in_range(TextRange const& a_range) const { auto range = a_range.normalized(); if (is_empty() || line_count() < range.end().line() - range.start().line()) @@ -359,7 +359,7 @@ String TextDocument::text_in_range(const TextRange& a_range) const return builder.to_string(); } -u32 TextDocument::code_point_at(const TextPosition& position) const +u32 TextDocument::code_point_at(TextPosition const& position) const { VERIFY(position.line() < line_count()); auto& line = this->line(position.line()); @@ -368,7 +368,7 @@ u32 TextDocument::code_point_at(const TextPosition& position) const return line.code_points()[position.column()]; } -TextPosition TextDocument::next_position_after(const TextPosition& position, SearchShouldWrap should_wrap) const +TextPosition TextDocument::next_position_after(TextPosition const& position, SearchShouldWrap should_wrap) const { auto& line = this->line(position.line()); if (position.column() == line.length()) { @@ -382,7 +382,7 @@ TextPosition TextDocument::next_position_after(const TextPosition& position, Sea return { position.line(), position.column() + 1 }; } -TextPosition TextDocument::previous_position_before(const TextPosition& position, SearchShouldWrap should_wrap) const +TextPosition TextDocument::previous_position_before(TextPosition const& position, SearchShouldWrap should_wrap) const { if (position.column() == 0) { if (position.line() == 0) { @@ -416,7 +416,7 @@ void TextDocument::update_regex_matches(StringView needle) } } -TextRange TextDocument::find_next(StringView needle, const TextPosition& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case) +TextRange TextDocument::find_next(StringView needle, TextPosition const& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case) { if (needle.is_empty()) return {}; @@ -496,7 +496,7 @@ TextRange TextDocument::find_next(StringView needle, const TextPosition& start, return {}; } -TextRange TextDocument::find_previous(StringView needle, const TextPosition& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case) +TextRange TextDocument::find_previous(StringView needle, TextPosition const& start, SearchShouldWrap should_wrap, bool regmatch, bool match_case) { if (needle.is_empty()) return {}; @@ -595,7 +595,7 @@ Vector<TextRange> TextDocument::find_all(StringView needle, bool regmatch, bool return ranges; } -Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_before(const TextPosition& position) const +Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_before(TextPosition const& position) const { for (int i = m_spans.size() - 1; i >= 0; --i) { if (!m_spans[i].range.contains(position)) @@ -609,7 +609,7 @@ Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_before(const T return {}; } -Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_after(const TextPosition& position) const +Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_after(TextPosition const& position) const { size_t i = 0; // Find the first span containing the cursor @@ -633,7 +633,7 @@ Optional<TextDocumentSpan> TextDocument::first_non_skippable_span_after(const Te return {}; } -TextPosition TextDocument::first_word_break_before(const TextPosition& position, bool start_at_column_before) const +TextPosition TextDocument::first_word_break_before(TextPosition const& position, bool start_at_column_before) const { if (position.column() == 0) { if (position.line() == 0) { @@ -663,7 +663,7 @@ TextPosition TextDocument::first_word_break_before(const TextPosition& position, return target; } -TextPosition TextDocument::first_word_break_after(const TextPosition& position) const +TextPosition TextDocument::first_word_break_after(TextPosition const& position) const { auto target = position; auto line = this->line(target.line()); @@ -689,7 +689,7 @@ TextPosition TextDocument::first_word_break_after(const TextPosition& position) return target; } -TextPosition TextDocument::first_word_before(const TextPosition& position, bool start_at_column_before) const +TextPosition TextDocument::first_word_before(TextPosition const& position, bool start_at_column_before) const { if (position.column() == 0) { if (position.line() == 0) { @@ -748,7 +748,7 @@ TextDocumentUndoCommand::TextDocumentUndoCommand(TextDocument& document) { } -InsertTextCommand::InsertTextCommand(TextDocument& document, const String& text, const TextPosition& position) +InsertTextCommand::InsertTextCommand(TextDocument& document, String const& text, TextPosition const& position) : TextDocumentUndoCommand(document) , m_text(text) , m_range({ position, position }) @@ -777,11 +777,11 @@ bool InsertTextCommand::merge_with(GUI::Command const& other) return true; } -void InsertTextCommand::perform_formatting(const TextDocument::Client& client) +void InsertTextCommand::perform_formatting(TextDocument::Client const& client) { const size_t tab_width = client.soft_tab_width(); - const auto& dest_line = m_document.line(m_range.start().line()); - const bool should_auto_indent = client.is_automatic_indentation_enabled(); + auto const& dest_line = m_document.line(m_range.start().line()); + bool const should_auto_indent = client.is_automatic_indentation_enabled(); StringBuilder builder; size_t column = m_range.start().column(); @@ -842,7 +842,7 @@ void InsertTextCommand::undo() m_document.set_all_cursors(m_range.start()); } -RemoveTextCommand::RemoveTextCommand(TextDocument& document, const String& text, const TextRange& range) +RemoveTextCommand::RemoveTextCommand(TextDocument& document, String const& text, TextRange const& range) : TextDocumentUndoCommand(document) , m_text(text) , m_range(range) @@ -884,7 +884,7 @@ void RemoveTextCommand::undo() m_document.set_all_cursors(new_cursor); } -TextPosition TextDocument::insert_at(const TextPosition& position, StringView text, const Client* client) +TextPosition TextDocument::insert_at(TextPosition const& position, StringView text, Client const* client) { TextPosition cursor = position; Utf8View utf8_view(text); @@ -893,7 +893,7 @@ TextPosition TextDocument::insert_at(const TextPosition& position, StringView te return cursor; } -TextPosition TextDocument::insert_at(const TextPosition& position, u32 code_point, const Client*) +TextPosition TextDocument::insert_at(TextPosition const& position, u32 code_point, Client const*) { if (code_point == '\n') { auto new_line = make<TextDocumentLine>(*this); @@ -909,7 +909,7 @@ TextPosition TextDocument::insert_at(const TextPosition& position, u32 code_poin } } -void TextDocument::remove(const TextRange& unnormalized_range) +void TextDocument::remove(TextRange const& unnormalized_range) { if (!unnormalized_range.is_valid()) return; @@ -970,7 +970,7 @@ TextRange TextDocument::range_for_entire_line(size_t line_index) const return { { line_index, 0 }, { line_index, line(line_index).length() } }; } -const TextDocumentSpan* TextDocument::span_at(const TextPosition& position) const +TextDocumentSpan const* TextDocument::span_at(TextPosition const& position) const { for (auto& span : m_spans) { if (span.range.contains(position)) diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h index c574d4b350..afef884465 100644 --- a/Userland/Libraries/LibGUI/TextDocument.h +++ b/Userland/Libraries/LibGUI/TextDocument.h @@ -48,7 +48,7 @@ public: virtual void document_did_remove_all_lines() = 0; virtual void document_did_change(AllowCallback = AllowCallback::Yes) = 0; virtual void document_did_set_text(AllowCallback = AllowCallback::Yes) = 0; - virtual void document_did_set_cursor(const TextPosition&) = 0; + virtual void document_did_set_cursor(TextPosition const&) = 0; virtual void document_did_update_undo_stack() = 0; virtual bool is_automatic_indentation_enabled() const = 0; @@ -59,22 +59,22 @@ public: virtual ~TextDocument() = default; size_t line_count() const { return m_lines.size(); } - const TextDocumentLine& line(size_t line_index) const { return m_lines[line_index]; } + TextDocumentLine const& line(size_t line_index) const { return m_lines[line_index]; } TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; } void set_spans(u32 span_collection_index, Vector<TextDocumentSpan> spans); bool set_text(StringView, AllowCallback = AllowCallback::Yes); - const NonnullOwnPtrVector<TextDocumentLine>& lines() const { return m_lines; } + NonnullOwnPtrVector<TextDocumentLine> const& lines() const { return m_lines; } NonnullOwnPtrVector<TextDocumentLine>& lines() { return m_lines; } bool has_spans() const { return !m_spans.is_empty(); } Vector<TextDocumentSpan>& spans() { return m_spans; } - const Vector<TextDocumentSpan>& spans() const { return m_spans; } + Vector<TextDocumentSpan> const& spans() const { return m_spans; } void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[index] = move(span); } - const TextDocumentSpan* span_at(const TextPosition&) const; + TextDocumentSpan const* span_at(TextPosition const&) const; void append_line(NonnullOwnPtr<TextDocumentLine>); void remove_line(size_t line_index); @@ -87,28 +87,28 @@ public: void update_views(Badge<TextDocumentLine>); String text() const; - String text_in_range(const TextRange&) const; + String text_in_range(TextRange const&) const; Vector<TextRange> find_all(StringView needle, bool regmatch = false, bool match_case = true); void update_regex_matches(StringView); - TextRange find_next(StringView, const TextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true); - TextRange find_previous(StringView, const TextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true); + TextRange find_next(StringView, TextPosition const& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true); + TextRange find_previous(StringView, TextPosition const& start = {}, SearchShouldWrap = SearchShouldWrap::Yes, bool regmatch = false, bool match_case = true); - TextPosition next_position_after(const TextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const; - TextPosition previous_position_before(const TextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const; + TextPosition next_position_after(TextPosition const&, SearchShouldWrap = SearchShouldWrap::Yes) const; + TextPosition previous_position_before(TextPosition const&, SearchShouldWrap = SearchShouldWrap::Yes) const; - u32 code_point_at(const TextPosition&) const; + u32 code_point_at(TextPosition const&) const; TextRange range_for_entire_line(size_t line_index) const; - Optional<TextDocumentSpan> first_non_skippable_span_before(const TextPosition&) const; - Optional<TextDocumentSpan> first_non_skippable_span_after(const TextPosition&) const; + Optional<TextDocumentSpan> first_non_skippable_span_before(TextPosition const&) const; + Optional<TextDocumentSpan> first_non_skippable_span_after(TextPosition const&) const; - TextPosition first_word_break_before(const TextPosition&, bool start_at_column_before) const; - TextPosition first_word_break_after(const TextPosition&) const; + TextPosition first_word_break_before(TextPosition const&, bool start_at_column_before) const; + TextPosition first_word_break_after(TextPosition const&) const; - TextPosition first_word_before(const TextPosition&, bool start_at_column_before) const; + TextPosition first_word_before(TextPosition const&, bool start_at_column_before) const; void add_to_undo_stack(NonnullOwnPtr<TextDocumentUndoCommand>); @@ -120,11 +120,11 @@ public: UndoStack const& undo_stack() const { return m_undo_stack; } void notify_did_change(); - void set_all_cursors(const TextPosition&); + void set_all_cursors(TextPosition const&); - TextPosition insert_at(const TextPosition&, u32, const Client* = nullptr); - TextPosition insert_at(const TextPosition&, StringView, const Client* = nullptr); - void remove(const TextRange&); + TextPosition insert_at(TextPosition const&, u32, Client const* = nullptr); + TextPosition insert_at(TextPosition const&, StringView, Client const* = nullptr); + void remove(TextRange const&); virtual bool is_code_document() const { return false; } @@ -163,7 +163,7 @@ public: String to_utf8() const; Utf32View view() const { return { code_points(), length() }; } - const u32* code_points() const { return m_text.data(); } + u32 const* code_points() const { return m_text.data(); } size_t length() const { return m_text.size(); } bool set_text(TextDocument&, StringView); void set_text(TextDocument&, Vector<u32>); @@ -171,7 +171,7 @@ public: void prepend(TextDocument&, u32); void insert(TextDocument&, size_t index, u32); void remove(TextDocument&, size_t index); - void append(TextDocument&, const u32*, size_t); + void append(TextDocument&, u32 const*, size_t); void truncate(TextDocument&, size_t length); void clear(TextDocument&); void remove_range(TextDocument&, size_t start, size_t length); @@ -192,9 +192,9 @@ class TextDocumentUndoCommand : public Command { public: TextDocumentUndoCommand(TextDocument&); virtual ~TextDocumentUndoCommand() = default; - virtual void perform_formatting(const TextDocument::Client&) { } + virtual void perform_formatting(TextDocument::Client const&) { } - void execute_from(const TextDocument::Client& client) + void execute_from(TextDocument::Client const& client) { m_client = &client; redo(); @@ -203,19 +203,19 @@ public: protected: TextDocument& m_document; - const TextDocument::Client* m_client { nullptr }; + TextDocument::Client const* m_client { nullptr }; }; class InsertTextCommand : public TextDocumentUndoCommand { public: - InsertTextCommand(TextDocument&, const String&, const TextPosition&); - virtual void perform_formatting(const TextDocument::Client&) override; + InsertTextCommand(TextDocument&, String const&, TextPosition const&); + virtual void perform_formatting(TextDocument::Client const&) override; virtual void undo() override; virtual void redo() override; virtual bool merge_with(GUI::Command const&) override; virtual String action_text() const override; - const String& text() const { return m_text; } - const TextRange& range() const { return m_range; } + String const& text() const { return m_text; } + TextRange const& range() const { return m_range; } private: String m_text; @@ -224,10 +224,10 @@ private: class RemoveTextCommand : public TextDocumentUndoCommand { public: - RemoveTextCommand(TextDocument&, const String&, const TextRange&); + RemoveTextCommand(TextDocument&, String const&, TextRange const&); virtual void undo() override; virtual void redo() override; - const TextRange& range() const { return m_range; } + TextRange const& range() const { return m_range; } virtual bool merge_with(GUI::Command const&) override; virtual String action_text() const override; diff --git a/Userland/Libraries/LibGUI/TextPosition.h b/Userland/Libraries/LibGUI/TextPosition.h index e779a02432..c6b0bf0225 100644 --- a/Userland/Libraries/LibGUI/TextPosition.h +++ b/Userland/Libraries/LibGUI/TextPosition.h @@ -27,11 +27,11 @@ public: void set_line(size_t line) { m_line = line; } void set_column(size_t column) { m_column = column; } - bool operator==(const TextPosition& other) const { return m_line == other.m_line && m_column == other.m_column; } - bool operator!=(const TextPosition& other) const { return m_line != other.m_line || m_column != other.m_column; } - bool operator<(const TextPosition& other) const { return m_line < other.m_line || (m_line == other.m_line && m_column < other.m_column); } - bool operator>(const TextPosition& other) const { return *this != other && !(*this < other); } - bool operator>=(const TextPosition& other) const { return *this > other || (*this == other); } + bool operator==(TextPosition const& other) const { return m_line == other.m_line && m_column == other.m_column; } + bool operator!=(TextPosition const& other) const { return m_line != other.m_line || m_column != other.m_column; } + bool operator<(TextPosition const& other) const { return m_line < other.m_line || (m_line == other.m_line && m_column < other.m_column); } + bool operator>(TextPosition const& other) const { return *this != other && !(*this < other); } + bool operator>=(TextPosition const& other) const { return *this > other || (*this == other); } private: size_t m_line { 0xffffffff }; diff --git a/Userland/Libraries/LibGUI/TextRange.h b/Userland/Libraries/LibGUI/TextRange.h index 736e2baa3d..2e0b7332ab 100644 --- a/Userland/Libraries/LibGUI/TextRange.h +++ b/Userland/Libraries/LibGUI/TextRange.h @@ -14,7 +14,7 @@ namespace GUI { class TextRange { public: TextRange() = default; - TextRange(const TextPosition& start, const TextPosition& end) + TextRange(TextPosition const& start, TextPosition const& end) : m_start(start) , m_end(end) { @@ -29,26 +29,26 @@ public: TextPosition& start() { return m_start; } TextPosition& end() { return m_end; } - const TextPosition& start() const { return m_start; } - const TextPosition& end() const { return m_end; } + TextPosition const& start() const { return m_start; } + TextPosition const& end() const { return m_end; } TextRange normalized() const { return TextRange(normalized_start(), normalized_end()); } - void set_start(const TextPosition& position) { m_start = position; } - void set_end(const TextPosition& position) { m_end = position; } + void set_start(TextPosition const& position) { m_start = position; } + void set_end(TextPosition const& position) { m_end = position; } - void set(const TextPosition& start, const TextPosition& end) + void set(TextPosition const& start, TextPosition const& end) { m_start = start; m_end = end; } - bool operator==(const TextRange& other) const + bool operator==(TextRange const& other) const { return m_start == other.m_start && m_end == other.m_end; } - bool contains(const TextPosition& position) const + bool contains(TextPosition const& position) const { if (!(position.line() > m_start.line() || (position.line() == m_start.line() && position.column() >= m_start.column()))) return false; diff --git a/Userland/Libraries/LibGUI/Toolbar.cpp b/Userland/Libraries/LibGUI/Toolbar.cpp index f42865341f..fee9db5daa 100644 --- a/Userland/Libraries/LibGUI/Toolbar.cpp +++ b/Userland/Libraries/LibGUI/Toolbar.cpp @@ -56,7 +56,7 @@ private: set_text(action.text()); set_button_style(Gfx::ButtonStyle::Coolbar); } - String tooltip(const Action& action) const + String tooltip(Action const& action) const { StringBuilder builder; builder.append(action.text()); diff --git a/Userland/Libraries/LibGUI/TreeView.cpp b/Userland/Libraries/LibGUI/TreeView.cpp index 50a20e9e94..681ab29094 100644 --- a/Userland/Libraries/LibGUI/TreeView.cpp +++ b/Userland/Libraries/LibGUI/TreeView.cpp @@ -21,7 +21,7 @@ struct TreeView::MetadataForIndex { bool open { false }; }; -TreeView::MetadataForIndex& TreeView::ensure_metadata_for_index(const ModelIndex& index) const +TreeView::MetadataForIndex& TreeView::ensure_metadata_for_index(ModelIndex const& index) const { VERIFY(index.is_valid()); auto it = m_view_metadata.find(index.internal_data()); @@ -44,14 +44,14 @@ TreeView::TreeView() m_collapse_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/serenity/treeview-collapse.png").release_value_but_fixme_should_propagate_errors(); } -ModelIndex TreeView::index_at_event_position(const Gfx::IntPoint& a_position, bool& is_toggle) const +ModelIndex TreeView::index_at_event_position(Gfx::IntPoint const& a_position, bool& is_toggle) const { auto position = a_position.translated(0, -column_header().height()).translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); is_toggle = false; if (!model()) return {}; ModelIndex result; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& rect, const Gfx::IntRect& toggle_rect, int) { + traverse_in_paint_order([&](ModelIndex const& index, Gfx::IntRect const& rect, Gfx::IntRect const& toggle_rect, int) { if (toggle_rect.contains(position)) { result = index; is_toggle = true; @@ -86,7 +86,7 @@ void TreeView::doubleclick_event(MouseEvent& event) } } -void TreeView::set_open_state_of_all_in_subtree(const ModelIndex& root, bool open) +void TreeView::set_open_state_of_all_in_subtree(ModelIndex const& root, bool open) { if (root.is_valid()) { ensure_metadata_for_index(root).open = open; @@ -103,7 +103,7 @@ void TreeView::set_open_state_of_all_in_subtree(const ModelIndex& root, bool ope } } -void TreeView::expand_all_parents_of(const ModelIndex& index) +void TreeView::expand_all_parents_of(ModelIndex const& index) { if (!model()) return; @@ -120,7 +120,7 @@ void TreeView::expand_all_parents_of(const ModelIndex& index) update(); } -void TreeView::expand_tree(const ModelIndex& root) +void TreeView::expand_tree(ModelIndex const& root) { if (!model()) return; @@ -130,7 +130,7 @@ void TreeView::expand_tree(const ModelIndex& root) update(); } -void TreeView::collapse_tree(const ModelIndex& root) +void TreeView::collapse_tree(ModelIndex const& root) { if (!model()) return; @@ -140,7 +140,7 @@ void TreeView::collapse_tree(const ModelIndex& root) update(); } -void TreeView::toggle_index(const ModelIndex& index) +void TreeView::toggle_index(ModelIndex const& index) { VERIFY(model()->row_count(index)); auto& metadata = ensure_metadata_for_index(index); @@ -166,7 +166,7 @@ void TreeView::traverse_in_paint_order(Callback callback) const int y_offset = 0; int tree_column_x_offset = this->tree_column_x_offset(); - Function<IterationDecision(const ModelIndex&)> traverse_index = [&](const ModelIndex& index) { + Function<IterationDecision(ModelIndex const&)> traverse_index = [&](ModelIndex const& index) { int row_count_at_index = model.row_count(index); if (index.is_valid()) { auto& metadata = ensure_metadata_for_index(index); @@ -234,7 +234,7 @@ void TreeView::paint_event(PaintEvent& event) int painted_row_index = 0; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& a_rect, const Gfx::IntRect& a_toggle_rect, int indent_level) { + traverse_in_paint_order([&](ModelIndex const& index, Gfx::IntRect const& a_rect, Gfx::IntRect const& a_toggle_rect, int indent_level) { if (!a_rect.intersects_vertically(visible_content_rect)) return IterationDecision::Continue; @@ -380,12 +380,12 @@ void TreeView::paint_event(PaintEvent& event) }); } -void TreeView::scroll_into_view(const ModelIndex& a_index, bool, bool scroll_vertically) +void TreeView::scroll_into_view(ModelIndex const& a_index, bool, bool scroll_vertically) { if (!a_index.is_valid()) return; Gfx::IntRect found_rect; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& rect, const Gfx::IntRect&, int) { + traverse_in_paint_order([&](ModelIndex const& index, Gfx::IntRect const& rect, Gfx::IntRect const&, int) { if (index == a_index) { found_rect = rect; return IterationDecision::Break; @@ -582,7 +582,7 @@ void TreeView::move_cursor(CursorMovement movement, SelectionUpdate selection_up return; } case CursorMovement::PageUp: { - const int items_per_page = visible_content_rect().height() / row_height(); + int const items_per_page = visible_content_rect().height() / row_height(); auto new_index = cursor_index(); for (int step = 0; step < items_per_page; ++step) new_index = step_up(new_index); @@ -591,7 +591,7 @@ void TreeView::move_cursor(CursorMovement movement, SelectionUpdate selection_up return; } case CursorMovement::PageDown: { - const int items_per_page = visible_content_rect().height() / row_height(); + int const items_per_page = visible_content_rect().height() / row_height(); auto new_index = cursor_index(); for (int step = 0; step < items_per_page; ++step) new_index = step_down(new_index); @@ -609,7 +609,7 @@ void TreeView::move_cursor(CursorMovement movement, SelectionUpdate selection_up int TreeView::item_count() const { int count = 0; - traverse_in_paint_order([&](const ModelIndex&, const Gfx::IntRect&, const Gfx::IntRect&, int) { + traverse_in_paint_order([&](ModelIndex const&, Gfx::IntRect const&, Gfx::IntRect const&, int) { ++count; return IterationDecision::Continue; }); @@ -632,7 +632,7 @@ void TreeView::auto_resize_column(int column) int column_width = header_width; bool is_empty = true; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int indent_level) { + traverse_in_paint_order([&](ModelIndex const& index, Gfx::IntRect const&, Gfx::IntRect const&, int indent_level) { auto cell_data = model.index(index.row(), column, index.parent()).data(); int cell_width = 0; if (cell_data.is_icon()) { @@ -675,7 +675,7 @@ void TreeView::update_column_sizes() if (column == m_key_column && model.is_column_sortable(column)) header_width += font().width(" \xE2\xAC\x86"); int column_width = header_width; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int) { + traverse_in_paint_order([&](ModelIndex const& index, Gfx::IntRect const&, Gfx::IntRect const&, int) { auto cell_data = model.index(index.row(), column, index.parent()).data(); int cell_width = 0; if (cell_data.is_icon()) { @@ -696,7 +696,7 @@ void TreeView::update_column_sizes() if (tree_column == m_key_column && model.is_column_sortable(tree_column)) tree_column_header_width += font().width(" \xE2\xAC\x86"); int tree_column_width = tree_column_header_width; - traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int indent_level) { + traverse_in_paint_order([&](ModelIndex const& index, Gfx::IntRect const&, Gfx::IntRect const&, int indent_level) { auto cell_data = model.index(index.row(), tree_column, index.parent()).data(); int cell_width = 0; if (cell_data.is_valid()) { diff --git a/Userland/Libraries/LibGUI/TreeView.h b/Userland/Libraries/LibGUI/TreeView.h index abb9c40436..75ba2abe5d 100644 --- a/Userland/Libraries/LibGUI/TreeView.h +++ b/Userland/Libraries/LibGUI/TreeView.h @@ -17,17 +17,17 @@ class TreeView : public AbstractTableView { public: virtual ~TreeView() override = default; - virtual void scroll_into_view(const ModelIndex&, bool scroll_horizontally, bool scroll_vertically) override; + virtual void scroll_into_view(ModelIndex const&, bool scroll_horizontally, bool scroll_vertically) override; virtual int item_count() const override; - virtual void toggle_index(const ModelIndex&) override; + virtual void toggle_index(ModelIndex const&) override; - void expand_tree(const ModelIndex& root = {}); - void collapse_tree(const ModelIndex& root = {}); + void expand_tree(ModelIndex const& root = {}); + void collapse_tree(ModelIndex const& root = {}); - void expand_all_parents_of(const ModelIndex&); + void expand_all_parents_of(ModelIndex const&); - Function<void(const ModelIndex&, const bool)> on_toggle; + Function<void(ModelIndex const&, bool const)> on_toggle; void set_should_fill_selected_rows(bool fill) { m_should_fill_selected_rows = fill; } bool should_fill_selected_rows() const { return m_should_fill_selected_rows; } @@ -51,7 +51,7 @@ protected: virtual void move_cursor(CursorMovement, SelectionUpdate) override; private: - virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const override; + virtual ModelIndex index_at_event_position(Gfx::IntPoint const&, bool& is_toggle) const override; int row_height() const { return 16; } int max_item_width() const { return frame_inner_rect().width(); } @@ -69,8 +69,8 @@ private: struct MetadataForIndex; - MetadataForIndex& ensure_metadata_for_index(const ModelIndex&) const; - void set_open_state_of_all_in_subtree(const ModelIndex& root, bool open); + MetadataForIndex& ensure_metadata_for_index(ModelIndex const&) const; + void set_open_state_of_all_in_subtree(ModelIndex const& root, bool open); mutable HashMap<void*, NonnullOwnPtr<MetadataForIndex>> m_view_metadata; diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp index 6034361e07..c7bc87aa08 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.cpp +++ b/Userland/Libraries/LibGUI/ValueSlider.cpp @@ -21,7 +21,7 @@ ValueSlider::ValueSlider(Gfx::Orientation orientation, String suffix) : AbstractSlider(orientation) , m_suffix(move(suffix)) { - //FIXME: Implement vertical mode + // FIXME: Implement vertical mode VERIFY(orientation == Orientation::Horizontal); set_fixed_height(20); @@ -132,7 +132,7 @@ Gfx::IntRect ValueSlider::knob_rect() const return knob_rect; } -int ValueSlider::value_at(const Gfx::IntPoint& position) const +int ValueSlider::value_at(Gfx::IntPoint const& position) const { if (position.x() < bar_rect().left()) return min(); diff --git a/Userland/Libraries/LibGUI/ValueSlider.h b/Userland/Libraries/LibGUI/ValueSlider.h index 91aba6ab19..8b0291a0ae 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.h +++ b/Userland/Libraries/LibGUI/ValueSlider.h @@ -39,7 +39,7 @@ private: explicit ValueSlider(Gfx::Orientation = Gfx::Orientation::Horizontal, String suffix = ""); String formatted_value() const; - int value_at(const Gfx::IntPoint& position) const; + int value_at(Gfx::IntPoint const& position) const; Gfx::IntRect bar_rect() const; Gfx::IntRect knob_rect() const; diff --git a/Userland/Libraries/LibGUI/Variant.cpp b/Userland/Libraries/LibGUI/Variant.cpp index a519a92354..8649705b07 100644 --- a/Userland/Libraries/LibGUI/Variant.cpp +++ b/Userland/Libraries/LibGUI/Variant.cpp @@ -12,7 +12,7 @@ namespace GUI { -const char* to_string(Variant::Type type) +char const* to_string(Variant::Type type) { switch (type) { case Variant::Type::Invalid: @@ -162,12 +162,12 @@ Variant::Variant(bool value) m_value.as_bool = value; } -Variant::Variant(const char* cstring) +Variant::Variant(char const* cstring) : Variant(String(cstring)) { } -Variant::Variant(const FlyString& value) +Variant::Variant(FlyString const& value) : Variant(String(value.impl())) { } @@ -177,14 +177,14 @@ Variant::Variant(StringView value) { } -Variant::Variant(const String& value) +Variant::Variant(String const& value) : m_type(Type::String) { m_value.as_string = const_cast<StringImpl*>(value.impl()); AK::ref_if_not_null(m_value.as_string); } -Variant::Variant(const JsonValue& value) +Variant::Variant(JsonValue const& value) { if (value.is_null()) { m_value.as_string = nullptr; @@ -231,7 +231,7 @@ Variant::Variant(const JsonValue& value) VERIFY_NOT_REACHED(); } -Variant::Variant(const Gfx::Bitmap& value) +Variant::Variant(Gfx::Bitmap const& value) : m_type(Type::Bitmap) { m_value.as_bitmap = const_cast<Gfx::Bitmap*>(&value); @@ -245,7 +245,7 @@ Variant::Variant(const GUI::Icon& value) AK::ref_if_not_null(m_value.as_icon); } -Variant::Variant(const Gfx::Font& value) +Variant::Variant(Gfx::Font const& value) : m_type(Type::Font) { m_value.as_font = &const_cast<Gfx::Font&>(value); @@ -258,25 +258,25 @@ Variant::Variant(Color color) m_value.as_color = color.value(); } -Variant::Variant(const Gfx::IntPoint& point) +Variant::Variant(Gfx::IntPoint const& point) : m_type(Type::Point) { m_value.as_point = { point.x(), point.y() }; } -Variant::Variant(const Gfx::IntSize& size) +Variant::Variant(Gfx::IntSize const& size) : m_type(Type::Size) { m_value.as_size = { size.width(), size.height() }; } -Variant::Variant(const Gfx::IntRect& rect) +Variant::Variant(Gfx::IntRect const& rect) : m_type(Type::Rect) { - m_value.as_rect = (const RawRect&)rect; + m_value.as_rect = (RawRect const&)rect; } -Variant& Variant::operator=(const Variant& other) +Variant& Variant::operator=(Variant const& other) { if (&other == this) return *this; @@ -294,7 +294,7 @@ Variant& Variant::operator=(Variant&& other) return *this; } -Variant::Variant(const Variant& other) +Variant::Variant(Variant const& other) { copy_from(other); } @@ -307,7 +307,7 @@ void Variant::move_from(Variant&& other) other.m_value.as_string = nullptr; } -void Variant::copy_from(const Variant& other) +void Variant::copy_from(Variant const& other) { VERIFY(!is_valid()); m_type = other.m_type; @@ -381,7 +381,7 @@ void Variant::copy_from(const Variant& other) } } -bool Variant::operator==(const Variant& other) const +bool Variant::operator==(Variant const& other) const { if (m_type != other.m_type) return to_string() == other.to_string(); @@ -432,7 +432,7 @@ bool Variant::operator==(const Variant& other) const VERIFY_NOT_REACHED(); } -bool Variant::operator<(const Variant& other) const +bool Variant::operator<(Variant const& other) const { if (m_type != other.m_type) return to_string() < other.to_string(); diff --git a/Userland/Libraries/LibGUI/Variant.h b/Userland/Libraries/LibGUI/Variant.h index 8862bfa27f..1789a8fd1b 100644 --- a/Userland/Libraries/LibGUI/Variant.h +++ b/Userland/Libraries/LibGUI/Variant.h @@ -24,27 +24,27 @@ public: Variant(i64); Variant(u32); Variant(u64); - Variant(const char*); + Variant(char const*); Variant(StringView); - Variant(const String&); - Variant(const FlyString&); - Variant(const Gfx::Bitmap&); + Variant(String const&); + Variant(FlyString const&); + Variant(Gfx::Bitmap const&); Variant(const GUI::Icon&); - Variant(const Gfx::IntPoint&); - Variant(const Gfx::IntSize&); - Variant(const Gfx::IntRect&); - Variant(const Gfx::Font&); + Variant(Gfx::IntPoint const&); + Variant(Gfx::IntSize const&); + Variant(Gfx::IntRect const&); + Variant(Gfx::Font const&); Variant(const Gfx::TextAlignment); Variant(const Gfx::ColorRole); Variant(const Gfx::AlignmentRole); Variant(const Gfx::FlagRole); Variant(const Gfx::MetricRole); Variant(const Gfx::PathRole); - Variant(const JsonValue&); + Variant(JsonValue const&); Variant(Color); - Variant(const Variant&); - Variant& operator=(const Variant&); + Variant(Variant const&); + Variant& operator=(Variant const&); Variant(Variant&&) = delete; Variant& operator=(Variant&&); @@ -220,7 +220,7 @@ public: return m_value.as_string; } - const Gfx::Bitmap& as_bitmap() const + Gfx::Bitmap const& as_bitmap() const { VERIFY(type() == Type::Bitmap); return *m_value.as_bitmap; @@ -238,7 +238,7 @@ public: return Color::from_argb(m_value.as_color); } - const Gfx::Font& as_font() const + Gfx::Font const& as_font() const { VERIFY(type() == Type::Font); return *m_value.as_font; @@ -300,11 +300,11 @@ public: String to_string() const; - bool operator==(const Variant&) const; - bool operator<(const Variant&) const; + bool operator==(Variant const&) const; + bool operator<(Variant const&) const; private: - void copy_from(const Variant&); + void copy_from(Variant const&); void move_from(Variant&&); struct RawPoint { @@ -348,6 +348,6 @@ private: Type m_type { Type::Invalid }; }; -const char* to_string(Variant::Type); +char const* to_string(Variant::Type); } diff --git a/Userland/Libraries/LibGUI/VimEditingEngine.cpp b/Userland/Libraries/LibGUI/VimEditingEngine.cpp index d69c3ed326..a12887a036 100644 --- a/Userland/Libraries/LibGUI/VimEditingEngine.cpp +++ b/Userland/Libraries/LibGUI/VimEditingEngine.cpp @@ -773,7 +773,7 @@ CursorWidth VimEditingEngine::cursor_width() const return m_vim_mode == VimMode::Insert ? CursorWidth::NARROW : CursorWidth::WIDE; } -bool VimEditingEngine::on_key(const KeyEvent& event) +bool VimEditingEngine::on_key(KeyEvent const& event) { switch (m_vim_mode) { case (VimMode::Insert): @@ -789,7 +789,7 @@ bool VimEditingEngine::on_key(const KeyEvent& event) return false; } -bool VimEditingEngine::on_key_in_insert_mode(const KeyEvent& event) +bool VimEditingEngine::on_key_in_insert_mode(KeyEvent const& event) { if (EditingEngine::on_key(event)) return true; @@ -819,7 +819,7 @@ bool VimEditingEngine::on_key_in_insert_mode(const KeyEvent& event) return false; } -bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event) +bool VimEditingEngine::on_key_in_normal_mode(KeyEvent const& event) { // Ignore auxiliary keypress events. if (event.key() == KeyCode::Key_LeftShift @@ -1102,7 +1102,7 @@ bool VimEditingEngine::on_key_in_normal_mode(const KeyEvent& event) return true; } -bool VimEditingEngine::on_key_in_visual_mode(const KeyEvent& event) +bool VimEditingEngine::on_key_in_visual_mode(KeyEvent const& event) { // If the motion state machine requires the next character, feed it. if (m_motion.should_consume_next_character()) { diff --git a/Userland/Libraries/LibGUI/VimEditingEngine.h b/Userland/Libraries/LibGUI/VimEditingEngine.h index 8be34cfbbd..b7216d0892 100644 --- a/Userland/Libraries/LibGUI/VimEditingEngine.h +++ b/Userland/Libraries/LibGUI/VimEditingEngine.h @@ -146,7 +146,7 @@ class VimEditingEngine final : public EditingEngine { public: virtual CursorWidth cursor_width() const override; - virtual bool on_key(const KeyEvent& event) override; + virtual bool on_key(KeyEvent const& event) override; private: enum VimMode { @@ -184,9 +184,9 @@ private: void move_to_previous_empty_lines_block(); void move_to_next_empty_lines_block(); - bool on_key_in_insert_mode(const KeyEvent& event); - bool on_key_in_normal_mode(const KeyEvent& event); - bool on_key_in_visual_mode(const KeyEvent& event); + bool on_key_in_insert_mode(KeyEvent const& event); + bool on_key_in_normal_mode(KeyEvent const& event); + bool on_key_in_visual_mode(KeyEvent const& event); virtual EngineType engine_type() const override { return EngineType::Vim; } }; diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index 7686960b5e..bc1036a145 100644 --- a/Userland/Libraries/LibGUI/Widget.cpp +++ b/Userland/Libraries/LibGUI/Widget.cpp @@ -217,7 +217,7 @@ void Widget::child_event(Core::ChildEvent& event) return Core::Object::child_event(event); } -void Widget::set_relative_rect(const Gfx::IntRect& a_rect) +void Widget::set_relative_rect(Gfx::IntRect const& a_rect) { // Get rid of negative width/height values. Gfx::IntRect rect = { @@ -596,7 +596,7 @@ void Widget::update() update(rect()); } -void Widget::update(const Gfx::IntRect& rect) +void Widget::update(Gfx::IntRect const& rect) { if (!is_visible()) return; @@ -653,7 +653,7 @@ Gfx::IntRect Widget::screen_relative_rect() const return window_relative_rect().translated(window_position); } -Widget* Widget::child_at(const Gfx::IntPoint& point) const +Widget* Widget::child_at(Gfx::IntPoint const& point) const { for (int i = children().size() - 1; i >= 0; --i) { if (!is<Widget>(children()[i])) @@ -667,7 +667,7 @@ Widget* Widget::child_at(const Gfx::IntPoint& point) const return nullptr; } -Widget::HitTestResult Widget::hit_test(const Gfx::IntPoint& position, ShouldRespectGreediness should_respect_greediness) +Widget::HitTestResult Widget::hit_test(Gfx::IntPoint const& position, ShouldRespectGreediness should_respect_greediness) { if (should_respect_greediness == ShouldRespectGreediness::Yes && is_greedy_for_hits()) return { this, position }; @@ -737,7 +737,7 @@ void Widget::set_focus(bool focus, FocusSource source) } } -void Widget::set_font(const Gfx::Font* font) +void Widget::set_font(Gfx::Font const* font) { if (m_font.ptr() == font) return; @@ -754,7 +754,7 @@ void Widget::set_font(const Gfx::Font* font) update(); } -void Widget::set_font_family(const String& family) +void Widget::set_font_family(String const& family) { set_font(Gfx::FontDatabase::the().get(family, m_font->presentation_size(), m_font->weight(), m_font->slope())); } @@ -777,7 +777,7 @@ void Widget::set_font_fixed_width(bool fixed_width) set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_font().family(), m_font->presentation_size(), m_font->weight(), m_font->slope())); } -void Widget::set_min_size(const Gfx::IntSize& size) +void Widget::set_min_size(Gfx::IntSize const& size) { if (m_min_size == size) return; @@ -785,7 +785,7 @@ void Widget::set_min_size(const Gfx::IntSize& size) invalidate_layout(); } -void Widget::set_max_size(const Gfx::IntSize& size) +void Widget::set_max_size(Gfx::IntSize const& size) { if (m_max_size == size) return; @@ -901,7 +901,7 @@ bool Widget::is_backmost() const return &parent->children().first() == this; } -Action* Widget::action_for_key_event(const KeyEvent& event) +Action* Widget::action_for_key_event(KeyEvent const& event) { Shortcut shortcut(event.modifiers(), (KeyCode)event.key()); @@ -970,7 +970,7 @@ Vector<Widget&> Widget::child_widgets() const return widgets; } -void Widget::set_palette(const Palette& palette) +void Widget::set_palette(Palette const& palette) { m_palette = palette.impl(); update(); @@ -1003,7 +1003,7 @@ void Widget::did_end_inspection() update(); } -void Widget::set_grabbable_margins(const Margins& margins) +void Widget::set_grabbable_margins(Margins const& margins) { if (m_grabbable_margins == margins) return; @@ -1061,13 +1061,13 @@ void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr< bool Widget::load_from_gml(StringView gml_string) { - return load_from_gml(gml_string, [](const String& class_name) -> RefPtr<Core::Object> { + return load_from_gml(gml_string, [](String const& class_name) -> RefPtr<Core::Object> { dbgln("Class '{}' not registered", class_name); return nullptr; }); } -bool Widget::load_from_gml(StringView gml_string, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)) +bool Widget::load_from_gml(StringView gml_string, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)) { auto value = GML::parse_gml(gml_string); if (value.is_error()) { @@ -1078,7 +1078,7 @@ bool Widget::load_from_gml(StringView gml_string, RefPtr<Core::Object> (*unregis return load_from_gml_ast(value.release_value(), unregistered_child_handler); } -bool Widget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)) +bool Widget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)) { if (is<GUI::GML::GMLFile>(ast.ptr())) return load_from_gml_ast(static_ptr_cast<GUI::GML::GMLFile>(ast)->main_class(), unregistered_child_handler); diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index f6fb217c2e..bda60d956d 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -61,7 +61,7 @@ public: virtual ~Widget() override; Layout* layout() { return m_layout.ptr(); } - const Layout* layout() const { return m_layout.ptr(); } + Layout const* layout() const { return m_layout.ptr(); } void set_layout(NonnullRefPtr<Layout>); template<class T, class... Args> @@ -81,7 +81,7 @@ public: } Gfx::IntSize min_size() const { return m_min_size; } - void set_min_size(const Gfx::IntSize&); + void set_min_size(Gfx::IntSize const&); void set_min_size(int width, int height) { set_min_size({ width, height }); } int min_width() const { return m_min_size.width(); } @@ -90,7 +90,7 @@ public: void set_min_height(int height) { set_min_size(min_width(), height); } Gfx::IntSize max_size() const { return m_max_size; } - void set_max_size(const Gfx::IntSize&); + void set_max_size(Gfx::IntSize const&); void set_max_size(int width, int height) { set_max_size({ width, height }); } int max_width() const { return m_max_size.width(); } @@ -98,7 +98,7 @@ public: void set_max_width(int width) { set_max_size(width, max_height()); } void set_max_height(int height) { set_max_size(max_width(), height); } - void set_fixed_size(const Gfx::IntSize& size) + void set_fixed_size(Gfx::IntSize const& size) { set_min_size(size); set_max_size(size); @@ -154,7 +154,7 @@ public: // Invalidate the widget (or an area thereof), causing a repaint to happen soon. void update(); - void update(const Gfx::IntRect&); + void update(Gfx::IntRect const&); // Repaint the widget (or an area thereof) immediately. void repaint(); @@ -163,13 +163,13 @@ public: bool is_focused() const; void set_focus(bool, FocusSource = FocusSource::Programmatic); - Function<void(const bool, const FocusSource)> on_focus_change; + Function<void(bool const, const FocusSource)> on_focus_change; // Returns true if this widget or one of its descendants is focused. bool has_focus_within() const; Widget* focus_proxy() { return m_focus_proxy; } - const Widget* focus_proxy() const { return m_focus_proxy; } + Widget const* focus_proxy() const { return m_focus_proxy; } void set_focus_proxy(Widget*); void set_focus_policy(FocusPolicy policy); @@ -183,10 +183,10 @@ public: WeakPtr<Widget> widget; Gfx::IntPoint local_position; }; - HitTestResult hit_test(const Gfx::IntPoint&, ShouldRespectGreediness = ShouldRespectGreediness::Yes); - Widget* child_at(const Gfx::IntPoint&) const; + HitTestResult hit_test(Gfx::IntPoint const&, ShouldRespectGreediness = ShouldRespectGreediness::Yes); + Widget* child_at(Gfx::IntPoint const&) const; - void set_relative_rect(const Gfx::IntRect&); + void set_relative_rect(Gfx::IntRect const&); void set_relative_rect(int x, int y, int width, int height) { set_relative_rect({ x, y, width, height }); } void set_x(int x) { set_relative_rect(x, y(), width(), height()); } @@ -194,13 +194,13 @@ public: void set_width(int width) { set_relative_rect(x(), y(), width, height()); } void set_height(int height) { set_relative_rect(x(), y(), width(), height); } - void move_to(const Gfx::IntPoint& point) { set_relative_rect({ point, relative_rect().size() }); } + void move_to(Gfx::IntPoint const& point) { set_relative_rect({ point, relative_rect().size() }); } void move_to(int x, int y) { move_to({ x, y }); } - void resize(const Gfx::IntSize& size) { set_relative_rect({ relative_rect().location(), size }); } + void resize(Gfx::IntSize const& size) { set_relative_rect({ relative_rect().location(), size }); } void resize(int width, int height) { resize({ width, height }); } void move_by(int x, int y) { move_by({ x, y }); } - void move_by(const Gfx::IntPoint& delta) { set_relative_rect({ relative_position().translated(delta), size() }); } + void move_by(Gfx::IntPoint const& delta) { set_relative_rect({ relative_position().translated(delta), size() }); } Gfx::ColorRole background_role() const { return m_background_role; } void set_background_role(Gfx::ColorRole); @@ -217,7 +217,7 @@ public: return m_window; } - const Window* window() const + Window const* window() const { if (auto* pw = parent_widget()) return pw->window(); @@ -227,17 +227,17 @@ public: void set_window(Window*); Widget* parent_widget(); - const Widget* parent_widget() const; + Widget const* parent_widget() const; void set_fill_with_background_color(bool b) { m_fill_with_background_color = b; } bool fill_with_background_color() const { return m_fill_with_background_color; } - const Gfx::Font& font() const { return *m_font; } + Gfx::Font const& font() const { return *m_font; } - void set_font(const Gfx::Font*); - void set_font(const Gfx::Font& font) { set_font(&font); } + void set_font(Gfx::Font const*); + void set_font(Gfx::Font const& font) { set_font(&font); } - void set_font_family(const String&); + void set_font_family(String const&); void set_font_size(unsigned); void set_font_weight(unsigned); void set_font_fixed_width(bool); @@ -259,7 +259,7 @@ public: bool is_frontmost() const; bool is_backmost() const; - Action* action_for_key_event(const KeyEvent&); + Action* action_for_key_event(KeyEvent const&); template<typename Callback> void for_each_child_widget(Callback callback) @@ -276,10 +276,10 @@ public: void do_layout(); Gfx::Palette palette() const; - void set_palette(const Gfx::Palette&); + void set_palette(Gfx::Palette const&); - const Margins& grabbable_margins() const { return m_grabbable_margins; } - void set_grabbable_margins(const Margins&); + Margins const& grabbable_margins() const { return m_grabbable_margins; } + void set_grabbable_margins(Margins const&); Gfx::IntRect relative_non_grabbable_rect() const; @@ -295,7 +295,7 @@ public: void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>>); bool load_from_gml(StringView); - bool load_from_gml(StringView, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)); + bool load_from_gml(StringView, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)); void set_shrink_to_fit(bool); bool is_shrink_to_fit() const { return m_shrink_to_fit; } @@ -303,7 +303,7 @@ public: bool has_pending_drop() const; // In order for others to be able to call this, it needs to be public. - virtual bool load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)); + virtual bool load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)); protected: Widget(); @@ -403,7 +403,7 @@ inline Widget* Widget::parent_widget() return &verify_cast<Widget>(*parent()); return nullptr; } -inline const Widget* Widget::parent_widget() const +inline Widget const* Widget::parent_widget() const { if (parent() && is<Widget>(*parent())) return &verify_cast<const Widget>(*parent()); diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index 1a7bf2aa79..7035d39c38 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -43,7 +43,7 @@ public: } Gfx::Bitmap& bitmap() { return *m_bitmap; } - const Gfx::Bitmap& bitmap() const { return *m_bitmap; } + Gfx::Bitmap const& bitmap() const { return *m_bitmap; } Gfx::IntSize size() const { return m_bitmap->size(); } @@ -255,7 +255,7 @@ Gfx::IntRect Window::rect() const return ConnectionToWindowServer::the().get_window_rect(m_window_id); } -void Window::set_rect(const Gfx::IntRect& a_rect) +void Window::set_rect(Gfx::IntRect const& a_rect) { if (a_rect.location() != m_rect_when_windowless.location()) { m_moved_by_client = true; @@ -284,7 +284,7 @@ Gfx::IntSize Window::minimum_size() const return ConnectionToWindowServer::the().get_window_minimum_size(m_window_id); } -void Window::set_minimum_size(const Gfx::IntSize& size) +void Window::set_minimum_size(Gfx::IntSize const& size) { m_minimum_size_modified = true; m_minimum_size_when_windowless = size; @@ -298,7 +298,7 @@ void Window::center_on_screen() set_rect(rect().centered_within(Desktop::the().rect())); } -void Window::center_within(const Window& other) +void Window::center_within(Window const& other) { if (this == &other) return; @@ -688,7 +688,7 @@ void Window::force_update() ConnectionToWindowServer::the().async_invalidate_rect(m_window_id, { { 0, 0, rect.width(), rect.height() } }, true); } -void Window::update(const Gfx::IntRect& a_rect) +void Window::update(Gfx::IntRect const& a_rect) { if (!is_visible()) return; @@ -847,7 +847,7 @@ void Window::set_current_backing_store(WindowBackingStore& backing_store, bool f ConnectionToWindowServer::the().set_window_backing_store(m_window_id, 32, bitmap.pitch(), bitmap.anonymous_buffer().fd(), backing_store.serial(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately); } -void Window::flip(const Vector<Gfx::IntRect, 32>& dirty_rects) +void Window::flip(Vector<Gfx::IntRect, 32> const& dirty_rects) { swap(m_front_store, m_back_store); @@ -869,7 +869,7 @@ void Window::flip(const Vector<Gfx::IntRect, 32>& dirty_rects) m_back_store->bitmap().set_volatile(); } -OwnPtr<WindowBackingStore> Window::create_backing_store(const Gfx::IntSize& size) +OwnPtr<WindowBackingStore> Window::create_backing_store(Gfx::IntSize const& size) { auto format = m_has_alpha_channel ? Gfx::BitmapFormat::BGRA8888 : Gfx::BitmapFormat::BGRx8888; @@ -911,7 +911,7 @@ void Window::applet_area_rect_change_event(AppletAreaRectChangeEvent&) { } -void Window::set_icon(const Gfx::Bitmap* icon) +void Window::set_icon(Gfx::Bitmap const* icon) { if (m_icon == icon) return; @@ -1096,7 +1096,7 @@ void Window::notify_state_changed(Badge<ConnectionToWindowServer>, bool minimize } } -Action* Window::action_for_key_event(const KeyEvent& event) +Action* Window::action_for_key_event(KeyEvent const& event) { Shortcut shortcut(event.modifiers(), (KeyCode)event.key()); Action* found_action = nullptr; @@ -1110,7 +1110,7 @@ Action* Window::action_for_key_event(const KeyEvent& event) return found_action; } -void Window::set_base_size(const Gfx::IntSize& base_size) +void Window::set_base_size(Gfx::IntSize const& base_size) { if (m_base_size == base_size) return; @@ -1119,7 +1119,7 @@ void Window::set_base_size(const Gfx::IntSize& base_size) ConnectionToWindowServer::the().async_set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment); } -void Window::set_size_increment(const Gfx::IntSize& size_increment) +void Window::set_size_increment(Gfx::IntSize const& size_increment) { if (m_size_increment == size_increment) return; @@ -1128,7 +1128,7 @@ void Window::set_size_increment(const Gfx::IntSize& size_increment) ConnectionToWindowServer::the().async_set_window_base_size_and_size_increment(m_window_id, m_base_size, m_size_increment); } -void Window::set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio) +void Window::set_resize_aspect_ratio(Optional<Gfx::IntSize> const& ratio) { if (m_resize_aspect_ratio == ratio) return; @@ -1219,7 +1219,7 @@ Menu& Window::add_menu(String name) return *menu; } -void Window::flash_menubar_menu_for(const MenuItem& menu_item) +void Window::flash_menubar_menu_for(MenuItem const& menu_item) { auto menu_id = menu_item.menu_id(); if (menu_id < 0) diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h index 102d834eb7..d8c10ba877 100644 --- a/Userland/Libraries/LibGUI/Window.h +++ b/Userland/Libraries/LibGUI/Window.h @@ -93,23 +93,23 @@ public: Gfx::IntRect rect() const; Gfx::IntRect applet_rect_on_screen() const; Gfx::IntSize size() const { return rect().size(); } - void set_rect(const Gfx::IntRect&); + void set_rect(Gfx::IntRect const&); void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } Gfx::IntPoint position() const { return rect().location(); } Gfx::IntSize minimum_size() const; - void set_minimum_size(const Gfx::IntSize&); + void set_minimum_size(Gfx::IntSize const&); void set_minimum_size(int width, int height) { set_minimum_size({ width, height }); } void move_to(int x, int y) { move_to({ x, y }); } - void move_to(const Gfx::IntPoint& point) { set_rect({ point, size() }); } + void move_to(Gfx::IntPoint const& point) { set_rect({ point, size() }); } void resize(int width, int height) { resize({ width, height }); } - void resize(const Gfx::IntSize& size) { set_rect({ position(), size }); } + void resize(Gfx::IntSize const& size) { set_rect({ position(), size }); } void center_on_screen(); - void center_within(const Window&); + void center_within(Window const&); virtual void event(Core::Event&) override; @@ -128,7 +128,7 @@ public: void start_interactive_resize(); Widget* main_widget() { return m_main_widget; } - const Widget* main_widget() const { return m_main_widget; } + Widget const* main_widget() const { return m_main_widget; } void set_main_widget(Widget*); template<class T, class... Args> @@ -152,37 +152,37 @@ public: void set_default_return_key_widget(Widget*); Widget* focused_widget() { return m_focused_widget; } - const Widget* focused_widget() const { return m_focused_widget; } + Widget const* focused_widget() const { return m_focused_widget; } void set_focused_widget(Widget*, FocusSource = FocusSource::Programmatic); void update(); - void update(const Gfx::IntRect&); + void update(Gfx::IntRect const&); void set_automatic_cursor_tracking_widget(Widget*); Widget* automatic_cursor_tracking_widget() { return m_automatic_cursor_tracking_widget.ptr(); } - const Widget* automatic_cursor_tracking_widget() const { return m_automatic_cursor_tracking_widget.ptr(); } + Widget const* automatic_cursor_tracking_widget() const { return m_automatic_cursor_tracking_widget.ptr(); } Widget* hovered_widget() { return m_hovered_widget.ptr(); } - const Widget* hovered_widget() const { return m_hovered_widget.ptr(); } + Widget const* hovered_widget() const { return m_hovered_widget.ptr(); } void set_hovered_widget(Widget*); Gfx::Bitmap* back_bitmap(); Gfx::IntSize size_increment() const { return m_size_increment; } - void set_size_increment(const Gfx::IntSize&); + void set_size_increment(Gfx::IntSize const&); Gfx::IntSize base_size() const { return m_base_size; } - void set_base_size(const Gfx::IntSize&); - const Optional<Gfx::IntSize>& resize_aspect_ratio() const { return m_resize_aspect_ratio; } + void set_base_size(Gfx::IntSize const&); + Optional<Gfx::IntSize> const& resize_aspect_ratio() const { return m_resize_aspect_ratio; } void set_resize_aspect_ratio(int width, int height) { set_resize_aspect_ratio(Gfx::IntSize(width, height)); } void set_no_resize_aspect_ratio() { set_resize_aspect_ratio({}); } - void set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio); + void set_resize_aspect_ratio(Optional<Gfx::IntSize> const& ratio); void set_cursor(Gfx::StandardCursor); void set_cursor(NonnullRefPtr<Gfx::Bitmap>); - void set_icon(const Gfx::Bitmap*); + void set_icon(Gfx::Bitmap const*); void apply_icon(); - const Gfx::Bitmap* icon() const { return m_icon.ptr(); } + Gfx::Bitmap const* icon() const { return m_icon.ptr(); } Vector<Widget&> focusable_widgets(FocusSource) const; @@ -196,7 +196,7 @@ public: virtual bool is_visible_for_timer_purposes() const override { return m_visible_for_timer_purposes; } - Action* action_for_key_event(const KeyEvent&); + Action* action_for_key_event(KeyEvent const&); void did_add_widget(Badge<Widget>, Widget&); void did_remove_widget(Badge<Widget>, Widget&); @@ -211,7 +211,7 @@ public: Menu& add_menu(String name); ErrorOr<NonnullRefPtr<Menu>> try_add_menu(String name); - void flash_menubar_menu_for(const MenuItem&); + void flash_menubar_menu_for(MenuItem const&); void flush_pending_paints_immediately(); @@ -249,9 +249,9 @@ private: void server_did_destroy(); - OwnPtr<WindowBackingStore> create_backing_store(const Gfx::IntSize&); + OwnPtr<WindowBackingStore> create_backing_store(Gfx::IntSize const&); void set_current_backing_store(WindowBackingStore&, bool flush_immediately = false); - void flip(const Vector<Gfx::IntRect, 32>& dirty_rects); + void flip(Vector<Gfx::IntRect, 32> const& dirty_rects); void force_update(); bool are_cursors_the_same(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const&, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const&) const; diff --git a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp index 72f297c761..967671d951 100644 --- a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp +++ b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp @@ -36,12 +36,12 @@ CoverWizardPage::CoverWizardPage() m_body_label->set_text_alignment(Gfx::TextAlignment::TopLeft); } -void CoverWizardPage::set_header_text(const String& text) +void CoverWizardPage::set_header_text(String const& text) { m_header_label->set_text(text); } -void CoverWizardPage::set_body_text(const String& text) +void CoverWizardPage::set_body_text(String const& text) { m_body_label->set_text(text); } diff --git a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.h b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.h index 4c7e7c534e..753dd74723 100644 --- a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.h +++ b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.h @@ -18,8 +18,8 @@ class CoverWizardPage : public AbstractWizardPage { ImageWidget& banner_image_widget() { return *m_banner_image_widget; } - void set_header_text(const String& text); - void set_body_text(const String& text); + void set_header_text(String const& text); + void set_body_text(String const& text); private: explicit CoverWizardPage(); diff --git a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp index a08f5e879f..d67ed97080 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp +++ b/Userland/Libraries/LibGUI/Wizards/WizardPage.cpp @@ -14,7 +14,7 @@ namespace GUI { -WizardPage::WizardPage(const String& title_text, const String& subtitle_text) +WizardPage::WizardPage(String const& title_text, String const& subtitle_text) : AbstractWizardPage() { set_layout<VerticalBoxLayout>(); @@ -44,12 +44,12 @@ WizardPage::WizardPage(const String& title_text, const String& subtitle_text) m_body_widget->layout()->set_margins(20); } -void WizardPage::set_page_title(const String& text) +void WizardPage::set_page_title(String const& text) { m_title_label->set_text(text); } -void WizardPage::set_page_subtitle(const String& text) +void WizardPage::set_page_subtitle(String const& text) { m_subtitle_label->set_text(text); } diff --git a/Userland/Libraries/LibGUI/Wizards/WizardPage.h b/Userland/Libraries/LibGUI/Wizards/WizardPage.h index b3c5d8e38e..3dfe2430ac 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardPage.h +++ b/Userland/Libraries/LibGUI/Wizards/WizardPage.h @@ -18,11 +18,11 @@ class WizardPage : public AbstractWizardPage { Widget& body_widget() { return *m_body_widget; }; - void set_page_title(const String& text); - void set_page_subtitle(const String& text); + void set_page_title(String const& text); + void set_page_subtitle(String const& text); private: - explicit WizardPage(const String& title_text, const String& subtitle_text); + explicit WizardPage(String const& title_text, String const& subtitle_text); RefPtr<Widget> m_body_widget; diff --git a/Userland/Libraries/LibGemini/Document.h b/Userland/Libraries/LibGemini/Document.h index 493dbc73fd..578ad24e3e 100644 --- a/Userland/Libraries/LibGemini/Document.h +++ b/Userland/Libraries/LibGemini/Document.h @@ -62,7 +62,7 @@ public: class Link : public Line { public: - Link(String line, const Document&); + Link(String line, Document const&); virtual ~Link() override = default; virtual String render_to_html() const override; diff --git a/Userland/Libraries/LibGemini/GeminiRequest.cpp b/Userland/Libraries/LibGemini/GeminiRequest.cpp index 4059ddec1b..eda8439b1d 100644 --- a/Userland/Libraries/LibGemini/GeminiRequest.cpp +++ b/Userland/Libraries/LibGemini/GeminiRequest.cpp @@ -18,7 +18,7 @@ ByteBuffer GeminiRequest::to_raw_request() const return builder.to_byte_buffer(); } -Optional<GeminiRequest> GeminiRequest::from_raw_request(const ByteBuffer& raw_request) +Optional<GeminiRequest> GeminiRequest::from_raw_request(ByteBuffer const& raw_request) { URL url = StringView(raw_request); if (!url.is_valid()) diff --git a/Userland/Libraries/LibGemini/GeminiRequest.h b/Userland/Libraries/LibGemini/GeminiRequest.h index 206ab2ad79..fdfa99739c 100644 --- a/Userland/Libraries/LibGemini/GeminiRequest.h +++ b/Userland/Libraries/LibGemini/GeminiRequest.h @@ -23,7 +23,7 @@ public: ByteBuffer to_raw_request() const; - static Optional<GeminiRequest> from_raw_request(const ByteBuffer&); + static Optional<GeminiRequest> from_raw_request(ByteBuffer const&); private: URL m_url; diff --git a/Userland/Libraries/LibGemini/Job.cpp b/Userland/Libraries/LibGemini/Job.cpp index 3051b626eb..5696a47632 100644 --- a/Userland/Libraries/LibGemini/Job.cpp +++ b/Userland/Libraries/LibGemini/Job.cpp @@ -12,7 +12,7 @@ namespace Gemini { -Job::Job(const GeminiRequest& request, Core::Stream::Stream& output_stream) +Job::Job(GeminiRequest const& request, Core::Stream::Stream& output_stream) : Core::NetworkJob(output_stream) , m_request(request) { diff --git a/Userland/Libraries/LibGemini/Job.h b/Userland/Libraries/LibGemini/Job.h index ca9342eb0c..7593f5345e 100644 --- a/Userland/Libraries/LibGemini/Job.h +++ b/Userland/Libraries/LibGemini/Job.h @@ -17,14 +17,14 @@ class Job : public Core::NetworkJob { C_OBJECT(Job); public: - explicit Job(const GeminiRequest&, Core::Stream::Stream&); + explicit Job(GeminiRequest const&, Core::Stream::Stream&); virtual ~Job() override = default; virtual void start(Core::Stream::Socket&) override; virtual void shutdown(ShutdownMode) override; GeminiResponse* response() { return static_cast<GeminiResponse*>(Core::NetworkJob::response()); } - const GeminiResponse* response() const { return static_cast<const GeminiResponse*>(Core::NetworkJob::response()); } + GeminiResponse const* response() const { return static_cast<GeminiResponse const*>(Core::NetworkJob::response()); } const URL& url() const { return m_request.url(); } Core::Stream::Socket const* socket() const { return m_socket; } diff --git a/Userland/Libraries/LibGemini/Line.cpp b/Userland/Libraries/LibGemini/Line.cpp index 8cfbe91344..5e5b2dd810 100644 --- a/Userland/Libraries/LibGemini/Line.cpp +++ b/Userland/Libraries/LibGemini/Line.cpp @@ -52,7 +52,7 @@ String Control::render_to_html() const } } -Link::Link(String text, const Document& document) +Link::Link(String text, Document const& document) : Line(move(text)) { size_t index = 2; diff --git a/Userland/Libraries/LibGfx/AffineTransform.cpp b/Userland/Libraries/LibGfx/AffineTransform.cpp index 2bd8f15f0c..3872c9be2e 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.cpp +++ b/Userland/Libraries/LibGfx/AffineTransform.cpp @@ -60,7 +60,7 @@ AffineTransform& AffineTransform::scale(float sx, float sy) return *this; } -AffineTransform& AffineTransform::scale(const FloatPoint& s) +AffineTransform& AffineTransform::scale(FloatPoint const& s) { return scale(s.x(), s.y()); } @@ -74,7 +74,7 @@ AffineTransform& AffineTransform::set_scale(float sx, float sy) return *this; } -AffineTransform& AffineTransform::set_scale(const FloatPoint& s) +AffineTransform& AffineTransform::set_scale(FloatPoint const& s) { return set_scale(s.x(), s.y()); } @@ -86,7 +86,7 @@ AffineTransform& AffineTransform::translate(float tx, float ty) return *this; } -AffineTransform& AffineTransform::translate(const FloatPoint& t) +AffineTransform& AffineTransform::translate(FloatPoint const& t) { return translate(t.x(), t.y()); } @@ -98,12 +98,12 @@ AffineTransform& AffineTransform::set_translation(float tx, float ty) return *this; } -AffineTransform& AffineTransform::set_translation(const FloatPoint& t) +AffineTransform& AffineTransform::set_translation(FloatPoint const& t) { return set_translation(t.x(), t.y()); } -AffineTransform& AffineTransform::multiply(const AffineTransform& other) +AffineTransform& AffineTransform::multiply(AffineTransform const& other) { AffineTransform result; result.m_values[0] = other.a() * a() + other.b() * c(); @@ -147,7 +147,7 @@ void AffineTransform::map(float unmapped_x, float unmapped_y, float& mapped_x, f } template<> -IntPoint AffineTransform::map(const IntPoint& point) const +IntPoint AffineTransform::map(IntPoint const& point) const { float mapped_x; float mapped_y; @@ -156,7 +156,7 @@ IntPoint AffineTransform::map(const IntPoint& point) const } template<> -FloatPoint AffineTransform::map(const FloatPoint& point) const +FloatPoint AffineTransform::map(FloatPoint const& point) const { float mapped_x; float mapped_y; @@ -165,7 +165,7 @@ FloatPoint AffineTransform::map(const FloatPoint& point) const } template<> -IntSize AffineTransform::map(const IntSize& size) const +IntSize AffineTransform::map(IntSize const& size) const { return { roundf(static_cast<float>(size.width()) * x_scale()), @@ -174,7 +174,7 @@ IntSize AffineTransform::map(const IntSize& size) const } template<> -FloatSize AffineTransform::map(const FloatSize& size) const +FloatSize AffineTransform::map(FloatSize const& size) const { return { size.width() * x_scale(), size.height() * y_scale() }; } @@ -192,7 +192,7 @@ static T largest_of(T p1, T p2, T p3, T p4) } template<> -FloatRect AffineTransform::map(const FloatRect& rect) const +FloatRect AffineTransform::map(FloatRect const& rect) const { FloatPoint p1 = map(rect.top_left()); FloatPoint p2 = map(rect.top_right().translated(1, 0)); @@ -206,7 +206,7 @@ FloatRect AffineTransform::map(const FloatRect& rect) const } template<> -IntRect AffineTransform::map(const IntRect& rect) const +IntRect AffineTransform::map(IntRect const& rect) const { return enclosing_int_rect(map(FloatRect(rect))); } diff --git a/Userland/Libraries/LibGfx/AffineTransform.h b/Userland/Libraries/LibGfx/AffineTransform.h index c2fc79820e..87a8f30b7a 100644 --- a/Userland/Libraries/LibGfx/AffineTransform.h +++ b/Userland/Libraries/LibGfx/AffineTransform.h @@ -29,13 +29,13 @@ public: void map(float unmapped_x, float unmapped_y, float& mapped_x, float& mapped_y) const; template<typename T> - Point<T> map(const Point<T>&) const; + Point<T> map(Point<T> const&) const; template<typename T> - Size<T> map(const Size<T>&) const; + Size<T> map(Size<T> const&) const; template<typename T> - Rect<T> map(const Rect<T>&) const; + Rect<T> map(Rect<T> const&) const; [[nodiscard]] ALWAYS_INLINE float a() const { return m_values[0]; } [[nodiscard]] ALWAYS_INLINE float b() const { return m_values[1]; } @@ -52,15 +52,15 @@ public: [[nodiscard]] FloatPoint translation() const; AffineTransform& scale(float sx, float sy); - AffineTransform& scale(const FloatPoint& s); + AffineTransform& scale(FloatPoint const& s); AffineTransform& set_scale(float sx, float sy); - AffineTransform& set_scale(const FloatPoint& s); + AffineTransform& set_scale(FloatPoint const& s); AffineTransform& translate(float tx, float ty); - AffineTransform& translate(const FloatPoint& t); + AffineTransform& translate(FloatPoint const& t); AffineTransform& set_translation(float tx, float ty); - AffineTransform& set_translation(const FloatPoint& t); + AffineTransform& set_translation(FloatPoint const& t); AffineTransform& rotate_radians(float); - AffineTransform& multiply(const AffineTransform&); + AffineTransform& multiply(AffineTransform const&); Optional<AffineTransform> inverse() const; diff --git a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp index 8d6cbe1010..b4a3bcd001 100644 --- a/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp +++ b/Userland/Libraries/LibGfx/AntiAliasingPainter.cpp @@ -179,7 +179,7 @@ void Gfx::AntiAliasingPainter::draw_quadratic_bezier_curve(FloatPoint const& con }); } -void Gfx::AntiAliasingPainter::draw_cubic_bezier_curve(const FloatPoint& control_point_0, const FloatPoint& control_point_1, const FloatPoint& p1, const FloatPoint& p2, Color color, float thickness, Painter::LineStyle style) +void Gfx::AntiAliasingPainter::draw_cubic_bezier_curve(FloatPoint const& control_point_0, FloatPoint const& control_point_1, FloatPoint const& p1, FloatPoint const& p2, Color color, float thickness, Painter::LineStyle style) { Gfx::Painter::for_each_line_segment_on_cubic_bezier_curve(control_point_0, control_point_1, p1, p2, [&](FloatPoint const& fp1, FloatPoint const& fp2) { draw_line(fp1, fp2, color, thickness, style); @@ -200,9 +200,9 @@ void Gfx::AntiAliasingPainter::draw_circle(IntPoint center, int radius, Color co // These happen to be the same here, but are treated separately in the paper: // intensity is the fill alpha - const int intensity = color.alpha(); + int const intensity = color.alpha(); // 0 to subpixel_resolution is the range of alpha values for the circle edges - const int subpixel_resolution = intensity; + int const subpixel_resolution = intensity; // Note: Variable names below are based off the paper diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp index 841e50aef6..38f3098a63 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/BMPLoader.cpp @@ -130,7 +130,7 @@ struct BMPLoadingContext { }; State state { State::NotDecoded }; - const u8* file_bytes { nullptr }; + u8 const* file_bytes { nullptr }; size_t file_size { 0 }; u32 data_offset { 0 }; @@ -167,7 +167,7 @@ struct BMPLoadingContext { class InputStreamer { public: - InputStreamer(const u8* data, size_t size) + InputStreamer(u8 const* data, size_t size) : m_data_ptr(data) , m_size_remaining(size) { @@ -217,7 +217,7 @@ public: size_t remaining() const { return m_size_remaining; } private: - const u8* m_data_ptr { nullptr }; + u8 const* m_data_ptr { nullptr }; size_t m_size_remaining { 0 }; }; @@ -1300,7 +1300,7 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context) return true; } -BMPImageDecoderPlugin::BMPImageDecoderPlugin(const u8* data, size_t data_size) +BMPImageDecoderPlugin::BMPImageDecoderPlugin(u8 const* data, size_t data_size) { m_context = make<BMPLoadingContext>(); m_context->file_bytes = data; diff --git a/Userland/Libraries/LibGfx/BMPLoader.h b/Userland/Libraries/LibGfx/BMPLoader.h index a690f32619..4351d6f4b4 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.h +++ b/Userland/Libraries/LibGfx/BMPLoader.h @@ -15,7 +15,7 @@ struct BMPLoadingContext; class BMPImageDecoderPlugin final : public ImageDecoderPlugin { public: virtual ~BMPImageDecoderPlugin() override; - BMPImageDecoderPlugin(const u8*, size_t); + BMPImageDecoderPlugin(u8 const*, size_t); virtual IntSize size() override; virtual void set_volatile() override; diff --git a/Userland/Libraries/LibGfx/BMPWriter.cpp b/Userland/Libraries/LibGfx/BMPWriter.cpp index 0de6bf3417..9b4a9c08ec 100644 --- a/Userland/Libraries/LibGfx/BMPWriter.cpp +++ b/Userland/Libraries/LibGfx/BMPWriter.cpp @@ -42,7 +42,7 @@ private: u8* m_data; }; -static ByteBuffer write_pixel_data(const RefPtr<Bitmap> bitmap, int pixel_row_data_size, int bytes_per_pixel, bool include_alpha_channel) +static ByteBuffer write_pixel_data(RefPtr<Bitmap> const bitmap, int pixel_row_data_size, int bytes_per_pixel, bool include_alpha_channel) { int image_size = pixel_row_data_size * bitmap->height(); auto buffer_result = ByteBuffer::create_uninitialized(image_size); @@ -67,7 +67,7 @@ static ByteBuffer write_pixel_data(const RefPtr<Bitmap> bitmap, int pixel_row_da return buffer; } -static ByteBuffer compress_pixel_data(const ByteBuffer& pixel_data, BMPWriter::Compression compression) +static ByteBuffer compress_pixel_data(ByteBuffer const& pixel_data, BMPWriter::Compression compression) { switch (compression) { case BMPWriter::Compression::BI_BITFIELDS: @@ -78,7 +78,7 @@ static ByteBuffer compress_pixel_data(const ByteBuffer& pixel_data, BMPWriter::C VERIFY_NOT_REACHED(); } -ByteBuffer BMPWriter::dump(const RefPtr<Bitmap> bitmap, DibHeader dib_header) +ByteBuffer BMPWriter::dump(RefPtr<Bitmap> const bitmap, DibHeader dib_header) { switch (dib_header) { diff --git a/Userland/Libraries/LibGfx/BMPWriter.h b/Userland/Libraries/LibGfx/BMPWriter.h index fad1c1820a..0dc3c2c0ba 100644 --- a/Userland/Libraries/LibGfx/BMPWriter.h +++ b/Userland/Libraries/LibGfx/BMPWriter.h @@ -27,7 +27,7 @@ public: V4 = 108, }; - ByteBuffer dump(const RefPtr<Bitmap>, DibHeader dib_header = DibHeader::V4); + ByteBuffer dump(RefPtr<Bitmap> const, DibHeader dib_header = DibHeader::V4); inline void set_compression(Compression compression) { m_compression = compression; } diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index 3a4d3b416e..22cb56ff64 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -173,7 +173,7 @@ BitmapFont::~BitmapFont() RefPtr<BitmapFont> BitmapFont::load_from_memory(u8 const* data) { - auto const& header = *reinterpret_cast<const FontFileHeader*>(data); + auto const& header = *reinterpret_cast<FontFileHeader const*>(data); if (memcmp(header.magic, "!Fnt", 4)) { dbgln("header.magic != '!Fnt', instead it's '{:c}{:c}{:c}{:c}'", header.magic[0], header.magic[1], header.magic[2], header.magic[3]); return nullptr; diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp index 1451e5ba89..77f1bff323 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp @@ -16,7 +16,7 @@ namespace Gfx { static constexpr int menubar_height = 20; -Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const +Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, IntRect const& window_rect, Palette const& palette) const { if (window_type == WindowType::ToolWindow) return {}; @@ -33,7 +33,7 @@ Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, cons return icon_rect; } -Gfx::IntRect ClassicWindowTheme::titlebar_text_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const +Gfx::IntRect ClassicWindowTheme::titlebar_text_rect(WindowType window_type, IntRect const& window_rect, Palette const& palette) const { auto titlebar_rect = this->titlebar_rect(window_type, window_rect, palette); auto titlebar_icon_rect = this->titlebar_icon_rect(window_type, window_rect, palette); @@ -45,7 +45,7 @@ Gfx::IntRect ClassicWindowTheme::titlebar_text_rect(WindowType window_type, cons }; } -void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, StringView window_title, const Bitmap& icon, const Palette& palette, const IntRect& leftmost_button_rect, int menu_row_count, [[maybe_unused]] bool window_modified) const +void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window_state, IntRect const& window_rect, StringView window_title, Bitmap const& icon, Palette const& palette, IntRect const& leftmost_button_rect, int menu_row_count, [[maybe_unused]] bool window_modified) const { auto frame_rect = frame_rect_for_window(WindowType::Normal, window_rect, palette, menu_row_count); frame_rect.set_location({ 0, 0 }); @@ -112,7 +112,7 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window painter.draw_scaled_bitmap(titlebar_icon_rect, icon, icon.rect()); } -void ClassicWindowTheme::paint_tool_window_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, StringView title_text, const Palette& palette, const IntRect& leftmost_button_rect) const +void ClassicWindowTheme::paint_tool_window_frame(Painter& painter, WindowState window_state, IntRect const& window_rect, StringView title_text, Palette const& palette, IntRect const& leftmost_button_rect) const { auto frame_rect = frame_rect_for_window(WindowType::ToolWindow, window_rect, palette, 0); frame_rect.set_location({ 0, 0 }); @@ -143,14 +143,14 @@ void ClassicWindowTheme::paint_tool_window_frame(Painter& painter, WindowState w } } -IntRect ClassicWindowTheme::menubar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette, int menu_row_count) const +IntRect ClassicWindowTheme::menubar_rect(WindowType window_type, IntRect const& window_rect, Palette const& palette, int menu_row_count) const { if (window_type != WindowType::Normal) return {}; return { palette.window_border_thickness(), palette.window_border_thickness() - 1 + titlebar_height(window_type, palette) + 2, window_rect.width(), menubar_height * menu_row_count }; } -IntRect ClassicWindowTheme::titlebar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const +IntRect ClassicWindowTheme::titlebar_rect(WindowType window_type, IntRect const& window_rect, Palette const& palette) const { auto& title_font = FontDatabase::default_font().bold_variant(); auto window_titlebar_height = titlebar_height(window_type, palette); @@ -162,7 +162,7 @@ IntRect ClassicWindowTheme::titlebar_rect(WindowType window_type, const IntRect& return { palette.window_border_thickness(), palette.window_border_thickness(), window_rect.width(), window_titlebar_height }; } -ClassicWindowTheme::FrameColors ClassicWindowTheme::compute_frame_colors(WindowState state, const Palette& palette) const +ClassicWindowTheme::FrameColors ClassicWindowTheme::compute_frame_colors(WindowState state, Palette const& palette) const { switch (state) { case WindowState::Highlighted: @@ -178,7 +178,7 @@ ClassicWindowTheme::FrameColors ClassicWindowTheme::compute_frame_colors(WindowS } } -void ClassicWindowTheme::paint_notification_frame(Painter& painter, const IntRect& window_rect, const Palette& palette, const IntRect& close_button_rect) const +void ClassicWindowTheme::paint_notification_frame(Painter& painter, IntRect const& window_rect, Palette const& palette, IntRect const& close_button_rect) const { auto frame_rect = frame_rect_for_window(WindowType::Notification, window_rect, palette, 0); frame_rect.set_location({ 0, 0 }); @@ -198,7 +198,7 @@ void ClassicWindowTheme::paint_notification_frame(Painter& painter, const IntRec } } -IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const IntRect& window_rect, const Gfx::Palette& palette, int menu_row_count) const +IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, IntRect const& window_rect, Gfx::Palette const& palette, int menu_row_count) const { auto window_titlebar_height = titlebar_height(window_type, palette); auto border_thickness = palette.window_border_thickness(); @@ -224,7 +224,7 @@ IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const } } -Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const IntRect& window_rect, const Palette& palette, size_t buttons) const +Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, IntRect const& window_rect, Palette const& palette, size_t buttons) const { int window_button_width = palette.window_title_button_width(); int window_button_height = palette.window_title_button_height(); @@ -252,7 +252,7 @@ Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const return button_rects; } -int ClassicWindowTheme::titlebar_height(WindowType window_type, const Palette& palette) const +int ClassicWindowTheme::titlebar_height(WindowType window_type, Palette const& palette) const { auto& title_font = FontDatabase::default_font().bold_variant(); switch (window_type) { diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.h b/Userland/Libraries/LibGfx/ClassicWindowTheme.h index 0aaa7f101e..8e2aff0fb1 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.h +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.h @@ -16,22 +16,22 @@ public: ClassicWindowTheme() = default; virtual ~ClassicWindowTheme() override = default; - virtual void paint_normal_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, StringView window_title, const Bitmap& icon, const Palette& palette, const IntRect& leftmost_button_rect, int menu_row_count, bool window_modified) const override; - virtual void paint_tool_window_frame(Painter&, WindowState, const IntRect& window_rect, StringView title, const Palette&, const IntRect& leftmost_button_rect) const override; - virtual void paint_notification_frame(Painter&, const IntRect& window_rect, const Palette&, const IntRect& close_button_rect) const override; + virtual void paint_normal_frame(Painter& painter, WindowState window_state, IntRect const& window_rect, StringView window_title, Bitmap const& icon, Palette const& palette, IntRect const& leftmost_button_rect, int menu_row_count, bool window_modified) const override; + virtual void paint_tool_window_frame(Painter&, WindowState, IntRect const& window_rect, StringView title, Palette const&, IntRect const& leftmost_button_rect) const override; + virtual void paint_notification_frame(Painter&, IntRect const& window_rect, Palette const&, IntRect const& close_button_rect) const override; - virtual int titlebar_height(WindowType, const Palette&) const override; - virtual IntRect titlebar_rect(WindowType, const IntRect& window_rect, const Palette&) const override; - virtual IntRect titlebar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const override; - virtual IntRect titlebar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const override; + virtual int titlebar_height(WindowType, Palette const&) const override; + virtual IntRect titlebar_rect(WindowType, IntRect const& window_rect, Palette const&) const override; + virtual IntRect titlebar_icon_rect(WindowType, IntRect const& window_rect, Palette const&) const override; + virtual IntRect titlebar_text_rect(WindowType, IntRect const& window_rect, Palette const&) const override; - virtual IntRect menubar_rect(WindowType, const IntRect& window_rect, const Palette&, int menu_row_count) const override; + virtual IntRect menubar_rect(WindowType, IntRect const& window_rect, Palette const&, int menu_row_count) const override; - virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&, int menu_row_count) const override; + virtual IntRect frame_rect_for_window(WindowType, IntRect const& window_rect, Palette const&, int menu_row_count) const override; - virtual Vector<IntRect> layout_buttons(WindowType, const IntRect& window_rect, const Palette&, size_t buttons) const override; + virtual Vector<IntRect> layout_buttons(WindowType, IntRect const& window_rect, Palette const&, size_t buttons) const override; virtual bool is_simple_rect_frame() const override { return true; } - virtual bool frame_uses_alpha(WindowState state, const Palette& palette) const override + virtual bool frame_uses_alpha(WindowState state, Palette const& palette) const override { return compute_frame_colors(state, palette).uses_alpha(); } @@ -54,7 +54,7 @@ private: } }; - FrameColors compute_frame_colors(WindowState, const Palette&) const; + FrameColors compute_frame_colors(WindowState, Palette const&) const; }; } diff --git a/Userland/Libraries/LibGfx/Color.h b/Userland/Libraries/LibGfx/Color.h index 1c158dd8d0..900e23f6b9 100644 --- a/Userland/Libraries/LibGfx/Color.h +++ b/Userland/Libraries/LibGfx/Color.h @@ -185,7 +185,7 @@ public: source.blue() }; - const int d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha(); + int const d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha(); const i32x4 out = (color * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source_color) / d; return Color(out[0], out[1], out[2], d / 255); #else diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp index 64ef66267b..d6a78b4997 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.cpp +++ b/Userland/Libraries/LibGfx/DDSLoader.cpp @@ -34,7 +34,7 @@ struct DDSLoadingContext { State state { State::NotDecoded }; - const u8* data { nullptr }; + u8 const* data { nullptr }; size_t data_size { 0 }; DDSHeader header; @@ -937,7 +937,7 @@ void DDSLoadingContext::dump_debug() dbgln("{}", builder.to_string()); } -DDSImageDecoderPlugin::DDSImageDecoderPlugin(const u8* data, size_t size) +DDSImageDecoderPlugin::DDSImageDecoderPlugin(u8 const* data, size_t size) { m_context = make<DDSLoadingContext>(); m_context->data = data; diff --git a/Userland/Libraries/LibGfx/DDSLoader.h b/Userland/Libraries/LibGfx/DDSLoader.h index a313d7d3e2..87321d79df 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.h +++ b/Userland/Libraries/LibGfx/DDSLoader.h @@ -236,7 +236,7 @@ struct DDSLoadingContext; class DDSImageDecoderPlugin final : public ImageDecoderPlugin { public: virtual ~DDSImageDecoderPlugin() override; - DDSImageDecoderPlugin(const u8*, size_t); + DDSImageDecoderPlugin(u8 const*, size_t); virtual IntSize size() override; virtual void set_volatile() override; diff --git a/Userland/Libraries/LibGfx/DisjointRectSet.cpp b/Userland/Libraries/LibGfx/DisjointRectSet.cpp index e2a4a0b181..20a95bc4c8 100644 --- a/Userland/Libraries/LibGfx/DisjointRectSet.cpp +++ b/Userland/Libraries/LibGfx/DisjointRectSet.cpp @@ -8,7 +8,7 @@ namespace Gfx { -bool DisjointRectSet::add_no_shatter(const IntRect& new_rect) +bool DisjointRectSet::add_no_shatter(IntRect const& new_rect) { if (new_rect.is_empty()) return false; @@ -59,7 +59,7 @@ void DisjointRectSet::move_by(int dx, int dy) r.translate_by(dx, dy); } -bool DisjointRectSet::contains(const IntRect& rect) const +bool DisjointRectSet::contains(IntRect const& rect) const { if (is_empty() || rect.is_empty()) return false; @@ -75,7 +75,7 @@ bool DisjointRectSet::contains(const IntRect& rect) const return false; } -bool DisjointRectSet::intersects(const IntRect& rect) const +bool DisjointRectSet::intersects(IntRect const& rect) const { for (auto& r : m_rects) { if (r.intersects(rect)) @@ -84,7 +84,7 @@ bool DisjointRectSet::intersects(const IntRect& rect) const return false; } -bool DisjointRectSet::intersects(const DisjointRectSet& rects) const +bool DisjointRectSet::intersects(DisjointRectSet const& rects) const { if (this == &rects) return true; @@ -98,7 +98,7 @@ bool DisjointRectSet::intersects(const DisjointRectSet& rects) const return false; } -DisjointRectSet DisjointRectSet::intersected(const IntRect& rect) const +DisjointRectSet DisjointRectSet::intersected(IntRect const& rect) const { DisjointRectSet intersected_rects; intersected_rects.m_rects.ensure_capacity(m_rects.capacity()); @@ -111,7 +111,7 @@ DisjointRectSet DisjointRectSet::intersected(const IntRect& rect) const return intersected_rects; } -DisjointRectSet DisjointRectSet::intersected(const DisjointRectSet& rects) const +DisjointRectSet DisjointRectSet::intersected(DisjointRectSet const& rects) const { if (&rects == this) return clone(); @@ -131,7 +131,7 @@ DisjointRectSet DisjointRectSet::intersected(const DisjointRectSet& rects) const return intersected_rects; } -DisjointRectSet DisjointRectSet::shatter(const IntRect& hammer) const +DisjointRectSet DisjointRectSet::shatter(IntRect const& hammer) const { if (hammer.is_empty()) return clone(); @@ -145,7 +145,7 @@ DisjointRectSet DisjointRectSet::shatter(const IntRect& hammer) const return shards; } -DisjointRectSet DisjointRectSet::shatter(const DisjointRectSet& hammer) const +DisjointRectSet DisjointRectSet::shatter(DisjointRectSet const& hammer) const { if (this == &hammer) return {}; diff --git a/Userland/Libraries/LibGfx/DisjointRectSet.h b/Userland/Libraries/LibGfx/DisjointRectSet.h index 9a256566e8..d6ce6fa074 100644 --- a/Userland/Libraries/LibGfx/DisjointRectSet.h +++ b/Userland/Libraries/LibGfx/DisjointRectSet.h @@ -14,13 +14,13 @@ namespace Gfx { class DisjointRectSet { public: - DisjointRectSet(const DisjointRectSet&) = delete; - DisjointRectSet& operator=(const DisjointRectSet&) = delete; + DisjointRectSet(DisjointRectSet const&) = delete; + DisjointRectSet& operator=(DisjointRectSet const&) = delete; DisjointRectSet() = default; ~DisjointRectSet() = default; - DisjointRectSet(const IntRect& rect) + DisjointRectSet(IntRect const& rect) { m_rects.append(rect); } @@ -36,22 +36,22 @@ public: } void move_by(int dx, int dy); - void move_by(const IntPoint& delta) + void move_by(IntPoint const& delta) { move_by(delta.x(), delta.y()); } - void add(const IntRect& rect) + void add(IntRect const& rect) { if (add_no_shatter(rect) && m_rects.size() > 1) shatter(); } template<typename Container> - void add_many(const Container& rects) + void add_many(Container const& rects) { bool added = false; - for (const auto& rect : rects) { + for (auto const& rect : rects) { if (add_no_shatter(rect)) added = true; } @@ -59,7 +59,7 @@ public: shatter(); } - void add(const DisjointRectSet& rect_set) + void add(DisjointRectSet const& rect_set) { if (this == &rect_set) return; @@ -70,17 +70,17 @@ public: } } - DisjointRectSet shatter(const IntRect&) const; - DisjointRectSet shatter(const DisjointRectSet& hammer) const; + DisjointRectSet shatter(IntRect const&) const; + DisjointRectSet shatter(DisjointRectSet const& hammer) const; - bool contains(const IntRect&) const; - bool intersects(const IntRect&) const; - bool intersects(const DisjointRectSet&) const; - DisjointRectSet intersected(const IntRect&) const; - DisjointRectSet intersected(const DisjointRectSet&) const; + bool contains(IntRect const&) const; + bool intersects(IntRect const&) const; + bool intersects(DisjointRectSet const&) const; + DisjointRectSet intersected(IntRect const&) const; + DisjointRectSet intersected(DisjointRectSet const&) const; template<typename Function> - IterationDecision for_each_intersected(const IntRect& rect, Function f) const + IterationDecision for_each_intersected(IntRect const& rect, Function f) const { if (is_empty() || rect.is_empty()) return IterationDecision::Continue; @@ -96,7 +96,7 @@ public: } template<typename Function> - IterationDecision for_each_intersected(const DisjointRectSet& rects, Function f) const + IterationDecision for_each_intersected(DisjointRectSet const& rects, Function f) const { if (is_empty() || rects.is_empty()) return IterationDecision::Continue; @@ -126,7 +126,7 @@ public: void clear() { m_rects.clear(); } void clear_with_capacity() { m_rects.clear_with_capacity(); } - const Vector<IntRect, 32>& rects() const { return m_rects; } + Vector<IntRect, 32> const& rects() const { return m_rects; } Vector<IntRect, 32> take_rects() { return move(m_rects); } void translate_by(int dx, int dy) @@ -141,7 +141,7 @@ public: } private: - bool add_no_shatter(const IntRect&); + bool add_no_shatter(IntRect const&); void shatter(); Vector<IntRect, 32> m_rects; diff --git a/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h b/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h index f42659fadc..e6c7384cd7 100644 --- a/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h +++ b/Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h @@ -34,14 +34,14 @@ class GenericConvolutionFilter : public Filter { public: class Parameters : public Filter::Parameters { public: - Parameters(const Gfx::Matrix<N, float>& kernel, bool should_wrap = false) + Parameters(Gfx::Matrix<N, float> const& kernel, bool should_wrap = false) : m_kernel(kernel) , m_should_wrap(should_wrap) { } - const Gfx::Matrix<N, float>& kernel() const { return m_kernel; } + Gfx::Matrix<N, float> const& kernel() const { return m_kernel; } Gfx::Matrix<N, float>& kernel() { return m_kernel; } bool should_wrap() const { return m_should_wrap; } @@ -64,16 +64,16 @@ public: virtual StringView class_name() const override { return "GenericConvolutionFilter"sv; } - virtual void apply(Bitmap& target_bitmap, const IntRect& target_rect, const Bitmap& source_bitmap, const IntRect& source_rect, const Filter::Parameters& parameters) override + virtual void apply(Bitmap& target_bitmap, IntRect const& target_rect, Bitmap const& source_bitmap, IntRect const& source_rect, Filter::Parameters const& parameters) override { VERIFY(parameters.is_generic_convolution_filter()); - auto& gcf_params = static_cast<const GenericConvolutionFilter::Parameters&>(parameters); + auto& gcf_params = static_cast<GenericConvolutionFilter::Parameters const&>(parameters); ApplyCache apply_cache; apply_with_cache(target_bitmap, target_rect, source_bitmap, source_rect, gcf_params, apply_cache); } - void apply_with_cache(Bitmap& target, IntRect target_rect, const Bitmap& source, const IntRect& source_rect, const GenericConvolutionFilter::Parameters& parameters, ApplyCache& apply_cache) + void apply_with_cache(Bitmap& target, IntRect target_rect, Bitmap const& source, IntRect const& source_rect, GenericConvolutionFilter::Parameters const& parameters, ApplyCache& apply_cache) { // The target area (where the filter is applied) must be entirely // contained by the source area. source_rect should be describing diff --git a/Userland/Libraries/LibGfx/Font.h b/Userland/Libraries/LibGfx/Font.h index fa0f29bc2b..be60b72546 100644 --- a/Userland/Libraries/LibGfx/Font.h +++ b/Userland/Libraries/LibGfx/Font.h @@ -22,7 +22,7 @@ namespace Gfx { class GlyphBitmap { public: GlyphBitmap() = default; - GlyphBitmap(const u8* rows, size_t start_index, IntSize size) + GlyphBitmap(u8 const* rows, size_t start_index, IntSize size) : m_rows(rows) , m_start_index(start_index) , m_size(size) @@ -48,14 +48,14 @@ private: return { const_cast<u8*>(m_rows) + bytes_per_row() * (m_start_index + y), bytes_per_row() * 8 }; } - const u8* m_rows { nullptr }; + u8 const* m_rows { nullptr }; size_t m_start_index { 0 }; IntSize m_size { 0, 0 }; }; class Glyph { public: - Glyph(const GlyphBitmap& glyph_bitmap, int left_bearing, int advance, int ascent) + Glyph(GlyphBitmap const& glyph_bitmap, int left_bearing, int advance, int ascent) : m_glyph_bitmap(glyph_bitmap) , m_left_bearing(left_bearing) , m_advance(advance) @@ -140,8 +140,8 @@ public: virtual u8 mean_line() const = 0; virtual int width(StringView) const = 0; - virtual int width(const Utf8View&) const = 0; - virtual int width(const Utf32View&) const = 0; + virtual int width(Utf8View const&) const = 0; + virtual int width(Utf32View const&) const = 0; virtual String name() const = 0; diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp index e761f5d89b..9a7645a17f 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/FontDatabase.cpp @@ -119,7 +119,7 @@ FontDatabase::FontDatabase() } } -void FontDatabase::for_each_font(Function<void(const Gfx::Font&)> callback) +void FontDatabase::for_each_font(Function<void(Gfx::Font const&)> callback) { Vector<RefPtr<Gfx::Font>> fonts; fonts.ensure_capacity(m_private->full_name_to_font_map.size()); @@ -130,7 +130,7 @@ void FontDatabase::for_each_font(Function<void(const Gfx::Font&)> callback) callback(*font); } -void FontDatabase::for_each_fixed_width_font(Function<void(const Gfx::Font&)> callback) +void FontDatabase::for_each_fixed_width_font(Function<void(Gfx::Font const&)> callback) { Vector<RefPtr<Gfx::Font>> fonts; fonts.ensure_capacity(m_private->full_name_to_font_map.size()); @@ -179,7 +179,7 @@ RefPtr<Gfx::Font> FontDatabase::get(FlyString const& family, FlyString const& va return nullptr; } -RefPtr<Typeface> FontDatabase::get_or_create_typeface(const String& family, const String& variant) +RefPtr<Typeface> FontDatabase::get_or_create_typeface(String const& family, String const& variant) { for (auto typeface : m_private->typefaces) { if (typeface->family() == family && typeface->variant() == variant) @@ -190,7 +190,7 @@ RefPtr<Typeface> FontDatabase::get_or_create_typeface(const String& family, cons return typeface; } -void FontDatabase::for_each_typeface(Function<void(const Typeface&)> callback) +void FontDatabase::for_each_typeface(Function<void(Typeface const&)> callback) { for (auto typeface : m_private->typefaces) { callback(*typeface); diff --git a/Userland/Libraries/LibGfx/FontDatabase.h b/Userland/Libraries/LibGfx/FontDatabase.h index effc8259ec..90ba0587d8 100644 --- a/Userland/Libraries/LibGfx/FontDatabase.h +++ b/Userland/Libraries/LibGfx/FontDatabase.h @@ -47,16 +47,16 @@ public: RefPtr<Gfx::Font> get(FlyString const& family, float point_size, unsigned weight, unsigned slope, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No); RefPtr<Gfx::Font> get(FlyString const& family, FlyString const& variant, float point_size, Font::AllowInexactSizeMatch = Font::AllowInexactSizeMatch::No); RefPtr<Gfx::Font> get_by_name(StringView); - void for_each_font(Function<void(const Gfx::Font&)>); - void for_each_fixed_width_font(Function<void(const Gfx::Font&)>); + void for_each_font(Function<void(Gfx::Font const&)>); + void for_each_fixed_width_font(Function<void(Gfx::Font const&)>); - void for_each_typeface(Function<void(const Typeface&)>); + void for_each_typeface(Function<void(Typeface const&)>); private: FontDatabase(); ~FontDatabase() = default; - RefPtr<Typeface> get_or_create_typeface(const String& family, const String& variant); + RefPtr<Typeface> get_or_create_typeface(String const& family, String const& variant); struct Private; OwnPtr<Private> m_private; diff --git a/Userland/Libraries/LibGfx/FontStyleMapping.h b/Userland/Libraries/LibGfx/FontStyleMapping.h index 7c499c35b9..1653dd0e43 100644 --- a/Userland/Libraries/LibGfx/FontStyleMapping.h +++ b/Userland/Libraries/LibGfx/FontStyleMapping.h @@ -12,7 +12,7 @@ namespace Gfx { struct FontStyleMapping { - constexpr FontStyleMapping(int s, const char* n) + constexpr FontStyleMapping(int s, char const* n) : style(s) , name(n) { diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp index 9943eaf719..a51261f037 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/GIFLoader.cpp @@ -70,7 +70,7 @@ struct GIFLoadingContext { FailedToLoadFrameDescriptors, }; ErrorState error_state { NoError }; - const u8* data { nullptr }; + u8 const* data { nullptr }; size_t data_size { 0 }; LogicalScreen logical_screen {}; u8 background_color_index { 0 }; @@ -110,7 +110,7 @@ private: static constexpr int max_code_size = 12; public: - explicit LZWDecoder(const Vector<u8>& lzw_bytes, u8 min_code_size) + explicit LZWDecoder(Vector<u8> const& lzw_bytes, u8 min_code_size) : m_lzw_bytes(lzw_bytes) , m_code_size(min_code_size) , m_original_code_size(min_code_size) @@ -160,7 +160,7 @@ public: for (int i = 0; current_byte_index + i < m_lzw_bytes.size(); ++i) { padded_last_bytes[i] = m_lzw_bytes[current_byte_index + i]; } - const u32* addr = (const u32*)&padded_last_bytes; + u32 const* addr = (u32 const*)&padded_last_bytes; m_current_code = (*addr & mask) >> current_bit_offset; } else { u32 tmp_word; @@ -213,7 +213,7 @@ private: m_original_code_table = m_code_table; } - void extend_code_table(const Vector<u8>& entry) + void extend_code_table(Vector<u8> const& entry) { if (entry.size() > 1 && m_code_table.size() < 4096) { m_code_table.append(entry); @@ -224,7 +224,7 @@ private: } } - const Vector<u8>& m_lzw_bytes; + Vector<u8> const& m_lzw_bytes; int m_current_bit_index { 0 }; @@ -240,13 +240,13 @@ private: Vector<u8> m_output {}; }; -static void copy_frame_buffer(Bitmap& dest, const Bitmap& src) +static void copy_frame_buffer(Bitmap& dest, Bitmap const& src) { VERIFY(dest.size_in_bytes() == src.size_in_bytes()); memcpy(dest.scanline(0), src.scanline(0), dest.size_in_bytes()); } -static void clear_rect(Bitmap& bitmap, const IntRect& rect, Color color) +static void clear_rect(Bitmap& bitmap, IntRect const& rect, Color color) { auto intersection_rect = rect.intersected(bitmap.rect()); if (intersection_rect.is_empty()) @@ -293,7 +293,7 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index) for (size_t i = start_frame; i <= frame_index; ++i) { auto& image = context.images.at(i); - const auto previous_image_disposal_method = i > 0 ? context.images.at(i - 1).disposal_method : GIFImageDescriptor::DisposalMethod::None; + auto const previous_image_disposal_method = i > 0 ? context.images.at(i - 1).disposal_method : GIFImageDescriptor::DisposalMethod::None; if (i == 0) { context.frame_buffer->fill(Color::Transparent); @@ -324,10 +324,10 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index) LZWDecoder decoder(image.lzw_encoded_bytes, image.lzw_min_code_size); // Add GIF-specific control codes - const int clear_code = decoder.add_control_code(); - const int end_of_information_code = decoder.add_control_code(); + int const clear_code = decoder.add_control_code(); + int const end_of_information_code = decoder.add_control_code(); - const auto& color_map = image.use_global_color_map ? context.logical_screen.color_map : image.color_map; + auto const& color_map = image.use_global_color_map ? context.logical_screen.color_map : image.color_map; int pixel_index = 0; int row = 0; @@ -349,7 +349,7 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index) continue; auto colors = decoder.get_output(); - for (const auto& color : colors) { + for (auto const& color : colors) { auto c = color_map[color]; int x = pixel_index % image.width + image.x; @@ -599,7 +599,7 @@ static bool load_gif_frame_descriptors(GIFLoadingContext& context) return true; } -GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size) +GIFImageDecoderPlugin::GIFImageDecoderPlugin(u8 const* data, size_t size) { m_context = make<GIFLoadingContext>(); m_context->data = data; diff --git a/Userland/Libraries/LibGfx/GIFLoader.h b/Userland/Libraries/LibGfx/GIFLoader.h index e42de30106..dbc6065d2a 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.h +++ b/Userland/Libraries/LibGfx/GIFLoader.h @@ -16,7 +16,7 @@ struct GIFLoadingContext; class GIFImageDecoderPlugin final : public ImageDecoderPlugin { public: virtual ~GIFImageDecoderPlugin() override; - GIFImageDecoderPlugin(const u8*, size_t); + GIFImageDecoderPlugin(u8 const*, size_t); virtual IntSize size() override; virtual void set_volatile() override; diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp index 245b337189..0bdcb05854 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.cpp +++ b/Userland/Libraries/LibGfx/ICOLoader.cpp @@ -83,7 +83,7 @@ struct ICOLoadingContext { BitmapDecoded }; State state { NotDecoded }; - const u8* data { nullptr }; + u8 const* data { nullptr }; size_t data_size { 0 }; Vector<ICOImageDescriptor> images; size_t largest_index; @@ -117,12 +117,12 @@ static Optional<ICOImageDescriptor> decode_ico_direntry(InputMemoryStream& strea return { desc }; } -static size_t find_largest_image(const ICOLoadingContext& context) +static size_t find_largest_image(ICOLoadingContext const& context) { size_t max_area = 0; size_t index = 0; size_t largest_index = 0; - for (const auto& desc : context.images) { + for (auto const& desc : context.images) { if (desc.width * desc.height > max_area) { max_area = desc.width * desc.height; largest_index = index; @@ -227,11 +227,11 @@ static bool load_ico_bmp(ICOLoadingContext& context, ICOImageDescriptor& desc) return false; desc.bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors(); Bitmap& bitmap = *desc.bitmap; - const u8* image_base = context.data + desc.offset + sizeof(info); + u8 const* image_base = context.data + desc.offset + sizeof(info); const BMP_ARGB* data_base = (const BMP_ARGB*)image_base; - const u8* mask_base = image_base + desc.width * desc.height * sizeof(BMP_ARGB); + u8 const* mask_base = image_base + desc.width * desc.height * sizeof(BMP_ARGB); for (int y = 0; y < desc.height; y++) { - const u8* row_mask = mask_base + mask_row_len * y; + u8 const* row_mask = mask_base + mask_row_len * y; const BMP_ARGB* row_data = data_base + desc.width * y; for (int x = 0; x < desc.width; x++) { u8 mask = !!(row_mask[x / 8] & (0x80 >> (x % 8))); @@ -279,7 +279,7 @@ static bool load_ico_bitmap(ICOLoadingContext& context, Optional<size_t> index) } } -ICOImageDecoderPlugin::ICOImageDecoderPlugin(const u8* data, size_t size) +ICOImageDecoderPlugin::ICOImageDecoderPlugin(u8 const* data, size_t size) { m_context = make<ICOLoadingContext>(); m_context->data = data; diff --git a/Userland/Libraries/LibGfx/ICOLoader.h b/Userland/Libraries/LibGfx/ICOLoader.h index b99afcd662..334e60f09c 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.h +++ b/Userland/Libraries/LibGfx/ICOLoader.h @@ -15,7 +15,7 @@ struct ICOLoadingContext; class ICOImageDecoderPlugin final : public ImageDecoderPlugin { public: virtual ~ICOImageDecoderPlugin() override; - ICOImageDecoderPlugin(const u8*, size_t); + ICOImageDecoderPlugin(u8 const*, size_t); virtual IntSize size() override; virtual void set_volatile() override; diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp index 2ff7f82aee..63c5a7395b 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPGLoader.cpp @@ -172,7 +172,7 @@ struct JPGLoadingContext { }; State state { State::NotDecoded }; - const u8* data { nullptr }; + u8 const* data { nullptr }; size_t data_size { 0 }; u32 luma_table[64] = { 0 }; u32 chroma_table[64] = { 0 }; @@ -224,7 +224,7 @@ static Optional<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t co return value; } -static Optional<u8> get_next_symbol(HuffmanStreamState& hstream, const HuffmanTableSpec& table) +static Optional<u8> get_next_symbol(HuffmanStreamState& hstream, HuffmanTableSpec const& table) { unsigned code = 0; size_t code_cursor = 0; @@ -649,7 +649,7 @@ static bool read_huffman_table(InputMemoryStream& stream, JPGLoadingContext& con return true; } -static inline bool validate_luma_and_modify_context(const ComponentSpec& luma, JPGLoadingContext& context) +static inline bool validate_luma_and_modify_context(ComponentSpec const& luma, JPGLoadingContext& context) { if ((luma.hsample_factor == 1 || luma.hsample_factor == 2) && (luma.vsample_factor == 1 || luma.vsample_factor == 2)) { context.mblock_meta.hpadded_count += luma.hsample_factor == 1 ? 0 : context.mblock_meta.hcount % 2; @@ -847,7 +847,7 @@ static void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macrobloc for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) { for (u32 i = 0; i < context.component_count; i++) { auto& component = context.components[i]; - const u32* table = component.qtable_id == 0 ? context.luma_table : context.chroma_table; + u32 const* table = component.qtable_id == 0 ? context.luma_table : context.chroma_table; for (u32 vfactor_i = 0; vfactor_i < component.vsample_factor; vfactor_i++) { for (u32 hfactor_i = 0; hfactor_i < component.hsample_factor; hfactor_i++) { u32 mb_index = (vcursor + vfactor_i) * context.mblock_meta.hpadded_count + (hfactor_i + hcursor); @@ -862,22 +862,22 @@ static void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macrobloc } } -static void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks) +static void inverse_dct(JPGLoadingContext const& context, Vector<Macroblock>& macroblocks) { - static const float m0 = 2.0 * AK::cos(1.0 / 16.0 * 2.0 * AK::Pi<double>); - static const float m1 = 2.0 * AK::cos(2.0 / 16.0 * 2.0 * AK::Pi<double>); - static const float m3 = 2.0 * AK::cos(2.0 / 16.0 * 2.0 * AK::Pi<double>); - static const float m5 = 2.0 * AK::cos(3.0 / 16.0 * 2.0 * AK::Pi<double>); - static const float m2 = m0 - m5; - static const float m4 = m0 + m5; - static const float s0 = AK::cos(0.0 / 16.0 * AK::Pi<double>) / sqrt(8); - static const float s1 = AK::cos(1.0 / 16.0 * AK::Pi<double>) / 2.0; - static const float s2 = AK::cos(2.0 / 16.0 * AK::Pi<double>) / 2.0; - static const float s3 = AK::cos(3.0 / 16.0 * AK::Pi<double>) / 2.0; - static const float s4 = AK::cos(4.0 / 16.0 * AK::Pi<double>) / 2.0; - static const float s5 = AK::cos(5.0 / 16.0 * AK::Pi<double>) / 2.0; - static const float s6 = AK::cos(6.0 / 16.0 * AK::Pi<double>) / 2.0; - static const float s7 = AK::cos(7.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const m0 = 2.0 * AK::cos(1.0 / 16.0 * 2.0 * AK::Pi<double>); + static float const m1 = 2.0 * AK::cos(2.0 / 16.0 * 2.0 * AK::Pi<double>); + static float const m3 = 2.0 * AK::cos(2.0 / 16.0 * 2.0 * AK::Pi<double>); + static float const m5 = 2.0 * AK::cos(3.0 / 16.0 * 2.0 * AK::Pi<double>); + static float const m2 = m0 - m5; + static float const m4 = m0 + m5; + static float const s0 = AK::cos(0.0 / 16.0 * AK::Pi<double>) / sqrt(8); + static float const s1 = AK::cos(1.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const s2 = AK::cos(2.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const s3 = AK::cos(3.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const s4 = AK::cos(4.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const s5 = AK::cos(5.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const s6 = AK::cos(6.0 / 16.0 * AK::Pi<double>) / 2.0; + static float const s7 = AK::cos(7.0 / 16.0 * AK::Pi<double>) / 2.0; for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) { for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) { @@ -889,62 +889,62 @@ static void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& ma Macroblock& block = macroblocks[mb_index]; i32* block_component = get_component(block, component_i); for (u32 k = 0; k < 8; ++k) { - const float g0 = block_component[0 * 8 + k] * s0; - const float g1 = block_component[4 * 8 + k] * s4; - const float g2 = block_component[2 * 8 + k] * s2; - const float g3 = block_component[6 * 8 + k] * s6; - const float g4 = block_component[5 * 8 + k] * s5; - const float g5 = block_component[1 * 8 + k] * s1; - const float g6 = block_component[7 * 8 + k] * s7; - const float g7 = block_component[3 * 8 + k] * s3; - - const float f0 = g0; - const float f1 = g1; - const float f2 = g2; - const float f3 = g3; - const float f4 = g4 - g7; - const float f5 = g5 + g6; - const float f6 = g5 - g6; - const float f7 = g4 + g7; - - const float e0 = f0; - const float e1 = f1; - const float e2 = f2 - f3; - const float e3 = f2 + f3; - const float e4 = f4; - const float e5 = f5 - f7; - const float e6 = f6; - const float e7 = f5 + f7; - const float e8 = f4 + f6; - - const float d0 = e0; - const float d1 = e1; - const float d2 = e2 * m1; - const float d3 = e3; - const float d4 = e4 * m2; - const float d5 = e5 * m3; - const float d6 = e6 * m4; - const float d7 = e7; - const float d8 = e8 * m5; - - const float c0 = d0 + d1; - const float c1 = d0 - d1; - const float c2 = d2 - d3; - const float c3 = d3; - const float c4 = d4 + d8; - const float c5 = d5 + d7; - const float c6 = d6 - d8; - const float c7 = d7; - const float c8 = c5 - c6; - - const float b0 = c0 + c3; - const float b1 = c1 + c2; - const float b2 = c1 - c2; - const float b3 = c0 - c3; - const float b4 = c4 - c8; - const float b5 = c8; - const float b6 = c6 - c7; - const float b7 = c7; + float const g0 = block_component[0 * 8 + k] * s0; + float const g1 = block_component[4 * 8 + k] * s4; + float const g2 = block_component[2 * 8 + k] * s2; + float const g3 = block_component[6 * 8 + k] * s6; + float const g4 = block_component[5 * 8 + k] * s5; + float const g5 = block_component[1 * 8 + k] * s1; + float const g6 = block_component[7 * 8 + k] * s7; + float const g7 = block_component[3 * 8 + k] * s3; + + float const f0 = g0; + float const f1 = g1; + float const f2 = g2; + float const f3 = g3; + float const f4 = g4 - g7; + float const f5 = g5 + g6; + float const f6 = g5 - g6; + float const f7 = g4 + g7; + + float const e0 = f0; + float const e1 = f1; + float const e2 = f2 - f3; + float const e3 = f2 + f3; + float const e4 = f4; + float const e5 = f5 - f7; + float const e6 = f6; + float const e7 = f5 + f7; + float const e8 = f4 + f6; + + float const d0 = e0; + float const d1 = e1; + float const d2 = e2 * m1; + float const d3 = e3; + float const d4 = e4 * m2; + float const d5 = e5 * m3; + float const d6 = e6 * m4; + float const d7 = e7; + float const d8 = e8 * m5; + + float const c0 = d0 + d1; + float const c1 = d0 - d1; + float const c2 = d2 - d3; + float const c3 = d3; + float const c4 = d4 + d8; + float const c5 = d5 + d7; + float const c6 = d6 - d8; + float const c7 = d7; + float const c8 = c5 - c6; + + float const b0 = c0 + c3; + float const b1 = c1 + c2; + float const b2 = c1 - c2; + float const b3 = c0 - c3; + float const b4 = c4 - c8; + float const b5 = c8; + float const b6 = c6 - c7; + float const b7 = c7; block_component[0 * 8 + k] = b0 + b7; block_component[1 * 8 + k] = b1 + b6; @@ -956,62 +956,62 @@ static void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& ma block_component[7 * 8 + k] = b0 - b7; } for (u32 l = 0; l < 8; ++l) { - const float g0 = block_component[l * 8 + 0] * s0; - const float g1 = block_component[l * 8 + 4] * s4; - const float g2 = block_component[l * 8 + 2] * s2; - const float g3 = block_component[l * 8 + 6] * s6; - const float g4 = block_component[l * 8 + 5] * s5; - const float g5 = block_component[l * 8 + 1] * s1; - const float g6 = block_component[l * 8 + 7] * s7; - const float g7 = block_component[l * 8 + 3] * s3; - - const float f0 = g0; - const float f1 = g1; - const float f2 = g2; - const float f3 = g3; - const float f4 = g4 - g7; - const float f5 = g5 + g6; - const float f6 = g5 - g6; - const float f7 = g4 + g7; - - const float e0 = f0; - const float e1 = f1; - const float e2 = f2 - f3; - const float e3 = f2 + f3; - const float e4 = f4; - const float e5 = f5 - f7; - const float e6 = f6; - const float e7 = f5 + f7; - const float e8 = f4 + f6; - - const float d0 = e0; - const float d1 = e1; - const float d2 = e2 * m1; - const float d3 = e3; - const float d4 = e4 * m2; - const float d5 = e5 * m3; - const float d6 = e6 * m4; - const float d7 = e7; - const float d8 = e8 * m5; - - const float c0 = d0 + d1; - const float c1 = d0 - d1; - const float c2 = d2 - d3; - const float c3 = d3; - const float c4 = d4 + d8; - const float c5 = d5 + d7; - const float c6 = d6 - d8; - const float c7 = d7; - const float c8 = c5 - c6; - - const float b0 = c0 + c3; - const float b1 = c1 + c2; - const float b2 = c1 - c2; - const float b3 = c0 - c3; - const float b4 = c4 - c8; - const float b5 = c8; - const float b6 = c6 - c7; - const float b7 = c7; + float const g0 = block_component[l * 8 + 0] * s0; + float const g1 = block_component[l * 8 + 4] * s4; + float const g2 = block_component[l * 8 + 2] * s2; + float const g3 = block_component[l * 8 + 6] * s6; + float const g4 = block_component[l * 8 + 5] * s5; + float const g5 = block_component[l * 8 + 1] * s1; + float const g6 = block_component[l * 8 + 7] * s7; + float const g7 = block_component[l * 8 + 3] * s3; + + float const f0 = g0; + float const f1 = g1; + float const f2 = g2; + float const f3 = g3; + float const f4 = g4 - g7; + float const f5 = g5 + g6; + float const f6 = g5 - g6; + float const f7 = g4 + g7; + + float const e0 = f0; + float const e1 = f1; + float const e2 = f2 - f3; + float const e3 = f2 + f3; + float const e4 = f4; + float const e5 = f5 - f7; + float const e6 = f6; + float const e7 = f5 + f7; + float const e8 = f4 + f6; + + float const d0 = e0; + float const d1 = e1; + float const d2 = e2 * m1; + float const d3 = e3; + float const d4 = e4 * m2; + float const d5 = e5 * m3; + float const d6 = e6 * m4; + float const d7 = e7; + float const d8 = e8 * m5; + + float const c0 = d0 + d1; + float const c1 = d0 - d1; + float const c2 = d2 - d3; + float const c3 = d3; + float const c4 = d4 + d8; + float const c5 = d5 + d7; + float const c6 = d6 - d8; + float const c7 = d7; + float const c8 = c5 - c6; + + float const b0 = c0 + c3; + float const b1 = c1 + c2; + float const b2 = c1 - c2; + float const b3 = c0 - c3; + float const b4 = c4 - c8; + float const b5 = c8; + float const b6 = c6 - c7; + float const b7 = c7; block_component[l * 8 + 0] = b0 + b7; block_component[l * 8 + 1] = b1 + b6; @@ -1029,12 +1029,12 @@ static void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& ma } } -static void ycbcr_to_rgb(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks) +static void ycbcr_to_rgb(JPGLoadingContext const& context, Vector<Macroblock>& macroblocks) { for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) { for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) { const u32 chroma_block_index = vcursor * context.mblock_meta.hpadded_count + hcursor; - const Macroblock& chroma = macroblocks[chroma_block_index]; + Macroblock const& chroma = macroblocks[chroma_block_index]; // Overflows are intentional. for (u8 vfactor_i = context.vsample_factor - 1; vfactor_i < context.vsample_factor; --vfactor_i) { for (u8 hfactor_i = context.hsample_factor - 1; hfactor_i < context.hsample_factor; --hfactor_i) { @@ -1062,7 +1062,7 @@ static void ycbcr_to_rgb(const JPGLoadingContext& context, Vector<Macroblock>& m } } -static bool compose_bitmap(JPGLoadingContext& context, const Vector<Macroblock>& macroblocks) +static bool compose_bitmap(JPGLoadingContext& context, Vector<Macroblock> const& macroblocks) { auto bitmap_or_error = Bitmap::try_create(BitmapFormat::BGRx8888, { context.frame.width, context.frame.height }); if (bitmap_or_error.is_error()) @@ -1224,7 +1224,7 @@ static bool decode_jpg(JPGLoadingContext& context) return true; } -JPGImageDecoderPlugin::JPGImageDecoderPlugin(const u8* data, size_t size) +JPGImageDecoderPlugin::JPGImageDecoderPlugin(u8 const* data, size_t size) { m_context = make<JPGLoadingContext>(); m_context->data = data; diff --git a/Userland/Libraries/LibGfx/JPGLoader.h b/Userland/Libraries/LibGfx/JPGLoader.h index 0813319177..592f8a93a0 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.h +++ b/Userland/Libraries/LibGfx/JPGLoader.h @@ -15,7 +15,7 @@ struct JPGLoadingContext; class JPGImageDecoderPlugin : public ImageDecoderPlugin { public: virtual ~JPGImageDecoderPlugin() override; - JPGImageDecoderPlugin(const u8*, size_t); + JPGImageDecoderPlugin(u8 const*, size_t); virtual IntSize size() override; virtual void set_volatile() override; [[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override; diff --git a/Userland/Libraries/LibGfx/Matrix.h b/Userland/Libraries/LibGfx/Matrix.h index 78be55f48f..cbb81daa3c 100644 --- a/Userland/Libraries/LibGfx/Matrix.h +++ b/Userland/Libraries/LibGfx/Matrix.h @@ -36,12 +36,12 @@ public: { } - Matrix(const Matrix& other) + Matrix(Matrix const& other) { __builtin_memcpy(m_elements, other.elements(), sizeof(T) * N * N); } - Matrix& operator=(const Matrix& other) + Matrix& operator=(Matrix const& other) { __builtin_memcpy(m_elements, other.elements(), sizeof(T) * N * N); return *this; @@ -50,7 +50,7 @@ public: constexpr auto elements() const { return m_elements; } constexpr auto elements() { return m_elements; } - constexpr Matrix operator*(const Matrix& other) const + constexpr Matrix operator*(Matrix const& other) const { Matrix product; for (size_t i = 0; i < N; ++i) { diff --git a/Userland/Libraries/LibGfx/Matrix4x4.h b/Userland/Libraries/LibGfx/Matrix4x4.h index ed767e48c9..7ff3ecad99 100644 --- a/Userland/Libraries/LibGfx/Matrix4x4.h +++ b/Userland/Libraries/LibGfx/Matrix4x4.h @@ -17,7 +17,7 @@ template<typename T> using Matrix4x4 = Matrix<4, T>; template<typename T> -constexpr static Vector4<T> operator*(const Matrix4x4<T>& m, const Vector4<T>& v) +constexpr static Vector4<T> operator*(Matrix4x4<T> const& m, Vector4<T> const& v) { auto const& elements = m.elements(); return Vector4<T>( @@ -30,7 +30,7 @@ constexpr static Vector4<T> operator*(const Matrix4x4<T>& m, const Vector4<T>& v // FIXME: this is a specific Matrix4x4 * Vector3 interaction that implies W=1; maybe move this out of LibGfx // or replace a Matrix4x4 * Vector4 operation? template<typename T> -constexpr static Vector3<T> transform_point(const Matrix4x4<T>& m, const Vector3<T>& p) +constexpr static Vector3<T> transform_point(Matrix4x4<T> const& m, Vector3<T> const& p) { auto const& elements = m.elements(); return Vector3<T>( @@ -40,7 +40,7 @@ constexpr static Vector3<T> transform_point(const Matrix4x4<T>& m, const Vector3 } template<typename T> -constexpr static Matrix4x4<T> translation_matrix(const Vector3<T>& p) +constexpr static Matrix4x4<T> translation_matrix(Vector3<T> const& p) { return Matrix4x4<T>( 1, 0, 0, p.x(), @@ -50,7 +50,7 @@ constexpr static Matrix4x4<T> translation_matrix(const Vector3<T>& p) } template<typename T> -constexpr static Matrix4x4<T> scale_matrix(const Vector3<T>& s) +constexpr static Matrix4x4<T> scale_matrix(Vector3<T> const& s) { return Matrix4x4<T>( s.x(), 0, 0, 0, @@ -60,7 +60,7 @@ constexpr static Matrix4x4<T> scale_matrix(const Vector3<T>& s) } template<typename T> -constexpr static Matrix4x4<T> rotation_matrix(const Vector3<T>& axis, T angle) +constexpr static Matrix4x4<T> rotation_matrix(Vector3<T> const& axis, T angle) { T c, s; AK::sincos(angle, s, c); diff --git a/Userland/Libraries/LibGfx/PGMLoader.cpp b/Userland/Libraries/LibGfx/PGMLoader.cpp index 6e52ef0815..a211209f83 100644 --- a/Userland/Libraries/LibGfx/PGMLoader.cpp +++ b/Userland/Libraries/LibGfx/PGMLoader.cpp @@ -13,7 +13,7 @@ namespace Gfx { -static void set_adjusted_pixels(PGMLoadingContext& context, const Vector<Gfx::Color>& color_data) +static void set_adjusted_pixels(PGMLoadingContext& context, Vector<Gfx::Color> const& color_data) { size_t index = 0; for (size_t y = 0; y < context.height; ++y) { diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index 12237b5793..1a5a5247be 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -83,7 +83,7 @@ struct PNGLoadingContext { BitmapDecoded, }; State state { State::NotDecoded }; - const u8* data { nullptr }; + u8 const* data { nullptr }; size_t data_size { 0 }; int width { -1 }; int height { -1 }; @@ -119,7 +119,7 @@ struct PNGLoadingContext { class Streamer { public: - Streamer(const u8* data, size_t size) + Streamer(u8 const* data, size_t size) : m_data_ptr(data) , m_size_remaining(size) { @@ -130,7 +130,7 @@ public: { if (m_size_remaining < sizeof(T)) return false; - value = *((const NetworkOrdered<T>*)m_data_ptr); + value = *((NetworkOrdered<T> const*)m_data_ptr); m_data_ptr += sizeof(T); m_size_remaining -= sizeof(T); return true; @@ -159,7 +159,7 @@ public: bool at_end() const { return !m_size_remaining; } private: - const u8* m_data_ptr { nullptr }; + u8 const* m_data_ptr { nullptr }; size_t m_size_remaining { 0 }; }; @@ -191,9 +191,9 @@ union [[gnu::packed]] Pixel { static_assert(AssertSize<Pixel, 4>()); template<bool has_alpha, u8 filter_type> -ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void* dummy_scanline_data) +ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, void const* dummy_scanline_data) { - auto* dummy_scanline = (const Pixel*)dummy_scanline_data; + auto* dummy_scanline = (Pixel const*)dummy_scanline_data; if constexpr (filter_type == 0) { auto* pixels = (Pixel*)bitmap.scanline(y); for (int i = 0; i < bitmap.width(); ++i) { @@ -208,7 +208,7 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void* for (int i = 1; i < bitmap.width(); ++i) { auto& x = pixels[i]; swap(x.r, x.b); - auto& a = (const Pixel&)pixels[i - 1]; + auto& a = (Pixel const&)pixels[i - 1]; x.v[0] += a.v[0]; x.v[1] += a.v[1]; x.v[2] += a.v[2]; @@ -219,11 +219,11 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void* } if constexpr (filter_type == 2) { auto* pixels = (Pixel*)bitmap.scanline(y); - auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (const Pixel*)bitmap.scanline(y - 1); + auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (Pixel const*)bitmap.scanline(y - 1); for (int i = 0; i < bitmap.width(); ++i) { auto& x = pixels[i]; swap(x.r, x.b); - const Pixel& b = pixels_y_minus_1[i]; + Pixel const& b = pixels_y_minus_1[i]; x.v[0] += b.v[0]; x.v[1] += b.v[1]; x.v[2] += b.v[2]; @@ -234,14 +234,14 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void* } if constexpr (filter_type == 3) { auto* pixels = (Pixel*)bitmap.scanline(y); - auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (const Pixel*)bitmap.scanline(y - 1); + auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (Pixel const*)bitmap.scanline(y - 1); for (int i = 0; i < bitmap.width(); ++i) { auto& x = pixels[i]; swap(x.r, x.b); Pixel a; if (i != 0) a = pixels[i - 1]; - const Pixel& b = pixels_y_minus_1[i]; + Pixel const& b = pixels_y_minus_1[i]; x.v[0] = x.v[0] + ((a.v[0] + b.v[0]) / 2); x.v[1] = x.v[1] + ((a.v[1] + b.v[1]) / 2); x.v[2] = x.v[2] + ((a.v[2] + b.v[2]) / 2); @@ -257,7 +257,7 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void* auto& x = pixels[i]; swap(x.r, x.b); Pixel a; - const Pixel& b = pixels_y_minus_1[i]; + Pixel const& b = pixels_y_minus_1[i]; Pixel c; if (i != 0) { a = pixels[i - 1]; @@ -291,7 +291,7 @@ template<typename T> ALWAYS_INLINE static void unpack_grayscale_with_alpha(PNGLoadingContext& context) { for (int y = 0; y < context.height; ++y) { - auto* tuples = reinterpret_cast<const Tuple<T>*>(context.scanlines[y].data.data()); + auto* tuples = reinterpret_cast<Tuple<T> const*>(context.scanlines[y].data.data()); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = tuples[i].gray; @@ -306,7 +306,7 @@ template<typename T> ALWAYS_INLINE static void unpack_triplets_without_alpha(PNGLoadingContext& context) { for (int y = 0; y < context.height; ++y) { - auto* triplets = reinterpret_cast<const Triplet<T>*>(context.scanlines[y].data.data()); + auto* triplets = reinterpret_cast<Triplet<T> const*>(context.scanlines[y].data.data()); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = triplets[i].r; @@ -321,7 +321,7 @@ template<typename T> ALWAYS_INLINE static void unpack_triplets_with_transparency_value(PNGLoadingContext& context, Triplet<T> transparency_value) { for (int y = 0; y < context.height; ++y) { - auto* triplets = reinterpret_cast<const Triplet<T>*>(context.scanlines[y].data.data()); + auto* triplets = reinterpret_cast<Triplet<T> const*>(context.scanlines[y].data.data()); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = triplets[i].r; @@ -401,7 +401,7 @@ NEVER_INLINE FLATTEN static ErrorOr<void> unfilter(PNGLoadingContext& context) } } else if (context.bit_depth == 16) { for (int y = 0; y < context.height; ++y) { - auto* triplets = reinterpret_cast<const Quad<u16>*>(context.scanlines[y].data.data()); + auto* triplets = reinterpret_cast<Quad<u16> const*>(context.scanlines[y].data.data()); for (int i = 0; i < context.width; ++i) { auto& pixel = (Pixel&)context.bitmap->scanline(y)[i]; pixel.r = triplets[i].r & 0xFF; @@ -538,7 +538,7 @@ static bool decode_png_size(PNGLoadingContext& context) return false; } - const u8* data_ptr = context.data + sizeof(png_header); + u8 const* data_ptr = context.data + sizeof(png_header); size_t data_remaining = context.data_size - sizeof(png_header); Streamer streamer(data_ptr, data_remaining); @@ -566,7 +566,7 @@ static bool decode_png_chunks(PNGLoadingContext& context) return false; } - const u8* data_ptr = context.data + sizeof(png_header); + u8 const* data_ptr = context.data + sizeof(png_header); int data_remaining = context.data_size - sizeof(png_header); context.compressed_data.ensure_capacity(context.data_size); @@ -861,7 +861,7 @@ static bool process_IDAT(ReadonlyBytes data, PNGLoadingContext& context) static bool process_PLTE(ReadonlyBytes data, PNGLoadingContext& context) { - context.palette_data.append((const PaletteEntry*)data.data(), data.size() / 3); + context.palette_data.append((PaletteEntry const*)data.data(), data.size() / 3); return true; } @@ -902,18 +902,18 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context) } dbgln_if(PNG_DEBUG, "Chunk type: '{}', size: {}, crc: {:x}", chunk_type, chunk_size, chunk_crc); - if (!strcmp((const char*)chunk_type, "IHDR")) + if (!strcmp((char const*)chunk_type, "IHDR")) return process_IHDR(chunk_data, context); - if (!strcmp((const char*)chunk_type, "IDAT")) + if (!strcmp((char const*)chunk_type, "IDAT")) return process_IDAT(chunk_data, context); - if (!strcmp((const char*)chunk_type, "PLTE")) + if (!strcmp((char const*)chunk_type, "PLTE")) return process_PLTE(chunk_data, context); - if (!strcmp((const char*)chunk_type, "tRNS")) + if (!strcmp((char const*)chunk_type, "tRNS")) return process_tRNS(chunk_data, context); return true; } -PNGImageDecoderPlugin::PNGImageDecoderPlugin(const u8* data, size_t size) +PNGImageDecoderPlugin::PNGImageDecoderPlugin(u8 const* data, size_t size) { m_context = make<PNGLoadingContext>(); m_context->data = data; diff --git a/Userland/Libraries/LibGfx/PNGLoader.h b/Userland/Libraries/LibGfx/PNGLoader.h index 9f7c0e7b6c..8e11319b5b 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.h +++ b/Userland/Libraries/LibGfx/PNGLoader.h @@ -15,7 +15,7 @@ struct PNGLoadingContext; class PNGImageDecoderPlugin final : public ImageDecoderPlugin { public: virtual ~PNGImageDecoderPlugin() override; - PNGImageDecoderPlugin(const u8*, size_t); + PNGImageDecoderPlugin(u8 const*, size_t); virtual IntSize size() override; virtual void set_volatile() override; diff --git a/Userland/Libraries/LibGfx/Palette.cpp b/Userland/Libraries/LibGfx/Palette.cpp index b6d6711a47..504cdf6b2a 100644 --- a/Userland/Libraries/LibGfx/Palette.cpp +++ b/Userland/Libraries/LibGfx/Palette.cpp @@ -22,7 +22,7 @@ PaletteImpl::PaletteImpl(Core::AnonymousBuffer buffer) { } -Palette::Palette(const PaletteImpl& impl) +Palette::Palette(PaletteImpl const& impl) : m_impl(impl) { } diff --git a/Userland/Libraries/LibGfx/Palette.h b/Userland/Libraries/LibGfx/Palette.h index 365e8cc2e0..2d88cddc1b 100644 --- a/Userland/Libraries/LibGfx/Palette.h +++ b/Userland/Libraries/LibGfx/Palette.h @@ -46,7 +46,7 @@ public: int metric(MetricRole) const; String path(PathRole) const; - const SystemTheme& theme() const { return *m_theme_buffer.data<SystemTheme>(); } + SystemTheme const& theme() const { return *m_theme_buffer.data<SystemTheme>(); } void replace_internal_buffer(Badge<GUI::Application>, Core::AnonymousBuffer buffer); @@ -59,7 +59,7 @@ private: class Palette { public: - explicit Palette(const PaletteImpl&); + explicit Palette(PaletteImpl const&); ~Palette() = default; Color accent() const { return color(ColorRole::Accent); } @@ -169,10 +169,10 @@ public: void set_metric(MetricRole, int); void set_path(PathRole, String); - const SystemTheme& theme() const { return m_impl->theme(); } + SystemTheme const& theme() const { return m_impl->theme(); } PaletteImpl& impl() { return *m_impl; } - const PaletteImpl& impl() const { return *m_impl; } + PaletteImpl const& impl() const { return *m_impl; } private: NonnullRefPtr<PaletteImpl> m_impl; diff --git a/Userland/Libraries/LibGfx/Path.cpp b/Userland/Libraries/LibGfx/Path.cpp index 7b40796f52..85500700aa 100644 --- a/Userland/Libraries/LibGfx/Path.cpp +++ b/Userland/Libraries/LibGfx/Path.cpp @@ -14,7 +14,7 @@ namespace Gfx { -void Path::elliptical_arc_to(const FloatPoint& point, const FloatPoint& radii, double x_axis_rotation, bool large_arc, bool sweep) +void Path::elliptical_arc_to(FloatPoint const& point, FloatPoint const& radii, double x_axis_rotation, bool large_arc, bool sweep) { auto next_point = point; @@ -207,16 +207,16 @@ String Path::to_string() const switch (segment.type()) { case Segment::Type::QuadraticBezierCurveTo: builder.append(", "); - builder.append(static_cast<const QuadraticBezierCurveSegment&>(segment).through().to_string()); + builder.append(static_cast<QuadraticBezierCurveSegment const&>(segment).through().to_string()); break; case Segment::Type::CubicBezierCurveTo: builder.append(", "); - builder.append(static_cast<const CubicBezierCurveSegment&>(segment).through_0().to_string()); + builder.append(static_cast<CubicBezierCurveSegment const&>(segment).through_0().to_string()); builder.append(", "); - builder.append(static_cast<const CubicBezierCurveSegment&>(segment).through_1().to_string()); + builder.append(static_cast<CubicBezierCurveSegment const&>(segment).through_1().to_string()); break; case Segment::Type::EllipticalArcTo: { - auto& arc = static_cast<const EllipticalArcSegment&>(segment); + auto& arc = static_cast<EllipticalArcSegment const&>(segment); builder.appendff(", {}, {}, {}, {}, {}", arc.radii().to_string().characters(), arc.center().to_string().characters(), @@ -243,7 +243,7 @@ void Path::segmentize_path() float max_x = 0; float max_y = 0; - auto add_point_to_bbox = [&](const Gfx::FloatPoint& point) { + auto add_point_to_bbox = [&](Gfx::FloatPoint const& point) { float x = point.x(); float y = point.y(); min_x = min(min_x, x); @@ -252,7 +252,7 @@ void Path::segmentize_path() max_y = max(max_y, y); }; - auto add_line = [&](const auto& p0, const auto& p1) { + auto add_line = [&](auto const& p0, auto const& p1) { float ymax = p0.y(), ymin = p1.y(), x_of_ymin = p1.x(), x_of_ymax = p0.x(); auto slope = p0.x() == p1.x() ? 0 : ((float)(p0.y() - p1.y())) / ((float)(p0.x() - p1.x())); if (p0.y() < p1.y()) { @@ -292,7 +292,7 @@ void Path::segmentize_path() } case Segment::Type::QuadraticBezierCurveTo: { auto& control = static_cast<QuadraticBezierCurveSegment&>(segment).through(); - Painter::for_each_line_segment_on_bezier_curve(control, cursor, segment.point(), [&](const FloatPoint& p0, const FloatPoint& p1) { + Painter::for_each_line_segment_on_bezier_curve(control, cursor, segment.point(), [&](FloatPoint const& p0, FloatPoint const& p1) { add_line(p0, p1); }); cursor = segment.point(); @@ -302,7 +302,7 @@ void Path::segmentize_path() auto& curve = static_cast<CubicBezierCurveSegment const&>(segment); auto& control_0 = curve.through_0(); auto& control_1 = curve.through_1(); - Painter::for_each_line_segment_on_cubic_bezier_curve(control_0, control_1, cursor, segment.point(), [&](const FloatPoint& p0, const FloatPoint& p1) { + Painter::for_each_line_segment_on_cubic_bezier_curve(control_0, control_1, cursor, segment.point(), [&](FloatPoint const& p0, FloatPoint const& p1) { add_line(p0, p1); }); cursor = segment.point(); @@ -310,7 +310,7 @@ void Path::segmentize_path() } case Segment::Type::EllipticalArcTo: { auto& arc = static_cast<EllipticalArcSegment&>(segment); - Painter::for_each_line_segment_on_elliptical_arc(cursor, arc.point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), [&](const FloatPoint& p0, const FloatPoint& p1) { + Painter::for_each_line_segment_on_elliptical_arc(cursor, arc.point(), arc.center(), arc.radii(), arc.x_axis_rotation(), arc.theta_1(), arc.theta_delta(), [&](FloatPoint const& p0, FloatPoint const& p1) { add_line(p0, p1); }); cursor = segment.point(); @@ -324,7 +324,7 @@ void Path::segmentize_path() } // sort segments by ymax - quick_sort(segments, [](const auto& line0, const auto& line1) { + quick_sort(segments, [](auto const& line0, auto const& line1) { return line1.maximum_y < line0.maximum_y; }); diff --git a/Userland/Libraries/LibGfx/Path.h b/Userland/Libraries/LibGfx/Path.h index cad1c88099..7c0ba83090 100644 --- a/Userland/Libraries/LibGfx/Path.h +++ b/Userland/Libraries/LibGfx/Path.h @@ -28,14 +28,14 @@ public: EllipticalArcTo, }; - Segment(const FloatPoint& point) + Segment(FloatPoint const& point) : m_point(point) { } virtual ~Segment() = default; - const FloatPoint& point() const { return m_point; } + FloatPoint const& point() const { return m_point; } virtual Type type() const = 0; protected: @@ -44,7 +44,7 @@ protected: class MoveSegment final : public Segment { public: - MoveSegment(const FloatPoint& point) + MoveSegment(FloatPoint const& point) : Segment(point) { } @@ -55,7 +55,7 @@ private: class LineSegment final : public Segment { public: - LineSegment(const FloatPoint& point) + LineSegment(FloatPoint const& point) : Segment(point) { } @@ -68,7 +68,7 @@ private: class QuadraticBezierCurveSegment final : public Segment { public: - QuadraticBezierCurveSegment(const FloatPoint& point, const FloatPoint& through) + QuadraticBezierCurveSegment(FloatPoint const& point, FloatPoint const& through) : Segment(point) , m_through(through) { @@ -76,7 +76,7 @@ public: virtual ~QuadraticBezierCurveSegment() override = default; - const FloatPoint& through() const { return m_through; } + FloatPoint const& through() const { return m_through; } private: virtual Type type() const override { return Segment::Type::QuadraticBezierCurveTo; } @@ -86,7 +86,7 @@ private: class CubicBezierCurveSegment final : public Segment { public: - CubicBezierCurveSegment(const FloatPoint& point, const FloatPoint& through_0, const FloatPoint& through_1) + CubicBezierCurveSegment(FloatPoint const& point, FloatPoint const& through_0, FloatPoint const& through_1) : Segment(point) , m_through_0(through_0) , m_through_1(through_1) @@ -95,8 +95,8 @@ public: virtual ~CubicBezierCurveSegment() override = default; - const FloatPoint& through_0() const { return m_through_0; } - const FloatPoint& through_1() const { return m_through_1; } + FloatPoint const& through_0() const { return m_through_0; } + FloatPoint const& through_1() const { return m_through_1; } private: virtual Type type() const override { return Segment::Type::CubicBezierCurveTo; } @@ -107,7 +107,7 @@ private: class EllipticalArcSegment final : public Segment { public: - EllipticalArcSegment(const FloatPoint& point, const FloatPoint& center, const FloatPoint radii, float x_axis_rotation, float theta_1, float theta_delta, bool large_arc, bool sweep) + EllipticalArcSegment(FloatPoint const& point, FloatPoint const& center, const FloatPoint radii, float x_axis_rotation, float theta_1, float theta_delta, bool large_arc, bool sweep) : Segment(point) , m_center(center) , m_radii(radii) @@ -121,8 +121,8 @@ public: virtual ~EllipticalArcSegment() override = default; - const FloatPoint& center() const { return m_center; } - const FloatPoint& radii() const { return m_radii; } + FloatPoint const& center() const { return m_center; } + FloatPoint const& radii() const { return m_radii; } float x_axis_rotation() const { return m_x_axis_rotation; } float theta_1() const { return m_theta_1; } float theta_delta() const { return m_theta_delta; } @@ -145,12 +145,12 @@ class Path { public: Path() = default; - void move_to(const FloatPoint& point) + void move_to(FloatPoint const& point) { append_segment<MoveSegment>(point); } - void line_to(const FloatPoint& point) + void line_to(FloatPoint const& point) { append_segment<LineSegment>(point); invalidate_split_lines(); @@ -172,7 +172,7 @@ public: line_to({ previous_x, y }); } - void quadratic_bezier_curve_to(const FloatPoint& through, const FloatPoint& point) + void quadratic_bezier_curve_to(FloatPoint const& through, FloatPoint const& point) { append_segment<QuadraticBezierCurveSegment>(point, through); invalidate_split_lines(); @@ -184,14 +184,14 @@ public: invalidate_split_lines(); } - void elliptical_arc_to(const FloatPoint& point, const FloatPoint& radii, double x_axis_rotation, bool large_arc, bool sweep); - void arc_to(const FloatPoint& point, float radius, bool large_arc, bool sweep) + void elliptical_arc_to(FloatPoint const& point, FloatPoint const& radii, double x_axis_rotation, bool large_arc, bool sweep); + void arc_to(FloatPoint const& point, float radius, bool large_arc, bool sweep) { elliptical_arc_to(point, { radius, radius }, 0, large_arc, sweep); } // Note: This does not do any sanity checks! - void elliptical_arc_to(const FloatPoint& endpoint, const FloatPoint& center, const FloatPoint& radii, double x_axis_rotation, double theta, double theta_delta, bool large_arc, bool sweep) + void elliptical_arc_to(FloatPoint const& endpoint, FloatPoint const& center, FloatPoint const& radii, double x_axis_rotation, double theta, double theta_delta, bool large_arc, bool sweep) { append_segment<EllipticalArcSegment>( endpoint, @@ -218,7 +218,7 @@ public: float x; }; - const NonnullRefPtrVector<Segment>& segments() const { return m_segments; } + NonnullRefPtrVector<Segment> const& segments() const { return m_segments; } auto& split_lines() const { if (!m_split_lines.has_value()) { diff --git a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h index c5cb419095..c1a67a3b23 100644 --- a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h +++ b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h @@ -45,7 +45,7 @@ static bool read_number(Streamer& streamer, TValue* value) sb.append(byte); } - const auto opt_value = sb.to_string().to_uint(); + auto const opt_value = sb.to_string().to_uint(); if (!opt_value.has_value()) { *value = 0; return false; @@ -133,7 +133,7 @@ static bool read_whitespace(TContext& context, Streamer& streamer) template<typename TContext> static bool read_width(TContext& context, Streamer& streamer) { - if (const bool result = read_number(streamer, &context.width); + if (bool const result = read_number(streamer, &context.width); !result || context.width == 0) { return false; } @@ -145,7 +145,7 @@ static bool read_width(TContext& context, Streamer& streamer) template<typename TContext> static bool read_height(TContext& context, Streamer& streamer) { - if (const bool result = read_number(streamer, &context.height); + if (bool const result = read_number(streamer, &context.height); !result || context.height == 0) { return false; } @@ -157,7 +157,7 @@ static bool read_height(TContext& context, Streamer& streamer) template<typename TContext> static bool read_max_val(TContext& context, Streamer& streamer) { - if (const bool result = read_number(streamer, &context.format_details.max_val); + if (bool const result = read_number(streamer, &context.format_details.max_val); !result || context.format_details.max_val == 0) { return false; } @@ -185,7 +185,7 @@ static bool create_bitmap(TContext& context) } template<typename TContext> -static void set_pixels(TContext& context, const Vector<Gfx::Color>& color_data) +static void set_pixels(TContext& context, Vector<Gfx::Color> const& color_data) { size_t index = 0; for (size_t y = 0; y < context.height; ++y) { @@ -248,7 +248,7 @@ static bool decode(TContext& context) } template<typename TContext> -static RefPtr<Gfx::Bitmap> load_impl(const u8* data, size_t data_size) +static RefPtr<Gfx::Bitmap> load_impl(u8 const* data, size_t data_size) { TContext context {}; context.data = data; diff --git a/Userland/Libraries/LibGfx/PortableImageMapLoader.h b/Userland/Libraries/LibGfx/PortableImageMapLoader.h index f854cd75eb..994a86961c 100644 --- a/Userland/Libraries/LibGfx/PortableImageMapLoader.h +++ b/Userland/Libraries/LibGfx/PortableImageMapLoader.h @@ -49,7 +49,7 @@ struct PortableImageMapLoadingContext { template<typename TContext> class PortableImageDecoderPlugin final : public ImageDecoderPlugin { public: - PortableImageDecoderPlugin(const u8*, size_t); + PortableImageDecoderPlugin(u8 const*, size_t); virtual ~PortableImageDecoderPlugin() override = default; virtual IntSize size() override; @@ -69,7 +69,7 @@ private: }; template<typename TContext> -PortableImageDecoderPlugin<TContext>::PortableImageDecoderPlugin(const u8* data, size_t size) +PortableImageDecoderPlugin<TContext>::PortableImageDecoderPlugin(u8 const* data, size_t size) { m_context = make<TContext>(); m_context->data = data; diff --git a/Userland/Libraries/LibGfx/Rect.cpp b/Userland/Libraries/LibGfx/Rect.cpp index 3c8714195a..64db8e6270 100644 --- a/Userland/Libraries/LibGfx/Rect.cpp +++ b/Userland/Libraries/LibGfx/Rect.cpp @@ -170,7 +170,7 @@ Point<T> Rect<T>::closest_to(Point<T> const& point) const return {}; Optional<Point<T>> closest_point; float closest_distance = 0.0; - auto check_distance = [&](const Line<T>& line) { + auto check_distance = [&](Line<T> const& line) { auto point_on_line = line.closest_to(point); auto distance = Line { point_on_line, point }.length(); if (!closest_point.has_value() || distance < closest_distance) { diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 57b7d249c6..82534cae6f 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -752,7 +752,7 @@ struct Formatter<Gfx::Rect<T>> : Formatter<StringView> { namespace IPC { -bool encode(Encoder&, const Gfx::IntRect&); +bool encode(Encoder&, Gfx::IntRect const&); ErrorOr<void> decode(Decoder&, Gfx::IntRect&); } diff --git a/Userland/Libraries/LibGfx/ShareableBitmap.cpp b/Userland/Libraries/LibGfx/ShareableBitmap.cpp index f76be7d897..2be857d4de 100644 --- a/Userland/Libraries/LibGfx/ShareableBitmap.cpp +++ b/Userland/Libraries/LibGfx/ShareableBitmap.cpp @@ -22,7 +22,7 @@ ShareableBitmap::ShareableBitmap(NonnullRefPtr<Bitmap> bitmap, Tag) namespace IPC { -bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap) +bool encode(Encoder& encoder, Gfx::ShareableBitmap const& shareable_bitmap) { encoder << shareable_bitmap.is_valid(); if (!shareable_bitmap.is_valid()) diff --git a/Userland/Libraries/LibGfx/ShareableBitmap.h b/Userland/Libraries/LibGfx/ShareableBitmap.h index 3eefade8ac..04e5985582 100644 --- a/Userland/Libraries/LibGfx/ShareableBitmap.h +++ b/Userland/Libraries/LibGfx/ShareableBitmap.h @@ -21,7 +21,7 @@ public: bool is_valid() const { return m_bitmap; } - const Bitmap* bitmap() const { return m_bitmap; } + Bitmap const* bitmap() const { return m_bitmap; } Bitmap* bitmap() { return m_bitmap; } private: @@ -34,7 +34,7 @@ private: namespace IPC { -bool encode(Encoder&, const Gfx::ShareableBitmap&); +bool encode(Encoder&, Gfx::ShareableBitmap const&); ErrorOr<void> decode(Decoder&, Gfx::ShareableBitmap&); } diff --git a/Userland/Libraries/LibGfx/Streamer.h b/Userland/Libraries/LibGfx/Streamer.h index 1de269e7fe..15acbd1106 100644 --- a/Userland/Libraries/LibGfx/Streamer.h +++ b/Userland/Libraries/LibGfx/Streamer.h @@ -16,7 +16,7 @@ namespace Gfx { class Streamer { public: - constexpr Streamer(const u8* data, size_t size) + constexpr Streamer(u8 const* data, size_t size) : m_data_ptr(data) , m_size_remaining(size) { @@ -52,7 +52,7 @@ public: } private: - const u8* m_data_ptr { nullptr }; + u8 const* m_data_ptr { nullptr }; size_t m_size_remaining { 0 }; }; diff --git a/Userland/Libraries/LibGfx/StylePainter.cpp b/Userland/Libraries/LibGfx/StylePainter.cpp index 286fc03684..8fbec27c83 100644 --- a/Userland/Libraries/LibGfx/StylePainter.cpp +++ b/Userland/Libraries/LibGfx/StylePainter.cpp @@ -18,42 +18,42 @@ BaseStylePainter& StylePainter::current() return style; } -void StylePainter::paint_tab_button(Painter& painter, const IntRect& rect, const Palette& palette, bool active, bool hovered, bool enabled, bool top, bool in_active_window) +void StylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, bool top, bool in_active_window) { current().paint_tab_button(painter, rect, palette, active, hovered, enabled, top, in_active_window); } -void StylePainter::paint_button(Painter& painter, const IntRect& rect, const Palette& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled, bool focused, bool default_button) +void StylePainter::paint_button(Painter& painter, IntRect const& rect, Palette const& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled, bool focused, bool default_button) { current().paint_button(painter, rect, palette, button_style, pressed, hovered, checked, enabled, focused, default_button); } -void StylePainter::paint_frame(Painter& painter, const IntRect& rect, const Palette& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines) +void StylePainter::paint_frame(Painter& painter, IntRect const& rect, Palette const& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines) { current().paint_frame(painter, rect, palette, shape, shadow, thickness, skip_vertical_lines); } -void StylePainter::paint_window_frame(Painter& painter, const IntRect& rect, const Palette& palette) +void StylePainter::paint_window_frame(Painter& painter, IntRect const& rect, Palette const& palette) { current().paint_window_frame(painter, rect, palette); } -void StylePainter::paint_progressbar(Painter& painter, const IntRect& rect, const Palette& palette, int min, int max, int value, StringView text, Orientation orientation) +void StylePainter::paint_progressbar(Painter& painter, IntRect const& rect, Palette const& palette, int min, int max, int value, StringView text, Orientation orientation) { current().paint_progressbar(painter, rect, palette, min, max, value, text, orientation); } -void StylePainter::paint_radio_button(Painter& painter, const IntRect& rect, const Palette& palette, bool is_checked, bool is_being_pressed) +void StylePainter::paint_radio_button(Painter& painter, IntRect const& rect, Palette const& palette, bool is_checked, bool is_being_pressed) { current().paint_radio_button(painter, rect, palette, is_checked, is_being_pressed); } -void StylePainter::paint_check_box(Painter& painter, const IntRect& rect, const Palette& palette, bool is_enabled, bool is_checked, bool is_being_pressed) +void StylePainter::paint_check_box(Painter& painter, IntRect const& rect, Palette const& palette, bool is_enabled, bool is_checked, bool is_being_pressed) { current().paint_check_box(painter, rect, palette, is_enabled, is_checked, is_being_pressed); } -void StylePainter::paint_transparency_grid(Painter& painter, const IntRect& rect, const Palette& palette) +void StylePainter::paint_transparency_grid(Painter& painter, IntRect const& rect, Palette const& palette) { current().paint_transparency_grid(painter, rect, palette); } diff --git a/Userland/Libraries/LibGfx/SystemTheme.cpp b/Userland/Libraries/LibGfx/SystemTheme.cpp index ed52299c08..815d0a62cc 100644 --- a/Userland/Libraries/LibGfx/SystemTheme.cpp +++ b/Userland/Libraries/LibGfx/SystemTheme.cpp @@ -13,7 +13,7 @@ namespace Gfx { static SystemTheme dummy_theme; -static const SystemTheme* theme_page = &dummy_theme; +static SystemTheme const* theme_page = &dummy_theme; static Core::AnonymousBuffer theme_buffer; Core::AnonymousBuffer& current_system_theme_buffer() diff --git a/Userland/Libraries/LibGfx/SystemTheme.h b/Userland/Libraries/LibGfx/SystemTheme.h index 769760c6dd..bc712ca7eb 100644 --- a/Userland/Libraries/LibGfx/SystemTheme.h +++ b/Userland/Libraries/LibGfx/SystemTheme.h @@ -135,7 +135,7 @@ enum class ColorRole { DisabledText = ThreedShadow1, }; -inline const char* to_string(ColorRole role) +inline char const* to_string(ColorRole role) { switch (role) { case ColorRole::NoRole: @@ -162,7 +162,7 @@ enum class AlignmentRole { __Count, }; -inline const char* to_string(AlignmentRole role) +inline char const* to_string(AlignmentRole role) { switch (role) { case AlignmentRole::NoRole: @@ -189,7 +189,7 @@ enum class FlagRole { __Count, }; -inline const char* to_string(FlagRole role) +inline char const* to_string(FlagRole role) { switch (role) { case FlagRole::NoRole: @@ -216,7 +216,7 @@ enum class MetricRole { __Count, }; -inline const char* to_string(MetricRole role) +inline char const* to_string(MetricRole role) { switch (role) { case MetricRole::NoRole: @@ -243,7 +243,7 @@ enum class PathRole { __Count, }; -inline const char* to_string(PathRole role) +inline char const* to_string(PathRole role) { switch (role) { case PathRole::NoRole: diff --git a/Userland/Libraries/LibGfx/TextAlignment.h b/Userland/Libraries/LibGfx/TextAlignment.h index 9c0f7a38d2..9d869fd3e1 100644 --- a/Userland/Libraries/LibGfx/TextAlignment.h +++ b/Userland/Libraries/LibGfx/TextAlignment.h @@ -62,7 +62,7 @@ inline Optional<TextAlignment> text_alignment_from_string(StringView string) return {}; } -inline const char* to_string(TextAlignment text_alignment) +inline char const* to_string(TextAlignment text_alignment) { #define __ENUMERATE(x) \ if (text_alignment == TextAlignment::x) \ diff --git a/Userland/Libraries/LibGfx/TextDirection.h b/Userland/Libraries/LibGfx/TextDirection.h index dc5ef5b184..20ac54d4b2 100644 --- a/Userland/Libraries/LibGfx/TextDirection.h +++ b/Userland/Libraries/LibGfx/TextDirection.h @@ -20,7 +20,7 @@ enum class BidirectionalClass { NEUTRAL, }; -extern const Array<BidirectionalClass, 0x1F000> char_bidi_class_lookup_table; +extern Array<BidirectionalClass, 0x1F000> const char_bidi_class_lookup_table; constexpr BidirectionalClass get_char_bidi_class(u32 ch) { diff --git a/Userland/Libraries/LibGfx/Typeface.cpp b/Userland/Libraries/LibGfx/Typeface.cpp index 87ba7eaf40..4c6f2be4c4 100644 --- a/Userland/Libraries/LibGfx/Typeface.cpp +++ b/Userland/Libraries/LibGfx/Typeface.cpp @@ -77,7 +77,7 @@ RefPtr<Font> Typeface::get_font(float point_size, Font::AllowInexactSizeMatch al return {}; } -void Typeface::for_each_fixed_size_font(Function<void(const Font&)> callback) const +void Typeface::for_each_fixed_size_font(Function<void(Font const&)> callback) const { for (auto font : m_bitmap_fonts) { callback(*font); diff --git a/Userland/Libraries/LibGfx/Typeface.h b/Userland/Libraries/LibGfx/Typeface.h index 10b865d8bc..fb2600862d 100644 --- a/Userland/Libraries/LibGfx/Typeface.h +++ b/Userland/Libraries/LibGfx/Typeface.h @@ -18,7 +18,7 @@ namespace Gfx { class Typeface : public RefCounted<Typeface> { public: - Typeface(const String& family, const String& variant) + Typeface(String const& family, String const& variant) : m_family(family) , m_variant(variant) { @@ -31,7 +31,7 @@ public: bool is_fixed_width() const; bool is_fixed_size() const { return !m_bitmap_fonts.is_empty(); } - void for_each_fixed_size_font(Function<void(const Font&)>) const; + void for_each_fixed_size_font(Function<void(Font const&)>) const; void add_bitmap_font(RefPtr<BitmapFont>); void set_ttf_font(RefPtr<TTF::Font>); diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index a8b64e723d..6e07a3b49d 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -62,7 +62,7 @@ public: return m_data[index]; } - constexpr VectorN& operator+=(const VectorN& other) + constexpr VectorN& operator+=(VectorN const& other) { UNROLL_LOOP for (auto i = 0u; i < N; ++i) @@ -70,7 +70,7 @@ public: return *this; } - constexpr VectorN& operator-=(const VectorN& other) + constexpr VectorN& operator-=(VectorN const& other) { UNROLL_LOOP for (auto i = 0u; i < N; ++i) @@ -86,7 +86,7 @@ public: return *this; } - [[nodiscard]] constexpr VectorN operator+(const VectorN& other) const + [[nodiscard]] constexpr VectorN operator+(VectorN const& other) const { VectorN result; UNROLL_LOOP @@ -95,7 +95,7 @@ public: return result; } - [[nodiscard]] constexpr VectorN operator-(const VectorN& other) const + [[nodiscard]] constexpr VectorN operator-(VectorN const& other) const { VectorN result; UNROLL_LOOP @@ -104,7 +104,7 @@ public: return result; } - [[nodiscard]] constexpr VectorN operator*(const VectorN& other) const + [[nodiscard]] constexpr VectorN operator*(VectorN const& other) const { VectorN result; UNROLL_LOOP @@ -122,7 +122,7 @@ public: return result; } - [[nodiscard]] constexpr VectorN operator/(const VectorN& other) const + [[nodiscard]] constexpr VectorN operator/(VectorN const& other) const { VectorN result; UNROLL_LOOP @@ -151,7 +151,7 @@ public: return result; } - [[nodiscard]] constexpr T dot(const VectorN& other) const + [[nodiscard]] constexpr T dot(VectorN const& other) const { T result {}; UNROLL_LOOP @@ -160,7 +160,7 @@ public: return result; } - [[nodiscard]] constexpr VectorN cross(const VectorN& other) const requires(N == 3) + [[nodiscard]] constexpr VectorN cross(VectorN const& other) const requires(N == 3) { return VectorN( y() * other.z() - z() * other.y(), diff --git a/Userland/Libraries/LibGfx/WindowTheme.h b/Userland/Libraries/LibGfx/WindowTheme.h index d307099983..4d7e07b2ae 100644 --- a/Userland/Libraries/LibGfx/WindowTheme.h +++ b/Userland/Libraries/LibGfx/WindowTheme.h @@ -31,22 +31,22 @@ public: static WindowTheme& current(); - virtual void paint_normal_frame(Painter&, WindowState, const IntRect& window_rect, StringView title, const Bitmap& icon, const Palette&, const IntRect& leftmost_button_rect, int menu_row_count, bool window_modified) const = 0; - virtual void paint_tool_window_frame(Painter&, WindowState, const IntRect& window_rect, StringView title, const Palette&, const IntRect& leftmost_button_rect) const = 0; - virtual void paint_notification_frame(Painter&, const IntRect& window_rect, const Palette&, const IntRect& close_button_rect) const = 0; + virtual void paint_normal_frame(Painter&, WindowState, IntRect const& window_rect, StringView title, Bitmap const& icon, Palette const&, IntRect const& leftmost_button_rect, int menu_row_count, bool window_modified) const = 0; + virtual void paint_tool_window_frame(Painter&, WindowState, IntRect const& window_rect, StringView title, Palette const&, IntRect const& leftmost_button_rect) const = 0; + virtual void paint_notification_frame(Painter&, IntRect const& window_rect, Palette const&, IntRect const& close_button_rect) const = 0; - virtual int titlebar_height(WindowType, const Palette&) const = 0; - virtual IntRect titlebar_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0; - virtual IntRect titlebar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0; - virtual IntRect titlebar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0; + virtual int titlebar_height(WindowType, Palette const&) const = 0; + virtual IntRect titlebar_rect(WindowType, IntRect const& window_rect, Palette const&) const = 0; + virtual IntRect titlebar_icon_rect(WindowType, IntRect const& window_rect, Palette const&) const = 0; + virtual IntRect titlebar_text_rect(WindowType, IntRect const& window_rect, Palette const&) const = 0; - virtual IntRect menubar_rect(WindowType, const IntRect& window_rect, const Palette&, int menu_row_count) const = 0; + virtual IntRect menubar_rect(WindowType, IntRect const& window_rect, Palette const&, int menu_row_count) const = 0; - virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&, int menu_row_count) const = 0; + virtual IntRect frame_rect_for_window(WindowType, IntRect const& window_rect, Palette const&, int menu_row_count) const = 0; - virtual Vector<IntRect> layout_buttons(WindowType, const IntRect& window_rect, const Palette&, size_t buttons) const = 0; + virtual Vector<IntRect> layout_buttons(WindowType, IntRect const& window_rect, Palette const&, size_t buttons) const = 0; virtual bool is_simple_rect_frame() const = 0; - virtual bool frame_uses_alpha(WindowState, const Palette&) const = 0; + virtual bool frame_uses_alpha(WindowState, Palette const&) const = 0; virtual float frame_alpha_hit_threshold(WindowState) const = 0; protected: diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index 8a5ea6cc4a..6ae5ecf281 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -17,7 +17,7 @@ namespace HTTP { -static Optional<ByteBuffer> handle_content_encoding(const ByteBuffer& buf, const String& content_encoding) +static Optional<ByteBuffer> handle_content_encoding(ByteBuffer const& buf, String const& content_encoding) { dbgln_if(JOB_DEBUG, "Job::handle_content_encoding: buf has content_encoding={}", content_encoding); diff --git a/Userland/Libraries/LibHTTP/Job.h b/Userland/Libraries/LibHTTP/Job.h index eef352410d..27736e78ba 100644 --- a/Userland/Libraries/LibHTTP/Job.h +++ b/Userland/Libraries/LibHTTP/Job.h @@ -30,7 +30,7 @@ public: URL url() const { return m_request.url(); } HttpResponse* response() { return static_cast<HttpResponse*>(Core::NetworkJob::response()); } - const HttpResponse* response() const { return static_cast<const HttpResponse*>(Core::NetworkJob::response()); } + HttpResponse const* response() const { return static_cast<HttpResponse const*>(Core::NetworkJob::response()); } protected: void finish_up(); diff --git a/Userland/Libraries/LibIMAP/Client.cpp b/Userland/Libraries/LibIMAP/Client.cpp index 318239205e..dfb99ec918 100644 --- a/Userland/Libraries/LibIMAP/Client.cpp +++ b/Userland/Libraries/LibIMAP/Client.cpp @@ -316,7 +316,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::search(Optional<String> charset args.append("CHARSET "); args.append(charset.value()); } - for (const auto& item : keys) { + for (auto const& item : keys) { args.append(item.serialize()); } auto command = Command { uid ? CommandType::UIDSearch : CommandType::Search, m_current_command, args }; diff --git a/Userland/Libraries/LibIMAP/Objects.h b/Userland/Libraries/LibIMAP/Objects.h index 4609503613..88aa8426fa 100644 --- a/Userland/Libraries/LibIMAP/Objects.h +++ b/Userland/Libraries/LibIMAP/Objects.h @@ -505,7 +505,7 @@ public: ResponseData(ResponseData&) = delete; ResponseData(ResponseData&&) = default; - ResponseData& operator=(const ResponseData&) = delete; + ResponseData& operator=(ResponseData const&) = delete; ResponseData& operator=(ResponseData&&) = default; [[nodiscard]] bool contains_response_type(ResponseType response_type) const diff --git a/Userland/Libraries/LibIPC/Connection.cpp b/Userland/Libraries/LibIPC/Connection.cpp index 111df5686c..5de66aa0f2 100644 --- a/Userland/Libraries/LibIPC/Connection.cpp +++ b/Userland/Libraries/LibIPC/Connection.cpp @@ -34,7 +34,7 @@ ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer) // Prepend the message size. uint32_t message_size = buffer.data.size(); - TRY(buffer.data.try_prepend(reinterpret_cast<const u8*>(&message_size), sizeof(message_size))); + TRY(buffer.data.try_prepend(reinterpret_cast<u8 const*>(&message_size), sizeof(message_size))); #ifdef __serenity__ for (auto& fd : buffer.fds) { diff --git a/Userland/Libraries/LibIPC/ConnectionFromClient.h b/Userland/Libraries/LibIPC/ConnectionFromClient.h index e18a7bea2e..8710dad444 100644 --- a/Userland/Libraries/LibIPC/ConnectionFromClient.h +++ b/Userland/Libraries/LibIPC/ConnectionFromClient.h @@ -46,7 +46,7 @@ public: this->shutdown(); } - void did_misbehave(const char* message) + void did_misbehave(char const* message) { dbgln("{} (id={}) misbehaved ({}), disconnecting.", *this, m_client_id, message); this->shutdown(); diff --git a/Userland/Libraries/LibIPC/Dictionary.h b/Userland/Libraries/LibIPC/Dictionary.h index 97a5eed718..42d85452c3 100644 --- a/Userland/Libraries/LibIPC/Dictionary.h +++ b/Userland/Libraries/LibIPC/Dictionary.h @@ -16,7 +16,7 @@ class Dictionary { public: Dictionary() = default; - Dictionary(const HashMap<String, String>& initial_entries) + Dictionary(HashMap<String, String> const& initial_entries) : m_entries(initial_entries) { } @@ -37,7 +37,7 @@ public: } } - const HashMap<String, String>& entries() const { return m_entries; } + HashMap<String, String> const& entries() const { return m_entries; } private: HashMap<String, String> m_entries; diff --git a/Userland/Libraries/LibIPC/Message.h b/Userland/Libraries/LibIPC/Message.h index 4dcaef9584..4690b1d505 100644 --- a/Userland/Libraries/LibIPC/Message.h +++ b/Userland/Libraries/LibIPC/Message.h @@ -52,7 +52,7 @@ public: virtual u32 endpoint_magic() const = 0; virtual int message_id() const = 0; - virtual const char* message_name() const = 0; + virtual char const* message_name() const = 0; virtual bool valid() const = 0; virtual MessageBuffer encode() const = 0; diff --git a/Userland/Libraries/LibIPC/Stub.h b/Userland/Libraries/LibIPC/Stub.h index 49ec6de666..7c72550df9 100644 --- a/Userland/Libraries/LibIPC/Stub.h +++ b/Userland/Libraries/LibIPC/Stub.h @@ -25,7 +25,7 @@ public: virtual u32 magic() const = 0; virtual String name() const = 0; - virtual OwnPtr<MessageBuffer> handle(const Message&) = 0; + virtual OwnPtr<MessageBuffer> handle(Message const&) = 0; protected: Stub() = default; diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 141f4ae590..0cce9e4665 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1955,7 +1955,7 @@ void ScopeNode::dump(int indent) const void BinaryExpression::dump(int indent) const { - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case BinaryOp::Addition: op_string = "+"; @@ -2035,7 +2035,7 @@ void BinaryExpression::dump(int indent) const void LogicalExpression::dump(int indent) const { - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case LogicalOp::And: op_string = "&&"; @@ -2058,7 +2058,7 @@ void LogicalExpression::dump(int indent) const void UnaryExpression::dump(int indent) const { - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case UnaryOp::BitwiseNot: op_string = "~"; @@ -2153,7 +2153,7 @@ void ClassMethod::dump(int indent) const outln("(Key)"); m_key->dump(indent + 1); - const char* kind_string = nullptr; + char const* kind_string = nullptr; switch (m_kind) { case Kind::Method: kind_string = "Method"; @@ -2346,7 +2346,7 @@ void FunctionDeclaration::dump(int indent) const FunctionNode::dump(indent, class_name()); } -ThrowCompletionOr<void> FunctionDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<const FlyString&>&& callback) const +ThrowCompletionOr<void> FunctionDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<FlyString const&>&& callback) const { if (name().is_empty()) return {}; @@ -2757,7 +2757,7 @@ Completion UpdateExpression::execute(Interpreter& interpreter, GlobalObject& glo void AssignmentExpression::dump(int indent) const { - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case AssignmentOp::Assignment: op_string = "="; @@ -2818,7 +2818,7 @@ void AssignmentExpression::dump(int indent) const void UpdateExpression::dump(int indent) const { - const char* op_string = nullptr; + char const* op_string = nullptr; switch (m_op) { case UpdateOp::Increment: op_string = "++"; @@ -2903,7 +2903,7 @@ ThrowCompletionOr<void> VariableDeclaration::for_each_bound_name(ThrowCompletion void VariableDeclaration::dump(int indent) const { - const char* declaration_kind_string = nullptr; + char const* declaration_kind_string = nullptr; switch (m_declaration_kind) { case DeclarationKind::Let: declaration_kind_string = "Let"; @@ -2927,7 +2927,7 @@ void VariableDeclaration::dump(int indent) const void VariableDeclarator::dump(int indent) const { ASTNode::dump(indent); - m_target.visit([indent](const auto& value) { value->dump(indent + 1); }); + m_target.visit([indent](auto const& value) { value->dump(indent + 1); }); if (m_init) m_init->dump(indent + 1); } diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index ea9b283116..87b5a4e2af 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -190,8 +190,8 @@ concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args) { { func(args...) - } - ->SameAs<ThrowCompletionOr<void>>; + } + -> SameAs<ThrowCompletionOr<void>>; }; template<typename... Args> diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 2ade544fe7..249e53b99d 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -1216,7 +1216,7 @@ Bytecode::CodeGenerationErrorOr<void> CallExpression::generate_bytecode(Bytecode "Unimplemented callee kind: SuperExpression"sv, }; } else if (is<MemberExpression>(*m_callee)) { - auto& member_expression = static_cast<const MemberExpression&>(*m_callee); + auto& member_expression = static_cast<MemberExpression const&>(*m_callee); if (is<SuperExpression>(member_expression.object())) { return Bytecode::CodeGenerationError { this, diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 7886f5f363..1623a31063 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -794,7 +794,7 @@ String NewArray::to_string_impl(Bytecode::Executable const&) const return builder.to_string(); } -String IteratorToArray::to_string_impl(const Bytecode::Executable&) const +String IteratorToArray::to_string_impl(Bytecode::Executable const&) const { return "IteratorToArray"; } @@ -814,7 +814,7 @@ String NewRegExp::to_string_impl(Bytecode::Executable const& executable) const return String::formatted("NewRegExp source:{} (\"{}\") flags:{} (\"{}\")", m_source_index, executable.get_string(m_source_index), m_flags_index, executable.get_string(m_flags_index)); } -String CopyObjectExcludingProperties::to_string_impl(const Bytecode::Executable&) const +String CopyObjectExcludingProperties::to_string_impl(Bytecode::Executable const&) const { StringBuilder builder; builder.appendff("CopyObjectExcludingProperties from:{}", m_from_object); @@ -859,7 +859,7 @@ String CreateVariable::to_string_impl(Bytecode::Executable const& executable) co return String::formatted("CreateVariable env:{} immutable:{} {} ({})", mode_string, m_is_immutable, m_identifier, executable.identifier_table->get(m_identifier)); } -String EnterObjectEnvironment::to_string_impl(const Executable&) const +String EnterObjectEnvironment::to_string_impl(Executable const&) const { return String::formatted("EnterObjectEnvironment"); } @@ -975,7 +975,7 @@ String EnterUnwindContext::to_string_impl(Bytecode::Executable const&) const return String::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point); } -String FinishUnwind::to_string_impl(const Bytecode::Executable&) const +String FinishUnwind::to_string_impl(Bytecode::Executable const&) const { return String::formatted("FinishUnwind next:{}", m_next_target); } @@ -998,7 +998,7 @@ String ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const return String::formatted("ContinuePendingUnwind resume:{}", m_resume_target); } -String PushDeclarativeEnvironment::to_string_impl(const Bytecode::Executable& executable) const +String PushDeclarativeEnvironment::to_string_impl(Bytecode::Executable const& executable) const { StringBuilder builder; builder.append("PushDeclarativeEnvironment"); @@ -1020,12 +1020,12 @@ String Yield::to_string_impl(Bytecode::Executable const&) const return String::formatted("Yield return"); } -String GetByValue::to_string_impl(const Bytecode::Executable&) const +String GetByValue::to_string_impl(Bytecode::Executable const&) const { return String::formatted("GetByValue base:{}", m_base); } -String PutByValue::to_string_impl(const Bytecode::Executable&) const +String PutByValue::to_string_impl(Bytecode::Executable const&) const { auto kind = m_kind == PropertyKind::Getter ? "getter" @@ -1046,7 +1046,7 @@ String GetIterator::to_string_impl(Executable const&) const return "GetIterator"; } -String GetObjectPropertyIterator::to_string_impl(const Bytecode::Executable&) const +String GetObjectPropertyIterator::to_string_impl(Bytecode::Executable const&) const { return "GetObjectPropertyIterator"; } diff --git a/Userland/Libraries/LibJS/Console.h b/Userland/Libraries/LibJS/Console.h index 30a67364c2..3928882a39 100644 --- a/Userland/Libraries/LibJS/Console.h +++ b/Userland/Libraries/LibJS/Console.h @@ -58,13 +58,13 @@ public: void set_client(ConsoleClient& client) { m_client = &client; } GlobalObject& global_object() { return m_global_object; } - const GlobalObject& global_object() const { return m_global_object; } + GlobalObject const& global_object() const { return m_global_object; } VM& vm(); Vector<Value> vm_arguments(); HashMap<String, unsigned>& counters() { return m_counters; } - const HashMap<String, unsigned>& counters() const { return m_counters; } + HashMap<String, unsigned> const& counters() const { return m_counters; } ThrowCompletionOr<Value> debug(); ThrowCompletionOr<Value> error(); @@ -119,7 +119,7 @@ protected: VM& vm(); GlobalObject& global_object() { return m_console.global_object(); } - const GlobalObject& global_object() const { return m_console.global_object(); } + GlobalObject const& global_object() const { return m_console.global_object(); } Console& m_console; }; diff --git a/Userland/Libraries/LibJS/Heap/Handle.h b/Userland/Libraries/LibJS/Heap/Handle.h index d353279e5d..3fa2a01c29 100644 --- a/Userland/Libraries/LibJS/Heap/Handle.h +++ b/Userland/Libraries/LibJS/Heap/Handle.h @@ -25,7 +25,7 @@ public: ~HandleImpl(); Cell* cell() { return m_cell; } - const Cell* cell() const { return m_cell; } + Cell const* cell() const { return m_cell; } private: template<class T> diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index fcc8575af5..ca50bc28d0 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -156,15 +156,15 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has for (auto possible_pointer : possible_pointers) { if (!possible_pointer) continue; - dbgln_if(HEAP_DEBUG, " ? {}", (const void*)possible_pointer); - auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<const Cell*>(possible_pointer)); + dbgln_if(HEAP_DEBUG, " ? {}", (void const*)possible_pointer); + auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<Cell const*>(possible_pointer)); if (all_live_heap_blocks.contains(possible_heap_block)) { if (auto* cell = possible_heap_block->cell_from_possible_pointer(possible_pointer)) { if (cell->state() == Cell::State::Live) { - dbgln_if(HEAP_DEBUG, " ?-> {}", (const void*)cell); + dbgln_if(HEAP_DEBUG, " ?-> {}", (void const*)cell); roots.set(cell); } else { - dbgln_if(HEAP_DEBUG, " #-> {}", (const void*)cell); + dbgln_if(HEAP_DEBUG, " #-> {}", (void const*)cell); } } } @@ -186,7 +186,7 @@ public: } }; -void Heap::mark_live_cells(const HashTable<Cell*>& roots) +void Heap::mark_live_cells(HashTable<Cell*> const& roots) { dbgln_if(HEAP_DEBUG, "mark_live_cells:"); @@ -200,7 +200,7 @@ void Heap::mark_live_cells(const HashTable<Cell*>& roots) m_uprooted_cells.clear(); } -void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measurement_timer) +void Heap::sweep_dead_cells(bool print_report, Core::ElapsedTimer const& measurement_timer) { dbgln_if(HEAP_DEBUG, "sweep_dead_cells:"); Vector<HeapBlock*, 32> empty_blocks; diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index 470f11a1af..752a2a97d8 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -84,8 +84,8 @@ private: void gather_roots(HashTable<Cell*>&); void gather_conservative_roots(HashTable<Cell*>&); - void mark_live_cells(const HashTable<Cell*>& live_cells); - void sweep_dead_cells(bool print_report, const Core::ElapsedTimer&); + void mark_live_cells(HashTable<Cell*> const& live_cells); + void sweep_dead_cells(bool print_report, Core::ElapsedTimer const&); CellAllocator& allocator_for_size(size_t); diff --git a/Userland/Libraries/LibJS/Heap/HeapBlock.h b/Userland/Libraries/LibJS/Heap/HeapBlock.h index 750394862c..891cc89fed 100644 --- a/Userland/Libraries/LibJS/Heap/HeapBlock.h +++ b/Userland/Libraries/LibJS/Heap/HeapBlock.h @@ -68,7 +68,7 @@ public: Heap& heap() { return m_heap; } - static HeapBlock* from_cell(const Cell* cell) + static HeapBlock* from_cell(Cell const* cell) { return reinterpret_cast<HeapBlock*>((FlatPtr)cell & ~(block_size - 1)); } @@ -84,7 +84,7 @@ public: return cell(cell_index); } - bool is_valid_cell_pointer(const Cell* cell) + bool is_valid_cell_pointer(Cell const* cell) { return cell_from_possible_pointer((FlatPtr)cell); } diff --git a/Userland/Libraries/LibJS/Interpreter.cpp b/Userland/Libraries/LibJS/Interpreter.cpp index 513e5a9f91..6d997698ba 100644 --- a/Userland/Libraries/LibJS/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Interpreter.cpp @@ -148,9 +148,9 @@ GlobalObject& Interpreter::global_object() return static_cast<GlobalObject&>(*m_global_object.cell()); } -const GlobalObject& Interpreter::global_object() const +GlobalObject const& Interpreter::global_object() const { - return static_cast<const GlobalObject&>(*m_global_object.cell()); + return static_cast<GlobalObject const&>(*m_global_object.cell()); } Realm& Interpreter::realm() @@ -158,9 +158,9 @@ Realm& Interpreter::realm() return static_cast<Realm&>(*m_realm.cell()); } -const Realm& Interpreter::realm() const +Realm const& Interpreter::realm() const { - return static_cast<const Realm&>(*m_realm.cell()); + return static_cast<Realm const&>(*m_realm.cell()); } } diff --git a/Userland/Libraries/LibJS/Interpreter.h b/Userland/Libraries/LibJS/Interpreter.h index 8d31526610..ce3e8dfefd 100644 --- a/Userland/Libraries/LibJS/Interpreter.h +++ b/Userland/Libraries/LibJS/Interpreter.h @@ -31,7 +31,7 @@ namespace JS { struct ExecutingASTNodeChain { ExecutingASTNodeChain* previous { nullptr }; - const ASTNode& node; + ASTNode const& node; }; class Interpreter : public Weakable<Interpreter> { @@ -107,7 +107,7 @@ public: ThrowCompletionOr<Value> run(SourceTextModule&); GlobalObject& global_object(); - const GlobalObject& global_object() const; + GlobalObject const& global_object() const; Realm& realm(); Realm const& realm() const; @@ -130,7 +130,7 @@ public: m_ast_node_chain = m_ast_node_chain->previous; } - const ASTNode* current_node() const { return m_ast_node_chain ? &m_ast_node_chain->node : nullptr; } + ASTNode const* current_node() const { return m_ast_node_chain ? &m_ast_node_chain->node : nullptr; } private: explicit Interpreter(VM&); diff --git a/Userland/Libraries/LibJS/MarkupGenerator.cpp b/Userland/Libraries/LibJS/MarkupGenerator.cpp index 6a5d5c776d..4f9d4bdc88 100644 --- a/Userland/Libraries/LibJS/MarkupGenerator.cpp +++ b/Userland/Libraries/LibJS/MarkupGenerator.cpp @@ -64,7 +64,7 @@ void MarkupGenerator::value_to_html(Value value, StringBuilder& output_html, Has if (value.is_object()) { auto& object = value.as_object(); if (is<Array>(object)) - return array_to_html(static_cast<const Array&>(object), output_html, seen_objects); + return array_to_html(static_cast<Array const&>(object), output_html, seen_objects); output_html.append(wrap_string_in_style(object.class_name(), StyleType::ObjectType)); if (object.is_function()) return function_to_html(object, output_html, seen_objects); @@ -91,7 +91,7 @@ void MarkupGenerator::value_to_html(Value value, StringBuilder& output_html, Has output_html.append("</span>"); } -void MarkupGenerator::array_to_html(const Array& array, StringBuilder& html_output, HashTable<Object*>& seen_objects) +void MarkupGenerator::array_to_html(Array const& array, StringBuilder& html_output, HashTable<Object*>& seen_objects) { html_output.append(wrap_string_in_style("[ ", StyleType::Punctuation)); bool first = true; @@ -105,7 +105,7 @@ void MarkupGenerator::array_to_html(const Array& array, StringBuilder& html_outp html_output.append(wrap_string_in_style(" ]", StyleType::Punctuation)); } -void MarkupGenerator::object_to_html(const Object& object, StringBuilder& html_output, HashTable<Object*>& seen_objects) +void MarkupGenerator::object_to_html(Object const& object, StringBuilder& html_output, HashTable<Object*>& seen_objects) { html_output.append(wrap_string_in_style("{ ", StyleType::Punctuation)); bool first = true; @@ -135,17 +135,17 @@ void MarkupGenerator::object_to_html(const Object& object, StringBuilder& html_o html_output.append(wrap_string_in_style(" }", StyleType::Punctuation)); } -void MarkupGenerator::function_to_html(const Object& function, StringBuilder& html_output, HashTable<Object*>&) +void MarkupGenerator::function_to_html(Object const& function, StringBuilder& html_output, HashTable<Object*>&) { html_output.appendff("[{}]", function.class_name()); } -void MarkupGenerator::date_to_html(const Object& date, StringBuilder& html_output, HashTable<Object*>&) +void MarkupGenerator::date_to_html(Object const& date, StringBuilder& html_output, HashTable<Object*>&) { html_output.appendff("Date {}", JS::to_date_string(static_cast<JS::Date const&>(date).date_value())); } -void MarkupGenerator::error_to_html(const Object& object, StringBuilder& html_output, HashTable<Object*>&) +void MarkupGenerator::error_to_html(Object const& object, StringBuilder& html_output, HashTable<Object*>&) { auto& vm = object.vm(); auto name = object.get_without_side_effects(vm.names.name).value_or(JS::js_undefined()); diff --git a/Userland/Libraries/LibJS/MarkupGenerator.h b/Userland/Libraries/LibJS/MarkupGenerator.h index 97940d64cb..f8bc16849c 100644 --- a/Userland/Libraries/LibJS/MarkupGenerator.h +++ b/Userland/Libraries/LibJS/MarkupGenerator.h @@ -33,11 +33,11 @@ private: }; static void value_to_html(Value, StringBuilder& output_html, HashTable<Object*> seen_objects = {}); - static void array_to_html(const Array&, StringBuilder& output_html, HashTable<Object*>&); - static void object_to_html(const Object&, StringBuilder& output_html, HashTable<Object*>&); - static void function_to_html(const Object&, StringBuilder& output_html, HashTable<Object*>&); - static void date_to_html(const Object&, StringBuilder& output_html, HashTable<Object*>&); - static void error_to_html(const Object&, StringBuilder& output_html, HashTable<Object*>&); + static void array_to_html(Array const&, StringBuilder& output_html, HashTable<Object*>&); + static void object_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&); + static void function_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&); + static void date_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&); + static void error_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&); static String style_from_style_type(StyleType); static StyleType style_type_for_token(Token); diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 3246f1c56b..31e2ce68a4 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -1798,7 +1798,7 @@ NonnullRefPtr<ArrayExpression> Parser::parse_array_expression() return create_ast_node<ArrayExpression>({ m_state.current_token.filename(), rule_start.position(), position() }, move(elements)); } -NonnullRefPtr<StringLiteral> Parser::parse_string_literal(const Token& token, bool in_template_literal) +NonnullRefPtr<StringLiteral> Parser::parse_string_literal(Token const& token, bool in_template_literal) { auto rule_start = push_start(); auto status = Token::StringValueStatus::Ok; @@ -3919,7 +3919,7 @@ Token Parser::consume_and_validate_numeric_literal() return token; } -void Parser::expected(const char* what) +void Parser::expected(char const* what) { auto message = m_state.current_token.message(); if (message.is_empty()) @@ -3936,7 +3936,7 @@ Position Parser::position() const }; } -bool Parser::try_parse_arrow_function_expression_failed_at_position(const Position& position) const +bool Parser::try_parse_arrow_function_expression_failed_at_position(Position const& position) const { auto it = m_token_memoizations.find(position); if (it == m_token_memoizations.end()) @@ -3945,12 +3945,12 @@ bool Parser::try_parse_arrow_function_expression_failed_at_position(const Positi return (*it).value.try_parse_arrow_function_expression_failed; } -void Parser::set_try_parse_arrow_function_expression_failed_at_position(const Position& position, bool failed) +void Parser::set_try_parse_arrow_function_expression_failed_at_position(Position const& position, bool failed) { m_token_memoizations.set(position, { failed }); } -void Parser::syntax_error(const String& message, Optional<Position> position) +void Parser::syntax_error(String const& message, Optional<Position> position) { if (!position.has_value()) position = this->position(); diff --git a/Userland/Libraries/LibJS/Parser.h b/Userland/Libraries/LibJS/Parser.h index 4d1eeb378d..10d708c1ed 100644 --- a/Userland/Libraries/LibJS/Parser.h +++ b/Userland/Libraries/LibJS/Parser.h @@ -135,7 +135,7 @@ public: NonnullRefPtr<RegExpLiteral> parse_regexp_literal(); NonnullRefPtr<ObjectExpression> parse_object_expression(); NonnullRefPtr<ArrayExpression> parse_array_expression(); - NonnullRefPtr<StringLiteral> parse_string_literal(const Token& token, bool in_template_literal = false); + NonnullRefPtr<StringLiteral> parse_string_literal(Token const& token, bool in_template_literal = false); NonnullRefPtr<TemplateLiteral> parse_template_literal(bool is_tagged); ExpressionResult parse_secondary_expression(NonnullRefPtr<Expression>, int min_precedence, Associativity associate = Associativity::Right, ForbiddenTokens forbidden = {}); NonnullRefPtr<Expression> parse_call_expression(NonnullRefPtr<Expression>); @@ -169,7 +169,7 @@ public: return String::formatted("{} (line: {}, column: {})", message, position.value().line, position.value().column); } - String source_location_hint(StringView source, const char spacer = ' ', const char indicator = '^') const + String source_location_hint(StringView source, char const spacer = ' ', char const indicator = '^') const { if (!position.has_value()) return {}; @@ -187,7 +187,7 @@ public: }; bool has_errors() const { return m_state.errors.size(); } - const Vector<Error>& errors() const { return m_state.errors; } + Vector<Error> const& errors() const { return m_state.errors; } void print_errors(bool print_hint = true) const { for (auto& error : m_state.errors) { @@ -229,8 +229,8 @@ private: bool is_private_identifier_valid() const; bool match(TokenType type) const; bool done() const; - void expected(const char* what); - void syntax_error(const String& message, Optional<Position> = {}); + void expected(char const* what); + void syntax_error(String const& message, Optional<Position> = {}); Token consume(); Token consume_identifier(); Token consume_identifier_reference(); @@ -248,8 +248,8 @@ private: void check_identifier_name_for_assignment_validity(FlyString const&, bool force_strict = false); - bool try_parse_arrow_function_expression_failed_at_position(const Position&) const; - void set_try_parse_arrow_function_expression_failed_at_position(const Position&, bool); + bool try_parse_arrow_function_expression_failed_at_position(Position const&) const; + void set_try_parse_arrow_function_expression_failed_at_position(Position const&, bool); bool match_invalid_escaped_keyword() const; @@ -278,7 +278,7 @@ private: VERIFY(last.column == m_position.column); } - const Position& position() const { return m_position; } + Position const& position() const { return m_position; } private: Parser& m_parser; @@ -316,12 +316,12 @@ private: class PositionKeyTraits { public: - static int hash(const Position& position) + static int hash(Position const& position) { return int_hash(position.line) ^ int_hash(position.column); } - static bool equals(const Position& a, const Position& b) + static bool equals(Position const& a, Position const& b) { return a.column == b.column && a.line == b.line; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index 9e33b5c1a5..7a728a7965 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -36,7 +36,7 @@ public: size_t byte_length() const { return buffer_impl().size(); } size_t max_byte_length() const { return m_max_byte_length.value(); } // Will VERIFY() that it has value ByteBuffer& buffer() { return buffer_impl(); } - const ByteBuffer& buffer() const { return buffer_impl(); } + ByteBuffer const& buffer() const { return buffer_impl(); } // Used by allocate_array_buffer() to attach the data block after construction void set_buffer(ByteBuffer buffer) { m_buffer = move(buffer); } @@ -71,7 +71,7 @@ private: return *ptr; } - const ByteBuffer& buffer_impl() const { return const_cast<ArrayBuffer*>(this)->buffer_impl(); } + ByteBuffer const& buffer_impl() const { return const_cast<ArrayBuffer*>(this)->buffer_impl(); } Variant<Empty, ByteBuffer, ByteBuffer*> m_buffer; // The various detach related members of ArrayBuffer are not used by any ECMA262 functionality, diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.h b/Userland/Libraries/LibJS/Runtime/BigInt.h index bdba742c50..9290c554f2 100644 --- a/Userland/Libraries/LibJS/Runtime/BigInt.h +++ b/Userland/Libraries/LibJS/Runtime/BigInt.h @@ -17,7 +17,7 @@ public: explicit BigInt(Crypto::SignedBigInteger); virtual ~BigInt() override = default; - const Crypto::SignedBigInteger& big_integer() const { return m_big_integer; } + Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; } const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); } private: diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp index e3f3fcb0d8..cee8afe7b8 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp @@ -35,7 +35,7 @@ JS_DEFINE_NATIVE_FUNCTION(BooleanPrototype::to_string) if (!this_value.is_object() || !is<BooleanObject>(this_value.as_object())) return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Boolean"); - bool bool_value = static_cast<const BooleanObject&>(this_value.as_object()).boolean(); + bool bool_value = static_cast<BooleanObject const&>(this_value.as_object()).boolean(); return js_string(vm, bool_value ? "true" : "false"); } @@ -48,6 +48,6 @@ JS_DEFINE_NATIVE_FUNCTION(BooleanPrototype::value_of) if (!this_value.is_object() || !is<BooleanObject>(this_value.as_object())) return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Boolean"); - return Value(static_cast<const BooleanObject&>(this_value.as_object()).boolean()); + return Value(static_cast<BooleanObject const&>(this_value.as_object()).boolean()); } } diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.h b/Userland/Libraries/LibJS/Runtime/BoundFunction.h index 35d5c2a7fc..9993ffcc4a 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.h @@ -23,7 +23,7 @@ public: virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override; virtual ThrowCompletionOr<Object*> internal_construct(MarkedVector<Value> arguments_list, FunctionObject& new_target) override; - virtual const FlyString& name() const override { return m_name; } + virtual FlyString const& name() const override { return m_name; } virtual bool is_strict_mode() const override { return m_bound_target_function->is_strict_mode(); } virtual bool has_constructor() const override { return m_bound_target_function->has_constructor(); } diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index 115d928a98..fb48a87a97 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -23,7 +23,7 @@ namespace JS { // 21.4.3.2 Date.parse ( string ), https://tc39.es/ecma262/#sec-date.parse -static Value parse_simplified_iso8601(GlobalObject& global_object, const String& iso_8601) +static Value parse_simplified_iso8601(GlobalObject& global_object, String const& iso_8601) { // 21.4.1.15 Date Time String Format, https://tc39.es/ecma262/#sec-date-time-string-format GenericLexer lexer(iso_8601); diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index f7318c9d17..dcb04428b3 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -875,7 +875,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() VERIFY_NOT_REACHED(); } -void ECMAScriptFunctionObject::set_name(const FlyString& name) +void ECMAScriptFunctionObject::set_name(FlyString const& name) { VERIFY(!name.is_null()); auto& vm = this->vm(); diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index 843a9878ab..2f6377c9b9 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -47,8 +47,8 @@ public: Statement const& ecmascript_code() const { return m_ecmascript_code; } Vector<FunctionNode::Parameter> const& formal_parameters() const { return m_formal_parameters; }; - virtual const FlyString& name() const override { return m_name; }; - void set_name(const FlyString& name); + virtual FlyString const& name() const override { return m_name; }; + void set_name(FlyString const& name); void set_is_class_constructor() { m_is_class_constructor = true; }; diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h index 91f4019f41..90b51982ed 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h @@ -302,18 +302,18 @@ public: JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR) #undef __ENUMERATE_JS_ERROR - const char* message() const + char const* message() const { return m_message; } private: - explicit ErrorType(const char* message) + explicit ErrorType(char const* message) : m_message(message) { } - const char* m_message; + char const* m_message; }; } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.h b/Userland/Libraries/LibJS/Runtime/FunctionObject.h index 12ba18359f..38b1b6fe9f 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.h @@ -27,7 +27,7 @@ public: virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) = 0; virtual ThrowCompletionOr<Object*> internal_construct([[maybe_unused]] MarkedVector<Value> arguments_list, [[maybe_unused]] FunctionObject& new_target) { VERIFY_NOT_REACHED(); } - virtual const FlyString& name() const = 0; + virtual FlyString const& name() const = 0; void set_function_name(Variant<PropertyKey, PrivateName> const& name_arg, Optional<StringView> const& prefix = {}); void set_function_length(double length); diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index 144e0551df..84f83e394c 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -488,7 +488,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval) } // 19.2.6.1.1 Encode ( string, unescapedSet ), https://tc39.es/ecma262/#sec-encode -static ThrowCompletionOr<String> encode([[maybe_unused]] JS::GlobalObject& global_object, const String& string, StringView unescaped_set) +static ThrowCompletionOr<String> encode([[maybe_unused]] JS::GlobalObject& global_object, String const& string, StringView unescaped_set) { auto& vm = global_object.vm(); auto utf16_string = Utf16String(string); @@ -544,7 +544,7 @@ static ThrowCompletionOr<String> encode([[maybe_unused]] JS::GlobalObject& globa } // 19.2.6.1.2 Decode ( string, reservedSet ), https://tc39.es/ecma262/#sec-decode -static ThrowCompletionOr<String> decode(JS::GlobalObject& global_object, const String& string, StringView reserved_set) +static ThrowCompletionOr<String> decode(JS::GlobalObject& global_object, String const& string, StringView reserved_set) { StringBuilder decoded_builder; auto code_point_start_offset = 0u; diff --git a/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp index aa1274a2c9..e0245cb3f0 100644 --- a/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp +++ b/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp @@ -177,7 +177,7 @@ bool GenericIndexedPropertyStorage::set_array_like_size(size_t new_size) return !any_failed; } -IndexedPropertyIterator::IndexedPropertyIterator(const IndexedProperties& indexed_properties, u32 staring_index, bool skip_empty) +IndexedPropertyIterator::IndexedPropertyIterator(IndexedProperties const& indexed_properties, u32 staring_index, bool skip_empty) : m_indexed_properties(indexed_properties) , m_index(staring_index) , m_skip_empty(skip_empty) @@ -203,7 +203,7 @@ IndexedPropertyIterator& IndexedPropertyIterator::operator*() return *this; } -bool IndexedPropertyIterator::operator!=(const IndexedPropertyIterator& other) const +bool IndexedPropertyIterator::operator!=(IndexedPropertyIterator const& other) const { return m_index != other.m_index; } @@ -265,7 +265,7 @@ size_t IndexedProperties::real_size() const if (!m_storage) return 0; if (m_storage->is_simple_storage()) { - auto& packed_elements = static_cast<const SimpleIndexedPropertyStorage&>(*m_storage).elements(); + auto& packed_elements = static_cast<SimpleIndexedPropertyStorage const&>(*m_storage).elements(); size_t size = 0; for (auto& element : packed_elements) { if (!element.is_empty()) @@ -273,7 +273,7 @@ size_t IndexedProperties::real_size() const } return size; } - return static_cast<const GenericIndexedPropertyStorage&>(*m_storage).size(); + return static_cast<GenericIndexedPropertyStorage const&>(*m_storage).size(); } Vector<u32> IndexedProperties::indices() const @@ -281,8 +281,8 @@ Vector<u32> IndexedProperties::indices() const if (!m_storage) return {}; if (m_storage->is_simple_storage()) { - const auto& storage = static_cast<const SimpleIndexedPropertyStorage&>(*m_storage); - const auto& elements = storage.elements(); + auto const& storage = static_cast<SimpleIndexedPropertyStorage const&>(*m_storage); + auto const& elements = storage.elements(); Vector<u32> indices; indices.ensure_capacity(storage.array_like_size()); for (size_t i = 0; i < elements.size(); ++i) { @@ -291,7 +291,7 @@ Vector<u32> IndexedProperties::indices() const } return indices; } - const auto& storage = static_cast<const GenericIndexedPropertyStorage&>(*m_storage); + auto const& storage = static_cast<GenericIndexedPropertyStorage const&>(*m_storage); auto indices = storage.sparse_elements().keys(); quick_sort(indices); return indices; diff --git a/Userland/Libraries/LibJS/Runtime/IndexedProperties.h b/Userland/Libraries/LibJS/Runtime/IndexedProperties.h index 8e4f965dae..b972362952 100644 --- a/Userland/Libraries/LibJS/Runtime/IndexedProperties.h +++ b/Userland/Libraries/LibJS/Runtime/IndexedProperties.h @@ -58,7 +58,7 @@ public: virtual bool set_array_like_size(size_t new_size) override; virtual bool is_simple_storage() const override { return true; } - const Vector<Value>& elements() const { return m_packed_elements; } + Vector<Value> const& elements() const { return m_packed_elements; } private: friend GenericIndexedPropertyStorage; @@ -86,7 +86,7 @@ public: virtual size_t array_like_size() const override { return m_array_size; } virtual bool set_array_like_size(size_t new_size) override; - const HashMap<u32, ValueAndAttributes>& sparse_elements() const { return m_sparse_elements; } + HashMap<u32, ValueAndAttributes> const& sparse_elements() const { return m_sparse_elements; } private: size_t m_array_size { 0 }; @@ -95,18 +95,18 @@ private: class IndexedPropertyIterator { public: - IndexedPropertyIterator(const IndexedProperties&, u32 starting_index, bool skip_empty); + IndexedPropertyIterator(IndexedProperties const&, u32 starting_index, bool skip_empty); IndexedPropertyIterator& operator++(); IndexedPropertyIterator& operator*(); - bool operator!=(const IndexedPropertyIterator&) const; + bool operator!=(IndexedPropertyIterator const&) const; u32 index() const { return m_index; }; private: void skip_empty_indices(); - const IndexedProperties& m_indexed_properties; + IndexedProperties const& m_indexed_properties; Vector<u32> m_cached_indices; u32 m_index { 0 }; bool m_skip_empty { false }; @@ -149,7 +149,7 @@ public: for (auto& value : static_cast<SimpleIndexedPropertyStorage&>(*m_storage).elements()) callback(value); } else { - for (auto& element : static_cast<const GenericIndexedPropertyStorage&>(*m_storage).sparse_elements()) + for (auto& element : static_cast<GenericIndexedPropertyStorage const&>(*m_storage).sparse_elements()) callback(element.value.value); } } diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index ac412398a5..60118b8832 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -122,7 +122,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify) } // 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty -ThrowCompletionOr<String> JSONObject::serialize_json_property(GlobalObject& global_object, StringifyState& state, const PropertyKey& key, Object* holder) +ThrowCompletionOr<String> JSONObject::serialize_json_property(GlobalObject& global_object, StringifyState& state, PropertyKey const& key, Object* holder) { auto& vm = global_object.vm(); @@ -229,7 +229,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(GlobalObject& global state.indent = String::formatted("{}{}", state.indent, state.gap); Vector<String> property_strings; - auto process_property = [&](const PropertyKey& key) -> ThrowCompletionOr<void> { + auto process_property = [&](PropertyKey const& key) -> ThrowCompletionOr<void> { if (key.is_symbol()) return {}; auto serialized_property_string = TRY(serialize_json_property(global_object, state, key, &object)); @@ -408,7 +408,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse) return unfiltered; } -Value JSONObject::parse_json_value(GlobalObject& global_object, const JsonValue& value) +Value JSONObject::parse_json_value(GlobalObject& global_object, JsonValue const& value) { if (value.is_object()) return Value(parse_json_object(global_object, value.as_object())); @@ -427,7 +427,7 @@ Value JSONObject::parse_json_value(GlobalObject& global_object, const JsonValue& VERIFY_NOT_REACHED(); } -Object* JSONObject::parse_json_object(GlobalObject& global_object, const JsonObject& json_object) +Object* JSONObject::parse_json_object(GlobalObject& global_object, JsonObject const& json_object) { auto* object = Object::create(global_object, global_object.object_prototype()); json_object.for_each_member([&](auto& key, auto& value) { @@ -436,7 +436,7 @@ Object* JSONObject::parse_json_object(GlobalObject& global_object, const JsonObj return object; } -Array* JSONObject::parse_json_array(GlobalObject& global_object, const JsonArray& json_array) +Array* JSONObject::parse_json_array(GlobalObject& global_object, JsonArray const& json_array) { auto* array = MUST(Array::create(global_object, 0)); size_t index = 0; @@ -455,7 +455,7 @@ ThrowCompletionOr<Value> JSONObject::internalize_json_property(GlobalObject& glo auto is_array = TRY(value.is_array(global_object)); auto& value_object = value.as_object(); - auto process_property = [&](const PropertyKey& key) -> ThrowCompletionOr<void> { + auto process_property = [&](PropertyKey const& key) -> ThrowCompletionOr<void> { auto element = TRY(internalize_json_property(global_object, &value_object, key, reviver)); if (element.is_undefined()) TRY(value_object.internal_delete(key)); diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.h b/Userland/Libraries/LibJS/Runtime/JSONObject.h index 3aa2cd97d8..98c25d9169 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.h +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.h @@ -22,7 +22,7 @@ public: // test-js to communicate between the JS tests and the C++ test runner. static ThrowCompletionOr<String> stringify_impl(GlobalObject&, Value value, Value replacer, Value space); - static Value parse_json_value(GlobalObject&, const JsonValue&); + static Value parse_json_value(GlobalObject&, JsonValue const&); private: struct StringifyState { @@ -34,14 +34,14 @@ private: }; // Stringify helpers - static ThrowCompletionOr<String> serialize_json_property(GlobalObject&, StringifyState&, const PropertyKey& key, Object* holder); + static ThrowCompletionOr<String> serialize_json_property(GlobalObject&, StringifyState&, PropertyKey const& key, Object* holder); static ThrowCompletionOr<String> serialize_json_object(GlobalObject&, StringifyState&, Object&); static ThrowCompletionOr<String> serialize_json_array(GlobalObject&, StringifyState&, Object&); static String quote_json_string(String); // Parse helpers - static Object* parse_json_object(GlobalObject&, const JsonObject&); - static Array* parse_json_array(GlobalObject&, const JsonArray&); + static Object* parse_json_object(GlobalObject&, JsonObject const&); + static Array* parse_json_array(GlobalObject&, JsonArray const&); static ThrowCompletionOr<Value> internalize_json_property(GlobalObject&, Object* holder, PropertyKey const& name, FunctionObject& reviver); JS_DECLARE_NATIVE_FUNCTION(stringify); diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index 998c80943b..978095470e 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -51,7 +51,7 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, Function<Thr return function; } -NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyString& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> function) +NativeFunction* NativeFunction::create(GlobalObject& global_object, FlyString const& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> function) { return global_object.heap().allocate<NativeFunction>(global_object, name, move(function), *global_object.function_prototype()); } diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index 27c85c83d1..cc76a46e2b 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -21,7 +21,7 @@ class NativeFunction : public FunctionObject { public: static NativeFunction* create(GlobalObject&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {}); - static NativeFunction* create(GlobalObject&, const FlyString& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>); + static NativeFunction* create(GlobalObject&, FlyString const& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>); NativeFunction(GlobalObject&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object* prototype, Realm& realm); NativeFunction(FlyString name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object& prototype); @@ -36,7 +36,7 @@ public: virtual ThrowCompletionOr<Value> call(); virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target); - virtual const FlyString& name() const override { return m_name; }; + virtual FlyString const& name() const override { return m_name; }; virtual bool is_strict_mode() const override; virtual bool has_constructor() const override { return false; } virtual Realm* realm() const override { return m_realm; } diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index b0ae3e98d4..d1392def42 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -16,9 +16,9 @@ # define MAX_SAFE_INTEGER_VALUE AK::exp2(53.) - 1 # define MIN_SAFE_INTEGER_VALUE -(AK::exp2(53.) - 1) #else -constexpr const double EPSILON_VALUE { __builtin_exp2(-52) }; -constexpr const double MAX_SAFE_INTEGER_VALUE { __builtin_exp2(53) - 1 }; -constexpr const double MIN_SAFE_INTEGER_VALUE { -(__builtin_exp2(53) - 1) }; +constexpr double const EPSILON_VALUE { __builtin_exp2(-52) }; +constexpr double const MAX_SAFE_INTEGER_VALUE { __builtin_exp2(53) - 1 }; +constexpr double const MIN_SAFE_INTEGER_VALUE { -(__builtin_exp2(53) - 1) }; #endif namespace JS { diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index d83d9fc3b0..956921cbcd 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -1083,7 +1083,7 @@ void Object::ensure_shape_is_unique() } // Simple side-effect free property lookup, following the prototype chain. Non-standard. -Value Object::get_without_side_effects(const PropertyKey& property_key) const +Value Object::get_without_side_effects(PropertyKey const& property_key) const { auto* object = this; while (object) { diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index f7675dced5..1aa7d361ad 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -149,7 +149,7 @@ public: // Non-standard methods - Value get_without_side_effects(const PropertyKey&) const; + Value get_without_side_effects(PropertyKey const&) const; void define_direct_property(PropertyKey const& property_key, Value value, PropertyAttributes attributes) { storage_set(property_key, { value, attributes }); }; void define_direct_accessor(PropertyKey const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes); @@ -176,7 +176,7 @@ public: Value get_direct(size_t index) const { return m_storage[index]; } - const IndexedProperties& indexed_properties() const { return m_indexed_properties; } + IndexedProperties const& indexed_properties() const { return m_indexed_properties; } IndexedProperties& indexed_properties() { return m_indexed_properties; } void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); } diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h index 71f1905fc6..bafd443ed5 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h @@ -74,10 +74,10 @@ public: virtual ~PromiseReaction() = default; Type type() const { return m_type; } - const Optional<PromiseCapability>& capability() const { return m_capability; } + Optional<PromiseCapability> const& capability() const { return m_capability; } Optional<JobCallback>& handler() { return m_handler; } - const Optional<JobCallback>& handler() const { return m_handler; } + Optional<JobCallback> const& handler() const { return m_handler; } private: virtual StringView class_name() const override { return "PromiseReaction"sv; } diff --git a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h index f00020246a..1c558e67ff 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h @@ -58,8 +58,8 @@ public: m_bits &= ~Attribute::Configurable; } - bool operator==(const PropertyAttributes& other) const { return m_bits == other.m_bits; } - bool operator!=(const PropertyAttributes& other) const { return m_bits != other.m_bits; } + bool operator==(PropertyAttributes const& other) const { return m_bits == other.m_bits; } + bool operator!=(PropertyAttributes const& other) const { return m_bits != other.m_bits; } [[nodiscard]] u8 bits() const { return m_bits; } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index e0571d357f..e2e9406a41 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -219,7 +219,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_prevent_extensions() } // 10.5.5 [[GetOwnProperty]] ( P ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p -ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_property(const PropertyKey& property_key) const +ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_property(PropertyKey const& property_key) const { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -858,7 +858,7 @@ void ProxyObject::visit_edges(Cell::Visitor& visitor) visitor.visit(&m_handler); } -const FlyString& ProxyObject::name() const +FlyString const& ProxyObject::name() const { VERIFY(is_function()); return static_cast<FunctionObject&>(m_target).name(); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index dc31bb9c2a..572bafc64d 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -21,11 +21,11 @@ public: ProxyObject(Object& target, Object& handler, Object& prototype); virtual ~ProxyObject() override = default; - virtual const FlyString& name() const override; + virtual FlyString const& name() const override; virtual bool has_constructor() const override; - const Object& target() const { return m_target; } - const Object& handler() const { return m_handler; } + Object const& target() const { return m_target; } + Object const& handler() const { return m_handler; } bool is_revoked() const { return m_is_revoked; } void revoke() { m_is_revoked = true; } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.h b/Userland/Libraries/LibJS/Runtime/RegExpObject.h index 1e76ebf7e6..7ae8f74f4d 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.h @@ -44,10 +44,10 @@ public: virtual void initialize(GlobalObject&) override; virtual ~RegExpObject() override = default; - const String& pattern() const { return m_pattern; } - const String& flags() const { return m_flags; } - const Regex<ECMA262>& regex() { return *m_regex; } - const Regex<ECMA262>& regex() const { return *m_regex; } + String const& pattern() const { return m_pattern; } + String const& flags() const { return m_flags; } + Regex<ECMA262> const& regex() { return *m_regex; } + Regex<ECMA262> const& regex() const { return *m_regex; } private: String m_pattern; diff --git a/Userland/Libraries/LibJS/Runtime/Shape.cpp b/Userland/Libraries/LibJS/Runtime/Shape.cpp index 691bc6a35c..b8f820e3c9 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.cpp +++ b/Userland/Libraries/LibJS/Runtime/Shape.cpp @@ -53,7 +53,7 @@ Shape* Shape::get_or_prune_cached_prototype_transition(Object* prototype) return it->value; } -Shape* Shape::create_put_transition(const StringOrSymbol& property_key, PropertyAttributes attributes) +Shape* Shape::create_put_transition(StringOrSymbol const& property_key, PropertyAttributes attributes) { TransitionKey key { property_key, attributes }; if (auto* existing_shape = get_or_prune_cached_forward_transition(key)) @@ -65,7 +65,7 @@ Shape* Shape::create_put_transition(const StringOrSymbol& property_key, Property return new_shape; } -Shape* Shape::create_configure_transition(const StringOrSymbol& property_key, PropertyAttributes attributes) +Shape* Shape::create_configure_transition(StringOrSymbol const& property_key, PropertyAttributes attributes) { TransitionKey key { property_key, attributes }; if (auto* existing_shape = get_or_prune_cached_forward_transition(key)) @@ -93,7 +93,7 @@ Shape::Shape(Object& global_object) { } -Shape::Shape(Shape& previous_shape, const StringOrSymbol& property_key, PropertyAttributes attributes, TransitionType transition_type) +Shape::Shape(Shape& previous_shape, StringOrSymbol const& property_key, PropertyAttributes attributes, TransitionType transition_type) : m_global_object(previous_shape.m_global_object) , m_previous(&previous_shape) , m_property_key(property_key) @@ -126,7 +126,7 @@ void Shape::visit_edges(Cell::Visitor& visitor) } } -Optional<PropertyMetadata> Shape::lookup(const StringOrSymbol& property_key) const +Optional<PropertyMetadata> Shape::lookup(StringOrSymbol const& property_key) const { if (m_property_count == 0) return {}; @@ -162,7 +162,7 @@ void Shape::ensure_property_table() const u32 next_offset = 0; - Vector<const Shape*, 64> transition_chain; + Vector<Shape const*, 64> transition_chain; for (auto* shape = m_previous; shape; shape = shape->m_previous) { if (shape->m_property_table) { *m_property_table = *shape->m_property_table; @@ -189,7 +189,7 @@ void Shape::ensure_property_table() const } } -void Shape::add_property_to_unique_shape(const StringOrSymbol& property_key, PropertyAttributes attributes) +void Shape::add_property_to_unique_shape(StringOrSymbol const& property_key, PropertyAttributes attributes) { VERIFY(is_unique()); VERIFY(m_property_table); @@ -200,7 +200,7 @@ void Shape::add_property_to_unique_shape(const StringOrSymbol& property_key, Pro ++m_property_count; } -void Shape::reconfigure_property_in_unique_shape(const StringOrSymbol& property_key, PropertyAttributes attributes) +void Shape::reconfigure_property_in_unique_shape(StringOrSymbol const& property_key, PropertyAttributes attributes) { VERIFY(is_unique()); VERIFY(m_property_table); @@ -210,7 +210,7 @@ void Shape::reconfigure_property_in_unique_shape(const StringOrSymbol& property_ m_property_table->set(property_key, it->value); } -void Shape::remove_property_from_unique_shape(const StringOrSymbol& property_key, size_t offset) +void Shape::remove_property_from_unique_shape(StringOrSymbol const& property_key, size_t offset) { VERIFY(is_unique()); VERIFY(m_property_table); diff --git a/Userland/Libraries/LibJS/Runtime/Shape.h b/Userland/Libraries/LibJS/Runtime/Shape.h index a4221c7c49..9ae5166082 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.h +++ b/Userland/Libraries/LibJS/Runtime/Shape.h @@ -28,7 +28,7 @@ struct TransitionKey { StringOrSymbol property_key; PropertyAttributes attributes { 0 }; - bool operator==(const TransitionKey& other) const + bool operator==(TransitionKey const& other) const { return property_key == other.property_key && attributes == other.attributes; } @@ -51,14 +51,14 @@ public: explicit Shape(ShapeWithoutGlobalObjectTag) {}; explicit Shape(Object& global_object); - Shape(Shape& previous_shape, const StringOrSymbol& property_key, PropertyAttributes attributes, TransitionType); + Shape(Shape& previous_shape, StringOrSymbol const& property_key, PropertyAttributes attributes, TransitionType); Shape(Shape& previous_shape, Object* new_prototype); - Shape* create_put_transition(const StringOrSymbol&, PropertyAttributes attributes); - Shape* create_configure_transition(const StringOrSymbol&, PropertyAttributes attributes); + Shape* create_put_transition(StringOrSymbol const&, PropertyAttributes attributes); + Shape* create_configure_transition(StringOrSymbol const&, PropertyAttributes attributes); Shape* create_prototype_transition(Object* new_prototype); - void add_property_without_transition(const StringOrSymbol&, PropertyAttributes); + void add_property_without_transition(StringOrSymbol const&, PropertyAttributes); void add_property_without_transition(PropertyKey const&, PropertyAttributes); bool is_unique() const { return m_unique; } @@ -67,10 +67,10 @@ public: GlobalObject* global_object() const; Object* prototype() { return m_prototype; } - const Object* prototype() const { return m_prototype; } + Object const* prototype() const { return m_prototype; } - Optional<PropertyMetadata> lookup(const StringOrSymbol&) const; - const HashMap<StringOrSymbol, PropertyMetadata>& property_table() const; + Optional<PropertyMetadata> lookup(StringOrSymbol const&) const; + HashMap<StringOrSymbol, PropertyMetadata> const& property_table() const; u32 property_count() const { return m_property_count; } struct Property { @@ -82,9 +82,9 @@ public: void set_prototype_without_transition(Object* new_prototype) { m_prototype = new_prototype; } - void remove_property_from_unique_shape(const StringOrSymbol&, size_t offset); - void add_property_to_unique_shape(const StringOrSymbol&, PropertyAttributes attributes); - void reconfigure_property_in_unique_shape(const StringOrSymbol& property_key, PropertyAttributes attributes); + void remove_property_from_unique_shape(StringOrSymbol const&, size_t offset); + void add_property_to_unique_shape(StringOrSymbol const&, PropertyAttributes attributes); + void reconfigure_property_in_unique_shape(StringOrSymbol const& property_key, PropertyAttributes attributes); private: virtual StringView class_name() const override { return "Shape"sv; } diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index bc2deecf54..767161ac96 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -73,7 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw) if (literal_segments == 0) return js_string(vm, ""); - const auto number_of_substituions = vm.argument_count() - 1; + auto const number_of_substituions = vm.argument_count() - 1; StringBuilder builder; for (size_t i = 0; i < literal_segments; ++i) { diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 2826c9d292..22a8664251 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -931,7 +931,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search) } // B.2.2.2.1 CreateHTML ( string, tag, attribute, value ), https://tc39.es/ecma262/#sec-createhtml -static ThrowCompletionOr<Value> create_html(GlobalObject& global_object, Value string, const String& tag, const String& attribute, Value value) +static ThrowCompletionOr<Value> create_html(GlobalObject& global_object, Value string, String const& tag, String const& attribute, Value value) { auto& vm = global_object.vm(); TRY(require_object_coercible(global_object, string)); diff --git a/Userland/Libraries/LibJS/Runtime/Symbol.h b/Userland/Libraries/LibJS/Runtime/Symbol.h index 955e3fde56..b4ae8dc148 100644 --- a/Userland/Libraries/LibJS/Runtime/Symbol.h +++ b/Userland/Libraries/LibJS/Runtime/Symbol.h @@ -21,7 +21,7 @@ public: virtual ~Symbol() = default; String description() const { return m_description.value_or(""); } - const Optional<String>& raw_description() const { return m_description; } + Optional<String> const& raw_description() const { return m_description; } bool is_global() const { return m_is_global; } String to_string() const { return String::formatted("Symbol({})", description()); } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.h b/Userland/Libraries/LibJS/Runtime/SymbolObject.h index fdb2e626db..8d3ba8607c 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolObject.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.h @@ -21,7 +21,7 @@ public: virtual ~SymbolObject() override = default; Symbol& primitive_symbol() { return m_symbol; } - const Symbol& primitive_symbol() const { return m_symbol; } + Symbol const& primitive_symbol() const { return m_symbol; } String description() const { return m_symbol.description(); } bool is_global() const { return m_symbol.is_global(); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h index ae76fd2a83..2943a16ca7 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h @@ -32,9 +32,9 @@ private: }; // -86400 * 10^17 -const auto INSTANT_NANOSECONDS_MIN = "-8640000000000000000000"_sbigint; +auto const INSTANT_NANOSECONDS_MIN = "-8640000000000000000000"_sbigint; // +86400 * 10^17 -const auto INSTANT_NANOSECONDS_MAX = "8640000000000000000000"_sbigint; +auto const INSTANT_NANOSECONDS_MAX = "8640000000000000000000"_sbigint; bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds); ThrowCompletionOr<Instant*> create_temporal_instant(GlobalObject&, BigInt const& nanoseconds, FunctionObject const* new_target = nullptr); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp index e290a2157a..6b179621c5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp @@ -74,9 +74,9 @@ BigInt* get_epoch_from_iso_parts(GlobalObject& global_object, i32 year, u8 month } // -864 * 10^19 - 864 * 10^11 -const auto DATETIME_NANOSECONDS_MIN = "-8640000086400000000000"_sbigint; +auto const DATETIME_NANOSECONDS_MIN = "-8640000086400000000000"_sbigint; // +864 * 10^19 + 864 * 10^11 -const auto DATETIME_NANOSECONDS_MAX = "8640000086400000000000"_sbigint; +auto const DATETIME_NANOSECONDS_MAX = "8640000086400000000000"_sbigint; // 5.5.2 ISODateTimeWithinLimits ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond ), https://tc39.es/proposal-temporal/#sec-temporal-isodatetimewithinlimits bool iso_date_time_within_limits(GlobalObject& global_object, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond) diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index bf6eb8a426..f428f2e2b5 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -230,7 +230,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_typed_array(GlobalObj // 23.2.5.1.5 InitializeTypedArrayFromArrayLike, https://tc39.es/ecma262/#sec-initializetypedarrayfromarraylike template<typename T> -static ThrowCompletionOr<void> initialize_typed_array_from_array_like(GlobalObject& global_object, TypedArray<T>& typed_array, const Object& array_like) +static ThrowCompletionOr<void> initialize_typed_array_from_array_like(GlobalObject& global_object, TypedArray<T>& typed_array, Object const& array_like) { auto& vm = global_object.vm(); @@ -291,7 +291,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_array_like(GlobalObje // 23.2.5.1.4 InitializeTypedArrayFromList, https://tc39.es/ecma262/#sec-initializetypedarrayfromlist template<typename T> -static ThrowCompletionOr<void> initialize_typed_array_from_list(GlobalObject& global_object, TypedArray<T>& typed_array, const MarkedVector<Value>& list) +static ThrowCompletionOr<void> initialize_typed_array_from_list(GlobalObject& global_object, TypedArray<T>& typed_array, MarkedVector<Value> const& list) { auto& vm = global_object.vm(); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 4e81d0eb38..d8f27ac701 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -425,7 +425,7 @@ public: Span<const UnderlyingBufferDataType> data() const { - return { reinterpret_cast<const UnderlyingBufferDataType*>(m_viewed_array_buffer->buffer().data() + m_byte_offset), m_array_length }; + return { reinterpret_cast<UnderlyingBufferDataType const*>(m_viewed_array_buffer->buffer().data() + m_byte_offset), m_array_length }; } Span<UnderlyingBufferDataType> data() { diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index 0d9cc8dac5..a6f014319f 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -11,7 +11,7 @@ namespace JS { -TypedArrayConstructor::TypedArrayConstructor(const FlyString& name, Object& prototype) +TypedArrayConstructor::TypedArrayConstructor(FlyString const& name, Object& prototype) : NativeFunction(name, prototype) { } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h index fa7ed0e9b4..6d53099685 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h @@ -14,7 +14,7 @@ class TypedArrayConstructor : public NativeFunction { JS_OBJECT(TypedArrayConstructor, NativeFunction); public: - TypedArrayConstructor(const FlyString& name, Object& prototype); + TypedArrayConstructor(FlyString const& name, Object& prototype); explicit TypedArrayConstructor(GlobalObject&); virtual void initialize(GlobalObject&) override; virtual ~TypedArrayConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 39cb7dfc10..edf9773165 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -82,7 +82,7 @@ static ThrowCompletionOr<TypedArrayBase*> validate_typed_array_from_this(GlobalO return typed_array; } -static ThrowCompletionOr<FunctionObject*> callback_from_args(GlobalObject& global_object, const String& name) +static ThrowCompletionOr<FunctionObject*> callback_from_args(GlobalObject& global_object, String const& name) { auto& vm = global_object.vm(); if (vm.argument_count() < 1) @@ -93,7 +93,7 @@ static ThrowCompletionOr<FunctionObject*> callback_from_args(GlobalObject& globa return &callback.as_function(); } -static ThrowCompletionOr<void> for_each_item(VM& vm, GlobalObject& global_object, const String& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) +static ThrowCompletionOr<void> for_each_item(VM& vm, GlobalObject& global_object, String const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) { auto* typed_array = TRY(validate_typed_array_from_this(global_object)); @@ -115,7 +115,7 @@ static ThrowCompletionOr<void> for_each_item(VM& vm, GlobalObject& global_object return {}; } -static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, GlobalObject& global_object, const String& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) +static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, GlobalObject& global_object, String const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) { auto* typed_array = TRY(validate_typed_array_from_this(global_object)); diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index 82f3aa4083..7d66de9f66 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -216,7 +216,7 @@ void VM::gather_roots(HashTable<Cell*>& roots) roots.set(finalization_registry); } -Symbol* VM::get_global_symbol(const String& description) +Symbol* VM::get_global_symbol(String const& description) { auto result = m_global_symbol_map.get(description); if (result.has_value()) diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 1295c2f01b..94495e1984 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -45,7 +45,7 @@ public: }; Heap& heap() { return m_heap; } - const Heap& heap() const { return m_heap; } + Heap const& heap() const { return m_heap; } Interpreter& interpreter(); Interpreter* interpreter_if_exists(); @@ -73,7 +73,7 @@ public: JS_ENUMERATE_WELL_KNOWN_SYMBOLS #undef __JS_ENUMERATE - Symbol* get_global_symbol(const String& description); + Symbol* get_global_symbol(String const& description); HashMap<String, PrimitiveString*>& string_cache() { return m_string_cache; } PrimitiveString& empty_string() { return *m_empty_string; } @@ -158,7 +158,7 @@ public: ThrowCompletionOr<Value> resolve_this_binding(GlobalObject&); - const StackInfo& stack_info() const { return m_stack_info; }; + StackInfo const& stack_info() const { return m_stack_info; }; u32 execution_generation() const { return m_execution_generation; } void finish_execution_generation() { ++m_execution_generation; } diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 06fdd8c0c7..7f5c80a90c 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -39,7 +39,7 @@ namespace JS { -static inline bool same_type_for_equality(const Value& lhs, const Value& rhs) +static inline bool same_type_for_equality(Value const& lhs, Value const& rhs) { if (lhs.type() == rhs.type()) return true; @@ -50,12 +50,12 @@ static inline bool same_type_for_equality(const Value& lhs, const Value& rhs) static const Crypto::SignedBigInteger BIGINT_ZERO { 0 }; -ALWAYS_INLINE bool both_number(const Value& lhs, const Value& rhs) +ALWAYS_INLINE bool both_number(Value const& lhs, Value const& rhs) { return lhs.is_number() && rhs.is_number(); } -ALWAYS_INLINE bool both_bigint(const Value& lhs, const Value& rhs) +ALWAYS_INLINE bool both_bigint(Value const& lhs, Value const& rhs) { return lhs.is_bigint() && rhs.is_bigint(); } @@ -1295,7 +1295,7 @@ ThrowCompletionOr<Value> ordinary_has_instance(GlobalObject& global_object, Valu auto& rhs_function = rhs.as_function(); if (is<BoundFunction>(rhs_function)) { - auto& bound_target = static_cast<const BoundFunction&>(rhs_function); + auto& bound_target = static_cast<BoundFunction const&>(rhs_function); return instance_of(global_object, lhs, Value(&bound_target.bound_target_function())); } diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 364c410c2e..0b1f1aac59 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -178,31 +178,31 @@ public: m_value.as_i32 = value; } - Value(const Object* object) + Value(Object const* object) : m_type(object ? Type::Object : Type::Null) { m_value.as_object = const_cast<Object*>(object); } - Value(const PrimitiveString* string) + Value(PrimitiveString const* string) : m_type(Type::String) { m_value.as_string = const_cast<PrimitiveString*>(string); } - Value(const Symbol* symbol) + Value(Symbol const* symbol) : m_type(Type::Symbol) { m_value.as_symbol = const_cast<Symbol*>(symbol); } - Value(const Accessor* accessor) + Value(Accessor const* accessor) : m_type(Type::Accessor) { m_value.as_accessor = const_cast<Accessor*>(accessor); } - Value(const BigInt* bigint) + Value(BigInt const* bigint) : m_type(Type::BigInt) { m_value.as_bigint = const_cast<BigInt*>(bigint); @@ -235,7 +235,7 @@ public: return *m_value.as_object; } - const Object& as_object() const + Object const& as_object() const { VERIFY(type() == Type::Object); return *m_value.as_object; @@ -247,7 +247,7 @@ public: return *m_value.as_string; } - const PrimitiveString& as_string() const + PrimitiveString const& as_string() const { VERIFY(is_string()); return *m_value.as_string; @@ -259,7 +259,7 @@ public: return *m_value.as_symbol; } - const Symbol& as_symbol() const + Symbol const& as_symbol() const { VERIFY(is_symbol()); return *m_value.as_symbol; diff --git a/Userland/Libraries/LibJS/SyntaxHighlighter.cpp b/Userland/Libraries/LibJS/SyntaxHighlighter.cpp index 737f9315b4..c527dc42b3 100644 --- a/Userland/Libraries/LibJS/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibJS/SyntaxHighlighter.cpp @@ -12,7 +12,7 @@ namespace JS { -static Syntax::TextStyle style_for_token_type(const Gfx::Palette& palette, JS::TokenType type) +static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, JS::TokenType type) { switch (JS::Token::category(type)) { case JS::TokenCategory::Invalid: @@ -47,7 +47,7 @@ bool SyntaxHighlighter::is_navigatable([[maybe_unused]] u64 token) const return false; } -void SyntaxHighlighter::rehighlight(const Palette& palette) +void SyntaxHighlighter::rehighlight(Palette const& palette) { auto text = m_client->get_text(); diff --git a/Userland/Libraries/LibJS/SyntaxHighlighter.h b/Userland/Libraries/LibJS/SyntaxHighlighter.h index d3929937f0..e1667cac70 100644 --- a/Userland/Libraries/LibJS/SyntaxHighlighter.h +++ b/Userland/Libraries/LibJS/SyntaxHighlighter.h @@ -19,7 +19,7 @@ public: virtual bool is_navigatable(u64) const override; virtual Syntax::Language language() const override { return Syntax::Language::JavaScript; } - virtual void rehighlight(const Palette&) override; + virtual void rehighlight(Palette const&) override; protected: virtual Vector<MatchingTokenPair> matching_token_pairs_impl() const override; diff --git a/Userland/Libraries/LibJS/Token.cpp b/Userland/Libraries/LibJS/Token.cpp index 9a51a15508..1d84a4aeaf 100644 --- a/Userland/Libraries/LibJS/Token.cpp +++ b/Userland/Libraries/LibJS/Token.cpp @@ -13,7 +13,7 @@ namespace JS { -const char* Token::name(TokenType type) +char const* Token::name(TokenType type) { switch (type) { #define __ENUMERATE_JS_TOKEN(type, category) \ @@ -27,7 +27,7 @@ const char* Token::name(TokenType type) } } -const char* Token::name() const +char const* Token::name() const { return name(m_type); } diff --git a/Userland/Libraries/LibJS/Token.h b/Userland/Libraries/LibJS/Token.h index 0e7d282aa2..086c1df3a3 100644 --- a/Userland/Libraries/LibJS/Token.h +++ b/Userland/Libraries/LibJS/Token.h @@ -14,12 +14,12 @@ namespace JS { // U+2028 LINE SEPARATOR -constexpr const char line_separator_chars[] { (char)0xe2, (char)0x80, (char)0xa8, 0 }; +constexpr char const line_separator_chars[] { (char)0xe2, (char)0x80, (char)0xa8, 0 }; constexpr const StringView LINE_SEPARATOR_STRING { line_separator_chars }; constexpr const u32 LINE_SEPARATOR { 0x2028 }; // U+2029 PARAGRAPH SEPARATOR -constexpr const char paragraph_separator_chars[] { (char)0xe2, (char)0x80, (char)0xa9, 0 }; +constexpr char const paragraph_separator_chars[] { (char)0xe2, (char)0x80, (char)0xa9, 0 }; constexpr const StringView PARAGRAPH_SEPARATOR_STRING { paragraph_separator_chars }; constexpr const u32 PARAGRAPH_SEPARATOR { 0x2029 }; @@ -197,10 +197,10 @@ public: TokenType type() const { return m_type; } TokenCategory category() const; static TokenCategory category(TokenType); - const char* name() const; - static const char* name(TokenType); + char const* name() const; + static char const* name(TokenType); - const String& message() const { return m_message; } + String const& message() const { return m_message; } StringView trivia() const { return m_trivia; } StringView original_value() const { return m_original_value; } StringView value() const diff --git a/Userland/Libraries/LibKeyboard/CharacterMap.cpp b/Userland/Libraries/LibKeyboard/CharacterMap.cpp index dec8014d0e..85b6df3e8e 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMap.cpp +++ b/Userland/Libraries/LibKeyboard/CharacterMap.cpp @@ -12,14 +12,14 @@ namespace Keyboard { -ErrorOr<CharacterMap> CharacterMap::load_from_file(const String& map_name) +ErrorOr<CharacterMap> CharacterMap::load_from_file(String const& map_name) { auto result = TRY(CharacterMapFile::load_from_file(map_name)); return CharacterMap(map_name, result); } -CharacterMap::CharacterMap(const String& map_name, const CharacterMapData& map_data) +CharacterMap::CharacterMap(String const& map_name, CharacterMapData const& map_data) : m_character_map_data(map_data) , m_character_map_name(map_name) { @@ -41,7 +41,7 @@ ErrorOr<CharacterMap> CharacterMap::fetch_system_map() return CharacterMap { keymap_name, map_data }; } -const String& CharacterMap::character_map_name() const +String const& CharacterMap::character_map_name() const { return m_character_map_name; } diff --git a/Userland/Libraries/LibKeyboard/CharacterMap.h b/Userland/Libraries/LibKeyboard/CharacterMap.h index 7d3e96f176..9990077bb0 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMap.h +++ b/Userland/Libraries/LibKeyboard/CharacterMap.h @@ -15,14 +15,14 @@ namespace Keyboard { class CharacterMap { public: - CharacterMap(const String& map_name, const CharacterMapData& map_data); - static ErrorOr<CharacterMap> load_from_file(const String& filename); + CharacterMap(String const& map_name, CharacterMapData const& map_data); + static ErrorOr<CharacterMap> load_from_file(String const& filename); int set_system_map(); static ErrorOr<CharacterMap> fetch_system_map(); - const CharacterMapData& character_map_data() const { return m_character_map_data; }; - const String& character_map_name() const; + CharacterMapData const& character_map_data() const { return m_character_map_data; }; + String const& character_map_name() const; private: CharacterMapData m_character_map_data; diff --git a/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp b/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp index 233e94e793..838de4e35c 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp +++ b/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp @@ -11,7 +11,7 @@ namespace Keyboard { -ErrorOr<CharacterMapData> CharacterMapFile::load_from_file(const String& filename) +ErrorOr<CharacterMapData> CharacterMapFile::load_from_file(String const& filename) { auto path = filename; if (!path.ends_with(".json")) { @@ -25,7 +25,7 @@ ErrorOr<CharacterMapData> CharacterMapFile::load_from_file(const String& filenam auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly)); auto file_contents = file->read_all(); auto json_result = TRY(JsonValue::from_string(file_contents)); - const auto& json = json_result.as_object(); + auto const& json = json_result.as_object(); Vector<u32> map = read_map(json, "map"); Vector<u32> shift_map = read_map(json, "shift_map"); @@ -55,7 +55,7 @@ ErrorOr<CharacterMapData> CharacterMapFile::load_from_file(const String& filenam return character_map; } -Vector<u32> CharacterMapFile::read_map(const JsonObject& json, const String& name) +Vector<u32> CharacterMapFile::read_map(JsonObject const& json, String const& name) { if (!json.has(name)) return {}; diff --git a/Userland/Libraries/LibKeyboard/CharacterMapFile.h b/Userland/Libraries/LibKeyboard/CharacterMapFile.h index 986278f71a..ad79e017f9 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMapFile.h +++ b/Userland/Libraries/LibKeyboard/CharacterMapFile.h @@ -14,10 +14,10 @@ namespace Keyboard { class CharacterMapFile { public: - static ErrorOr<CharacterMapData> load_from_file(const String& filename); + static ErrorOr<CharacterMapData> load_from_file(String const& filename); private: - static Vector<u32> read_map(const JsonObject& json, const String& name); + static Vector<u32> read_map(JsonObject const& json, String const& name); }; } diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index c2bd3c3a5b..0d2baf01b4 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -2040,7 +2040,7 @@ size_t StringMetrics::offset_with_addition(StringMetrics const& offset, size_t c bool Editor::Spans::contains_up_to_offset(Spans const& other, size_t offset) const { - auto compare = [&]<typename K, typename V>(const HashMap<K, HashMap<K, V>>& left, const HashMap<K, HashMap<K, V>>& right) -> bool { + auto compare = [&]<typename K, typename V>(HashMap<K, HashMap<K, V>> const& left, HashMap<K, HashMap<K, V>> const& right) -> bool { for (auto& entry : right) { if (entry.key > offset + 1) continue; diff --git a/Userland/Libraries/LibLine/Editor.h b/Userland/Libraries/LibLine/Editor.h index bc835398e3..e6a62dfedf 100644 --- a/Userland/Libraries/LibLine/Editor.h +++ b/Userland/Libraries/LibLine/Editor.h @@ -191,7 +191,7 @@ public: cursor = m_buffer.size(); m_cursor = cursor; } - const Vector<u32, 1024>& buffer() const { return m_buffer; } + Vector<u32, 1024> const& buffer() const { return m_buffer; } u32 buffer_at(size_t pos) const { return m_buffer.at(pos); } String line() const { return line(m_buffer.size()); } String line(size_t up_to_index) const; diff --git a/Userland/Libraries/LibLine/InternalFunctions.cpp b/Userland/Libraries/LibLine/InternalFunctions.cpp index ba57fab492..7bfec19a9c 100644 --- a/Userland/Libraries/LibLine/InternalFunctions.cpp +++ b/Userland/Libraries/LibLine/InternalFunctions.cpp @@ -516,7 +516,7 @@ void Editor::uppercase_word() void Editor::edit_in_external_editor() { - const auto* editor_command = getenv("EDITOR"); + auto const* editor_command = getenv("EDITOR"); if (!editor_command) editor_command = m_configuration.m_default_text_editor.characters(); @@ -553,7 +553,7 @@ void Editor::edit_in_external_editor() } }; - Vector<const char*> args { editor_command, file_path, nullptr }; + Vector<char const*> args { editor_command, file_path, nullptr }; auto pid = fork(); if (pid == -1) { diff --git a/Userland/Libraries/LibLine/KeyCallbackMachine.h b/Userland/Libraries/LibLine/KeyCallbackMachine.h index 82900471b0..4d09ee1012 100644 --- a/Userland/Libraries/LibLine/KeyCallbackMachine.h +++ b/Userland/Libraries/LibLine/KeyCallbackMachine.h @@ -80,7 +80,7 @@ struct Traits<Line::Key> : public GenericTraits<Line::Key> { template<> struct Traits<Vector<Line::Key>> : public GenericTraits<Vector<Line::Key>> { static constexpr bool is_trivial() { return false; } - static unsigned hash(const Vector<Line::Key>& ks) + static unsigned hash(Vector<Line::Key> const& ks) { unsigned h = 0; for (auto& k : ks) diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index 94d2e350f8..f3760cccd2 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -340,17 +340,17 @@ static FloatT internal_gamma(FloatT x) NOEXCEPT extern "C" { -float nanf(const char* s) NOEXCEPT +float nanf(char const* s) NOEXCEPT { return __builtin_nanf(s); } -double nan(const char* s) NOEXCEPT +double nan(char const* s) NOEXCEPT { return __builtin_nan(s); } -long double nanl(const char* s) NOEXCEPT +long double nanl(char const* s) NOEXCEPT { return __builtin_nanl(s); } diff --git a/Userland/Libraries/LibM/math.h b/Userland/Libraries/LibM/math.h index a54e81ac63..b5269044b0 100644 --- a/Userland/Libraries/LibM/math.h +++ b/Userland/Libraries/LibM/math.h @@ -128,9 +128,9 @@ float fminf(float, float) NOEXCEPT; long double remainderl(long double, long double) NOEXCEPT; double remainder(double, double) NOEXCEPT; float remainderf(float, float) NOEXCEPT; -long double nanl(const char*) NOEXCEPT; -double nan(const char*) NOEXCEPT; -float nanf(const char*) NOEXCEPT; +long double nanl(char const*) NOEXCEPT; +double nan(char const*) NOEXCEPT; +float nanf(char const*) NOEXCEPT; /* Exponential functions */ long double expl(long double) NOEXCEPT; diff --git a/Userland/Libraries/LibMarkdown/Document.cpp b/Userland/Libraries/LibMarkdown/Document.cpp index 2d00188ee2..a4fa2307ae 100644 --- a/Userland/Libraries/LibMarkdown/Document.cpp +++ b/Userland/Libraries/LibMarkdown/Document.cpp @@ -53,7 +53,7 @@ RecursionDecision Document::walk(Visitor& visitor) const OwnPtr<Document> Document::parse(StringView str) { - const Vector<StringView> lines_vec = str.lines(); + Vector<StringView> const lines_vec = str.lines(); LineIterator lines(lines_vec.begin()); return make<Document>(ContainerBlock::parse(lines)); } diff --git a/Userland/Libraries/LibMarkdown/List.cpp b/Userland/Libraries/LibMarkdown/List.cpp index 2ecd58401e..d98288f355 100644 --- a/Userland/Libraries/LibMarkdown/List.cpp +++ b/Userland/Libraries/LibMarkdown/List.cpp @@ -16,7 +16,7 @@ String List::render_to_html(bool) const { StringBuilder builder; - const char* tag = m_is_ordered ? "ol" : "ul"; + char const* tag = m_is_ordered ? "ol" : "ul"; builder.appendff("<{}", tag); if (m_start_number != 1) diff --git a/Userland/Libraries/LibMarkdown/Table.cpp b/Userland/Libraries/LibMarkdown/Table.cpp index 445b969ea3..5cf26bd48e 100644 --- a/Userland/Libraries/LibMarkdown/Table.cpp +++ b/Userland/Libraries/LibMarkdown/Table.cpp @@ -16,7 +16,7 @@ String Table::render_for_terminal(size_t view_width) const auto unit_width_length = view_width == 0 ? 4 : ((float)(view_width - m_columns.size()) / (float)m_total_width); StringBuilder builder; - auto write_aligned = [&](const auto& text, auto width, auto alignment) { + auto write_aligned = [&](auto const& text, auto width, auto alignment) { size_t original_length = text.terminal_length(); auto string = text.render_for_terminal(); if (alignment == Alignment::Center) { diff --git a/Userland/Libraries/LibPCIDB/Database.cpp b/Userland/Libraries/LibPCIDB/Database.cpp index ce23b80994..bffd5b7d07 100644 --- a/Userland/Libraries/LibPCIDB/Database.cpp +++ b/Userland/Libraries/LibPCIDB/Database.cpp @@ -12,7 +12,7 @@ namespace PCIDB { -RefPtr<Database> Database::open(const String& filename) +RefPtr<Database> Database::open(String const& filename) { auto file_or_error = Core::MappedFile::map(filename); if (file_or_error.is_error()) @@ -25,7 +25,7 @@ RefPtr<Database> Database::open(const String& filename) const StringView Database::get_vendor(u16 vendor_id) const { - const auto& vendor = m_vendors.get(vendor_id); + auto const& vendor = m_vendors.get(vendor_id); if (!vendor.has_value()) return ""; return vendor.value()->name; @@ -33,10 +33,10 @@ const StringView Database::get_vendor(u16 vendor_id) const const StringView Database::get_device(u16 vendor_id, u16 device_id) const { - const auto& vendor = m_vendors.get(vendor_id); + auto const& vendor = m_vendors.get(vendor_id); if (!vendor.has_value()) return ""; - const auto& device = vendor.value()->devices.get(device_id); + auto const& device = vendor.value()->devices.get(device_id); if (!device.has_value()) return ""; return device.value()->name; @@ -44,13 +44,13 @@ const StringView Database::get_device(u16 vendor_id, u16 device_id) const const StringView Database::get_subsystem(u16 vendor_id, u16 device_id, u16 subvendor_id, u16 subdevice_id) const { - const auto& vendor = m_vendors.get(vendor_id); + auto const& vendor = m_vendors.get(vendor_id); if (!vendor.has_value()) return ""; - const auto& device = vendor.value()->devices.get(device_id); + auto const& device = vendor.value()->devices.get(device_id); if (!device.has_value()) return ""; - const auto& subsystem = device.value()->subsystems.get((subvendor_id << 16) + subdevice_id); + auto const& subsystem = device.value()->subsystems.get((subvendor_id << 16) + subdevice_id); if (!subsystem.has_value()) return ""; return subsystem.value()->name; @@ -58,7 +58,7 @@ const StringView Database::get_subsystem(u16 vendor_id, u16 device_id, u16 subve const StringView Database::get_class(u8 class_id) const { - const auto& xclass = m_classes.get(class_id); + auto const& xclass = m_classes.get(class_id); if (!xclass.has_value()) return ""; return xclass.value()->name; @@ -66,10 +66,10 @@ const StringView Database::get_class(u8 class_id) const const StringView Database::get_subclass(u8 class_id, u8 subclass_id) const { - const auto& xclass = m_classes.get(class_id); + auto const& xclass = m_classes.get(class_id); if (!xclass.has_value()) return ""; - const auto& subclass = xclass.value()->subclasses.get(subclass_id); + auto const& subclass = xclass.value()->subclasses.get(subclass_id); if (!subclass.has_value()) return ""; return subclass.value()->name; @@ -77,13 +77,13 @@ const StringView Database::get_subclass(u8 class_id, u8 subclass_id) const const StringView Database::get_programming_interface(u8 class_id, u8 subclass_id, u8 programming_interface_id) const { - const auto& xclass = m_classes.get(class_id); + auto const& xclass = m_classes.get(class_id); if (!xclass.has_value()) return ""; - const auto& subclass = xclass.value()->subclasses.get(subclass_id); + auto const& subclass = xclass.value()->subclasses.get(subclass_id); if (!subclass.has_value()) return ""; - const auto& programming_interface = subclass.value()->programming_interfaces.get(programming_interface_id); + auto const& programming_interface = subclass.value()->programming_interfaces.get(programming_interface_id); if (!programming_interface.has_value()) return ""; return programming_interface.value()->name; diff --git a/Userland/Libraries/LibPCIDB/Database.h b/Userland/Libraries/LibPCIDB/Database.h index 7577f55898..2145a2dbfa 100644 --- a/Userland/Libraries/LibPCIDB/Database.h +++ b/Userland/Libraries/LibPCIDB/Database.h @@ -53,7 +53,7 @@ struct Class { class Database : public RefCounted<Database> { public: - static RefPtr<Database> open(const String& filename); + static RefPtr<Database> open(String const& filename); static RefPtr<Database> open() { return open("/res/pci.ids"); }; const StringView get_vendor(u16 vendor_id) const; diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index c6c93d781c..5d7da106b4 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -47,11 +47,11 @@ ErrorOr<ByteBuffer> Filter::decode_ascii_hex(ReadonlyBytes bytes) auto output = TRY(ByteBuffer::create_zeroed(bytes.size() / 2 + 1)); for (size_t i = 0; i < bytes.size() / 2; ++i) { - const auto c1 = decode_hex_digit(static_cast<char>(bytes[i * 2])); + auto const c1 = decode_hex_digit(static_cast<char>(bytes[i * 2])); if (c1 >= 16) return Error::from_string_literal("Hex string contains invalid digit"); - const auto c2 = decode_hex_digit(static_cast<char>(bytes[i * 2 + 1])); + auto const c2 = decode_hex_digit(static_cast<char>(bytes[i * 2 + 1])); if (c2 >= 16) return Error::from_string_literal("Hex string contains invalid digit"); diff --git a/Userland/Libraries/LibPDF/Object.h b/Userland/Libraries/LibPDF/Object.h index 71b6bb9a4c..b1ff82d0b3 100644 --- a/Userland/Libraries/LibPDF/Object.h +++ b/Userland/Libraries/LibPDF/Object.h @@ -19,7 +19,7 @@ namespace { template<PDF::IsObject T> -const char* object_name() +char const* object_name() { # define ENUMERATE_TYPE(class_name, snake_name) \ if constexpr (IsSame<PDF::class_name, T>) { \ @@ -73,7 +73,7 @@ public: return NonnullRefPtr<T>(static_cast<T const&>(*this)); } - virtual const char* type_name() const = 0; + virtual char const* type_name() const = 0; virtual String to_string(int indent) const = 0; protected: diff --git a/Userland/Libraries/LibPDF/ObjectDerivatives.h b/Userland/Libraries/LibPDF/ObjectDerivatives.h index 769d0c2d40..c719ef2f27 100644 --- a/Userland/Libraries/LibPDF/ObjectDerivatives.h +++ b/Userland/Libraries/LibPDF/ObjectDerivatives.h @@ -31,7 +31,7 @@ public: [[nodiscard]] ALWAYS_INLINE bool is_binary() const { return m_is_binary; } void set_string(String string) { m_string = move(string); } - const char* type_name() const override { return "string"; } + char const* type_name() const override { return "string"; } String to_string(int indent) const override; protected: @@ -53,7 +53,7 @@ public: [[nodiscard]] ALWAYS_INLINE FlyString const& name() const { return m_name; } - const char* type_name() const override { return "name"; } + char const* type_name() const override { return "name"; } String to_string(int indent) const override; protected: @@ -86,7 +86,7 @@ public: ENUMERATE_OBJECT_TYPES(DEFINE_INDEXER) #undef DEFINE_INDEXER - const char* type_name() const override + char const* type_name() const override { return "array"; } @@ -129,7 +129,7 @@ public: ENUMERATE_OBJECT_TYPES(DEFINE_GETTER) #undef DEFINE_GETTER - const char* type_name() const override + char const* type_name() const override { return "dict"; } @@ -156,7 +156,7 @@ public: [[nodiscard]] ReadonlyBytes bytes() const { return m_buffer.bytes(); }; [[nodiscard]] ByteBuffer& buffer() { return m_buffer; }; - const char* type_name() const override { return "stream"; } + char const* type_name() const override { return "stream"; } String to_string(int indent) const override; private: @@ -180,7 +180,7 @@ public: [[nodiscard]] ALWAYS_INLINE u32 index() const { return m_index; } [[nodiscard]] ALWAYS_INLINE Value const& value() const { return m_value; } - const char* type_name() const override { return "indirect_object"; } + char const* type_name() const override { return "indirect_object"; } String to_string(int indent) const override; protected: diff --git a/Userland/Libraries/LibPDF/Operator.h b/Userland/Libraries/LibPDF/Operator.h index 88ee18991c..89e66b8690 100644 --- a/Userland/Libraries/LibPDF/Operator.h +++ b/Userland/Libraries/LibPDF/Operator.h @@ -114,7 +114,7 @@ public: VERIFY_NOT_REACHED(); } - static const char* operator_name(OperatorType operator_type) + static char const* operator_name(OperatorType operator_type) { #define V(name, snake_name, symbol) \ if (operator_type == OperatorType::name) \ @@ -130,7 +130,7 @@ public: VERIFY_NOT_REACHED(); } - static const char* operator_symbol(OperatorType operator_type) + static char const* operator_symbol(OperatorType operator_type) { #define V(name, snake_name, symbol) \ if (operator_type == OperatorType::name) \ diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp index 00be30bb34..81988d3191 100644 --- a/Userland/Libraries/LibPDF/Parser.cpp +++ b/Userland/Libraries/LibPDF/Parser.cpp @@ -49,7 +49,7 @@ PDFErrorOr<void> Parser::initialize() { TRY(parse_header()); - const auto linearization_result = TRY(initialize_linearization_dict()); + auto const linearization_result = TRY(initialize_linearization_dict()); if (linearization_result == LinearizationResult::NotLinearized) return initialize_non_linearized_xref_table(); diff --git a/Userland/Libraries/LibPDF/Reader.h b/Userland/Libraries/LibPDF/Reader.h index d9ae301ac8..862decb8e1 100644 --- a/Userland/Libraries/LibPDF/Reader.h +++ b/Userland/Libraries/LibPDF/Reader.h @@ -79,7 +79,7 @@ public: return !done() && peek() == ch; } - bool matches(const char* chars) const + bool matches(char const* chars) const { String string(chars); if (remaining() < string.length()) diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp index ccbb3d6e29..484b5a7142 100644 --- a/Userland/Libraries/LibProtocol/Request.cpp +++ b/Userland/Libraries/LibProtocol/Request.cpp @@ -128,7 +128,7 @@ void Request::did_progress(Badge<RequestClient>, Optional<u32> total_size, u32 d on_progress(total_size, downloaded_size); } -void Request::did_receive_headers(Badge<RequestClient>, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> response_code) +void Request::did_receive_headers(Badge<RequestClient>, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code) { if (on_headers_received) on_headers_received(response_headers, response_code); diff --git a/Userland/Libraries/LibProtocol/Request.h b/Userland/Libraries/LibProtocol/Request.h index b649a208ae..f004935175 100644 --- a/Userland/Libraries/LibProtocol/Request.h +++ b/Userland/Libraries/LibProtocol/Request.h @@ -46,15 +46,15 @@ public: void set_should_buffer_all_input(bool); /// Note: Must be set before `set_should_buffer_all_input(true)`. - Function<void(bool success, u32 total_size, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish; + Function<void(bool success, u32 total_size, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish; Function<void(bool success, u32 total_size)> on_finish; Function<void(Optional<u32> total_size, u32 downloaded_size)> on_progress; - Function<void(const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> response_code)> on_headers_received; + Function<void(HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received; Function<CertificateAndKey()> on_certificate_requested; void did_finish(Badge<RequestClient>, bool success, u32 total_size); void did_progress(Badge<RequestClient>, Optional<u32> total_size, u32 downloaded_size); - void did_receive_headers(Badge<RequestClient>, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> response_code); + void did_receive_headers(Badge<RequestClient>, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code); void did_request_certificates(Badge<RequestClient>); RefPtr<Core::Notifier>& write_notifier(Badge<RequestClient>) { return m_write_notifier; } diff --git a/Userland/Libraries/LibProtocol/WebSocketClient.cpp b/Userland/Libraries/LibProtocol/WebSocketClient.cpp index 43dccd76c2..5c84919bfc 100644 --- a/Userland/Libraries/LibProtocol/WebSocketClient.cpp +++ b/Userland/Libraries/LibProtocol/WebSocketClient.cpp @@ -14,7 +14,7 @@ WebSocketClient::WebSocketClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket { } -RefPtr<WebSocket> WebSocketClient::connect(const URL& url, const String& origin, const Vector<String>& protocols, const Vector<String>& extensions, const HashMap<String, String>& request_headers) +RefPtr<WebSocket> WebSocketClient::connect(const URL& url, String const& origin, Vector<String> const& protocols, Vector<String> const& extensions, HashMap<String, String> const& request_headers) { IPC::Dictionary header_dictionary; for (auto& it : request_headers) diff --git a/Userland/Libraries/LibProtocol/WebSocketClient.h b/Userland/Libraries/LibProtocol/WebSocketClient.h index 37226c4275..f802c73597 100644 --- a/Userland/Libraries/LibProtocol/WebSocketClient.h +++ b/Userland/Libraries/LibProtocol/WebSocketClient.h @@ -21,7 +21,7 @@ class WebSocketClient final IPC_CLIENT_CONNECTION(WebSocketClient, "/tmp/portal/websocket") public: - RefPtr<WebSocket> connect(const URL&, const String& origin = {}, const Vector<String>& protocols = {}, const Vector<String>& extensions = {}, const HashMap<String, String>& request_headers = {}); + RefPtr<WebSocket> connect(const URL&, String const& origin = {}, Vector<String> const& protocols = {}, Vector<String> const& extensions = {}, HashMap<String, String> const& request_headers = {}); u32 ready_state(Badge<WebSocket>, WebSocket&); void send(Badge<WebSocket>, WebSocket&, ByteBuffer, bool is_text); diff --git a/Userland/Libraries/LibPthread/pthread.cpp b/Userland/Libraries/LibPthread/pthread.cpp index 38997a8139..ea1b5b3227 100644 --- a/Userland/Libraries/LibPthread/pthread.cpp +++ b/Userland/Libraries/LibPthread/pthread.cpp @@ -176,7 +176,7 @@ int pthread_detach(pthread_t thread) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_sigmask.html -int pthread_sigmask(int how, const sigset_t* set, sigset_t* old_set) +int pthread_sigmask(int how, sigset_t const* set, sigset_t* old_set) { if (sigprocmask(how, set, old_set)) return errno; @@ -184,7 +184,7 @@ int pthread_sigmask(int how, const sigset_t* set, sigset_t* old_set) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutex_init.html -int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attributes) +int pthread_mutex_init(pthread_mutex_t* mutex, pthread_mutexattr_t const* attributes) { return __pthread_mutex_init(mutex, attributes); } @@ -269,9 +269,9 @@ int pthread_attr_destroy(pthread_attr_t* attributes) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getdetachstate.html -int pthread_attr_getdetachstate(const pthread_attr_t* attributes, int* p_detach_state) +int pthread_attr_getdetachstate(pthread_attr_t const* attributes, int* p_detach_state) { - auto* attributes_impl = *(reinterpret_cast<const PthreadAttrImpl* const*>(attributes)); + auto* attributes_impl = *(reinterpret_cast<PthreadAttrImpl const* const*>(attributes)); if (!attributes_impl || !p_detach_state) return EINVAL; @@ -305,9 +305,9 @@ int pthread_attr_setdetachstate(pthread_attr_t* attributes, int detach_state) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getguardsize.html -int pthread_attr_getguardsize(const pthread_attr_t* attributes, size_t* p_guard_size) +int pthread_attr_getguardsize(pthread_attr_t const* attributes, size_t* p_guard_size) { - auto* attributes_impl = *(reinterpret_cast<const PthreadAttrImpl* const*>(attributes)); + auto* attributes_impl = *(reinterpret_cast<PthreadAttrImpl const* const*>(attributes)); if (!attributes_impl || !p_guard_size) return EINVAL; @@ -349,9 +349,9 @@ int pthread_attr_setguardsize(pthread_attr_t* attributes, size_t guard_size) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getschedparam.html -int pthread_attr_getschedparam(const pthread_attr_t* attributes, struct sched_param* p_sched_param) +int pthread_attr_getschedparam(pthread_attr_t const* attributes, struct sched_param* p_sched_param) { - auto* attributes_impl = *(reinterpret_cast<const PthreadAttrImpl* const*>(attributes)); + auto* attributes_impl = *(reinterpret_cast<PthreadAttrImpl const* const*>(attributes)); if (!attributes_impl || !p_sched_param) return EINVAL; @@ -384,9 +384,9 @@ int pthread_attr_setschedparam(pthread_attr_t* attributes, const struct sched_pa } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getstack.html -int pthread_attr_getstack(const pthread_attr_t* attributes, void** p_stack_ptr, size_t* p_stack_size) +int pthread_attr_getstack(pthread_attr_t const* attributes, void** p_stack_ptr, size_t* p_stack_size) { - auto* attributes_impl = *(reinterpret_cast<const PthreadAttrImpl* const*>(attributes)); + auto* attributes_impl = *(reinterpret_cast<PthreadAttrImpl const* const*>(attributes)); if (!attributes_impl || !p_stack_ptr || !p_stack_size) return EINVAL; @@ -429,9 +429,9 @@ int pthread_attr_setstack(pthread_attr_t* attributes, void* p_stack, size_t stac } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getstacksize.html -int pthread_attr_getstacksize(const pthread_attr_t* attributes, size_t* p_stack_size) +int pthread_attr_getstacksize(pthread_attr_t const* attributes, size_t* p_stack_size) { - auto* attributes_impl = *(reinterpret_cast<const PthreadAttrImpl* const*>(attributes)); + auto* attributes_impl = *(reinterpret_cast<PthreadAttrImpl const* const*>(attributes)); if (!attributes_impl || !p_stack_size) return EINVAL; @@ -465,7 +465,7 @@ int pthread_attr_setstacksize(pthread_attr_t* attributes, size_t stack_size) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getscope.html -int pthread_attr_getscope([[maybe_unused]] const pthread_attr_t* attributes, [[maybe_unused]] int* contention_scope) +int pthread_attr_getscope([[maybe_unused]] pthread_attr_t const* attributes, [[maybe_unused]] int* contention_scope) { return 0; } @@ -514,12 +514,12 @@ void* pthread_getspecific(pthread_key_t key) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_setspecific.html -int pthread_setspecific(pthread_key_t key, const void* value) +int pthread_setspecific(pthread_key_t key, void const* value) { return __pthread_setspecific(key, value); } -int pthread_setname_np(pthread_t thread, const char* name) +int pthread_setname_np(pthread_t thread, char const* name) { if (!name) return EFAULT; @@ -577,7 +577,7 @@ int pthread_spin_init(pthread_spinlock_t* lock, [[maybe_unused]] int shared) // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_spin_lock.html int pthread_spin_lock(pthread_spinlock_t* lock) { - const auto desired = gettid(); + auto const desired = gettid(); while (true) { auto current = AK::atomic_load(&lock->m_lock); @@ -647,7 +647,7 @@ constexpr static u32 writer_wake_mask = 1 << 31; constexpr static u32 writer_locked_mask = 1 << 17; constexpr static u32 writer_intent_mask = 1 << 16; // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_rwlock_init.html -int pthread_rwlock_init(pthread_rwlock_t* __restrict lockp, const pthread_rwlockattr_t* __restrict attr) +int pthread_rwlock_init(pthread_rwlock_t* __restrict lockp, pthread_rwlockattr_t const* __restrict attr) { // Just ignore the attributes. use defaults for now. (void)attr; @@ -868,7 +868,7 @@ int pthread_rwlockattr_destroy(pthread_rwlockattr_t*) } // https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_rwlockattr_getpshared.html -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* __restrict, int* __restrict) +int pthread_rwlockattr_getpshared(pthread_rwlockattr_t const* __restrict, int* __restrict) { VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibPthread/pthread.h b/Userland/Libraries/LibPthread/pthread.h index 009ca6bd65..6260cd5454 100644 --- a/Userland/Libraries/LibPthread/pthread.h +++ b/Userland/Libraries/LibPthread/pthread.h @@ -24,7 +24,7 @@ int pthread_join(pthread_t, void**); int pthread_mutex_lock(pthread_mutex_t*); int pthread_mutex_trylock(pthread_mutex_t* mutex); int pthread_mutex_unlock(pthread_mutex_t*); -int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*); +int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t const*); int pthread_mutex_destroy(pthread_mutex_t*); int pthread_attr_init(pthread_attr_t*); @@ -35,31 +35,31 @@ int pthread_attr_destroy(pthread_attr_t*); #define PTHREAD_CANCELED (-1) -int pthread_attr_getdetachstate(const pthread_attr_t*, int*); +int pthread_attr_getdetachstate(pthread_attr_t const*, int*); int pthread_attr_setdetachstate(pthread_attr_t*, int); -int pthread_attr_getguardsize(const pthread_attr_t*, size_t*); +int pthread_attr_getguardsize(pthread_attr_t const*, size_t*); int pthread_attr_setguardsize(pthread_attr_t*, size_t); -int pthread_attr_getschedparam(const pthread_attr_t*, struct sched_param*); +int pthread_attr_getschedparam(pthread_attr_t const*, struct sched_param*); int pthread_attr_setschedparam(pthread_attr_t*, const struct sched_param*); -int pthread_attr_getstack(const pthread_attr_t*, void**, size_t*); +int pthread_attr_getstack(pthread_attr_t const*, void**, size_t*); int pthread_attr_setstack(pthread_attr_t* attr, void*, size_t); -int pthread_attr_getstacksize(const pthread_attr_t*, size_t*); +int pthread_attr_getstacksize(pthread_attr_t const*, size_t*); int pthread_attr_setstacksize(pthread_attr_t*, size_t); #define PTHREAD_SCOPE_SYSTEM 0 #define PTHREAD_SCOPE_PROCESS 1 -int pthread_attr_getscope(const pthread_attr_t*, int*); +int pthread_attr_getscope(pthread_attr_t const*, int*); int pthread_attr_setscope(pthread_attr_t*, int); int pthread_once(pthread_once_t*, void (*)(void)); #define PTHREAD_ONCE_INIT 0 void* pthread_getspecific(pthread_key_t key); -int pthread_setspecific(pthread_key_t key, const void* value); +int pthread_setspecific(pthread_key_t key, void const* value); int pthread_getschedparam(pthread_t thread, int* policy, struct sched_param* param); int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param); @@ -88,7 +88,7 @@ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)); int pthread_key_delete(pthread_key_t key); int pthread_cond_broadcast(pthread_cond_t*); -int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*); +int pthread_cond_init(pthread_cond_t*, pthread_condattr_t const*); int pthread_cond_signal(pthread_cond_t*); int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); int pthread_condattr_init(pthread_condattr_t*); @@ -122,13 +122,13 @@ int pthread_mutexattr_settype(pthread_mutexattr_t*, int); int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*); int pthread_mutexattr_destroy(pthread_mutexattr_t*); -int pthread_setname_np(pthread_t, const char*); +int pthread_setname_np(pthread_t, char const*); int pthread_getname_np(pthread_t, char*, size_t); int pthread_equal(pthread_t t1, pthread_t t2); int pthread_rwlock_destroy(pthread_rwlock_t*); -int pthread_rwlock_init(pthread_rwlock_t* __restrict, const pthread_rwlockattr_t* __restrict); +int pthread_rwlock_init(pthread_rwlock_t* __restrict, pthread_rwlockattr_t const* __restrict); int pthread_rwlock_rdlock(pthread_rwlock_t*); int pthread_rwlock_timedrdlock(pthread_rwlock_t* __restrict, const struct timespec* __restrict); int pthread_rwlock_timedwrlock(pthread_rwlock_t* __restrict, const struct timespec* __restrict); @@ -137,7 +137,7 @@ int pthread_rwlock_trywrlock(pthread_rwlock_t*); int pthread_rwlock_unlock(pthread_rwlock_t*); int pthread_rwlock_wrlock(pthread_rwlock_t*); int pthread_rwlockattr_destroy(pthread_rwlockattr_t*); -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* __restrict, int* __restrict); +int pthread_rwlockattr_getpshared(pthread_rwlockattr_t const* __restrict, int* __restrict); int pthread_rwlockattr_init(pthread_rwlockattr_t*); int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int); diff --git a/Userland/Libraries/LibPthread/pthread_cond.cpp b/Userland/Libraries/LibPthread/pthread_cond.cpp index f63978c988..5ba15c368e 100644 --- a/Userland/Libraries/LibPthread/pthread_cond.cpp +++ b/Userland/Libraries/LibPthread/pthread_cond.cpp @@ -64,7 +64,7 @@ static constexpr u32 NEED_TO_WAKE_ALL = 2; static constexpr u32 INCREMENT = 4; // https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_init.html -int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) +int pthread_cond_init(pthread_cond_t* cond, pthread_condattr_t const* attr) { cond->mutex = nullptr; cond->value = 0; diff --git a/Userland/Libraries/LibPthread/semaphore.cpp b/Userland/Libraries/LibPthread/semaphore.cpp index 380355fffe..81564b1422 100644 --- a/Userland/Libraries/LibPthread/semaphore.cpp +++ b/Userland/Libraries/LibPthread/semaphore.cpp @@ -17,7 +17,7 @@ static constexpr u32 POST_WAKES = 1 << 31; // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_open.html -sem_t* sem_open(const char*, int, ...) +sem_t* sem_open(char const*, int, ...) { errno = ENOSYS; return nullptr; @@ -31,7 +31,7 @@ int sem_close(sem_t*) } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_unlink.html -int sem_unlink(const char*) +int sem_unlink(char const*) { errno = ENOSYS; return -1; diff --git a/Userland/Libraries/LibPthread/semaphore.h b/Userland/Libraries/LibPthread/semaphore.h index afcbe11283..d04c22943e 100644 --- a/Userland/Libraries/LibPthread/semaphore.h +++ b/Userland/Libraries/LibPthread/semaphore.h @@ -21,10 +21,10 @@ int sem_close(sem_t*); int sem_destroy(sem_t*); int sem_getvalue(sem_t*, int*); int sem_init(sem_t*, int, unsigned int); -sem_t* sem_open(const char*, int, ...); +sem_t* sem_open(char const*, int, ...); int sem_post(sem_t*); int sem_trywait(sem_t*); -int sem_unlink(const char*); +int sem_unlink(char const*); int sem_wait(sem_t*); int sem_timedwait(sem_t*, const struct timespec* abstime); diff --git a/Userland/Libraries/LibRegex/C/Regex.cpp b/Userland/Libraries/LibRegex/C/Regex.cpp index 14affd613c..a3b9abcc75 100644 --- a/Userland/Libraries/LibRegex/C/Regex.cpp +++ b/Userland/Libraries/LibRegex/C/Regex.cpp @@ -36,14 +36,14 @@ static internal_regex_t* impl_from(regex_t* re) return reinterpret_cast<internal_regex_t*>(re->__data); } -static const internal_regex_t* impl_from(const regex_t* re) +static internal_regex_t const* impl_from(regex_t const* re) { return impl_from(const_cast<regex_t*>(re)); } extern "C" { -int regcomp(regex_t* reg, const char* pattern, int cflags) +int regcomp(regex_t* reg, char const* pattern, int cflags) { if (!reg) return REG_ESPACE; @@ -80,7 +80,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags) return REG_NOERR; } -int regexec(const regex_t* reg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags) +int regexec(regex_t const* reg, char const* string, size_t nmatch, regmatch_t pmatch[], int eflags) { auto const* preg = impl_from(reg); @@ -210,7 +210,7 @@ inline static String get_error(ReError errcode) return error; } -size_t regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_size) +size_t regerror(int errcode, regex_t const* reg, char* errbuf, size_t errbuf_size) { String error; auto const* preg = impl_from(reg); diff --git a/Userland/Libraries/LibSQL/AST/AST.h b/Userland/Libraries/LibSQL/AST/AST.h index cf58e78f13..d9e242e97c 100644 --- a/Userland/Libraries/LibSQL/AST/AST.h +++ b/Userland/Libraries/LibSQL/AST/AST.h @@ -62,8 +62,8 @@ public: VERIFY(m_signed_numbers.size() <= 2); } - const String& name() const { return m_name; } - const NonnullRefPtrVector<SignedNumber>& signed_numbers() const { return m_signed_numbers; } + String const& name() const { return m_name; } + NonnullRefPtrVector<SignedNumber> const& signed_numbers() const { return m_signed_numbers; } private: String m_name; @@ -78,8 +78,8 @@ public: { } - const String& name() const { return m_name; } - const NonnullRefPtr<TypeName>& type_name() const { return m_type_name; } + String const& name() const { return m_name; } + NonnullRefPtr<TypeName> const& type_name() const { return m_type_name; } private: String m_name; @@ -95,9 +95,9 @@ public: { } - const String& table_name() const { return m_table_name; } - const Vector<String>& column_names() const { return m_column_names; } - const NonnullRefPtr<Select>& select_statement() const { return m_select_statement; } + String const& table_name() const { return m_table_name; } + Vector<String> const& column_names() const { return m_column_names; } + NonnullRefPtr<Select> const& select_statement() const { return m_select_statement; } private: String m_table_name; @@ -115,7 +115,7 @@ public: } bool recursive() const { return m_recursive; } - const NonnullRefPtrVector<CommonTableExpression>& common_table_expressions() const { return m_common_table_expressions; } + NonnullRefPtrVector<CommonTableExpression> const& common_table_expressions() const { return m_common_table_expressions; } private: bool m_recursive; @@ -131,9 +131,9 @@ public: { } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } - const String& alias() const { return m_alias; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } + String const& alias() const { return m_alias; } private: String m_schema_name; @@ -156,7 +156,7 @@ public: } bool return_all_columns() const { return m_columns.is_empty(); }; - const Vector<ColumnClause>& columns() const { return m_columns; } + Vector<ColumnClause> const& columns() const { return m_columns; } private: Vector<ColumnClause> m_columns; @@ -188,11 +188,11 @@ public: ResultType type() const { return m_type; } bool select_from_table() const { return !m_table_name.is_null(); } - const String& table_name() const { return m_table_name; } + String const& table_name() const { return m_table_name; } bool select_from_expression() const { return !m_expression.is_null(); } - const RefPtr<Expression>& expression() const { return m_expression; } - const String& column_alias() const { return m_column_alias; } + RefPtr<Expression> const& expression() const { return m_expression; } + String const& column_alias() const { return m_column_alias; } private: ResultType m_type { ResultType::All }; @@ -212,8 +212,8 @@ public: VERIFY(!m_group_by_list.is_empty()); } - const NonnullRefPtrVector<Expression>& group_by_list() const { return m_group_by_list; } - const RefPtr<Expression>& having_clause() const { return m_having_clause; } + NonnullRefPtrVector<Expression> const& group_by_list() const { return m_group_by_list; } + RefPtr<Expression> const& having_clause() const { return m_having_clause; } private: NonnullRefPtrVector<Expression> m_group_by_list; @@ -239,12 +239,12 @@ public: } bool is_table() const { return m_is_table; } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } - const String& table_alias() const { return m_table_alias; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } + String const& table_alias() const { return m_table_alias; } bool is_subquery() const { return m_is_subquery; } - const NonnullRefPtrVector<TableOrSubquery>& subqueries() const { return m_subqueries; } + NonnullRefPtrVector<TableOrSubquery> const& subqueries() const { return m_subqueries; } private: bool m_is_table { false }; @@ -266,8 +266,8 @@ public: { } - const NonnullRefPtr<Expression>& expression() const { return m_expression; } - const String& collation_name() const { return m_collation_name; } + NonnullRefPtr<Expression> const& expression() const { return m_expression; } + String const& collation_name() const { return m_collation_name; } Order order() const { return m_order; } Nulls nulls() const { return m_nulls; } @@ -286,8 +286,8 @@ public: { } - const NonnullRefPtr<Expression>& limit_expression() const { return m_limit_expression; } - const RefPtr<Expression>& offset_expression() const { return m_offset_expression; } + NonnullRefPtr<Expression> const& limit_expression() const { return m_limit_expression; } + RefPtr<Expression> const& offset_expression() const { return m_offset_expression; } private: NonnullRefPtr<Expression> m_limit_expression; @@ -336,7 +336,7 @@ public: { } - const String& value() const { return m_value; } + String const& value() const { return m_value; } virtual ResultOr<Value> evaluate(ExecutionContext&) const override; private: @@ -350,7 +350,7 @@ public: { } - const String& value() const { return m_value; } + String const& value() const { return m_value; } private: String m_value; @@ -363,7 +363,7 @@ public: class NestedExpression : public Expression { public: - const NonnullRefPtr<Expression>& expression() const { return m_expression; } + NonnullRefPtr<Expression> const& expression() const { return m_expression; } virtual ResultOr<Value> evaluate(ExecutionContext&) const override; protected: @@ -378,8 +378,8 @@ private: class NestedDoubleExpression : public Expression { public: - const NonnullRefPtr<Expression>& lhs() const { return m_lhs; } - const NonnullRefPtr<Expression>& rhs() const { return m_rhs; } + NonnullRefPtr<Expression> const& lhs() const { return m_lhs; } + NonnullRefPtr<Expression> const& rhs() const { return m_rhs; } protected: NestedDoubleExpression(NonnullRefPtr<Expression> lhs, NonnullRefPtr<Expression> rhs) @@ -432,9 +432,9 @@ public: { } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } - const String& column_name() const { return m_column_name; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } + String const& column_name() const { return m_column_name; } virtual ResultOr<Value> evaluate(ExecutionContext&) const override; private: @@ -547,7 +547,7 @@ public: { } - const NonnullRefPtrVector<Expression>& expressions() const { return m_expressions; } + NonnullRefPtrVector<Expression> const& expressions() const { return m_expressions; } virtual ResultOr<Value> evaluate(ExecutionContext&) const override; private: @@ -562,7 +562,7 @@ public: { } - const NonnullRefPtr<TypeName>& type_name() const { return m_type_name; } + NonnullRefPtr<TypeName> const& type_name() const { return m_type_name; } private: NonnullRefPtr<TypeName> m_type_name; @@ -583,9 +583,9 @@ public: VERIFY(!m_when_then_clauses.is_empty()); } - const RefPtr<Expression>& case_expression() const { return m_case_expression; } - const Vector<WhenThenClause>& when_then_clauses() const { return m_when_then_clauses; } - const RefPtr<Expression>& else_expression() const { return m_else_expression; } + RefPtr<Expression> const& case_expression() const { return m_case_expression; } + Vector<WhenThenClause> const& when_then_clauses() const { return m_when_then_clauses; } + RefPtr<Expression> const& else_expression() const { return m_else_expression; } private: RefPtr<Expression> m_case_expression; @@ -601,7 +601,7 @@ public: { } - const NonnullRefPtr<Select>& select_statement() const { return m_select_statement; } + NonnullRefPtr<Select> const& select_statement() const { return m_select_statement; } bool invert_expression() const { return m_invert_expression; } private: @@ -617,7 +617,7 @@ public: { } - const String& collation_name() const { return m_collation_name; } + String const& collation_name() const { return m_collation_name; } private: String m_collation_name; @@ -640,7 +640,7 @@ public: } MatchOperator type() const { return m_type; } - const RefPtr<Expression>& escape() const { return m_escape; } + RefPtr<Expression> const& escape() const { return m_escape; } virtual ResultOr<Value> evaluate(ExecutionContext&) const override; private: @@ -672,7 +672,7 @@ public: { } - const NonnullRefPtr<Expression>& expression() const { return m_expression; } + NonnullRefPtr<Expression> const& expression() const { return m_expression; } private: NonnullRefPtr<Expression> m_expression; @@ -686,7 +686,7 @@ public: { } - const NonnullRefPtr<Select>& select_statement() const { return m_select_statement; } + NonnullRefPtr<Select> const& select_statement() const { return m_select_statement; } private: NonnullRefPtr<Select> m_select_statement; @@ -700,7 +700,7 @@ public: { } - const NonnullRefPtr<ChainedExpression>& expression_chain() const { return m_expression_chain; } + NonnullRefPtr<ChainedExpression> const& expression_chain() const { return m_expression_chain; } private: NonnullRefPtr<ChainedExpression> m_expression_chain; @@ -715,8 +715,8 @@ public: { } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } private: String m_schema_name; @@ -748,7 +748,7 @@ public: { } - const String& schema_name() const { return m_schema_name; } + String const& schema_name() const { return m_schema_name; } bool is_error_if_schema_exists() const { return m_is_error_if_schema_exists; } ResultOr<ResultSet> execute(ExecutionContext&) const override; @@ -778,14 +778,14 @@ public: { } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } bool has_selection() const { return !m_select_statement.is_null(); } - const RefPtr<Select>& select_statement() const { return m_select_statement; } + RefPtr<Select> const& select_statement() const { return m_select_statement; } bool has_columns() const { return !m_columns.is_empty(); } - const NonnullRefPtrVector<ColumnDefinition>& columns() const { return m_columns; } + NonnullRefPtrVector<ColumnDefinition> const& columns() const { return m_columns; } bool is_temporary() const { return m_is_temporary; } bool is_error_if_table_exists() const { return m_is_error_if_table_exists; } @@ -803,8 +803,8 @@ private: class AlterTable : public Statement { public: - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } protected: AlterTable(String schema_name, String table_name) @@ -826,7 +826,7 @@ public: { } - const String& new_table_name() const { return m_new_table_name; } + String const& new_table_name() const { return m_new_table_name; } private: String m_new_table_name; @@ -841,8 +841,8 @@ public: { } - const String& column_name() const { return m_column_name; } - const String& new_column_name() const { return m_new_column_name; } + String const& column_name() const { return m_column_name; } + String const& new_column_name() const { return m_new_column_name; } private: String m_column_name; @@ -857,7 +857,7 @@ public: { } - const NonnullRefPtr<ColumnDefinition>& column() const { return m_column; } + NonnullRefPtr<ColumnDefinition> const& column() const { return m_column; } private: NonnullRefPtr<ColumnDefinition> m_column; @@ -871,7 +871,7 @@ public: { } - const String& column_name() const { return m_column_name; } + String const& column_name() const { return m_column_name; } private: String m_column_name; @@ -886,8 +886,8 @@ public: { } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } bool is_error_if_table_does_not_exist() const { return m_is_error_if_table_does_not_exist; } private: @@ -938,20 +938,20 @@ public: { } - const RefPtr<CommonTableExpressionList>& common_table_expression_list() const { return m_common_table_expression_list; } + RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; } ConflictResolution conflict_resolution() const { return m_conflict_resolution; } - const String& schema_name() const { return m_schema_name; } - const String& table_name() const { return m_table_name; } - const String& alias() const { return m_alias; } - const Vector<String>& column_names() const { return m_column_names; } + String const& schema_name() const { return m_schema_name; } + String const& table_name() const { return m_table_name; } + String const& alias() const { return m_alias; } + Vector<String> const& column_names() const { return m_column_names; } bool default_values() const { return !has_expressions() && !has_selection(); }; bool has_expressions() const { return !m_chained_expressions.is_empty(); } - const NonnullRefPtrVector<ChainedExpression>& chained_expressions() const { return m_chained_expressions; } + NonnullRefPtrVector<ChainedExpression> const& chained_expressions() const { return m_chained_expressions; } bool has_selection() const { return !m_select_statement.is_null(); } - const RefPtr<Select>& select_statement() const { return m_select_statement; } + RefPtr<Select> const& select_statement() const { return m_select_statement; } virtual ResultOr<ResultSet> execute(ExecutionContext&) const override; @@ -984,13 +984,13 @@ public: { } - const RefPtr<CommonTableExpressionList>& common_table_expression_list() const { return m_common_table_expression_list; } + RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; } ConflictResolution conflict_resolution() const { return m_conflict_resolution; } - const NonnullRefPtr<QualifiedTableName>& qualified_table_name() const { return m_qualified_table_name; } - const Vector<UpdateColumns>& update_columns() const { return m_update_columns; } - const NonnullRefPtrVector<TableOrSubquery>& table_or_subquery_list() const { return m_table_or_subquery_list; } - const RefPtr<Expression>& where_clause() const { return m_where_clause; } - const RefPtr<ReturningClause>& returning_clause() const { return m_returning_clause; } + NonnullRefPtr<QualifiedTableName> const& qualified_table_name() const { return m_qualified_table_name; } + Vector<UpdateColumns> const& update_columns() const { return m_update_columns; } + NonnullRefPtrVector<TableOrSubquery> const& table_or_subquery_list() const { return m_table_or_subquery_list; } + RefPtr<Expression> const& where_clause() const { return m_where_clause; } + RefPtr<ReturningClause> const& returning_clause() const { return m_returning_clause; } private: RefPtr<CommonTableExpressionList> m_common_table_expression_list; @@ -1012,10 +1012,10 @@ public: { } - const RefPtr<CommonTableExpressionList>& common_table_expression_list() const { return m_common_table_expression_list; } - const NonnullRefPtr<QualifiedTableName>& qualified_table_name() const { return m_qualified_table_name; } - const RefPtr<Expression>& where_clause() const { return m_where_clause; } - const RefPtr<ReturningClause>& returning_clause() const { return m_returning_clause; } + RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; } + NonnullRefPtr<QualifiedTableName> const& qualified_table_name() const { return m_qualified_table_name; } + RefPtr<Expression> const& where_clause() const { return m_where_clause; } + RefPtr<ReturningClause> const& returning_clause() const { return m_returning_clause; } private: RefPtr<CommonTableExpressionList> m_common_table_expression_list; @@ -1038,14 +1038,14 @@ public: { } - const RefPtr<CommonTableExpressionList>& common_table_expression_list() const { return m_common_table_expression_list; } + RefPtr<CommonTableExpressionList> const& common_table_expression_list() const { return m_common_table_expression_list; } bool select_all() const { return m_select_all; } - const NonnullRefPtrVector<ResultColumn>& result_column_list() const { return m_result_column_list; } - const NonnullRefPtrVector<TableOrSubquery>& table_or_subquery_list() const { return m_table_or_subquery_list; } - const RefPtr<Expression>& where_clause() const { return m_where_clause; } - const RefPtr<GroupByClause>& group_by_clause() const { return m_group_by_clause; } - const NonnullRefPtrVector<OrderingTerm>& ordering_term_list() const { return m_ordering_term_list; } - const RefPtr<LimitClause>& limit_clause() const { return m_limit_clause; } + NonnullRefPtrVector<ResultColumn> const& result_column_list() const { return m_result_column_list; } + NonnullRefPtrVector<TableOrSubquery> const& table_or_subquery_list() const { return m_table_or_subquery_list; } + RefPtr<Expression> const& where_clause() const { return m_where_clause; } + RefPtr<GroupByClause> const& group_by_clause() const { return m_group_by_clause; } + NonnullRefPtrVector<OrderingTerm> const& ordering_term_list() const { return m_ordering_term_list; } + RefPtr<LimitClause> const& limit_clause() const { return m_limit_clause; } ResultOr<ResultSet> execute(ExecutionContext&) const override; private: diff --git a/Userland/Libraries/LibSQL/AST/Parser.cpp b/Userland/Libraries/LibSQL/AST/Parser.cpp index b081183729..94ed6f55e3 100644 --- a/Userland/Libraries/LibSQL/AST/Parser.cpp +++ b/Userland/Libraries/LibSQL/AST/Parser.cpp @@ -809,7 +809,7 @@ RefPtr<Expression> Parser::parse_between_expression(NonnullRefPtr<Expression> ex return create_ast_node<ErrorExpression>(); } - const auto& binary_expression = static_cast<const BinaryOperatorExpression&>(*nested); + auto const& binary_expression = static_cast<BinaryOperatorExpression const&>(*nested); if (binary_expression.type() != BinaryOperator::And) { expected("AND Expression"); return create_ast_node<ErrorExpression>(); @@ -1030,7 +1030,7 @@ NonnullRefPtr<OrderingTerm> Parser::parse_ordering_term() String collation_name; if (is<CollateExpression>(*expression)) { - const auto& collate = static_cast<const CollateExpression&>(*expression); + auto const& collate = static_cast<CollateExpression const&>(*expression); collation_name = collate.collation_name(); expression = collate.expression(); } else if (consume_if(TokenType::Collate)) { diff --git a/Userland/Libraries/LibSQL/AST/Parser.h b/Userland/Libraries/LibSQL/AST/Parser.h index 6a4db5695d..9d35018d3f 100644 --- a/Userland/Libraries/LibSQL/AST/Parser.h +++ b/Userland/Libraries/LibSQL/AST/Parser.h @@ -38,7 +38,7 @@ public: NonnullRefPtr<Statement> next_statement(); bool has_errors() const { return m_parser_state.m_errors.size(); } - const Vector<Error>& errors() const { return m_parser_state.m_errors; } + Vector<Error> const& errors() const { return m_parser_state.m_errors; } protected: NonnullRefPtr<Expression> parse_expression(); // Protected for unit testing. diff --git a/Userland/Libraries/LibSQL/Meta.cpp b/Userland/Libraries/LibSQL/Meta.cpp index 5dab68e598..8202c9d9be 100644 --- a/Userland/Libraries/LibSQL/Meta.cpp +++ b/Userland/Libraries/LibSQL/Meta.cpp @@ -65,7 +65,7 @@ Key ColumnDef::key() const return key; } -void ColumnDef::set_default_value(const Value& default_value) +void ColumnDef::set_default_value(Value const& default_value) { VERIFY(default_value.type() == type()); m_default = default_value; diff --git a/Userland/Libraries/LibSQL/Tuple.cpp b/Userland/Libraries/LibSQL/Tuple.cpp index a25a057cbb..58a96fabe8 100644 --- a/Userland/Libraries/LibSQL/Tuple.cpp +++ b/Userland/Libraries/LibSQL/Tuple.cpp @@ -117,7 +117,7 @@ Value& Tuple::operator[](String const& name) return (*this)[index.value()]; } -void Tuple::append(const Value& value) +void Tuple::append(Value const& value) { VERIFY(descriptor()->size() >= size()); if (descriptor()->size() == size()) { @@ -198,7 +198,7 @@ Vector<String> Tuple::to_string_vector() const return ret; } -void Tuple::copy_from(const Tuple& other) +void Tuple::copy_from(Tuple const& other) { if (*m_descriptor != *other.m_descriptor) { m_descriptor->clear(); @@ -213,7 +213,7 @@ void Tuple::copy_from(const Tuple& other) m_pointer = other.pointer(); } -int Tuple::compare(const Tuple& other) const +int Tuple::compare(Tuple const& other) const { auto num_values = min(m_data.size(), other.m_data.size()); VERIFY(num_values > 0); @@ -228,7 +228,7 @@ int Tuple::compare(const Tuple& other) const return 0; } -int Tuple::match(const Tuple& other) const +int Tuple::match(Tuple const& other) const { auto other_index = 0u; for (auto& part : *other.descriptor()) { diff --git a/Userland/Libraries/LibSanitizer/UBSanitizer.cpp b/Userland/Libraries/LibSanitizer/UBSanitizer.cpp index 7411a34ff6..c86a74d9af 100644 --- a/Userland/Libraries/LibSanitizer/UBSanitizer.cpp +++ b/Userland/Libraries/LibSanitizer/UBSanitizer.cpp @@ -17,7 +17,7 @@ Atomic<bool> AK::UBSanitizer::g_ubsan_is_deadly; extern "C" { -static void print_location(const SourceLocation& location) +static void print_location(SourceLocation const& location) { if (!location.filename()) { WARNLN_AND_DBGLN("UBSAN: in unknown file"); @@ -76,8 +76,8 @@ void __ubsan_handle_nullability_arg(NonnullArgData& data) print_location(location); } -void __ubsan_handle_nonnull_return_v1(const NonnullReturnData&, SourceLocation&) __attribute__((used)); -void __ubsan_handle_nonnull_return_v1(const NonnullReturnData&, SourceLocation& location) +void __ubsan_handle_nonnull_return_v1(NonnullReturnData const&, SourceLocation&) __attribute__((used)); +void __ubsan_handle_nonnull_return_v1(NonnullReturnData const&, SourceLocation& location) { auto loc = location.permanently_clear(); if (!loc.needs_logging()) @@ -86,8 +86,8 @@ void __ubsan_handle_nonnull_return_v1(const NonnullReturnData&, SourceLocation& print_location(loc); } -void __ubsan_handle_nullability_return_v1(const NonnullReturnData& data, SourceLocation& location) __attribute__((used)); -void __ubsan_handle_nullability_return_v1(const NonnullReturnData&, SourceLocation& location) +void __ubsan_handle_nullability_return_v1(NonnullReturnData const& data, SourceLocation& location) __attribute__((used)); +void __ubsan_handle_nullability_return_v1(NonnullReturnData const&, SourceLocation& location) { auto loc = location.permanently_clear(); if (!loc.needs_logging()) @@ -258,8 +258,8 @@ void __ubsan_handle_implicit_conversion(ImplicitConversionData& data, ValueHandl auto location = data.location.permanently_clear(); if (!location.needs_logging()) return; - const char* src_signed = data.from_type.is_signed() ? "" : "un"; - const char* dst_signed = data.to_type.is_signed() ? "" : "un"; + char const* src_signed = data.from_type.is_signed() ? "" : "un"; + char const* dst_signed = data.to_type.is_signed() ? "" : "un"; WARNLN_AND_DBGLN("UBSAN: implicit conversion from type {} ({}-bit, {}signed) to type {} ({}-bit, {}signed)", data.from_type.name(), data.from_type.bit_width(), src_signed, data.to_type.name(), data.to_type.bit_width(), dst_signed); print_location(location); diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 3db74a188a..20dc857d1b 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -44,18 +44,18 @@ using AK::SIMD::to_f32x4; using AK::SIMD::to_u32x4; using AK::SIMD::u32x4; -constexpr static float edge_function(const FloatVector2& a, const FloatVector2& b, const FloatVector2& c) +constexpr static float edge_function(FloatVector2 const& a, FloatVector2 const& b, FloatVector2 const& c) { return (c.x() - a.x()) * (b.y() - a.y()) - (c.y() - a.y()) * (b.x() - a.x()); } -constexpr static f32x4 edge_function4(const FloatVector2& a, const FloatVector2& b, const Vector2<f32x4>& c) +constexpr static f32x4 edge_function4(FloatVector2 const& a, FloatVector2 const& b, Vector2<f32x4> const& c) { return (c.x() - a.x()) * (b.y() - a.y()) - (c.y() - a.y()) * (b.x() - a.x()); } template<typename T, typename U> -constexpr static auto interpolate(const T& v0, const T& v1, const T& v2, const Vector3<U>& barycentric_coords) +constexpr static auto interpolate(const T& v0, const T& v1, const T& v2, Vector3<U> const& barycentric_coords) { return v0 * barycentric_coords.x() + v1 * barycentric_coords.y() + v2 * barycentric_coords.z(); } @@ -175,7 +175,7 @@ void Device::setup_blend_factors() } } -void Device::rasterize_triangle(const Triangle& triangle) +void Device::rasterize_triangle(Triangle const& triangle) { INCREASE_STATISTICS_COUNTER(g_num_rasterized_triangles, 1); @@ -1190,7 +1190,7 @@ void Device::draw_statistics_overlay(Gfx::Bitmap& target) painter.draw_text(target.rect().translated(2, 2), debug_string, font, Gfx::TextAlignment::TopLeft, Gfx::Color::White); } -void Device::set_options(const RasterizerOptions& options) +void Device::set_options(RasterizerOptions const& options) { m_options = options; @@ -1198,7 +1198,7 @@ void Device::set_options(const RasterizerOptions& options) setup_blend_factors(); } -void Device::set_light_model_params(const LightModelParameters& lighting_model) +void Device::set_light_model_params(LightModelParameters const& lighting_model) { m_lighting_model = lighting_model; } diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h index aefc01aa96..86568ec57b 100644 --- a/Userland/Libraries/LibSoftGPU/Device.h +++ b/Userland/Libraries/LibSoftGPU/Device.h @@ -111,7 +111,7 @@ struct StencilConfiguration { class Device final { public: - Device(const Gfx::IntSize& min_size); + Device(Gfx::IntSize const& min_size); DeviceInfo info() const; @@ -123,8 +123,8 @@ public: void blit_color_buffer_to(Gfx::Bitmap& target); void blit_to_color_buffer_at_raster_position(Gfx::Bitmap const&); void blit_to_depth_buffer_at_raster_position(Vector<DepthType> const&, int, int); - void set_options(const RasterizerOptions&); - void set_light_model_params(const LightModelParameters&); + void set_options(RasterizerOptions const&); + void set_light_model_params(LightModelParameters const&); RasterizerOptions options() const { return m_options; } LightModelParameters light_model() const { return m_lighting_model; } ColorType get_color_buffer_pixel(int x, int y); @@ -145,7 +145,7 @@ private: void draw_statistics_overlay(Gfx::Bitmap&); Gfx::IntRect get_rasterization_rect_of_size(Gfx::IntSize size); - void rasterize_triangle(const Triangle& triangle); + void rasterize_triangle(Triangle const& triangle); void setup_blend_factors(); void shade_fragments(PixelQuad&); bool test_alpha(PixelQuad&); diff --git a/Userland/Libraries/LibSymbolication/Symbolication.cpp b/Userland/Libraries/LibSymbolication/Symbolication.cpp index 42852a0fb6..bef6ca0b2c 100644 --- a/Userland/Libraries/LibSymbolication/Symbolication.cpp +++ b/Userland/Libraries/LibSymbolication/Symbolication.cpp @@ -211,7 +211,7 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid, IncludeSourcePosition in bool first_frame = true; for (auto address : stack) { - const RegionWithSymbols* found_region = nullptr; + RegionWithSymbols const* found_region = nullptr; for (auto& region : regions) { FlatPtr region_end; if (Checked<FlatPtr>::addition_would_overflow(region.base, region.size)) diff --git a/Userland/Libraries/LibSyntax/Highlighter.h b/Userland/Libraries/LibSyntax/Highlighter.h index 984c52857d..e6a2cc487c 100644 --- a/Userland/Libraries/LibSyntax/Highlighter.h +++ b/Userland/Libraries/LibSyntax/Highlighter.h @@ -29,7 +29,7 @@ enum class Language { struct TextStyle { const Gfx::Color color; - const bool bold { false }; + bool const bold { false }; }; class Highlighter { @@ -41,7 +41,7 @@ public: virtual Language language() const = 0; StringView language_string(Language) const; - virtual void rehighlight(const Palette&) = 0; + virtual void rehighlight(Palette const&) = 0; virtual void highlight_matching_token_pair(); virtual bool is_identifier(u64) const { return false; }; @@ -125,7 +125,7 @@ public: private: virtual Vector<GUI::TextDocumentSpan>& spans() override { return m_spans; } - virtual const Vector<GUI::TextDocumentSpan>& spans() const override { return m_spans; } + virtual Vector<GUI::TextDocumentSpan> const& spans() const override { return m_spans; } virtual void set_span_at_index(size_t index, GUI::TextDocumentSpan span) override { m_spans.at(index) = move(span); } virtual String highlighter_did_request_text() const override { return m_text; } diff --git a/Userland/Libraries/LibSyntax/HighlighterClient.h b/Userland/Libraries/LibSyntax/HighlighterClient.h index 60ee1bb9ab..1edd69fac6 100644 --- a/Userland/Libraries/LibSyntax/HighlighterClient.h +++ b/Userland/Libraries/LibSyntax/HighlighterClient.h @@ -18,7 +18,7 @@ public: virtual ~HighlighterClient() = default; virtual Vector<GUI::TextDocumentSpan>& spans() = 0; - virtual const Vector<GUI::TextDocumentSpan>& spans() const = 0; + virtual Vector<GUI::TextDocumentSpan> const& spans() const = 0; virtual void set_span_at_index(size_t index, GUI::TextDocumentSpan span) = 0; virtual String highlighter_did_request_text() const = 0; diff --git a/Userland/Libraries/LibTLS/Certificate.h b/Userland/Libraries/LibTLS/Certificate.h index 15f352d50d..b806e4213e 100644 --- a/Userland/Libraries/LibTLS/Certificate.h +++ b/Userland/Libraries/LibTLS/Certificate.h @@ -63,7 +63,7 @@ class DefaultRootCACertificates { public: DefaultRootCACertificates(); - const Vector<Certificate>& certificates() const { return m_ca_certificates; } + Vector<Certificate> const& certificates() const { return m_ca_certificates; } static DefaultRootCACertificates& the() { return s_the; } diff --git a/Userland/Libraries/LibTLS/Handshake.cpp b/Userland/Libraries/LibTLS/Handshake.cpp index 6a7c160546..5720674be7 100644 --- a/Userland/Libraries/LibTLS/Handshake.cpp +++ b/Userland/Libraries/LibTLS/Handshake.cpp @@ -99,7 +99,7 @@ ByteBuffer TLSv12::build_hello() builder.append((u8)0); // SNI host length + value builder.append((u16)sni_length); - builder.append((const u8*)m_context.extensions.SNI.characters(), sni_length); + builder.append((u8 const*)m_context.extensions.SNI.characters(), sni_length); } // signature_algorithms extension @@ -180,7 +180,7 @@ ByteBuffer TLSv12::build_handshake_finished() auto digest = m_context.handshake_hash.digest(); auto hashbuf = ReadonlyBytes { digest.immutable_data(), m_context.handshake_hash.digest_size() }; - pseudorandom_function(outbuffer, m_context.master_key, (const u8*)"client finished", 15, hashbuf, dummy); + pseudorandom_function(outbuffer, m_context.master_key, (u8 const*)"client finished", 15, hashbuf, dummy); builder.append(outbuffer); auto packet = builder.build(); @@ -314,7 +314,7 @@ ssize_t TLSv12::handle_handshake_payload(ReadonlyBytes vbuffer) } payload_res = handle_certificate(buffer.slice(1, payload_size)); if (m_context.certificates.size()) { - auto it = m_context.certificates.find_if([](const auto& cert) { return cert.is_valid(); }); + auto it = m_context.certificates.find_if([](auto const& cert) { return cert.is_valid(); }); if (it.is_end()) { // no valid certificates diff --git a/Userland/Libraries/LibTLS/HandshakeClient.cpp b/Userland/Libraries/LibTLS/HandshakeClient.cpp index 1420e7a1ef..2f2efbccfd 100644 --- a/Userland/Libraries/LibTLS/HandshakeClient.cpp +++ b/Userland/Libraries/LibTLS/HandshakeClient.cpp @@ -36,7 +36,7 @@ bool TLSv12::expand_key() pseudorandom_function( key_buffer, m_context.master_key, - (const u8*)"key expansion", 13, + (u8 const*)"key expansion", 13, ReadonlyBytes { m_context.remote_random, sizeof(m_context.remote_random) }, ReadonlyBytes { m_context.local_random, sizeof(m_context.local_random) }); @@ -129,7 +129,7 @@ bool TLSv12::compute_master_secret_from_pre_master_secret(size_t length) pseudorandom_function( m_context.master_key, m_context.premaster_key, - (const u8*)"master secret", 13, + (u8 const*)"master secret", 13, ReadonlyBytes { m_context.local_random, sizeof(m_context.local_random) }, ReadonlyBytes { m_context.remote_random, sizeof(m_context.remote_random) }); @@ -211,7 +211,7 @@ void TLSv12::build_rsa_pre_master_secret(PacketBuilder& builder) } m_context.premaster_key = premaster_key_result.release_value(); - const auto& certificate_option = verify_chain_and_get_matching_certificate(m_context.extensions.SNI); // if the SNI is empty, we'll make a special case and match *a* leaf certificate. + auto const& certificate_option = verify_chain_and_get_matching_certificate(m_context.extensions.SNI); // if the SNI is empty, we'll make a special case and match *a* leaf certificate. if (!certificate_option.has_value()) { dbgln("certificate verification failed :("); alert(AlertLevel::Critical, AlertDescription::BadCertificate); diff --git a/Userland/Libraries/LibTLS/HandshakeServer.cpp b/Userland/Libraries/LibTLS/HandshakeServer.cpp index e263d82d4d..92ca783706 100644 --- a/Userland/Libraries/LibTLS/HandshakeServer.cpp +++ b/Userland/Libraries/LibTLS/HandshakeServer.cpp @@ -133,7 +133,7 @@ ssize_t TLSv12::handle_server_hello(ReadonlyBytes buffer, WritePacketStage& writ // Exactly one ServerName should be present if (buffer.size() - res < 3) return (i8)Error::NeedMoreData; - auto sni_name_type = (NameType)(*(const u8*)buffer.offset_pointer(res++)); + auto sni_name_type = (NameType)(*(u8 const*)buffer.offset_pointer(res++)); auto sni_name_length = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res += 2))); if (sni_name_type != NameType::HostName) @@ -145,7 +145,7 @@ ssize_t TLSv12::handle_server_hello(ReadonlyBytes buffer, WritePacketStage& writ // Read out the host_name if (buffer.size() - res < sni_name_length) return (i8)Error::NeedMoreData; - m_context.extensions.SNI = String { (const char*)buffer.offset_pointer(res), sni_name_length }; + m_context.extensions.SNI = String { (char const*)buffer.offset_pointer(res), sni_name_length }; res += sni_name_length; dbgln("SNI host_name: {}", m_context.extensions.SNI); } @@ -153,13 +153,13 @@ ssize_t TLSv12::handle_server_hello(ReadonlyBytes buffer, WritePacketStage& writ if (buffer.size() - res > 2) { auto alpn_length = AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(res))); if (alpn_length && alpn_length <= extension_length - 2) { - const u8* alpn = buffer.offset_pointer(res + 2); + u8 const* alpn = buffer.offset_pointer(res + 2); size_t alpn_position = 0; while (alpn_position < alpn_length) { u8 alpn_size = alpn[alpn_position++]; if (alpn_size + alpn_position >= extension_length) break; - String alpn_str { (const char*)alpn + alpn_position, alpn_length }; + String alpn_str { (char const*)alpn + alpn_position, alpn_length }; if (alpn_size && m_context.alpn.contains_slow(alpn_str)) { m_context.negotiated_alpn = alpn_str; dbgln("negotiated alpn: {}", alpn_str); diff --git a/Userland/Libraries/LibTLS/Record.cpp b/Userland/Libraries/LibTLS/Record.cpp index 2063e168d9..00c63b38e9 100644 --- a/Userland/Libraries/LibTLS/Record.cpp +++ b/Userland/Libraries/LibTLS/Record.cpp @@ -274,20 +274,20 @@ void TLSv12::ensure_hmac(size_t digest_size, bool local) m_hmac_remote = move(hmac); } -ByteBuffer TLSv12::hmac_message(ReadonlyBytes buf, const Optional<ReadonlyBytes> buf2, size_t mac_length, bool local) +ByteBuffer TLSv12::hmac_message(ReadonlyBytes buf, Optional<ReadonlyBytes> const buf2, size_t mac_length, bool local) { u64 sequence_number = AK::convert_between_host_and_network_endian(local ? m_context.local_sequence_number : m_context.remote_sequence_number); ensure_hmac(mac_length, local); auto& hmac = local ? *m_hmac_local : *m_hmac_remote; if constexpr (TLS_DEBUG) { dbgln("========================= PACKET DATA =========================="); - print_buffer((const u8*)&sequence_number, sizeof(u64)); + print_buffer((u8 const*)&sequence_number, sizeof(u64)); print_buffer(buf.data(), buf.size()); if (buf2.has_value()) print_buffer(buf2.value().data(), buf2.value().size()); dbgln("========================= PACKET DATA =========================="); } - hmac.update((const u8*)&sequence_number, sizeof(u64)); + hmac.update((u8 const*)&sequence_number, sizeof(u64)); hmac.update(buf); if (buf2.has_value() && buf2.value().size()) { hmac.update(buf2.value()); diff --git a/Userland/Libraries/LibTLS/Socket.cpp b/Userland/Libraries/LibTLS/Socket.cpp index f63900d790..79ba5d08a7 100644 --- a/Userland/Libraries/LibTLS/Socket.cpp +++ b/Userland/Libraries/LibTLS/Socket.cpp @@ -71,7 +71,7 @@ ErrorOr<size_t> TLSv12::write(ReadonlyBytes bytes) return bytes.size(); } -ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(const String& host, u16 port, Options options) +ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(String const& host, u16 port, Options options) { Core::EventLoop loop; OwnPtr<Core::Stream::Socket> tcp_socket = TRY(Core::Stream::TCPSocket::connect(host, port)); @@ -93,7 +93,7 @@ ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(const String& host, u16 port, Opt return AK::Error::from_string_literal(alert_name(static_cast<AlertDescription>(256 - result))); } -ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(const String& host, Core::Stream::Socket& underlying_stream, Options options) +ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(String const& host, Core::Stream::Socket& underlying_stream, Options options) { StreamVariantType socket { &underlying_stream }; auto tls_socket = make<TLSv12>(&underlying_stream, move(options)); diff --git a/Userland/Libraries/LibTLS/TLSPacketBuilder.h b/Userland/Libraries/LibTLS/TLSPacketBuilder.h index fa43b2a40a..6c864a3700 100644 --- a/Userland/Libraries/LibTLS/TLSPacketBuilder.h +++ b/Userland/Libraries/LibTLS/TLSPacketBuilder.h @@ -46,11 +46,11 @@ public: inline void append(u16 value) { value = AK::convert_between_host_and_network_endian(value); - append((const u8*)&value, sizeof(value)); + append((u8 const*)&value, sizeof(value)); } inline void append(u8 value) { - append((const u8*)&value, sizeof(value)); + append((u8 const*)&value, sizeof(value)); } inline void append(ReadonlyBytes data) { @@ -67,7 +67,7 @@ public: append(buf, 3); } - inline void append(const u8* data, size_t bytes) + inline void append(u8 const* data, size_t bytes) { if (bytes == 0) return; diff --git a/Userland/Libraries/LibTLS/TLSv12.cpp b/Userland/Libraries/LibTLS/TLSv12.cpp index bd9a2a4280..240cfd9399 100644 --- a/Userland/Libraries/LibTLS/TLSv12.cpp +++ b/Userland/Libraries/LibTLS/TLSv12.cpp @@ -191,7 +191,7 @@ bool Context::verify_chain() const if (!options.validate_certificates) return true; - const Vector<Certificate>* local_chain = nullptr; + Vector<Certificate> const* local_chain = nullptr; if (is_server) { dbgln("Unsupported: Server mode"); TODO(); @@ -236,7 +236,7 @@ bool Context::verify_chain() const } template<typename HMACType> -static void hmac_pseudorandom_function(Bytes output, ReadonlyBytes secret, const u8* label, size_t label_length, ReadonlyBytes seed, ReadonlyBytes seed_b) +static void hmac_pseudorandom_function(Bytes output, ReadonlyBytes secret, u8 const* label, size_t label_length, ReadonlyBytes seed, ReadonlyBytes seed_b) { if (!secret.size()) { dbgln("null secret"); @@ -274,7 +274,7 @@ static void hmac_pseudorandom_function(Bytes output, ReadonlyBytes secret, const } } -void TLSv12::pseudorandom_function(Bytes output, ReadonlyBytes secret, const u8* label, size_t label_length, ReadonlyBytes seed, ReadonlyBytes seed_b) +void TLSv12::pseudorandom_function(Bytes output, ReadonlyBytes secret, u8 const* label, size_t label_length, ReadonlyBytes seed, ReadonlyBytes seed_b) { // Simplification: We only support the HMAC PRF with the hash function SHA-256 or stronger. diff --git a/Userland/Libraries/LibTLS/TLSv12.h b/Userland/Libraries/LibTLS/TLSv12.h index cad8f945ba..d04d4ec830 100644 --- a/Userland/Libraries/LibTLS/TLSv12.h +++ b/Userland/Libraries/LibTLS/TLSv12.h @@ -28,12 +28,12 @@ inline void print_buffer(ReadonlyBytes buffer) dbgln("{:hex-dump}", buffer); } -inline void print_buffer(const ByteBuffer& buffer) +inline void print_buffer(ByteBuffer const& buffer) { print_buffer(buffer.bytes()); } -inline void print_buffer(const u8* buffer, size_t size) +inline void print_buffer(u8 const* buffer, size_t size) { print_buffer(ReadonlyBytes { buffer, size }); } @@ -75,7 +75,7 @@ enum class AlertDescription : u8 { #undef ENUMERATE_ALERT_DESCRIPTION }; -constexpr static const char* alert_name(AlertDescription descriptor) +constexpr static char const* alert_name(AlertDescription descriptor) { #define ENUMERATE_ALERT_DESCRIPTION(name, value) \ case AlertDescription::name: \ @@ -445,7 +445,7 @@ private: void consume(ReadonlyBytes record); - ByteBuffer hmac_message(ReadonlyBytes buf, const Optional<ReadonlyBytes> buf2, size_t mac_length, bool local = false); + ByteBuffer hmac_message(ReadonlyBytes buf, Optional<ReadonlyBytes> const buf2, size_t mac_length, bool local = false); void ensure_hmac(size_t digest_size, bool local); void update_packet(ByteBuffer& packet); @@ -486,7 +486,7 @@ private: ssize_t handle_message(ReadonlyBytes); ssize_t handle_random(ReadonlyBytes); - void pseudorandom_function(Bytes output, ReadonlyBytes secret, const u8* label, size_t label_length, ReadonlyBytes seed, ReadonlyBytes seed_b); + void pseudorandom_function(Bytes output, ReadonlyBytes secret, u8 const* label, size_t label_length, ReadonlyBytes seed, ReadonlyBytes seed_b); ssize_t verify_rsa_server_key_exchange(ReadonlyBytes server_key_info_buffer, ReadonlyBytes signature_buffer); diff --git a/Userland/Libraries/LibTest/CrashTest.cpp b/Userland/Libraries/LibTest/CrashTest.cpp index 419867342a..f77a1de069 100644 --- a/Userland/Libraries/LibTest/CrashTest.cpp +++ b/Userland/Libraries/LibTest/CrashTest.cpp @@ -78,7 +78,7 @@ bool Crash::do_report(Report report) out("\x1B[31mFAIL\x1B[0m: "); report.visit( - [&](const Failure& failure) { + [&](Failure const& failure) { switch (failure) { case Failure::DidNotCrash: out("Did not crash"); @@ -90,7 +90,7 @@ bool Crash::do_report(Report report) VERIFY_NOT_REACHED(); } }, - [&](const int& signal) { + [&](int const& signal) { out("Terminated with signal {}", signal); }); diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h index 7c0cb92d7c..b9ab53af2d 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h @@ -96,7 +96,7 @@ { \ ::Test::JS::g_run_file = hook; \ } \ - static ::Test::JS::IntermediateRunFileResult hook(const String&, JS::Interpreter&, JS::ExecutionContext&); \ + static ::Test::JS::IntermediateRunFileResult hook(String const&, JS::Interpreter&, JS::ExecutionContext&); \ } __testjs_common_run_file {}; \ ::Test::JS::IntermediateRunFileResult __TestJS_run_file::hook(__VA_ARGS__) @@ -164,7 +164,7 @@ enum class RunFileHookResult { }; using IntermediateRunFileResult = AK::Result<JSFileResult, RunFileHookResult>; -extern IntermediateRunFileResult (*g_run_file)(const String&, JS::Interpreter&, JS::ExecutionContext&); +extern IntermediateRunFileResult (*g_run_file)(String const&, JS::Interpreter&, JS::ExecutionContext&); class TestRunner : public ::Test::TestRunner { public: @@ -178,10 +178,10 @@ public: virtual ~TestRunner() = default; protected: - virtual void do_run_single_test(const String& test_path, size_t, size_t) override; + virtual void do_run_single_test(String const& test_path, size_t, size_t) override; virtual Vector<String> get_test_paths() const override; - virtual JSFileResult run_file_test(const String& test_path); - void print_file_result(const JSFileResult& file_result) const; + virtual JSFileResult run_file_test(String const& test_path); + void print_file_result(JSFileResult const& file_result) const; String m_common_path; }; @@ -261,7 +261,7 @@ inline ErrorOr<JsonValue> get_test_results(JS::Interpreter& interpreter) return JsonValue::from_string(json_string); } -inline void TestRunner::do_run_single_test(const String& test_path, size_t, size_t) +inline void TestRunner::do_run_single_test(String const& test_path, size_t, size_t) { auto file_result = run_file_test(test_path); if (!m_print_json) @@ -274,7 +274,7 @@ inline void TestRunner::do_run_single_test(const String& test_path, size_t, size inline Vector<String> TestRunner::get_test_paths() const { Vector<String> paths; - iterate_directory_recursively(m_test_root, [&](const String& file_path) { + iterate_directory_recursively(m_test_root, [&](String const& file_path) { if (!file_path.ends_with(".js")) return; if (!file_path.ends_with("test-common.js")) @@ -284,7 +284,7 @@ inline Vector<String> TestRunner::get_test_paths() const return paths; } -inline JSFileResult TestRunner::run_file_test(const String& test_path) +inline JSFileResult TestRunner::run_file_test(String const& test_path) { g_currently_running_test = test_path; @@ -404,7 +404,7 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path) file_result.logged_messages.append(message.to_string_without_side_effects()); } - test_json.value().as_object().for_each_member([&](const String& suite_name, const JsonValue& suite_value) { + test_json.value().as_object().for_each_member([&](String const& suite_name, JsonValue const& suite_value) { Test::Suite suite { test_path, suite_name }; VERIFY(suite_value.is_object()); @@ -461,7 +461,7 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path) return file_result; } -inline void TestRunner::print_file_result(const JSFileResult& file_result) const +inline void TestRunner::print_file_result(JSFileResult const& file_result) const { if (file_result.most_severe_test_result == Test::Result::Fail || file_result.error.has_value()) { print_modifiers({ BG_RED, FG_BLACK, FG_BOLD }); diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index 7b5bc0df75..a4a6e41bd2 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -25,7 +25,7 @@ HashMap<String, FunctionWithLength> s_exposed_global_functions; Function<void()> g_main_hook; Function<NonnullOwnPtr<JS::Interpreter>()> g_create_interpreter_hook; HashMap<bool*, Tuple<String, String, char>> g_extra_args; -IntermediateRunFileResult (*g_run_file)(const String&, JS::Interpreter&, JS::ExecutionContext&) = nullptr; +IntermediateRunFileResult (*g_run_file)(String const&, JS::Interpreter&, JS::ExecutionContext&) = nullptr; String g_test_root; int g_test_argc; char** g_test_argv; @@ -88,7 +88,7 @@ int main(int argc, char** argv) #endif bool print_json = false; bool per_file = false; - const char* specified_test_root = nullptr; + char const* specified_test_root = nullptr; String common_path; String test_glob; diff --git a/Userland/Libraries/LibTest/Macros.h b/Userland/Libraries/LibTest/Macros.h index 6f32e0ae13..7fd1912c3e 100644 --- a/Userland/Libraries/LibTest/Macros.h +++ b/Userland/Libraries/LibTest/Macros.h @@ -14,7 +14,7 @@ namespace AK { template<typename... Parameters> -void warnln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&...); +void warnln(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&...); } namespace Test { diff --git a/Userland/Libraries/LibTest/TestCase.h b/Userland/Libraries/LibTest/TestCase.h index 866bba5d2e..18efcccf90 100644 --- a/Userland/Libraries/LibTest/TestCase.h +++ b/Userland/Libraries/LibTest/TestCase.h @@ -20,7 +20,7 @@ using TestFunction = Function<void()>; class TestCase : public RefCounted<TestCase> { public: - TestCase(const String& name, TestFunction&& fn, bool is_benchmark) + TestCase(String const& name, TestFunction&& fn, bool is_benchmark) : m_name(name) , m_function(move(fn)) , m_is_benchmark(is_benchmark) @@ -28,8 +28,8 @@ public: } bool is_benchmark() const { return m_is_benchmark; } - const String& name() const { return m_name; } - const TestFunction& func() const { return m_function; } + String const& name() const { return m_name; } + TestFunction const& func() const { return m_function; } private: String m_name; @@ -38,7 +38,7 @@ private: }; // Helper to hide implementation of TestSuite from users -void add_test_case_to_suite(const NonnullRefPtr<TestCase>& test_case); +void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case); void set_suite_setup_function(Function<void()> setup); } diff --git a/Userland/Libraries/LibTest/TestRunner.h b/Userland/Libraries/LibTest/TestRunner.h index 4e8bad2a40..bde37c12bf 100644 --- a/Userland/Libraries/LibTest/TestRunner.h +++ b/Userland/Libraries/LibTest/TestRunner.h @@ -44,7 +44,7 @@ public: virtual void run(String test_glob); - const Test::Counts& counts() const { return m_counts; } + Test::Counts const& counts() const { return m_counts; } bool is_printing_progress() const { return m_print_progress; } @@ -65,8 +65,8 @@ protected: void print_test_results_as_json() const; virtual Vector<String> get_test_paths() const = 0; - virtual void do_run_single_test(const String&, size_t current_test_index, size_t num_tests) = 0; - virtual const Vector<String>* get_failed_test_names() const { return nullptr; } + virtual void do_run_single_test(String const&, size_t current_test_index, size_t num_tests) = 0; + virtual Vector<String> const* get_failed_test_names() const { return nullptr; } String m_test_root; bool m_print_times; @@ -101,7 +101,7 @@ inline double get_time_in_ms() } template<typename Callback> -inline void iterate_directory_recursively(const String& directory_path, Callback callback) +inline void iterate_directory_recursively(String const& directory_path, Callback callback) { Core::DirIterator directory_iterator(directory_path, Core::DirIterator::Flags::SkipDots); diff --git a/Userland/Libraries/LibTest/TestSuite.cpp b/Userland/Libraries/LibTest/TestSuite.cpp index e6923040ea..1eca37492d 100644 --- a/Userland/Libraries/LibTest/TestSuite.cpp +++ b/Userland/Libraries/LibTest/TestSuite.cpp @@ -45,7 +45,7 @@ void current_test_case_did_fail() } // Declared in TestCase.h -void add_test_case_to_suite(const NonnullRefPtr<TestCase>& test_case) +void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case) { TestSuite::the().add_case(test_case); } @@ -56,7 +56,7 @@ void set_suite_setup_function(Function<void()> setup) TestSuite::the().set_suite_setup(move(setup)); } -int TestSuite::main(const String& suite_name, int argc, char** argv) +int TestSuite::main(String const& suite_name, int argc, char** argv) { m_suite_name = suite_name; @@ -65,7 +65,7 @@ int TestSuite::main(const String& suite_name, int argc, char** argv) bool do_tests_only = getenv("TESTS_ONLY") != nullptr; bool do_benchmarks_only = false; bool do_list_cases = false; - const char* search_string = "*"; + char const* search_string = "*"; args_parser.add_option(do_tests_only, "Only run tests.", "tests", 0); args_parser.add_option(do_benchmarks_only, "Only run benchmarks.", "bench", 0); @@ -76,11 +76,11 @@ int TestSuite::main(const String& suite_name, int argc, char** argv) if (m_setup) m_setup(); - const auto& matching_tests = find_cases(search_string, !do_benchmarks_only, !do_tests_only); + auto const& matching_tests = find_cases(search_string, !do_benchmarks_only, !do_tests_only); if (do_list_cases) { outln("Available cases for {}:", suite_name); - for (const auto& test : matching_tests) { + for (auto const& test : matching_tests) { outln(" {}", test.name()); } return 0; @@ -91,10 +91,10 @@ int TestSuite::main(const String& suite_name, int argc, char** argv) return run(matching_tests); } -NonnullRefPtrVector<TestCase> TestSuite::find_cases(const String& search, bool find_tests, bool find_benchmarks) +NonnullRefPtrVector<TestCase> TestSuite::find_cases(String const& search, bool find_tests, bool find_benchmarks) { NonnullRefPtrVector<TestCase> matches; - for (const auto& t : m_cases) { + for (auto const& t : m_cases) { if (!search.is_empty() && !t.name().matches(search, CaseSensitivity::CaseInsensitive)) { continue; } @@ -111,22 +111,22 @@ NonnullRefPtrVector<TestCase> TestSuite::find_cases(const String& search, bool f return matches; } -int TestSuite::run(const NonnullRefPtrVector<TestCase>& tests) +int TestSuite::run(NonnullRefPtrVector<TestCase> const& tests) { size_t test_count = 0; size_t test_failed_count = 0; size_t benchmark_count = 0; TestElapsedTimer global_timer; - for (const auto& t : tests) { - const auto test_type = t.is_benchmark() ? "benchmark" : "test"; + for (auto const& t : tests) { + auto const test_type = t.is_benchmark() ? "benchmark" : "test"; warnln("Running {} '{}'.", test_type, t.name()); m_current_test_case_passed = true; TestElapsedTimer timer; t.func()(); - const auto time = timer.elapsed_milliseconds(); + auto const time = timer.elapsed_milliseconds(); dbgln("{} {} '{}' in {}ms", m_current_test_case_passed ? "Completed" : "Failed", test_type, t.name(), time); diff --git a/Userland/Libraries/LibTest/TestSuite.h b/Userland/Libraries/LibTest/TestSuite.h index 4cc1142514..4863329b63 100644 --- a/Userland/Libraries/LibTest/TestSuite.h +++ b/Userland/Libraries/LibTest/TestSuite.h @@ -33,10 +33,10 @@ public: s_global = nullptr; } - int run(const NonnullRefPtrVector<TestCase>&); - int main(const String& suite_name, int argc, char** argv); - NonnullRefPtrVector<TestCase> find_cases(const String& search, bool find_tests, bool find_benchmarks); - void add_case(const NonnullRefPtr<TestCase>& test_case) + int run(NonnullRefPtrVector<TestCase> const&); + int main(String const& suite_name, int argc, char** argv); + NonnullRefPtrVector<TestCase> find_cases(String const& search, bool find_tests, bool find_benchmarks); + void add_case(NonnullRefPtr<TestCase> const& test_case) { m_cases.append(test_case); } diff --git a/Userland/Libraries/LibTextCodec/Decoder.cpp b/Userland/Libraries/LibTextCodec/Decoder.cpp index 57695ec847..e312107f9e 100644 --- a/Userland/Libraries/LibTextCodec/Decoder.cpp +++ b/Userland/Libraries/LibTextCodec/Decoder.cpp @@ -26,7 +26,7 @@ TurkishDecoder s_turkish_decoder; XUserDefinedDecoder s_x_user_defined_decoder; } -Decoder* decoder_for(const String& a_encoding) +Decoder* decoder_for(String const& a_encoding) { auto encoding = get_standardized_encoding(a_encoding); if (encoding.has_value()) { diff --git a/Userland/Libraries/LibUSBDB/Database.cpp b/Userland/Libraries/LibUSBDB/Database.cpp index 140ca5bb65..2be7c04ad2 100644 --- a/Userland/Libraries/LibUSBDB/Database.cpp +++ b/Userland/Libraries/LibUSBDB/Database.cpp @@ -12,7 +12,7 @@ namespace USBDB { -RefPtr<Database> Database::open(const String& filename) +RefPtr<Database> Database::open(String const& filename) { auto file_or_error = Core::MappedFile::map(filename); if (file_or_error.is_error()) @@ -25,7 +25,7 @@ RefPtr<Database> Database::open(const String& filename) const StringView Database::get_vendor(u16 vendor_id) const { - const auto& vendor = m_vendors.get(vendor_id); + auto const& vendor = m_vendors.get(vendor_id); if (!vendor.has_value()) return ""; return vendor.value()->name; @@ -33,11 +33,11 @@ const StringView Database::get_vendor(u16 vendor_id) const const StringView Database::get_device(u16 vendor_id, u16 device_id) const { - const auto& vendor = m_vendors.get(vendor_id); + auto const& vendor = m_vendors.get(vendor_id); if (!vendor.has_value()) { return ""; } - const auto& device = vendor.value()->devices.get(device_id); + auto const& device = vendor.value()->devices.get(device_id); if (!device.has_value()) return ""; return device.value()->name; @@ -45,13 +45,13 @@ const StringView Database::get_device(u16 vendor_id, u16 device_id) const const StringView Database::get_interface(u16 vendor_id, u16 device_id, u16 interface_id) const { - const auto& vendor = m_vendors.get(vendor_id); + auto const& vendor = m_vendors.get(vendor_id); if (!vendor.has_value()) return ""; - const auto& device = vendor.value()->devices.get(device_id); + auto const& device = vendor.value()->devices.get(device_id); if (!device.has_value()) return ""; - const auto& interface = device.value()->interfaces.get(interface_id); + auto const& interface = device.value()->interfaces.get(interface_id); if (!interface.has_value()) return ""; return interface.value()->name; @@ -59,7 +59,7 @@ const StringView Database::get_interface(u16 vendor_id, u16 device_id, u16 inter const StringView Database::get_class(u8 class_id) const { - const auto& xclass = m_classes.get(class_id); + auto const& xclass = m_classes.get(class_id); if (!xclass.has_value()) return ""; return xclass.value()->name; @@ -67,10 +67,10 @@ const StringView Database::get_class(u8 class_id) const const StringView Database::get_subclass(u8 class_id, u8 subclass_id) const { - const auto& xclass = m_classes.get(class_id); + auto const& xclass = m_classes.get(class_id); if (!xclass.has_value()) return ""; - const auto& subclass = xclass.value()->subclasses.get(subclass_id); + auto const& subclass = xclass.value()->subclasses.get(subclass_id); if (!subclass.has_value()) return ""; return subclass.value()->name; @@ -78,13 +78,13 @@ const StringView Database::get_subclass(u8 class_id, u8 subclass_id) const const StringView Database::get_protocol(u8 class_id, u8 subclass_id, u8 protocol_id) const { - const auto& xclass = m_classes.get(class_id); + auto const& xclass = m_classes.get(class_id); if (!xclass.has_value()) return ""; - const auto& subclass = xclass.value()->subclasses.get(subclass_id); + auto const& subclass = xclass.value()->subclasses.get(subclass_id); if (!subclass.has_value()) return ""; - const auto& protocol = subclass.value()->protocols.get(protocol_id); + auto const& protocol = subclass.value()->protocols.get(protocol_id); if (!protocol.has_value()) return ""; return protocol.value()->name; diff --git a/Userland/Libraries/LibUSBDB/Database.h b/Userland/Libraries/LibUSBDB/Database.h index 207fedcc1e..d9f77e284c 100644 --- a/Userland/Libraries/LibUSBDB/Database.h +++ b/Userland/Libraries/LibUSBDB/Database.h @@ -52,7 +52,7 @@ struct Class { class Database : public RefCounted<Database> { public: - static RefPtr<Database> open(const String& filename); + static RefPtr<Database> open(String const& filename); static RefPtr<Database> open() { return open("/res/usb.ids"); }; const StringView get_vendor(u16 vendor_id) const; diff --git a/Userland/Libraries/LibVT/Attribute.h b/Userland/Libraries/LibVT/Attribute.h index 9b6a9ea897..a9c60ee80d 100644 --- a/Userland/Libraries/LibVT/Attribute.h +++ b/Userland/Libraries/LibVT/Attribute.h @@ -59,11 +59,11 @@ struct Attribute { Flags flags { Flags::NoAttributes }; - constexpr bool operator==(const Attribute& other) const + constexpr bool operator==(Attribute const& other) const { return foreground_color == other.foreground_color && background_color == other.background_color && flags == other.flags; } - constexpr bool operator!=(const Attribute& other) const + constexpr bool operator!=(Attribute const& other) const { return !(*this == other); } diff --git a/Userland/Libraries/LibVT/Color.h b/Userland/Libraries/LibVT/Color.h index 5e8a6b4b94..0144f55ea7 100644 --- a/Userland/Libraries/LibVT/Color.h +++ b/Userland/Libraries/LibVT/Color.h @@ -95,7 +95,7 @@ public: } } - constexpr bool operator==(const Color& other) const + constexpr bool operator==(Color const& other) const { if (m_kind != other.kind()) return false; diff --git a/Userland/Libraries/LibVT/EscapeSequenceParser.h b/Userland/Libraries/LibVT/EscapeSequenceParser.h index 5f4b5ad87d..6fec1ce6a9 100644 --- a/Userland/Libraries/LibVT/EscapeSequenceParser.h +++ b/Userland/Libraries/LibVT/EscapeSequenceParser.h @@ -19,7 +19,7 @@ class EscapeSequenceExecutor { public: virtual ~EscapeSequenceExecutor() = default; - using Parameters = Span<const unsigned>; + using Parameters = Span<unsigned const>; using Intermediates = Span<const u8>; using OscParameter = Span<const u8>; using OscParameters = Span<const OscParameter>; diff --git a/Userland/Libraries/LibVT/Line.cpp b/Userland/Libraries/LibVT/Line.cpp index bf348d4371..6c09c0056b 100644 --- a/Userland/Libraries/LibVT/Line.cpp +++ b/Userland/Libraries/LibVT/Line.cpp @@ -117,7 +117,7 @@ void Line::take_cells_from_next_line(size_t new_length, Line* next_line, bool cu next_line->m_cells.clear(); } -void Line::clear_range(size_t first_column, size_t last_column, const Attribute& attribute) +void Line::clear_range(size_t first_column, size_t last_column, Attribute const& attribute) { VERIFY(first_column <= last_column); VERIFY(last_column < m_cells.size()); diff --git a/Userland/Libraries/LibVT/Line.h b/Userland/Libraries/LibVT/Line.h index 09f9989868..fd920b593c 100644 --- a/Userland/Libraries/LibVT/Line.h +++ b/Userland/Libraries/LibVT/Line.h @@ -31,18 +31,18 @@ public: bool operator!=(Cell const& other) const { return code_point != other.code_point || attribute != other.attribute; } }; - const Attribute& attribute_at(size_t index) const { return m_cells[index].attribute; } + Attribute const& attribute_at(size_t index) const { return m_cells[index].attribute; } Attribute& attribute_at(size_t index) { return m_cells[index].attribute; } Cell& cell_at(size_t index) { return m_cells[index]; } - const Cell& cell_at(size_t index) const { return m_cells[index]; } + Cell const& cell_at(size_t index) const { return m_cells[index]; } - void clear(const Attribute& attribute = Attribute()) + void clear(Attribute const& attribute = Attribute()) { m_terminated_at.clear(); clear_range(0, m_cells.size() - 1, attribute); } - void clear_range(size_t first_column, size_t last_column, const Attribute& attribute = Attribute()); + void clear_range(size_t first_column, size_t last_column, Attribute const& attribute = Attribute()); bool has_only_one_background_color() const; bool is_empty() const diff --git a/Userland/Libraries/LibVT/Position.h b/Userland/Libraries/LibVT/Position.h index c880a4c005..b24e6e6a8f 100644 --- a/Userland/Libraries/LibVT/Position.h +++ b/Userland/Libraries/LibVT/Position.h @@ -23,27 +23,27 @@ public: int row() const { return m_row; } int column() const { return m_column; } - bool operator<(const Position& other) const + bool operator<(Position const& other) const { return m_row < other.m_row || (m_row == other.m_row && m_column < other.m_column); } - bool operator<=(const Position& other) const + bool operator<=(Position const& other) const { return *this < other || *this == other; } - bool operator>=(const Position& other) const + bool operator>=(Position const& other) const { return !(*this < other); } - bool operator==(const Position& other) const + bool operator==(Position const& other) const { return m_row == other.m_row && m_column == other.m_column; } - bool operator!=(const Position& other) const + bool operator!=(Position const& other) const { return !(*this == other); } diff --git a/Userland/Libraries/LibVT/Range.h b/Userland/Libraries/LibVT/Range.h index db3cb9015c..bc7566d923 100644 --- a/Userland/Libraries/LibVT/Range.h +++ b/Userland/Libraries/LibVT/Range.h @@ -48,7 +48,7 @@ public: m_end = Position(m_end.row() + delta, m_end.column()); } - bool operator==(const Range& other) const + bool operator==(Range const& other) const { return m_start == other.m_start && m_end == other.m_end; } diff --git a/Userland/Libraries/LibVT/Terminal.cpp b/Userland/Libraries/LibVT/Terminal.cpp index 7e669a5f40..5eaacb682e 100644 --- a/Userland/Libraries/LibVT/Terminal.cpp +++ b/Userland/Libraries/LibVT/Terminal.cpp @@ -1347,7 +1347,7 @@ void Terminal::inject_string(StringView str) void Terminal::emit_string(StringView string) { - m_client.emit((const u8*)string.characters_without_null_termination(), string.length()); + m_client.emit((u8 const*)string.characters_without_null_termination(), string.length()); } void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags) @@ -1657,7 +1657,7 @@ void Terminal::invalidate_cursor() active_buffer()[cursor_row()].set_dirty(true); } -Attribute Terminal::attribute_at(const Position& position) const +Attribute Terminal::attribute_at(Position const& position) const { if (!position.is_valid()) return {}; diff --git a/Userland/Libraries/LibVT/Terminal.h b/Userland/Libraries/LibVT/Terminal.h index 6e8828f717..b3760b0106 100644 --- a/Userland/Libraries/LibVT/Terminal.h +++ b/Userland/Libraries/LibVT/Terminal.h @@ -53,7 +53,7 @@ public: virtual void set_window_progress(int value, int max) = 0; virtual void terminal_did_resize(u16 columns, u16 rows) = 0; virtual void terminal_history_changed(int delta) = 0; - virtual void emit(const u8*, size_t) = 0; + virtual void emit(u8 const*, size_t) = 0; virtual void set_cursor_style(CursorStyle) = 0; }; @@ -129,7 +129,7 @@ public: return m_normal_screen_buffer[index - m_history.size()]; } } - const Line& line(size_t index) const + Line const& line(size_t index) const { return const_cast<Terminal*>(this)->line(index); } @@ -139,7 +139,7 @@ public: return active_buffer()[index]; } - const Line& visible_line(size_t index) const + Line const& visible_line(size_t index) const { return active_buffer()[index]; } @@ -177,7 +177,7 @@ public: void handle_key_press(KeyCode, u32, u8 flags); #ifndef KERNEL - Attribute attribute_at(const Position&) const; + Attribute attribute_at(Position const&) const; #endif bool needs_bracketed_paste() const @@ -404,7 +404,7 @@ protected: } NonnullOwnPtrVector<Line>& active_buffer() { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; }; - const NonnullOwnPtrVector<Line>& active_buffer() const { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; }; + NonnullOwnPtrVector<Line> const& active_buffer() const { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; }; NonnullOwnPtrVector<Line> m_normal_screen_buffer; NonnullOwnPtrVector<Line> m_alternate_screen_buffer; #endif diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index 5c9b70121c..c1d0d59344 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -492,7 +492,7 @@ void TerminalWidget::resize_event(GUI::ResizeEvent& event) relayout(event.size()); } -void TerminalWidget::relayout(const Gfx::IntSize& size) +void TerminalWidget::relayout(Gfx::IntSize const& size) { if (!m_scrollbar) return; @@ -580,7 +580,7 @@ bool TerminalWidget::selection_contains(const VT::Position& position) const return position >= normalized_selection.start() && position <= normalized_selection.end(); } -VT::Position TerminalWidget::buffer_position_at(const Gfx::IntPoint& position) const +VT::Position TerminalWidget::buffer_position_at(Gfx::IntPoint const& position) const { auto adjusted_position = position.translated(-(frame_thickness() + m_inset), -(frame_thickness() + m_inset)); int row = adjusted_position.y() / m_line_height; @@ -1030,7 +1030,7 @@ void TerminalWidget::beep() update(); } -void TerminalWidget::emit(const u8* data, size_t size) +void TerminalWidget::emit(u8 const* data, size_t size) { if (write(m_ptm_fd, data, size) < 0) { perror("TerminalWidget::emit: write"); @@ -1229,7 +1229,7 @@ void TerminalWidget::set_color_scheme(StringView name) update(); } -Gfx::IntSize TerminalWidget::widget_size_for_font(const Gfx::Font& font) const +Gfx::IntSize TerminalWidget::widget_size_for_font(Gfx::Font const& font) const { return { (frame_thickness() * 2) + (m_inset * 2) + (m_terminal.columns() * font.glyph_width('x')) + m_scrollbar->width(), @@ -1260,7 +1260,7 @@ constexpr Gfx::Color TerminalWidget::terminal_color_to_rgb(VT::Color color) cons } }; -void TerminalWidget::set_font_and_resize_to_fit(const Gfx::Font& font) +void TerminalWidget::set_font_and_resize_to_fit(Gfx::Font const& font) { set_font(font); resize(widget_size_for_font(font)); diff --git a/Userland/Libraries/LibVT/TerminalWidget.h b/Userland/Libraries/LibVT/TerminalWidget.h index aeadd8b00c..99f3a85226 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.h +++ b/Userland/Libraries/LibVT/TerminalWidget.h @@ -60,7 +60,7 @@ public: String selected_text() const; VT::Range normalized_selection() const { return m_selection.normalized(); } void set_selection(const VT::Range& selection); - VT::Position buffer_position_at(const Gfx::IntPoint&) const; + VT::Position buffer_position_at(Gfx::IntPoint const&) const; VT::Range find_next(StringView, const VT::Position& start = {}, bool case_sensitivity = false, bool should_wrap = false); VT::Range find_previous(StringView, const VT::Position& start = {}, bool case_sensitivity = false, bool should_wrap = false); @@ -85,14 +85,14 @@ public: const StringView color_scheme_name() const { return m_color_scheme_name; } Function<void(StringView)> on_title_change; - Function<void(const Gfx::IntSize&)> on_terminal_size_change; + Function<void(Gfx::IntSize const&)> on_terminal_size_change; Function<void()> on_command_exit; GUI::Menu& context_menu() { return *m_context_menu; } constexpr Gfx::Color terminal_color_to_rgb(VT::Color) const; - void set_font_and_resize_to_fit(const Gfx::Font&); + void set_font_and_resize_to_fit(Gfx::Font const&); void set_color_scheme(StringView); @@ -123,11 +123,11 @@ private: virtual void set_window_progress(int value, int max) override; virtual void terminal_did_resize(u16 columns, u16 rows) override; virtual void terminal_history_changed(int delta) override; - virtual void emit(const u8*, size_t) override; + virtual void emit(u8 const*, size_t) override; virtual void set_cursor_style(CursorStyle) override; // ^GUI::Clipboard::ClipboardClient - virtual void clipboard_content_did_change(const String&) override { update_paste_action(); } + virtual void clipboard_content_did_change(String const&) override { update_paste_action(); } void set_logical_focus(bool); @@ -136,12 +136,12 @@ private: Gfx::IntRect glyph_rect(u16 row, u16 column); Gfx::IntRect row_rect(u16 row); - Gfx::IntSize widget_size_for_font(const Gfx::Font&) const; + Gfx::IntSize widget_size_for_font(Gfx::Font const&) const; void update_cursor(); void invalidate_cursor(); - void relayout(const Gfx::IntSize&); + void relayout(Gfx::IntSize const&); void update_copy_action(); void update_paste_action(); diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.cpp b/Userland/Libraries/LibVideo/VP9/Decoder.cpp index 725d9ac29b..9d9e739dc9 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.cpp +++ b/Userland/Libraries/LibVideo/VP9/Decoder.cpp @@ -39,7 +39,7 @@ u8 Decoder::merge_prob(u8 pre_prob, u8 count_0, u8 count_1, u8 count_sat, u8 max return round_2(pre_prob * (256 - factor) + (prob * factor), 8); } -u8 Decoder::merge_probs(const int* tree, int index, u8* probs, u8* counts, u8 count_sat, u8 max_update_factor) +u8 Decoder::merge_probs(int const* tree, int index, u8* probs, u8* counts, u8 count_sat, u8 max_update_factor) { auto s = tree[index]; auto left_count = (s <= 0) ? counts[-s] : merge_probs(tree, s, probs, counts, count_sat, max_update_factor); diff --git a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp index bd702c251c..1a218044d4 100644 --- a/Userland/Libraries/LibVideo/VP9/TreeParser.cpp +++ b/Userland/Libraries/LibVideo/VP9/TreeParser.cpp @@ -560,8 +560,8 @@ u8 TreeParser::calculate_tx_size_probability(u8 node) u8 TreeParser::calculate_inter_mode_probability(u8 node) { - //FIXME: Implement when ModeContext is implemented - // m_ctx = m_decoder.m_mode_context[m_decoder.m_ref_frame[0]] + // FIXME: Implement when ModeContext is implemented + // m_ctx = m_decoder.m_mode_context[m_decoder.m_ref_frame[0]] return m_decoder.m_probability_tables->inter_mode_probs()[m_ctx][node]; } diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp index f3dee8492d..0bb260ee5b 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Configuration.cpp @@ -84,8 +84,7 @@ Result Configuration::execute(Interpreter& interpreter) void Configuration::dump_stack() { - auto print_value = []<typename... Ts>(CheckedFormatString<Ts...> format, Ts... vs) - { + auto print_value = []<typename... Ts>(CheckedFormatString<Ts...> format, Ts... vs) { DuplexMemoryStream memory_stream; Printer { memory_stream }.print(vs...); ByteBuffer buffer = memory_stream.copy_into_contiguous_buffer(); diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp index c5ba30fcb7..18e8eb95c1 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp @@ -2155,7 +2155,7 @@ VALIDATE_INSTRUCTION(call_indirect) return {}; } -ErrorOr<void, ValidationError> Validator::validate(const Instruction& instruction, Stack& stack, bool& is_constant) +ErrorOr<void, ValidationError> Validator::validate(Instruction const& instruction, Stack& stack, bool& is_constant) { switch (instruction.opcode().value()) { #define M(name, integer_value) \ @@ -2194,7 +2194,7 @@ ErrorOr<Validator::ExpressionTypeResult, ValidationError> Validator::validate(Ex return ExpressionTypeResult { stack.release_vector(), is_constant_expression }; } -bool Validator::Stack::operator==(const Stack& other) const +bool Validator::Stack::operator==(Stack const& other) const { if (!m_did_insert_unknown_entry && !other.m_did_insert_unknown_entry) return static_cast<Vector<StackEntry> const&>(*this) == static_cast<Vector<StackEntry> const&>(other); diff --git a/Userland/Libraries/LibWasm/Printer/Printer.cpp b/Userland/Libraries/LibWasm/Printer/Printer.cpp index ed310f3629..7650720047 100644 --- a/Userland/Libraries/LibWasm/Printer/Printer.cpp +++ b/Userland/Libraries/LibWasm/Printer/Printer.cpp @@ -416,14 +416,15 @@ void Printer::print(Wasm::ImportSection::Import const& import) { TemporaryChange change { m_indent, m_indent + 1 }; import.description().visit( - [this](auto const& type) { print(type); }, + [this](auto const& type) { print(type); + }, [this](TypeIndex const& index) { - print_indent(); - print("(type index {})\n", index.value()); + print_indent(); + print("(type index {})\n", index.value()); }); - } - print_indent(); - print(")\n"); +} +print_indent(); +print(")\n"); } void Printer::print(Wasm::Instruction const& instruction) @@ -671,7 +672,6 @@ void Printer::print(Wasm::Reference const& value) [](Wasm::Reference::Null const&) { return String("null"); }, [](auto const& ref) { return String::number(ref.address.value()); })); } - } HashMap<Wasm::OpCode, String> Wasm::Names::instruction_names { diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.h b/Userland/Libraries/LibWeb/Bindings/WindowObject.h index 7b579f2805..04a662b5b0 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.h @@ -42,11 +42,11 @@ public: LocationObject* location_object() { return m_location_object; } LocationObject const* location_object() const { return m_location_object; } - JS::Object* web_prototype(const String& class_name) { return m_prototypes.get(class_name).value_or(nullptr); } - JS::NativeFunction* web_constructor(const String& class_name) { return m_constructors.get(class_name).value_or(nullptr); } + JS::Object* web_prototype(String const& class_name) { return m_prototypes.get(class_name).value_or(nullptr); } + JS::NativeFunction* web_constructor(String const& class_name) { return m_constructors.get(class_name).value_or(nullptr); } template<typename T> - JS::Object& ensure_web_prototype(const String& class_name) + JS::Object& ensure_web_prototype(String const& class_name) { auto it = m_prototypes.find(class_name); if (it != m_prototypes.end()) @@ -57,7 +57,7 @@ public: } template<typename T> - JS::NativeFunction& ensure_web_constructor(const String& class_name) + JS::NativeFunction& ensure_web_constructor(String const& class_name) { auto it = m_constructors.find(class_name); if (it != m_constructors.end()) diff --git a/Userland/Libraries/LibWeb/Bindings/Wrappable.h b/Userland/Libraries/LibWeb/Bindings/Wrappable.h index 36a581f399..26d2fbcc1d 100644 --- a/Userland/Libraries/LibWeb/Bindings/Wrappable.h +++ b/Userland/Libraries/LibWeb/Bindings/Wrappable.h @@ -19,7 +19,7 @@ public: void set_wrapper(Wrapper&); Wrapper* wrapper() { return m_wrapper; } - const Wrapper* wrapper() const { return m_wrapper; } + Wrapper const* wrapper() const { return m_wrapper; } private: WeakPtr<Wrapper> m_wrapper; diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index 37c219005e..667887d697 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -32,8 +32,8 @@ public: bool has_import_result() const { return !m_style_sheet.is_null(); } RefPtr<CSSStyleSheet> loaded_style_sheet() { return m_style_sheet; } - const RefPtr<CSSStyleSheet> loaded_style_sheet() const { return m_style_sheet; } - void set_style_sheet(const RefPtr<CSSStyleSheet>& style_sheet) { m_style_sheet = style_sheet; } + RefPtr<CSSStyleSheet> const loaded_style_sheet() const { return m_style_sheet; } + void set_style_sheet(RefPtr<CSSStyleSheet> const& style_sheet) { m_style_sheet = style_sheet; } virtual StringView class_name() const override { return "CSSImportRule"; }; virtual Type type() const override { return Type::Import; }; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index fcf5ff116a..31897d477d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -69,9 +69,9 @@ public: virtual Optional<StyleProperty> property(PropertyID) const override; virtual bool set_property(PropertyID, StringView css_text) override; - const Vector<StyleProperty>& properties() const { return m_properties; } - const HashMap<String, StyleProperty>& custom_properties() const { return m_custom_properties; } - Optional<StyleProperty> custom_property(const String& custom_property_name) const { return m_custom_properties.get(custom_property_name); } + Vector<StyleProperty> const& properties() const { return m_properties; } + HashMap<String, StyleProperty> const& custom_properties() const { return m_custom_properties; } + Optional<StyleProperty> custom_property(String const& custom_property_name) const { return m_custom_properties.get(custom_property_name); } size_t custom_property_count() const { return m_custom_properties.size(); } virtual String serialized() const final override; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index 23f8c1564c..5f61504a57 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -29,8 +29,8 @@ public: virtual ~CSSStyleRule() override = default; - const NonnullRefPtrVector<Selector>& selectors() const { return m_selectors; } - const CSSStyleDeclaration& declaration() const { return m_declaration; } + NonnullRefPtrVector<Selector> const& selectors() const { return m_selectors; } + CSSStyleDeclaration const& declaration() const { return m_declaration; } virtual StringView class_name() const override { return "CSSStyleRule"; }; virtual Type type() const override { return Type::Style; }; diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 88779b1626..3462c152bd 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -152,10 +152,10 @@ public: const CSS::LengthBox& margin() const { return m_noninherited.margin; } const CSS::LengthBox& padding() const { return m_noninherited.padding; } - const BorderData& border_left() const { return m_noninherited.border_left; } - const BorderData& border_top() const { return m_noninherited.border_top; } - const BorderData& border_right() const { return m_noninherited.border_right; } - const BorderData& border_bottom() const { return m_noninherited.border_bottom; } + BorderData const& border_left() const { return m_noninherited.border_left; } + BorderData const& border_top() const { return m_noninherited.border_top; } + BorderData const& border_right() const { return m_noninherited.border_right; } + BorderData const& border_bottom() const { return m_noninherited.border_bottom; } const CSS::LengthPercentage& border_bottom_left_radius() const { return m_noninherited.border_bottom_left_radius; } const CSS::LengthPercentage& border_bottom_right_radius() const { return m_noninherited.border_bottom_right_radius; } @@ -267,12 +267,12 @@ public: void set_font_size(float font_size) { m_inherited.font_size = font_size; } void set_font_weight(int font_weight) { m_inherited.font_weight = font_weight; } void set_font_variant(CSS::FontVariant font_variant) { m_inherited.font_variant = font_variant; } - void set_color(const Color& color) { m_inherited.color = color; } + void set_color(Color const& color) { m_inherited.color = color; } void set_content(ContentData const& content) { m_noninherited.content = content; } void set_cursor(CSS::Cursor cursor) { m_inherited.cursor = cursor; } void set_image_rendering(CSS::ImageRendering value) { m_inherited.image_rendering = value; } void set_pointer_events(CSS::PointerEvents value) { m_inherited.pointer_events = value; } - void set_background_color(const Color& color) { m_noninherited.background_color = color; } + void set_background_color(Color const& color) { m_noninherited.background_color = color; } void set_background_layers(Vector<BackgroundLayerData>&& layers) { m_noninherited.background_layers = move(layers); } void set_float(CSS::Float value) { m_noninherited.float_ = value; } void set_clear(CSS::Clear value) { m_noninherited.clear = value; } diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index 237fd4d4d9..724315c55e 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -118,7 +118,7 @@ String Length::to_string() const return String::formatted("{}{}", m_value, unit_name()); } -const char* Length::unit_name() const +char const* Length::unit_name() const { switch (m_type) { case Type::Cm: diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h index 57ae881f76..97663b95fd 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.h +++ b/Userland/Libraries/LibWeb/CSS/Length.h @@ -116,14 +116,14 @@ public: String to_string() const; - bool operator==(const Length& other) const + bool operator==(Length const& other) const { if (is_calculated()) return m_calculated_style == other.m_calculated_style; return m_type == other.m_type && m_value == other.m_value; } - bool operator!=(const Length& other) const + bool operator!=(Length const& other) const { return !(*this == other); } @@ -131,7 +131,7 @@ public: float relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const; private: - const char* unit_name() const; + char const* unit_name() const; Type m_type; float m_value { 0 }; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 5e2a33d63b..0ae1e192b6 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -28,7 +28,7 @@ #include <LibWeb/DOM/Document.h> #include <LibWeb/Dump.h> -static void log_parse_error(const SourceLocation& location = SourceLocation::current()) +static void log_parse_error(SourceLocation const& location = SourceLocation::current()) { dbgln_if(CSS_PARSER_DEBUG, "Parse error (CSS) {}", location); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp index b4d1d3d6ca..45cfb6f077 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.cpp @@ -17,7 +17,7 @@ #define REPLACEMENT_CHARACTER 0xFFFD static constexpr u32 TOKENIZER_EOF = 0xFFFFFFFF; -static inline void log_parse_error(const SourceLocation& location = SourceLocation::current()) +static inline void log_parse_error(SourceLocation const& location = SourceLocation::current()) { dbgln_if(CSS_TOKENIZER_DEBUG, "Parse error (css tokenization) {} ", location); } @@ -192,7 +192,7 @@ static inline bool is_E(u32 code_point) namespace Web::CSS { -Tokenizer::Tokenizer(StringView input, const String& encoding) +Tokenizer::Tokenizer(StringView input, String const& encoding) { auto* decoder = TextCodec::decoder_for(encoding); VERIFY(decoder); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h index 6521e74eb2..39eb09d923 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Tokenizer.h @@ -60,7 +60,7 @@ public: class Tokenizer { public: - explicit Tokenizer(StringView input, const String& encoding); + explicit Tokenizer(StringView input, String const& encoding); [[nodiscard]] Vector<Token> parse(); diff --git a/Userland/Libraries/LibWeb/CSS/Ratio.cpp b/Userland/Libraries/LibWeb/CSS/Ratio.cpp index f6285dfa45..b2a46b766a 100644 --- a/Userland/Libraries/LibWeb/CSS/Ratio.cpp +++ b/Userland/Libraries/LibWeb/CSS/Ratio.cpp @@ -27,7 +27,7 @@ String Ratio::to_string() const return String::formatted("{} / {}", m_first_value, m_second_value); } -auto Ratio::operator<=>(const Ratio& other) const +auto Ratio::operator<=>(Ratio const& other) const { return value() - other.value(); } diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index 4bfc3562d3..43794e2f6b 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -114,7 +114,7 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co return !attribute.value.is_empty() && element.attribute(attribute.name).contains(attribute.value, case_sensitivity); case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment: { - const auto element_attr_value = element.attribute(attribute.name); + auto const element_attr_value = element.attribute(attribute.name); if (element_attr_value.is_empty()) { // If the attribute value on element is empty, the selector is true // if the match value is also empty and false otherwise. diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index bf1a4cbb4d..4ae796ec1a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -862,7 +862,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele float font_size_in_px = 10; if (font_size->is_identifier()) { - switch (static_cast<const IdentifierStyleValue&>(*font_size).id()) { + switch (static_cast<IdentifierStyleValue const&>(*font_size).id()) { case CSS::ValueID::XxSmall: case CSS::ValueID::XSmall: case CSS::ValueID::Small: diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index b320bc1dfe..9856396e74 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -15,7 +15,7 @@ namespace Web::CSS { -StyleProperties::StyleProperties(const StyleProperties& other) +StyleProperties::StyleProperties(StyleProperties const& other) : m_property_values(other.m_property_values) { if (other.m_font) { @@ -412,7 +412,7 @@ Optional<CSS::Position> StyleProperties::position() const } } -bool StyleProperties::operator==(const StyleProperties& other) const +bool StyleProperties::operator==(StyleProperties const& other) const { if (m_property_values.size() != other.m_property_values.size()) return false; diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index 82c0f1f932..ef34a95e1b 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -20,7 +20,7 @@ class StyleProperties : public RefCounted<StyleProperties> { public: StyleProperties() = default; - explicit StyleProperties(const StyleProperties&); + explicit StyleProperties(StyleProperties const&); static NonnullRefPtr<StyleProperties> create() { return adopt_ref(*new StyleProperties); } @@ -92,10 +92,10 @@ public: m_font = move(font); } - float line_height(const Layout::Node&) const; + float line_height(Layout::Node const&) const; - bool operator==(const StyleProperties&) const; - bool operator!=(const StyleProperties& other) const { return !(*this == other); } + bool operator==(StyleProperties const&) const; + bool operator!=(StyleProperties const& other) const { return !(*this == other); } Optional<CSS::Position> position() const; Optional<int> z_index() const; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index b90fe67ba0..970c9b74a3 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -941,7 +941,7 @@ public: { if (type() != other.type()) return false; - return m_color == static_cast<const ColorStyleValue&>(other).m_color; + return m_color == static_cast<ColorStyleValue const&>(other).m_color; } private: @@ -1151,7 +1151,7 @@ public: { if (type() != other.type()) return false; - return m_id == static_cast<const IdentifierStyleValue&>(other).m_id; + return m_id == static_cast<IdentifierStyleValue const&>(other).m_id; } private: diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp index 7044d67d6d..fd06e2949b 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp @@ -27,7 +27,7 @@ static void on_secure_attribute(ParsedCookie& parsed_cookie); static void on_http_only_attribute(ParsedCookie& parsed_cookie); static Optional<Core::DateTime> parse_date_time(StringView date_string); -Optional<ParsedCookie> parse_cookie(const String& cookie_string) +Optional<ParsedCookie> parse_cookie(String const& cookie_string) { // https://tools.ietf.org/html/rfc6265#section-5.2 @@ -293,7 +293,7 @@ Optional<Core::DateTime> parse_date_time(StringView date_string) bool found_month = false; bool found_year = false; - for (const auto& date_token : date_tokens) { + for (auto const& date_token : date_tokens) { if (!found_time && parse_time(date_token)) { found_time = true; } else if (!found_day_of_month && parse_day_of_month(date_token)) { @@ -333,7 +333,7 @@ Optional<Core::DateTime> parse_date_time(StringView date_string) } -bool IPC::encode(IPC::Encoder& encoder, const Web::Cookie::ParsedCookie& cookie) +bool IPC::encode(IPC::Encoder& encoder, Web::Cookie::ParsedCookie const& cookie) { encoder << cookie.name; encoder << cookie.value; diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h index 6a8bb72551..2d293c3fa2 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h @@ -24,13 +24,13 @@ struct ParsedCookie { bool http_only_attribute_present { false }; }; -Optional<ParsedCookie> parse_cookie(const String& cookie_string); +Optional<ParsedCookie> parse_cookie(String const& cookie_string); } namespace IPC { -bool encode(IPC::Encoder&, const Web::Cookie::ParsedCookie&); +bool encode(IPC::Encoder&, Web::Cookie::ParsedCookie const&); ErrorOr<void> decode(IPC::Decoder&, Web::Cookie::ParsedCookie&); } diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index 277fec25b5..b6008f9aca 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -62,27 +62,27 @@ String Crypto::random_uuid() const bytes[8] |= 1 << 7; bytes[8] &= ~(1 << 6); - /* 5. Return the string concatenation of - « + /* 5. Return the string concatenation of + « hexadecimal representation of bytes[0], - hexadecimal representation of bytes[1], + hexadecimal representation of bytes[1], hexadecimal representation of bytes[2], hexadecimal representation of bytes[3], - "-", - hexadecimal representation of bytes[4], + "-", + hexadecimal representation of bytes[4], hexadecimal representation of bytes[5], "-", - hexadecimal representation of bytes[6], + hexadecimal representation of bytes[6], hexadecimal representation of bytes[7], "-", - hexadecimal representation of bytes[8], + hexadecimal representation of bytes[8], hexadecimal representation of bytes[9], "-", - hexadecimal representation of bytes[10], - hexadecimal representation of bytes[11], - hexadecimal representation of bytes[12], - hexadecimal representation of bytes[13], - hexadecimal representation of bytes[14], + hexadecimal representation of bytes[10], + hexadecimal representation of bytes[11], + hexadecimal representation of bytes[12], + hexadecimal representation of bytes[13], + hexadecimal representation of bytes[14], hexadecimal representation of bytes[15] ». */ diff --git a/Userland/Libraries/LibWeb/DOM/AbstractRange.h b/Userland/Libraries/LibWeb/DOM/AbstractRange.h index 0547879aa8..0407de68f2 100644 --- a/Userland/Libraries/LibWeb/DOM/AbstractRange.h +++ b/Userland/Libraries/LibWeb/DOM/AbstractRange.h @@ -20,11 +20,11 @@ public: virtual ~AbstractRange() override = default; Node* start_container() { return m_start_container; } - const Node* start_container() const { return m_start_container; } + Node const* start_container() const { return m_start_container; } unsigned start_offset() const { return m_start_offset; } Node* end_container() { return m_end_container; } - const Node* end_container() const { return m_end_container; } + Node const* end_container() const { return m_end_container; } unsigned end_offset() const { return m_end_offset; } // https://dom.spec.whatwg.org/#range-collapsed diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp index dec8901baf..2b17e0955e 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp @@ -10,7 +10,7 @@ namespace Web::DOM { -CharacterData::CharacterData(Document& document, NodeType type, const String& data) +CharacterData::CharacterData(Document& document, NodeType type, String const& data) : Node(document, type) , m_data(data) { diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.h b/Userland/Libraries/LibWeb/DOM/CharacterData.h index 0b38ec92a0..d72d5bdfc4 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.h +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.h @@ -22,7 +22,7 @@ public: virtual ~CharacterData() override = default; - const String& data() const { return m_data; } + String const& data() const { return m_data; } void set_data(String); unsigned length() const { return m_data.length(); } @@ -31,7 +31,7 @@ public: ExceptionOr<void> replace_data(size_t offset, size_t count, String const&); protected: - explicit CharacterData(Document&, NodeType, const String&); + explicit CharacterData(Document&, NodeType, String const&); private: String m_data; diff --git a/Userland/Libraries/LibWeb/DOM/Comment.cpp b/Userland/Libraries/LibWeb/DOM/Comment.cpp index 8b70cf501b..9e79dd5869 100644 --- a/Userland/Libraries/LibWeb/DOM/Comment.cpp +++ b/Userland/Libraries/LibWeb/DOM/Comment.cpp @@ -10,7 +10,7 @@ namespace Web::DOM { -Comment::Comment(Document& document, const String& data) +Comment::Comment(Document& document, String const& data) : CharacterData(document, NodeType::COMMENT_NODE, data) { } diff --git a/Userland/Libraries/LibWeb/DOM/Comment.h b/Userland/Libraries/LibWeb/DOM/Comment.h index 7f34f43a13..9696a31137 100644 --- a/Userland/Libraries/LibWeb/DOM/Comment.h +++ b/Userland/Libraries/LibWeb/DOM/Comment.h @@ -15,7 +15,7 @@ class Comment final : public CharacterData { public: using WrapperType = Bindings::CommentWrapper; - explicit Comment(Document&, const String&); + explicit Comment(Document&, String const&); virtual ~Comment() override = default; virtual FlyString node_name() const override { return "#comment"; } diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.h b/Userland/Libraries/LibWeb/DOM/CustomEvent.h index ed549d87d7..6ecbd83950 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.h +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.h @@ -23,7 +23,7 @@ public: { return adopt_ref(*new CustomEvent(event_name, event_init)); } - static NonnullRefPtr<CustomEvent> create_with_global_object(Bindings::WindowObject&, const FlyString& event_name, CustomEventInit const& event_init) + static NonnullRefPtr<CustomEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, CustomEventInit const& event_init) { return CustomEvent::create(event_name, event_init); } diff --git a/Userland/Libraries/LibWeb/DOM/DOMException.h b/Userland/Libraries/LibWeb/DOM/DOMException.h index 6e555536bf..95475e2829 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMException.h +++ b/Userland/Libraries/LibWeb/DOM/DOMException.h @@ -78,7 +78,7 @@ namespace Web::DOM { __ENUMERATE(OperationError) \ __ENUMERATE(NotAllowedError) -static u16 get_legacy_code_for_name(const FlyString& name) +static u16 get_legacy_code_for_name(FlyString const& name) { #define __ENUMERATE(ErrorName, code) \ if (name == #ErrorName) \ @@ -95,23 +95,23 @@ class DOMException final public: using WrapperType = Bindings::DOMExceptionWrapper; - static NonnullRefPtr<DOMException> create(const FlyString& name, const FlyString& message) + static NonnullRefPtr<DOMException> create(FlyString const& name, FlyString const& message) { return adopt_ref(*new DOMException(name, message)); } // JS constructor has message first, name second - static NonnullRefPtr<DOMException> create_with_global_object(Bindings::WindowObject&, const FlyString& message, const FlyString& name) + static NonnullRefPtr<DOMException> create_with_global_object(Bindings::WindowObject&, FlyString const& message, FlyString const& name) { return adopt_ref(*new DOMException(name, message)); } - const FlyString& name() const { return m_name; } - const FlyString& message() const { return m_message; } + FlyString const& name() const { return m_name; } + FlyString const& message() const { return m_message; } u16 code() const { return get_legacy_code_for_name(m_name); } protected: - DOMException(const FlyString& name, const FlyString& message) + DOMException(FlyString const& name, FlyString const& message) : m_name(name) , m_message(message) { @@ -125,7 +125,7 @@ private: #define __ENUMERATE(ErrorName) \ class ErrorName final { \ public: \ - static NonnullRefPtr<DOMException> create(const FlyString& message) \ + static NonnullRefPtr<DOMException> create(FlyString const& message) \ { \ return DOMException::create(#ErrorName, message); \ } \ diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 08ae8d5de2..3da0c63c1a 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -20,7 +20,7 @@ DOMImplementation::DOMImplementation(Document& document) } // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument -ExceptionOr<NonnullRefPtr<Document>> DOMImplementation::create_document(const String& namespace_, const String& qualified_name, RefPtr<DocumentType> doctype) const +ExceptionOr<NonnullRefPtr<Document>> DOMImplementation::create_document(String const& namespace_, String const& qualified_name, RefPtr<DocumentType> doctype) const { // FIXME: This should specifically be an XML document. auto xml_document = Document::create(); @@ -51,7 +51,7 @@ ExceptionOr<NonnullRefPtr<Document>> DOMImplementation::create_document(const St } // https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument -NonnullRefPtr<Document> DOMImplementation::create_html_document(const String& title) const +NonnullRefPtr<Document> DOMImplementation::create_html_document(String const& title) const { // FIXME: This should specifically be a HTML document. auto html_document = Document::create(); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 74948243be..1c8d828696 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -28,7 +28,7 @@ public: } ExceptionOr<NonnullRefPtr<Document>> create_document(String const&, String const&, RefPtr<DocumentType>) const; - NonnullRefPtr<Document> create_html_document(const String& title) const; + NonnullRefPtr<Document> create_html_document(String const& title) const; ExceptionOr<NonnullRefPtr<DocumentType>> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); // https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 929042dc74..d91d6c1e44 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -307,7 +307,7 @@ Origin Document::origin() const return { m_url.protocol(), m_url.host(), m_url.port_or_default() }; } -void Document::set_origin(const Origin& origin) +void Document::set_origin(Origin const& origin) { m_url.set_protocol(origin.protocol()); m_url.set_host(origin.host()); @@ -328,7 +328,7 @@ void Document::schedule_layout_update() m_layout_update_timer->start(); } -bool Document::is_child_allowed(const Node& node) const +bool Document::is_child_allowed(Node const& node) const { switch (node.type()) { case NodeType::DOCUMENT_NODE: @@ -350,7 +350,7 @@ Element* Document::document_element() return first_child_of_type<Element>(); } -const Element* Document::document_element() const +Element const* Document::document_element() const { return first_child_of_type<Element>(); } @@ -432,7 +432,7 @@ String Document::title() const return builder.to_string(); } -void Document::set_title(const String& title) +void Document::set_title(String const& title) { auto* head_element = const_cast<HTML::HTMLHeadElement*>(head()); if (!head_element) @@ -651,9 +651,9 @@ void Document::set_visited_link_color(Color color) m_visited_link_color = color; } -const Layout::InitialContainingBlock* Document::layout_node() const +Layout::InitialContainingBlock const* Document::layout_node() const { - return static_cast<const Layout::InitialContainingBlock*>(Node::layout_node()); + return static_cast<Layout::InitialContainingBlock const*>(Node::layout_node()); } Layout::InitialContainingBlock* Document::layout_node() @@ -935,12 +935,12 @@ NonnullRefPtr<DocumentFragment> Document::create_document_fragment() return adopt_ref(*new DocumentFragment(*this)); } -NonnullRefPtr<Text> Document::create_text_node(const String& data) +NonnullRefPtr<Text> Document::create_text_node(String const& data) { return adopt_ref(*new Text(*this, data)); } -NonnullRefPtr<Comment> Document::create_comment(const String& data) +NonnullRefPtr<Comment> Document::create_comment(String const& data) { return adopt_ref(*new Comment(*this, data)); } @@ -951,7 +951,7 @@ NonnullRefPtr<Range> Document::create_range() } // https://dom.spec.whatwg.org/#dom-document-createevent -NonnullRefPtr<Event> Document::create_event(const String& interface) +NonnullRefPtr<Event> Document::create_event(String const& interface) { auto interface_lowercase = interface.to_lowercase(); RefPtr<Event> event; @@ -1101,12 +1101,12 @@ ExceptionOr<NonnullRefPtr<Node>> Document::adopt_node_binding(NonnullRefPtr<Node return node; } -const DocumentType* Document::doctype() const +DocumentType const* Document::doctype() const { return first_child_of_type<DocumentType>(); } -const String& Document::compat_mode() const +String const& Document::compat_mode() const { static String back_compat = "BackCompat"; static String css1_compat = "CSS1Compat"; @@ -1192,12 +1192,12 @@ Page* Document::page() return m_browsing_context ? m_browsing_context->page() : nullptr; } -const Page* Document::page() const +Page const* Document::page() const { return m_browsing_context ? m_browsing_context->page() : nullptr; } -EventTarget* Document::get_parent(const Event& event) +EventTarget* Document::get_parent(Event const& event) { if (event.type() == HTML::EventNames::load) return nullptr; diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 7b1ca335c7..4412efd5e9 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -68,7 +68,7 @@ public: AK::URL url() const { return m_url; } Origin origin() const; - void set_origin(const Origin& origin); + void set_origin(Origin const& origin); AK::URL parse_url(String const&) const; @@ -84,14 +84,14 @@ public: void set_hovered_node(Node*); Node* hovered_node() { return m_hovered_node; } - const Node* hovered_node() const { return m_hovered_node; } + Node const* hovered_node() const { return m_hovered_node; } void set_inspected_node(Node*); Node* inspected_node() { return m_inspected_node; } - const Node* inspected_node() const { return m_inspected_node; } + Node const* inspected_node() const { return m_inspected_node; } Element* document_element(); - const Element* document_element() const; + Element const* document_element() const; HTML::HTMLHtmlElement* html_element(); HTML::HTMLHeadElement* head(); @@ -115,7 +115,7 @@ public: ExceptionOr<void> set_body(HTML::HTMLElement* new_body); String title() const; - void set_title(const String&); + void set_title(String const&); void attach_to_browsing_context(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&); void detach_from_browsing_context(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&); @@ -124,9 +124,9 @@ public: HTML::BrowsingContext const* browsing_context() const { return m_browsing_context.ptr(); } Page* page(); - const Page* page() const; + Page const* page() const; - Color background_color(const Gfx::Palette&) const; + Color background_color(Gfx::Palette const&) const; Vector<CSS::BackgroundLayerData> const* background_layers() const; Color link_color() const; @@ -148,9 +148,9 @@ public: void invalidate_layout(); void invalidate_stacking_context_tree(); - virtual bool is_child_allowed(const Node&) const override; + virtual bool is_child_allowed(Node const&) const override; - const Layout::InitialContainingBlock* layout_node() const; + Layout::InitialContainingBlock const* layout_node() const; Layout::InitialContainingBlock* layout_node(); void schedule_style_update(); @@ -168,8 +168,8 @@ public: NonnullRefPtr<HTMLCollection> forms(); NonnullRefPtr<HTMLCollection> scripts(); - const String& source() const { return m_source; } - void set_source(const String& source) { m_source = source; } + String const& source() const { return m_source; } + void set_source(String const& source) { m_source = source; } HTML::EnvironmentSettingsObject& relevant_settings_object(); JS::Realm& realm(); @@ -177,13 +177,13 @@ public: JS::Value run_javascript(StringView source, StringView filename = "(unknown)"); - ExceptionOr<NonnullRefPtr<Element>> create_element(const String& tag_name); - ExceptionOr<NonnullRefPtr<Element>> create_element_ns(const String& namespace_, const String& qualified_name); + ExceptionOr<NonnullRefPtr<Element>> create_element(String const& tag_name); + ExceptionOr<NonnullRefPtr<Element>> create_element_ns(String const& namespace_, String const& qualified_name); NonnullRefPtr<DocumentFragment> create_document_fragment(); - NonnullRefPtr<Text> create_text_node(const String& data); - NonnullRefPtr<Comment> create_comment(const String& data); + NonnullRefPtr<Text> create_text_node(String const& data); + NonnullRefPtr<Comment> create_comment(String const& data); NonnullRefPtr<Range> create_range(); - NonnullRefPtr<Event> create_event(const String& interface); + NonnullRefPtr<Event> create_event(String const& interface); void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*); HTML::HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; } @@ -205,18 +205,18 @@ public: void adopt_node(Node&); ExceptionOr<NonnullRefPtr<Node>> adopt_node_binding(NonnullRefPtr<Node>); - const DocumentType* doctype() const; - const String& compat_mode() const; + DocumentType const* doctype() const; + String const& compat_mode() const; void set_editable(bool editable) { m_editable = editable; } virtual bool is_editable() const final; Element* focused_element() { return m_focused_element; } - const Element* focused_element() const { return m_focused_element; } + Element const* focused_element() const { return m_focused_element; } void set_focused_element(Element*); - const Element* active_element() const { return m_active_element; } + Element const* active_element() const { return m_active_element; } void set_active_element(Element*); @@ -224,7 +224,7 @@ public: void set_created_for_appropriate_template_contents(bool value) { m_created_for_appropriate_template_contents = value; } Document* associated_inert_template_document() { return m_associated_inert_template_document; } - const Document* associated_inert_template_document() const { return m_associated_inert_template_document; } + Document const* associated_inert_template_document() const { return m_associated_inert_template_document; } void set_associated_inert_template_document(Document& document) { m_associated_inert_template_document = document; } String ready_state() const; @@ -253,13 +253,13 @@ public: HTML::Window* default_view() { return m_window; } - const String& content_type() const { return m_content_type; } - void set_content_type(const String& content_type) { m_content_type = content_type; } + String const& content_type() const { return m_content_type; } + void set_content_type(String const& content_type) { m_content_type = content_type; } bool has_encoding() const { return m_encoding.has_value(); } - const Optional<String>& encoding() const { return m_encoding; } + Optional<String> const& encoding() const { return m_encoding; } String encoding_or_default() const { return m_encoding.value_or("UTF-8"); } - void set_encoding(const Optional<String>& encoding) { m_encoding = encoding; } + void set_encoding(Optional<String> const& encoding) { m_encoding = encoding; } // NOTE: These are intended for the JS bindings String character_set() const { return encoding_or_default(); } @@ -280,7 +280,7 @@ public: void increment_ignore_destructive_writes_counter() { m_ignore_destructive_writes_counter++; } void decrement_ignore_destructive_writes_counter() { m_ignore_destructive_writes_counter--; } - virtual EventTarget* get_parent(const Event&) override; + virtual EventTarget* get_parent(Event const&) override; String dump_dom_tree_as_json() const; diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.h b/Userland/Libraries/LibWeb/DOM/DocumentType.h index 0e8a9eedd0..89816ef0ea 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.h @@ -28,14 +28,14 @@ public: virtual FlyString node_name() const override { return "#doctype"; } - const String& name() const { return m_name; } - void set_name(const String& name) { m_name = name; } + String const& name() const { return m_name; } + void set_name(String const& name) { m_name = name; } - const String& public_id() const { return m_public_id; } - void set_public_id(const String& public_id) { m_public_id = public_id; } + String const& public_id() const { return m_public_id; } + void set_public_id(String const& public_id) { m_public_id = public_id; } - const String& system_id() const { return m_system_id; } - void set_system_id(const String& system_id) { m_system_id = system_id; } + String const& system_id() const { return m_system_id; } + void set_system_id(String const& system_id) { m_system_id = system_id; } private: String m_name; diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 4068fa5160..6bce81f358 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -51,7 +51,7 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name) Element::~Element() = default; // https://dom.spec.whatwg.org/#dom-element-getattribute -String Element::get_attribute(const FlyString& name) const +String Element::get_attribute(FlyString const& name) const { // 1. Let attr be the result of getting an attribute given qualifiedName and this. auto const* attribute = m_attributes->get_attribute(name); @@ -65,7 +65,7 @@ String Element::get_attribute(const FlyString& name) const } // https://dom.spec.whatwg.org/#dom-element-setattribute -ExceptionOr<void> Element::set_attribute(const FlyString& name, const String& value) +ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value) { // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // FIXME: Proper name validation @@ -156,7 +156,7 @@ ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyStri } // https://dom.spec.whatwg.org/#dom-element-removeattribute -void Element::remove_attribute(const FlyString& name) +void Element::remove_attribute(FlyString const& name) { m_attributes->remove_attribute(name); @@ -167,7 +167,7 @@ void Element::remove_attribute(const FlyString& name) } // https://dom.spec.whatwg.org/#dom-element-hasattribute -bool Element::has_attribute(const FlyString& name) const +bool Element::has_attribute(FlyString const& name) const { return m_attributes->get_attribute(name) != nullptr; } @@ -232,7 +232,7 @@ Vector<String> Element::get_attribute_names() const return names; } -bool Element::has_class(const FlyString& class_name, CaseSensitivity case_sensitivity) const +bool Element::has_class(FlyString const& class_name, CaseSensitivity case_sensitivity) const { return any_of(m_classes, [&](auto& it) { return case_sensitivity == CaseSensitivity::CaseSensitive @@ -291,7 +291,7 @@ RefPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Document& TODO(); } -void Element::parse_attribute(const FlyString& name, const String& value) +void Element::parse_attribute(FlyString const& name, String const& value) { if (name == HTML::AttributeNames::class_) { auto new_classes = value.split_view(is_ascii_space); diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 8746a69f6f..5608534806 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -36,27 +36,27 @@ public: Element(Document&, DOM::QualifiedName); virtual ~Element() override; - const String& qualified_name() const { return m_qualified_name.as_string(); } - const String& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; } + String const& qualified_name() const { return m_qualified_name.as_string(); } + String const& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; } virtual FlyString node_name() const final { return html_uppercased_qualified_name(); } - const FlyString& local_name() const { return m_qualified_name.local_name(); } + FlyString const& local_name() const { return m_qualified_name.local_name(); } // NOTE: This is for the JS bindings - const String& tag_name() const { return html_uppercased_qualified_name(); } + String const& tag_name() const { return html_uppercased_qualified_name(); } - const FlyString& prefix() const { return m_qualified_name.prefix(); } - const FlyString& namespace_() const { return m_qualified_name.namespace_(); } + FlyString const& prefix() const { return m_qualified_name.prefix(); } + FlyString const& namespace_() const { return m_qualified_name.namespace_(); } // NOTE: This is for the JS bindings - const FlyString& namespace_uri() const { return namespace_(); } + FlyString const& namespace_uri() const { return namespace_(); } - bool has_attribute(const FlyString& name) const; + bool has_attribute(FlyString const& name) const; bool has_attributes() const { return !m_attributes->is_empty(); } - String attribute(const FlyString& name) const { return get_attribute(name); } - String get_attribute(const FlyString& name) const; - ExceptionOr<void> set_attribute(const FlyString& name, const String& value); + String attribute(FlyString const& name) const { return get_attribute(name); } + String get_attribute(FlyString const& name) const; + ExceptionOr<void> set_attribute(FlyString const& name, String const& value); ExceptionOr<void> set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value); - void remove_attribute(const FlyString& name); + void remove_attribute(FlyString const& name); DOM::ExceptionOr<bool> toggle_attribute(FlyString const& name, Optional<bool> force); size_t attribute_list_size() const { return m_attributes->length(); } NonnullRefPtr<NamedNodeMap> const& attributes() const { return m_attributes; } @@ -81,11 +81,11 @@ public: } } - bool has_class(const FlyString&, CaseSensitivity = CaseSensitivity::CaseSensitive) const; - const Vector<FlyString>& class_names() const { return m_classes; } + bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const; + Vector<FlyString> const& class_names() const { return m_classes; } virtual void apply_presentational_hints(CSS::StyleProperties&) const { } - virtual void parse_attribute(const FlyString& name, const String& value); + virtual void parse_attribute(FlyString const& name, String const& value); virtual void did_remove_attribute(FlyString const&); enum class NeedsRelayout { @@ -95,7 +95,7 @@ public: NeedsRelayout recompute_style(); Layout::NodeWithStyle* layout_node() { return static_cast<Layout::NodeWithStyle*>(Node::layout_node()); } - const Layout::NodeWithStyle* layout_node() const { return static_cast<const Layout::NodeWithStyle*>(Node::layout_node()); } + Layout::NodeWithStyle const* layout_node() const { return static_cast<Layout::NodeWithStyle const*>(Node::layout_node()); } String name() const { return attribute(HTML::AttributeNames::name); } @@ -116,7 +116,7 @@ public: NonnullRefPtr<HTMLCollection> get_elements_by_class_name(FlyString const&); ShadowRoot* shadow_root() { return m_shadow_root; } - const ShadowRoot* shadow_root() const { return m_shadow_root; } + ShadowRoot const* shadow_root() const { return m_shadow_root; } void set_shadow_root(RefPtr<ShadowRoot>); void set_custom_properties(HashMap<FlyString, CSS::StyleProperty> custom_properties) { m_custom_properties = move(custom_properties); } diff --git a/Userland/Libraries/LibWeb/DOM/Event.cpp b/Userland/Libraries/LibWeb/DOM/Event.cpp index 16ef6055f3..dc16bad15b 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.cpp +++ b/Userland/Libraries/LibWeb/DOM/Event.cpp @@ -37,7 +37,7 @@ void Event::set_cancelled_flag() } // https://dom.spec.whatwg.org/#concept-event-initialize -void Event::initialize(const String& type, bool bubbles, bool cancelable) +void Event::initialize(String const& type, bool bubbles, bool cancelable) { m_initialized = true; m_stop_propagation = false; @@ -51,7 +51,7 @@ void Event::initialize(const String& type, bool bubbles, bool cancelable) } // https://dom.spec.whatwg.org/#dom-event-initevent -void Event::init_event(const String& type, bool bubbles, bool cancelable) +void Event::init_event(String const& type, bool bubbles, bool cancelable) { if (m_dispatch) return; diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h index 23d25f040e..698b65250b 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.h +++ b/Userland/Libraries/LibWeb/DOM/Event.h @@ -47,11 +47,11 @@ public: using Path = Vector<PathEntry>; - static NonnullRefPtr<Event> create(const FlyString& event_name, EventInit const& event_init = {}) + static NonnullRefPtr<Event> create(FlyString const& event_name, EventInit const& event_init = {}) { return adopt_ref(*new Event(event_name, event_init)); } - static NonnullRefPtr<Event> create_with_global_object(Bindings::WindowObject&, const FlyString& event_name, EventInit const& event_init) + static NonnullRefPtr<Event> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, EventInit const& event_init) { return Event::create(event_name, event_init); } @@ -60,7 +60,7 @@ public: double time_stamp() const; - const FlyString& type() const { return m_type; } + FlyString const& type() const { return m_type; } void set_type(StringView type) { m_type = type; } RefPtr<EventTarget> target() const { return m_target; } @@ -111,7 +111,7 @@ public: void append_to_path(EventTarget&, RefPtr<EventTarget>, RefPtr<EventTarget>, TouchTargetList&, bool); Path& path() { return m_path; } - const Path& path() const { return m_path; } + Path const& path() const { return m_path; } void clear_path() { m_path.clear(); } void set_touch_target_list(TouchTargetList& touch_target_list) { m_touch_target_list = touch_target_list; } @@ -142,7 +142,7 @@ public: m_stop_immediate_propagation = true; } - void init_event(const String&, bool, bool); + void init_event(String const&, bool, bool); void set_time_stamp(double time_stamp) { m_time_stamp = time_stamp; } @@ -163,7 +163,7 @@ protected: { } - void initialize(const String&, bool, bool); + void initialize(String const&, bool, bool); private: FlyString m_type; diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.h b/Userland/Libraries/LibWeb/DOM/EventTarget.h index 75586c3d36..c0098efc47 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.h +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.h @@ -41,7 +41,7 @@ public: virtual JS::Object* create_wrapper(JS::GlobalObject&) = 0; - virtual EventTarget* get_parent(const Event&) { return nullptr; } + virtual EventTarget* get_parent(Event const&) { return nullptr; } void add_an_event_listener(NonnullRefPtr<DOMEventListener>); void remove_an_event_listener(DOMEventListener&); @@ -50,7 +50,7 @@ public: auto& event_listener_list() { return m_event_listener_list; } auto const& event_listener_list() const { return m_event_listener_list; } - Function<void(const Event&)> activation_behavior; + Function<void(Event const&)> activation_behavior; // NOTE: These only exist for checkbox and radio input elements. virtual void legacy_pre_activation_behavior() { } diff --git a/Userland/Libraries/LibWeb/DOM/ExceptionOr.h b/Userland/Libraries/LibWeb/DOM/ExceptionOr.h index e741cbceba..bef730ff68 100644 --- a/Userland/Libraries/LibWeb/DOM/ExceptionOr.h +++ b/Userland/Libraries/LibWeb/DOM/ExceptionOr.h @@ -39,7 +39,7 @@ public: { } - ExceptionOr(const ValueType& result) + ExceptionOr(ValueType const& result) : m_result(result) { } @@ -65,7 +65,7 @@ public: } ExceptionOr(ExceptionOr&& other) = default; - ExceptionOr(const ExceptionOr& other) = default; + ExceptionOr(ExceptionOr const& other) = default; ~ExceptionOr() = default; ValueType& value() requires(!IsSame<ValueType, Empty>) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index ad6773e4e3..c12ed76f78 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -95,7 +95,7 @@ const HTML::HTMLElement* Node::enclosing_html_element() const return first_ancestor_of_type<HTML::HTMLElement>(); } -const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(const FlyString& attribute) const +const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(FlyString const& attribute) const { for (auto* node = this; node; node = node->parent()) { if (is<HTML::HTMLElement>(*node) && verify_cast<HTML::HTMLElement>(*node).has_attribute(attribute)) @@ -162,7 +162,7 @@ String Node::node_value() const } // https://dom.spec.whatwg.org/#ref-for-dom-node-nodevalue%E2%91%A0 -void Node::set_node_value(const String& value) +void Node::set_node_value(String const& value) { if (is<Attribute>(this)) { @@ -249,7 +249,7 @@ Element* Node::parent_element() return verify_cast<Element>(parent()); } -const Element* Node::parent_element() const +Element const* Node::parent_element() const { if (!parent() || !is<Element>(parent())) return nullptr; @@ -650,7 +650,7 @@ void Node::set_layout_node(Badge<Layout::Node>, Layout::Node* layout_node) const m_layout_node = nullptr; } -EventTarget* Node::get_parent(const Event&) +EventTarget* Node::get_parent(Event const&) { // FIXME: returns the node’s assigned slot, if node is assigned, and node’s parent otherwise. return parent(); @@ -746,7 +746,7 @@ u16 Node::compare_document_position(RefPtr<Node> other) } // https://dom.spec.whatwg.org/#concept-tree-host-including-inclusive-ancestor -bool Node::is_host_including_inclusive_ancestor_of(const Node& other) const +bool Node::is_host_including_inclusive_ancestor_of(Node const& other) const { if (is_inclusive_ancestor_of(other)) return true; diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 44d63efb96..ffc513642b 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -50,7 +50,7 @@ public: using TreeNode<Node>::unref; ParentNode* parent_or_shadow_host(); - const ParentNode* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); } + ParentNode const* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); } // ^EventTarget virtual void ref_event_target() final { ref(); } @@ -121,24 +121,24 @@ public: void set_node_value(String const&); Document& document() { return *m_document; } - const Document& document() const { return *m_document; } + Document const& document() const { return *m_document; } RefPtr<Document> owner_document() const; const HTML::HTMLAnchorElement* enclosing_link_element() const; const HTML::HTMLElement* enclosing_html_element() const; - const HTML::HTMLElement* enclosing_html_element_with_attribute(const FlyString&) const; + const HTML::HTMLElement* enclosing_html_element_with_attribute(FlyString const&) const; String child_text_content() const; Node& root(); - const Node& root() const + Node const& root() const { return const_cast<Node*>(this)->root(); } Node& shadow_including_root(); - const Node& shadow_including_root() const + Node const& shadow_including_root() const { return const_cast<Node*>(this)->shadow_including_root(); } @@ -146,10 +146,10 @@ public: bool is_connected() const; Node* parent_node() { return parent(); } - const Node* parent_node() const { return parent(); } + Node const* parent_node() const { return parent(); } Element* parent_element(); - const Element* parent_element() const; + Element const* parent_element() const; virtual void inserted(); virtual void removed_from(Node*) { } @@ -157,7 +157,7 @@ public: virtual void adopted_from(Document&) { } virtual void cloned(Node&, bool) {}; - const Layout::Node* layout_node() const { return m_layout_node; } + Layout::Node const* layout_node() const { return m_layout_node; } Layout::Node* layout_node() { return m_layout_node; } Painting::PaintableBox const* paint_box() const; @@ -165,7 +165,7 @@ public: void set_layout_node(Badge<Layout::Node>, Layout::Node*) const; - virtual bool is_child_allowed(const Node&) const { return true; } + virtual bool is_child_allowed(Node const&) const { return true; } bool needs_style_update() const { return m_needs_style_update; } void set_needs_style_update(bool); @@ -179,14 +179,14 @@ public: void set_document(Badge<Document>, Document&); - virtual EventTarget* get_parent(const Event&) override; + virtual EventTarget* get_parent(Event const&) override; template<typename T> bool fast_is() const = delete; ExceptionOr<void> ensure_pre_insertion_validity(NonnullRefPtr<Node> node, RefPtr<Node> child) const; - bool is_host_including_inclusive_ancestor_of(const Node&) const; + bool is_host_including_inclusive_ancestor_of(Node const&) const; bool is_scripting_enabled() const; bool is_scripting_disabled() const; diff --git a/Userland/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h b/Userland/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h index 3929382b7c..37a4fde5bd 100644 --- a/Userland/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h +++ b/Userland/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h @@ -51,10 +51,10 @@ public: return nullptr; } - const Element* previous_element_sibling() const { return const_cast<NonDocumentTypeChildNode*>(this)->previous_element_sibling(); } - const Element* previous_element_in_pre_order() const { return const_cast<NonDocumentTypeChildNode*>(this)->previous_element_in_pre_order(); } - const Element* next_element_sibling() const { return const_cast<NonDocumentTypeChildNode*>(this)->next_element_sibling(); } - const Element* next_element_in_pre_order() const { return const_cast<NonDocumentTypeChildNode*>(this)->next_element_in_pre_order(); } + Element const* previous_element_sibling() const { return const_cast<NonDocumentTypeChildNode*>(this)->previous_element_sibling(); } + Element const* previous_element_in_pre_order() const { return const_cast<NonDocumentTypeChildNode*>(this)->previous_element_in_pre_order(); } + Element const* next_element_sibling() const { return const_cast<NonDocumentTypeChildNode*>(this)->next_element_sibling(); } + Element const* next_element_in_pre_order() const { return const_cast<NonDocumentTypeChildNode*>(this)->next_element_in_pre_order(); } protected: NonDocumentTypeChildNode() = default; diff --git a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h index 4b8605d4bd..59c1ef65cb 100644 --- a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h @@ -16,10 +16,10 @@ namespace Web::DOM { template<typename NodeType> class NonElementParentNode { public: - RefPtr<Element> get_element_by_id(const FlyString& id) const + RefPtr<Element> get_element_by_id(FlyString const& id) const { RefPtr<Element> found_element; - static_cast<const NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) { + static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) { if (element.attribute(HTML::AttributeNames::id) == id) { found_element = &element; return IterationDecision::Break; @@ -28,9 +28,9 @@ public: }); return found_element; } - RefPtr<Element> get_element_by_id(const FlyString& id) + RefPtr<Element> get_element_by_id(FlyString const& id) { - return const_cast<const NonElementParentNode*>(this)->get_element_by_id(id); + return const_cast<NonElementParentNode const*>(this)->get_element_by_id(id); } protected: diff --git a/Userland/Libraries/LibWeb/DOM/Position.h b/Userland/Libraries/LibWeb/DOM/Position.h index a4fe55a57e..45ef6768a7 100644 --- a/Userland/Libraries/LibWeb/DOM/Position.h +++ b/Userland/Libraries/LibWeb/DOM/Position.h @@ -21,7 +21,7 @@ public: bool is_valid() const { return m_node; } Node* node() { return m_node; } - const Node* node() const { return m_node; } + Node const* node() const { return m_node; } unsigned offset() const { return m_offset; } bool offset_is_at_end_of_node() const; @@ -29,12 +29,12 @@ public: bool increment_offset(); bool decrement_offset(); - bool operator==(const Position& other) const + bool operator==(Position const& other) const { return m_node == other.m_node && m_offset == other.m_offset; } - bool operator!=(const Position& other) const + bool operator!=(Position const& other) const { return !(*this == other); } diff --git a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp index c1cc2f2dce..66cb7a56bc 100644 --- a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp +++ b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp @@ -9,7 +9,7 @@ namespace Web::DOM { -ProcessingInstruction::ProcessingInstruction(Document& document, const String& data, const String& target) +ProcessingInstruction::ProcessingInstruction(Document& document, String const& data, String const& target) : CharacterData(document, NodeType::PROCESSING_INSTRUCTION_NODE, data) , m_target(target) { diff --git a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h index 087960ca3c..5bc6706daf 100644 --- a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h +++ b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h @@ -15,12 +15,12 @@ class ProcessingInstruction final : public CharacterData { public: using WrapperType = Bindings::ProcessingInstructionWrapper; - ProcessingInstruction(Document&, const String& data, const String& target); + ProcessingInstruction(Document&, String const& data, String const& target); virtual ~ProcessingInstruction() override = default; virtual FlyString node_name() const override { return m_target; } - const String& target() const { return m_target; } + String const& target() const { return m_target; } private: String m_target; diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp index 98965b475d..01a312ee65 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp @@ -19,7 +19,7 @@ ShadowRoot::ShadowRoot(Document& document, Element& host) } // https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6 -EventTarget* ShadowRoot::get_parent(const Event& event) +EventTarget* ShadowRoot::get_parent(Event const& event) { if (!event.composed()) { auto& events_first_invocation_target = verify_cast<Node>(*event.path().first().invocation_target); diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h index f550c0e5cb..b4306c4461 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h @@ -23,7 +23,7 @@ public: void set_available_to_element_internals(bool available_to_element_internals) { m_available_to_element_internals = available_to_element_internals; } // ^EventTarget - virtual EventTarget* get_parent(const Event&) override; + virtual EventTarget* get_parent(Event const&) override; // NOTE: This is intended for the JS bindings. String mode() const { return m_closed ? "closed" : "open"; } diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 83b21fcdd7..d2ea61a2bb 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -12,7 +12,7 @@ namespace Web::DOM { -Text::Text(Document& document, const String& data) +Text::Text(Document& document, String const& data) : CharacterData(document, NodeType::TEXT_NODE, data) { } diff --git a/Userland/Libraries/LibWeb/DOM/Text.h b/Userland/Libraries/LibWeb/DOM/Text.h index 2d839cb63a..bccfc2024e 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.h +++ b/Userland/Libraries/LibWeb/DOM/Text.h @@ -16,7 +16,7 @@ class Text final : public CharacterData { public: using WrapperType = Bindings::TextWrapper; - explicit Text(Document&, const String&); + explicit Text(Document&, String const&); virtual ~Text() override = default; static NonnullRefPtr<Text> create_with_global_object(Bindings::WindowObject& window, String const& data); diff --git a/Userland/Libraries/LibWeb/DOMTreeModel.h b/Userland/Libraries/LibWeb/DOMTreeModel.h index 94b7606a62..2d971a1384 100644 --- a/Userland/Libraries/LibWeb/DOMTreeModel.h +++ b/Userland/Libraries/LibWeb/DOMTreeModel.h @@ -36,14 +36,14 @@ public: private: DOMTreeModel(JsonObject, GUI::TreeView&); - ALWAYS_INLINE JsonObject const* get_parent(const JsonObject& o) const + ALWAYS_INLINE JsonObject const* get_parent(JsonObject const& o) const { auto parent_node = m_dom_node_to_parent_map.get(&o); VERIFY(parent_node.has_value()); return *parent_node; } - ALWAYS_INLINE static JsonArray const* get_children(const JsonObject& o) + ALWAYS_INLINE static JsonArray const* get_children(JsonObject const& o) { if (auto const* maybe_children = o.get_ptr("children"); maybe_children) return &maybe_children->as_array(); diff --git a/Userland/Libraries/LibWeb/FontCache.cpp b/Userland/Libraries/LibWeb/FontCache.cpp index 12edddc2d4..7350049dd3 100644 --- a/Userland/Libraries/LibWeb/FontCache.cpp +++ b/Userland/Libraries/LibWeb/FontCache.cpp @@ -13,7 +13,7 @@ FontCache& FontCache::the() return cache; } -RefPtr<Gfx::Font> FontCache::get(const FontSelector& font_selector) const +RefPtr<Gfx::Font> FontCache::get(FontSelector const& font_selector) const { auto cached_font = m_fonts.get(font_selector); if (cached_font.has_value()) @@ -21,7 +21,7 @@ RefPtr<Gfx::Font> FontCache::get(const FontSelector& font_selector) const return nullptr; } -void FontCache::set(const FontSelector& font_selector, NonnullRefPtr<Gfx::Font> font) +void FontCache::set(FontSelector const& font_selector, NonnullRefPtr<Gfx::Font> font) { m_fonts.set(font_selector, move(font)); } diff --git a/Userland/Libraries/LibWeb/FontCache.h b/Userland/Libraries/LibWeb/FontCache.h index f36411570f..647e6b6813 100644 --- a/Userland/Libraries/LibWeb/FontCache.h +++ b/Userland/Libraries/LibWeb/FontCache.h @@ -18,7 +18,7 @@ struct FontSelector { int weight { 0 }; int slope { 0 }; - bool operator==(const FontSelector& other) const + bool operator==(FontSelector const& other) const { return family == other.family && point_size == other.point_size && weight == other.weight && slope == other.slope; } @@ -27,15 +27,15 @@ struct FontSelector { namespace AK { template<> struct Traits<FontSelector> : public GenericTraits<FontSelector> { - static unsigned hash(const FontSelector& key) { return pair_int_hash(pair_int_hash(key.family.hash(), key.weight), key.point_size); } + static unsigned hash(FontSelector const& key) { return pair_int_hash(pair_int_hash(key.family.hash(), key.weight), key.point_size); } }; } class FontCache { public: static FontCache& the(); - RefPtr<Gfx::Font> get(const FontSelector&) const; - void set(const FontSelector&, NonnullRefPtr<Gfx::Font>); + RefPtr<Gfx::Font> get(FontSelector const&) const; + void set(FontSelector const&, NonnullRefPtr<Gfx::Font>); private: FontCache() = default; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h index 8d44b124c6..78b6071d9c 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h @@ -16,7 +16,7 @@ public: virtual ~BrowsingContextContainer() override; BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; } - const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; } + BrowsingContext const* nested_browsing_context() const { return m_nested_browsing_context; } const DOM::Document* content_document() const; DOM::Document const* content_document_without_origin_check() const; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 806cae33cc..d3994da800 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -207,7 +207,7 @@ void CanvasRenderingContext2D::rotate(float radians) m_drawing_state.transform.rotate_radians(radians); } -void CanvasRenderingContext2D::did_draw(const Gfx::FloatRect&) +void CanvasRenderingContext2D::did_draw(Gfx::FloatRect const&) { // FIXME: Make use of the rect to reduce the invalidated area when possible. if (!m_element) @@ -230,7 +230,7 @@ OwnPtr<Gfx::Painter> CanvasRenderingContext2D::painter() return make<Gfx::Painter>(*m_element->bitmap()); } -void CanvasRenderingContext2D::fill_text(const String& text, float x, float y, Optional<double> max_width) +void CanvasRenderingContext2D::fill_text(String const& text, float x, float y, Optional<double> max_width) { if (max_width.has_value() && max_width.value() <= 0) return; @@ -383,7 +383,7 @@ void CanvasRenderingContext2D::fill(Gfx::Painter::WindingRule winding) did_draw(m_path.bounding_box()); } -void CanvasRenderingContext2D::fill(const String& fill_rule) +void CanvasRenderingContext2D::fill(String const& fill_rule) { if (fill_rule == "evenodd") return fill(Gfx::Painter::WindingRule::EvenOdd); @@ -439,7 +439,7 @@ DOM::ExceptionOr<RefPtr<ImageData>> CanvasRenderingContext2D::get_image_data(int return image_data; } -void CanvasRenderingContext2D::put_image_data(const ImageData& image_data, float x, float y) +void CanvasRenderingContext2D::put_image_data(ImageData const& image_data, float x, float y) { auto painter = this->painter(); if (!painter) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index ceacd1b5c8..f7465670b0 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -72,16 +72,16 @@ public: void rect(float x, float y, float width, float height); void stroke(); - void fill_text(const String&, float x, float y, Optional<double> max_width); + void fill_text(String const&, float x, float y, Optional<double> max_width); void stroke_text(String const&, float x, float y, Optional<double> max_width); // FIXME: We should only have one fill(), really. Fix the wrapper generator! void fill(Gfx::Painter::WindingRule); - void fill(const String& fill_rule); + void fill(String const& fill_rule); RefPtr<ImageData> create_image_data(int width, int height) const; DOM::ExceptionOr<RefPtr<ImageData>> get_image_data(int x, int y, int width, int height) const; - void put_image_data(const ImageData&, float x, float y); + void put_image_data(ImageData const&, float x, float y); void save(); void restore(); @@ -112,7 +112,7 @@ private: Gfx::IntRect bounding_box; }; - void did_draw(const Gfx::FloatRect&); + void did_draw(Gfx::FloatRect const&); PreparedText prepare_text(String const& text, float max_width = INFINITY); OwnPtr<Gfx::Painter> painter(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 5d75290daa..ad0d688c6f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -37,7 +37,7 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co }); } -void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value) +void HTMLBodyElement::parse_attribute(FlyString const& name, String const& value) { HTMLElement::parse_attribute(name, value); if (name.equals_ignoring_case("link")) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h index 9bbb48ec2f..2aef6df4d5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -17,7 +17,7 @@ public: HTMLBodyElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLBodyElement() override; - virtual void parse_attribute(const FlyString&, const String&) override; + virtual void parse_attribute(FlyString const&, String const&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; private: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 2f132faff9..1244c3dfc0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -59,7 +59,7 @@ CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type) return m_context; } -static Gfx::IntSize bitmap_size_for_canvas(const HTMLCanvasElement& canvas) +static Gfx::IntSize bitmap_size_for_canvas(HTMLCanvasElement const& canvas) { auto width = canvas.width(); auto height = canvas.height(); @@ -94,7 +94,7 @@ bool HTMLCanvasElement::create_bitmap() return m_bitmap; } -String HTMLCanvasElement::to_data_url(const String& type, [[maybe_unused]] Optional<double> quality) const +String HTMLCanvasElement::to_data_url(String const& type, [[maybe_unused]] Optional<double> quality) const { if (!m_bitmap) return {}; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h index d242c12adf..b6bda5884c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -19,7 +19,7 @@ public: HTMLCanvasElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLCanvasElement() override; - const Gfx::Bitmap* bitmap() const { return m_bitmap; } + Gfx::Bitmap const* bitmap() const { return m_bitmap; } Gfx::Bitmap* bitmap() { return m_bitmap; } bool create_bitmap(); @@ -31,7 +31,7 @@ public: void set_width(unsigned); void set_height(unsigned); - String to_data_url(const String& type, Optional<double> quality) const; + String to_data_url(String const& type, Optional<double> quality) const; private: virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index b9523d51cf..748d85fc5e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -78,7 +78,7 @@ String HTMLElement::content_editable() const } // https://html.spec.whatwg.org/multipage/interaction.html#contenteditable -DOM::ExceptionOr<void> HTMLElement::set_content_editable(const String& content_editable) +DOM::ExceptionOr<void> HTMLElement::set_content_editable(String const& content_editable) { if (content_editable.equals_ignoring_case("inherit")) { remove_attribute(HTML::AttributeNames::contenteditable); @@ -112,7 +112,7 @@ String HTMLElement::inner_text() if (!layout_node()) return text_content(); - Function<void(const Layout::Node&)> recurse = [&](auto& node) { + Function<void(Layout::Node const&)> recurse = [&](auto& node) { for (auto* child = node.first_child(); child; child = child->next_sibling()) { if (is<Layout::TextNode>(child)) builder.append(verify_cast<Layout::TextNode>(*child).text_for_rendering()); @@ -168,7 +168,7 @@ bool HTMLElement::cannot_navigate() const return !is<HTML::HTMLAnchorElement>(this) && !is_connected(); } -void HTMLElement::parse_attribute(const FlyString& name, const String& value) +void HTMLElement::parse_attribute(FlyString const& name, String const& value) { Element::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h index 6e6239c56e..c4f0ba8bfc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h @@ -26,7 +26,7 @@ public: virtual bool is_editable() const final; String content_editable() const; - DOM::ExceptionOr<void> set_content_editable(const String&); + DOM::ExceptionOr<void> set_content_editable(String const&); String inner_text(); void set_inner_text(StringView); @@ -50,7 +50,7 @@ public: virtual bool is_labelable() const { return false; } protected: - virtual void parse_attribute(const FlyString& name, const String& value) override; + virtual void parse_attribute(FlyString const& name, String const& value) override; private: // ^HTML::GlobalEventHandlers diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h index cb3427e697..1cb3a6c06c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h @@ -22,7 +22,7 @@ public: HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLFieldSetElement() override; - const String& type() const + String const& type() const { static String fieldset = "fieldset"; return fieldset; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 5879b7b4cf..163a457553 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -25,7 +25,7 @@ RefPtr<Layout::Node> HTMLIFrameElement::create_layout_node(NonnullRefPtr<CSS::St return adopt_ref(*new Layout::FrameBox(document(), *this, move(style))); } -void HTMLIFrameElement::parse_attribute(const FlyString& name, const String& value) +void HTMLIFrameElement::parse_attribute(FlyString const& name, String const& value) { HTMLElement::parse_attribute(name, value); if (name == HTML::AttributeNames::src) @@ -56,7 +56,7 @@ void HTMLIFrameElement::removed_from(DOM::Node* node) discard_nested_browsing_context(); } -void HTMLIFrameElement::load_src(const String& value) +void HTMLIFrameElement::load_src(String const& value) { if (!m_nested_browsing_context) return; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 1276480fc9..34149e50ed 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -22,9 +22,9 @@ public: private: virtual void inserted() override; virtual void removed_from(Node*) override; - virtual void parse_attribute(const FlyString& name, const String& value) override; + virtual void parse_attribute(FlyString const& name, String const& value) override; - void load_src(const String&); + void load_src(String const&); }; void run_iframe_load_event_steps(HTML::HTMLIFrameElement&); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index bf05d8983e..17fdca1b91 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -70,7 +70,7 @@ void HTMLImageElement::apply_presentational_hints(CSS::StyleProperties& style) c }); } -void HTMLImageElement::parse_attribute(const FlyString& name, const String& value) +void HTMLImageElement::parse_attribute(FlyString const& name, String const& value) { HTMLElement::parse_attribute(name, value); @@ -83,7 +83,7 @@ RefPtr<Layout::Node> HTMLImageElement::create_layout_node(NonnullRefPtr<CSS::Sty return adopt_ref(*new Layout::ImageBox(document(), *this, move(style), m_image_loader)); } -const Gfx::Bitmap* HTMLImageElement::bitmap() const +Gfx::Bitmap const* HTMLImageElement::bitmap() const { return m_image_loader.bitmap(m_image_loader.current_frame_index()); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index e488e96f58..c7b46db958 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -26,12 +26,12 @@ public: HTMLImageElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLImageElement() override; - virtual void parse_attribute(const FlyString& name, const String& value) override; + virtual void parse_attribute(FlyString const& name, String const& value) override; String alt() const { return attribute(HTML::AttributeNames::alt); } String src() const { return attribute(HTML::AttributeNames::src); } - const Gfx::Bitmap* bitmap() const; + Gfx::Bitmap const* bitmap() const; unsigned width() const; void set_width(unsigned); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index b1f835e43b..acebc098f8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -53,7 +53,7 @@ void HTMLLinkElement::inserted() } } -void HTMLLinkElement::parse_attribute(const FlyString& name, const String& value) +void HTMLLinkElement::parse_attribute(FlyString const& name, String const& value) { if (name == HTML::AttributeNames::rel) { m_relationship = 0; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h index 9a5153f9db..f033b27d0a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -29,7 +29,7 @@ public: String href() const { return attribute(HTML::AttributeNames::href); } private: - void parse_attribute(const FlyString&, const String&) override; + void parse_attribute(FlyString const&, String const&) override; // ^ResourceClient virtual void resource_did_fail() override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 0b324c3f05..8c59e43d23 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -23,7 +23,7 @@ HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName HTMLObjectElement::~HTMLObjectElement() = default; -void HTMLObjectElement::parse_attribute(const FlyString& name, const String& value) +void HTMLObjectElement::parse_attribute(FlyString const& name, String const& value) { BrowsingContextContainer::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h index 34cb9c4a3a..9b8b7aa558 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -34,7 +34,7 @@ public: HTMLObjectElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLObjectElement() override; - virtual void parse_attribute(const FlyString& name, const String& value) override; + virtual void parse_attribute(FlyString const& name, String const& value) override; String data() const; void set_data(String const& data) { set_attribute(HTML::AttributeNames::data, data); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h index 3e38612e8e..fb3ad802d0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h @@ -23,7 +23,7 @@ public: HTMLOutputElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLOutputElement() override; - const String& type() const + String const& type() const { static String output = "output"; return output; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 71ab5b1eb9..32fa015405 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -99,7 +99,7 @@ void HTMLScriptElement::execute_script() } // https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match -static bool is_javascript_mime_type_essence_match(const String& string) +static bool is_javascript_mime_type_essence_match(String const& string) { auto lowercase_string = string.to_lowercase(); return lowercase_string.is_one_of("application/ecmascript", "application/javascript", "application/x-ecmascript", "application/x-javascript", "text/ecmascript", "text/javascript", "text/javascript1.0", "text/javascript1.1", "text/javascript1.2", "text/javascript1.3", "text/javascript1.4", "text/javascript1.5", "text/jscript", "text/livescript", "text/x-ecmascript", "text/x-javascript"); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h index d2eb8509cd..b00dc90bf7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h @@ -19,7 +19,7 @@ public: virtual ~HTMLTemplateElement() override; NonnullRefPtr<DOM::DocumentFragment> content() { return *m_content; } - const NonnullRefPtr<DOM::DocumentFragment> content() const { return *m_content; } + NonnullRefPtr<DOM::DocumentFragment> const content() const { return *m_content; } virtual void adopted_from(DOM::Document&) override; virtual void cloned(Node& copy, bool clone_children) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h index 23c3148b7e..f8705b2551 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h @@ -23,7 +23,7 @@ public: HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName); virtual ~HTMLTextAreaElement() override; - const String& type() const + String const& type() const { static String textarea = "textarea"; return textarea; diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.h b/Userland/Libraries/LibWeb/HTML/ImageData.h index ed14a5852e..9f5c14d7c0 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.h +++ b/Userland/Libraries/LibWeb/HTML/ImageData.h @@ -26,7 +26,7 @@ public: unsigned height() const; Gfx::Bitmap& bitmap() { return m_bitmap; } - const Gfx::Bitmap& bitmap() const { return m_bitmap; } + Gfx::Bitmap const& bitmap() const { return m_bitmap; } JS::Uint8ClampedArray* data(); const JS::Uint8ClampedArray* data() const; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp index 2a9b622df5..f492a4170f 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp @@ -16,17 +16,17 @@ namespace Web::HTML { -bool prescan_should_abort(const ByteBuffer& input, const size_t& position) +bool prescan_should_abort(ByteBuffer const& input, size_t const& position) { return position >= input.size() || position >= 1024; } -bool prescan_is_whitespace_or_slash(const u8& byte) +bool prescan_is_whitespace_or_slash(u8 const& byte) { return byte == '\t' || byte == '\n' || byte == '\f' || byte == '\r' || byte == ' ' || byte == '/'; } -bool prescan_skip_whitespace_and_slashes(const ByteBuffer& input, size_t& position) +bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& position) { while (!prescan_should_abort(input, position) && (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ' || input[position] == '/')) ++position; @@ -96,7 +96,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const& return TextCodec::get_standardized_encoding(encoding); } -RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document& document, const ByteBuffer& input, size_t& position) +RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document& document, ByteBuffer const& input, size_t& position) { if (!prescan_skip_whitespace_and_slashes(input, position)) return {}; @@ -160,7 +160,7 @@ value: } // https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding -Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, const ByteBuffer& input) +Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, ByteBuffer const& input) { // https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding @@ -249,7 +249,7 @@ Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, cons } // https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding -String run_encoding_sniffing_algorithm(DOM::Document& document, const ByteBuffer& input) +String run_encoding_sniffing_algorithm(DOM::Document& document, ByteBuffer const& input) { if (input.size() >= 2) { if (input[0] == 0xFE && input[1] == 0xFF) { diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.h index e388b68d99..6cb9fc7e31 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.h @@ -12,12 +12,12 @@ namespace Web::HTML { -bool prescan_should_abort(const ByteBuffer& input, const size_t& position); -bool prescan_is_whitespace_or_slash(const u8& byte); -bool prescan_skip_whitespace_and_slashes(const ByteBuffer& input, size_t& position); +bool prescan_should_abort(ByteBuffer const& input, size_t const& position); +bool prescan_is_whitespace_or_slash(u8 const& byte); +bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& position); Optional<StringView> extract_character_encoding_from_meta_element(String const&); -RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document&, const ByteBuffer& input, size_t& position); -Optional<String> run_prescan_byte_stream_algorithm(DOM::Document&, const ByteBuffer& input); -String run_encoding_sniffing_algorithm(DOM::Document&, const ByteBuffer& input); +RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document&, ByteBuffer const& input, size_t& position); +Optional<String> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input); +String run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input); } diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index ba5e00dc13..7e59679b08 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -32,7 +32,7 @@ namespace Web::HTML { -static inline void log_parse_error(const SourceLocation& location = SourceLocation::current()) +static inline void log_parse_error(SourceLocation const& location = SourceLocation::current()) { dbgln("Parse error! {}", location); } @@ -118,7 +118,7 @@ static bool is_html_integration_point(DOM::Element const& element) return false; } -RefPtr<DOM::Document> parse_html_document(StringView data, const AK::URL& url, const String& encoding) +RefPtr<DOM::Document> parse_html_document(StringView data, const AK::URL& url, String const& encoding) { auto document = DOM::Document::create(url); auto parser = HTMLParser::create(document, data, encoding); @@ -126,7 +126,7 @@ RefPtr<DOM::Document> parse_html_document(StringView data, const AK::URL& url, c return document; } -HTMLParser::HTMLParser(DOM::Document& document, StringView input, const String& encoding) +HTMLParser::HTMLParser(DOM::Document& document, StringView input, String const& encoding) : m_tokenizer(input, encoding) , m_document(document) { @@ -389,7 +389,7 @@ void HTMLParser::process_using_the_rules_for(InsertionMode mode, HTMLToken& toke } } -DOM::QuirksMode HTMLParser::which_quirks_mode(const HTMLToken& doctype_token) const +DOM::QuirksMode HTMLParser::which_quirks_mode(HTMLToken const& doctype_token) const { if (doctype_token.doctype_data().force_quirks) return DOM::QuirksMode::Yes; @@ -651,7 +651,7 @@ NonnullRefPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& toke } // https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element -NonnullRefPtr<DOM::Element> HTMLParser::insert_foreign_element(const HTMLToken& token, const FlyString& namespace_) +NonnullRefPtr<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken const& token, FlyString const& namespace_) { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); @@ -677,7 +677,7 @@ NonnullRefPtr<DOM::Element> HTMLParser::insert_foreign_element(const HTMLToken& return element; } -NonnullRefPtr<DOM::Element> HTMLParser::insert_html_element(const HTMLToken& token) +NonnullRefPtr<DOM::Element> HTMLParser::insert_html_element(HTMLToken const& token) { return insert_foreign_element(token, Namespace::HTML); } @@ -1011,7 +1011,7 @@ AnythingElse: process_using_the_rules_for(m_insertion_mode, token); } -void HTMLParser::generate_implied_end_tags(const FlyString& exception) +void HTMLParser::generate_implied_end_tags(FlyString const& exception) { while (current_node().local_name() != exception && current_node().local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc)) (void)m_stack_of_open_elements.pop(); @@ -1335,7 +1335,7 @@ HTMLParser::AdoptionAgencyAlgorithmOutcome HTMLParser::run_the_adoption_agency_a } } -bool HTMLParser::is_special_tag(const FlyString& tag_name, const FlyString& namespace_) +bool HTMLParser::is_special_tag(FlyString const& tag_name, FlyString const& namespace_) { if (namespace_ == Namespace::HTML) { return tag_name.is_one_of( @@ -3357,7 +3357,7 @@ void HTMLParser::reset_the_insertion_mode_appropriately() m_insertion_mode = InsertionMode::InBody; } -const char* HTMLParser::insertion_mode_name() const +char const* HTMLParser::insertion_mode_name() const { switch (m_insertion_mode) { #define __ENUMERATE_INSERTION_MODE(mode) \ @@ -3430,7 +3430,7 @@ NonnullRefPtr<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& docume return adopt_ref(*new HTMLParser(document)); } -NonnullRefPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, const ByteBuffer& input) +NonnullRefPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input) { if (document.has_encoding()) return adopt_ref(*new HTMLParser(document, input, document.encoding().value())); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h index 7fbfb363d6..81d0e46dd3 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h @@ -39,7 +39,7 @@ namespace Web::HTML { __ENUMERATE_INSERTION_MODE(AfterAfterBody) \ __ENUMERATE_INSERTION_MODE(AfterAfterFrameset) -RefPtr<DOM::Document> parse_html_document(StringView, const AK::URL&, const String& encoding); +RefPtr<DOM::Document> parse_html_document(StringView, const AK::URL&, String const& encoding); class HTMLParser : public RefCounted<HTMLParser> { friend class HTMLTokenizer; @@ -67,7 +67,7 @@ public: InsertionMode insertion_mode() const { return m_insertion_mode; } - static bool is_special_tag(const FlyString& tag_name, const FlyString& namespace_); + static bool is_special_tag(FlyString const& tag_name, FlyString const& namespace_); HTMLTokenizer& tokenizer() { return m_tokenizer; } @@ -76,12 +76,12 @@ public: size_t script_nesting_level() const { return m_script_nesting_level; } private: - HTMLParser(DOM::Document&, StringView input, const String& encoding); + HTMLParser(DOM::Document&, StringView input, String const& encoding); HTMLParser(DOM::Document&); - const char* insertion_mode_name() const; + char const* insertion_mode_name() const; - DOM::QuirksMode which_quirks_mode(const HTMLToken&) const; + DOM::QuirksMode which_quirks_mode(HTMLToken const&) const; void handle_initial(HTMLToken&); void handle_before_html(HTMLToken&); @@ -111,7 +111,7 @@ private: void stop_parsing() { m_stop_parsing = true; } - void generate_implied_end_tags(const FlyString& exception = {}); + void generate_implied_end_tags(FlyString const& exception = {}); void generate_all_implied_end_tags_thoroughly(); NonnullRefPtr<DOM::Element> create_element_for(HTMLToken const&, FlyString const& namespace_, DOM::Node const& intended_parent); @@ -124,8 +124,8 @@ private: DOM::Text* find_character_insertion_node(); void flush_character_insertions(); - NonnullRefPtr<DOM::Element> insert_foreign_element(const HTMLToken&, const FlyString&); - NonnullRefPtr<DOM::Element> insert_html_element(const HTMLToken&); + NonnullRefPtr<DOM::Element> insert_foreign_element(HTMLToken const&, FlyString const&); + NonnullRefPtr<DOM::Element> insert_html_element(HTMLToken const&); DOM::Element& current_node(); DOM::Element& adjusted_current_node(); DOM::Element& node_before_current_node(); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.cpp b/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.cpp index 838f147df6..1d2453aad6 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.cpp @@ -31,7 +31,7 @@ bool ListOfActiveFormattingElements::contains(const DOM::Element& element) const return false; } -DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(const FlyString& tag_name) +DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(FlyString const& tag_name) { for (ssize_t i = m_entries.size() - 1; i >= 0; --i) { auto& entry = m_entries[i]; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.h b/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.h index 9476e28497..bf8293d1f5 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/ListOfActiveFormattingElements.h @@ -34,10 +34,10 @@ public: void remove(DOM::Element&); - const Vector<Entry>& entries() const { return m_entries; } + Vector<Entry> const& entries() const { return m_entries; } Vector<Entry>& entries() { return m_entries; } - DOM::Element* last_element_with_tag_name_before_marker(const FlyString& tag_name); + DOM::Element* last_element_with_tag_name_before_marker(FlyString const& tag_name); void clear_up_to_the_last_marker(); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.cpp b/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.cpp index f71b35cdaf..f67c64305d 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.cpp @@ -14,7 +14,7 @@ static Vector<FlyString> s_base_list { "applet", "caption", "html", "table", "td StackOfOpenElements::~StackOfOpenElements() = default; -bool StackOfOpenElements::has_in_scope_impl(const FlyString& tag_name, const Vector<FlyString>& list) const +bool StackOfOpenElements::has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const& list) const { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { auto& node = m_elements.at(i); @@ -26,12 +26,12 @@ bool StackOfOpenElements::has_in_scope_impl(const FlyString& tag_name, const Vec VERIFY_NOT_REACHED(); } -bool StackOfOpenElements::has_in_scope(const FlyString& tag_name) const +bool StackOfOpenElements::has_in_scope(FlyString const& tag_name) const { return has_in_scope_impl(tag_name, s_base_list); } -bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, const Vector<FlyString>& list) const +bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const& list) const { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { auto& node = m_elements.at(i); @@ -48,19 +48,19 @@ bool StackOfOpenElements::has_in_scope(const DOM::Element& target_node) const return has_in_scope_impl(target_node, s_base_list); } -bool StackOfOpenElements::has_in_button_scope(const FlyString& tag_name) const +bool StackOfOpenElements::has_in_button_scope(FlyString const& tag_name) const { auto list = s_base_list; list.append("button"); return has_in_scope_impl(tag_name, list); } -bool StackOfOpenElements::has_in_table_scope(const FlyString& tag_name) const +bool StackOfOpenElements::has_in_table_scope(FlyString const& tag_name) const { return has_in_scope_impl(tag_name, { "html", "table", "template" }); } -bool StackOfOpenElements::has_in_list_item_scope(const FlyString& tag_name) const +bool StackOfOpenElements::has_in_list_item_scope(FlyString const& tag_name) const { auto list = s_base_list; list.append("ol"); @@ -74,7 +74,7 @@ bool StackOfOpenElements::has_in_list_item_scope(const FlyString& tag_name) cons // - optgroup in the HTML namespace // - option in the HTML namespace // NOTE: In this case it's "all element types _except_" -bool StackOfOpenElements::has_in_select_scope(const FlyString& tag_name) const +bool StackOfOpenElements::has_in_select_scope(FlyString const& tag_name) const { // https://html.spec.whatwg.org/multipage/parsing.html#has-an-element-in-the-specific-scope for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { @@ -103,7 +103,7 @@ bool StackOfOpenElements::contains(const DOM::Element& element) const return false; } -bool StackOfOpenElements::contains(const FlyString& tag_name) const +bool StackOfOpenElements::contains(FlyString const& tag_name) const { for (auto& element_on_stack : m_elements) { if (element_on_stack.local_name() == tag_name) @@ -112,7 +112,7 @@ bool StackOfOpenElements::contains(const FlyString& tag_name) const return false; } -void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(const FlyString& tag_name) +void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(FlyString const& tag_name) { while (m_elements.last().local_name() != tag_name) (void)pop(); @@ -132,7 +132,7 @@ DOM::Element* StackOfOpenElements::topmost_special_node_below(const DOM::Element return found_element; } -StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_tag_name(const FlyString& tag_name) +StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_tag_name(FlyString const& tag_name) { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { auto& element = m_elements[i]; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.h b/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.h index 8c6baae04a..726d7018de 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/StackOfOpenElements.h @@ -36,21 +36,21 @@ public: const DOM::Element& current_node() const { return m_elements.last(); } DOM::Element& current_node() { return m_elements.last(); } - bool has_in_scope(const FlyString& tag_name) const; - bool has_in_button_scope(const FlyString& tag_name) const; - bool has_in_table_scope(const FlyString& tag_name) const; - bool has_in_list_item_scope(const FlyString& tag_name) const; - bool has_in_select_scope(const FlyString& tag_name) const; + bool has_in_scope(FlyString const& tag_name) const; + bool has_in_button_scope(FlyString const& tag_name) const; + bool has_in_table_scope(FlyString const& tag_name) const; + bool has_in_list_item_scope(FlyString const& tag_name) const; + bool has_in_select_scope(FlyString const& tag_name) const; bool has_in_scope(const DOM::Element&) const; bool contains(const DOM::Element&) const; - bool contains(const FlyString& tag_name) const; + bool contains(FlyString const& tag_name) const; - const NonnullRefPtrVector<DOM::Element>& elements() const { return m_elements; } + NonnullRefPtrVector<DOM::Element> const& elements() const { return m_elements; } NonnullRefPtrVector<DOM::Element>& elements() { return m_elements; } - void pop_until_an_element_with_tag_name_has_been_popped(const FlyString&); + void pop_until_an_element_with_tag_name_has_been_popped(FlyString const&); DOM::Element* topmost_special_node_below(const DOM::Element&); @@ -58,12 +58,12 @@ public: DOM::Element* element; ssize_t index; }; - LastElementResult last_element_with_tag_name(const FlyString&); + LastElementResult last_element_with_tag_name(FlyString const&); DOM::Element* element_immediately_above(DOM::Element const&); private: - bool has_in_scope_impl(const FlyString& tag_name, const Vector<FlyString>&) const; - bool has_in_scope_impl(const DOM::Element& target_node, const Vector<FlyString>&) const; + bool has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const&) const; + bool has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const&) const; NonnullRefPtrVector<DOM::Element> m_elements; }; diff --git a/Userland/Libraries/LibWeb/InProcessWebView.cpp b/Userland/Libraries/LibWeb/InProcessWebView.cpp index 688b0994cb..3ecd087454 100644 --- a/Userland/Libraries/LibWeb/InProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/InProcessWebView.cpp @@ -64,7 +64,7 @@ void InProcessWebView::page_did_layout() set_content_size(layout_root()->paint_box()->content_size().to_type<int>()); } -void InProcessWebView::page_did_change_title(const String& title) +void InProcessWebView::page_did_change_title(String const& title) { if (on_title_change) on_title_change(title); @@ -101,19 +101,19 @@ void InProcessWebView::page_did_request_cursor_change(Gfx::StandardCursor cursor set_override_cursor(cursor); } -void InProcessWebView::page_did_request_context_menu(const Gfx::IntPoint& content_position) +void InProcessWebView::page_did_request_context_menu(Gfx::IntPoint const& content_position) { if (on_context_menu_request) on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position))); } -void InProcessWebView::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const AK::URL& url, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) +void InProcessWebView::page_did_request_link_context_menu(Gfx::IntPoint const& content_position, const AK::URL& url, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers) { if (on_link_context_menu_request) on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position))); } -void InProcessWebView::page_did_request_image_context_menu(const Gfx::IntPoint& content_position, const AK::URL& url, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers, const Gfx::Bitmap* bitmap) +void InProcessWebView::page_did_request_image_context_menu(Gfx::IntPoint const& content_position, const AK::URL& url, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers, Gfx::Bitmap const* bitmap) { if (!on_image_context_menu_request) return; @@ -123,19 +123,19 @@ void InProcessWebView::page_did_request_image_context_menu(const Gfx::IntPoint& on_image_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)), move(shareable_bitmap)); } -void InProcessWebView::page_did_click_link(const AK::URL& url, const String& target, unsigned modifiers) +void InProcessWebView::page_did_click_link(const AK::URL& url, String const& target, unsigned modifiers) { if (on_link_click) on_link_click(url, target, modifiers); } -void InProcessWebView::page_did_middle_click_link(const AK::URL& url, const String& target, unsigned modifiers) +void InProcessWebView::page_did_middle_click_link(const AK::URL& url, String const& target, unsigned modifiers) { if (on_link_middle_click) on_link_middle_click(url, target, modifiers); } -void InProcessWebView::page_did_enter_tooltip_area([[maybe_unused]] const Gfx::IntPoint& content_position, const String& title) +void InProcessWebView::page_did_enter_tooltip_area([[maybe_unused]] Gfx::IntPoint const& content_position, String const& title) { GUI::Application::the()->show_tooltip(title, nullptr); } @@ -157,12 +157,12 @@ void InProcessWebView::page_did_unhover_link() on_link_hover({}); } -void InProcessWebView::page_did_invalidate(const Gfx::IntRect&) +void InProcessWebView::page_did_invalidate(Gfx::IntRect const&) { update(); } -void InProcessWebView::page_did_change_favicon(const Gfx::Bitmap& bitmap) +void InProcessWebView::page_did_change_favicon(Gfx::Bitmap const& bitmap) { if (on_favicon_change) on_favicon_change(bitmap); @@ -306,7 +306,7 @@ bool InProcessWebView::load(const AK::URL& url) return page().top_level_browsing_context().loader().load(url, FrameLoader::Type::Navigation); } -const Layout::InitialContainingBlock* InProcessWebView::layout_root() const +Layout::InitialContainingBlock const* InProcessWebView::layout_root() const { return document() ? document()->layout_node() : nullptr; } @@ -318,7 +318,7 @@ Layout::InitialContainingBlock* InProcessWebView::layout_root() return const_cast<Layout::InitialContainingBlock*>(document()->layout_node()); } -void InProcessWebView::page_did_request_scroll_into_view(const Gfx::IntRect& rect) +void InProcessWebView::page_did_request_scroll_into_view(Gfx::IntRect const& rect) { scroll_into_view(rect, true, true); set_override_cursor(Gfx::StandardCursor::None); @@ -360,18 +360,18 @@ void InProcessWebView::drop_event(GUI::DropEvent& event) AbstractScrollableWidget::drop_event(event); } -void InProcessWebView::page_did_request_alert(const String& message) +void InProcessWebView::page_did_request_alert(String const& message) { GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information); } -bool InProcessWebView::page_did_request_confirm(const String& message) +bool InProcessWebView::page_did_request_confirm(String const& message) { auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); return confirm_result == GUI::Dialog::ExecResult::ExecOK; } -String InProcessWebView::page_did_request_prompt(const String& message, const String& default_) +String InProcessWebView::page_did_request_prompt(String const& message, String const& default_) { String value { default_ }; if (GUI::InputBox::show(window(), value, message, "Prompt") == GUI::InputBox::ExecOK) @@ -386,7 +386,7 @@ String InProcessWebView::page_did_request_cookie(const AK::URL& url, Cookie::Sou return {}; } -void InProcessWebView::page_did_set_cookie(const AK::URL& url, const Cookie::ParsedCookie& cookie, Cookie::Source source) +void InProcessWebView::page_did_set_cookie(const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source) { if (on_set_cookie) on_set_cookie(url, cookie, source); diff --git a/Userland/Libraries/LibWeb/InProcessWebView.h b/Userland/Libraries/LibWeb/InProcessWebView.h index b51a384e2c..c62cd6fbdc 100644 --- a/Userland/Libraries/LibWeb/InProcessWebView.h +++ b/Userland/Libraries/LibWeb/InProcessWebView.h @@ -32,7 +32,7 @@ public: void set_document(DOM::Document*); - const Layout::InitialContainingBlock* layout_root() const; + Layout::InitialContainingBlock const* layout_root() const; Layout::InitialContainingBlock* layout_root(); void reload(); @@ -50,7 +50,7 @@ private: InProcessWebView(); Page& page() { return *m_page; } - const Page& page() const { return *m_page; } + Page const& page() const { return *m_page; } virtual void resize_event(GUI::ResizeEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; @@ -67,30 +67,30 @@ private: virtual Gfx::Palette palette() const override { return GUI::AbstractScrollableWidget::palette(); } virtual Gfx::IntRect screen_rect() const override { return GUI::Desktop::the().rect(); } virtual CSS::PreferredColorScheme preferred_color_scheme() const override { return m_preferred_color_scheme; } - virtual void page_did_change_title(const String&) override; + virtual void page_did_change_title(String const&) override; virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) override; virtual void page_did_start_loading(const AK::URL&) override; virtual void page_did_finish_loading(const AK::URL&) override; virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(Gfx::StandardCursor) override; - virtual void page_did_request_context_menu(const Gfx::IntPoint&) override; - virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const AK::URL&, const String& target, unsigned modifiers) override; - virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const AK::URL&, const String& target, unsigned modifiers, const Gfx::Bitmap*) override; - virtual void page_did_click_link(const AK::URL&, const String& target, unsigned modifiers) override; - virtual void page_did_middle_click_link(const AK::URL&, const String& target, unsigned modifiers) override; - virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override; + virtual void page_did_request_context_menu(Gfx::IntPoint const&) override; + virtual void page_did_request_link_context_menu(Gfx::IntPoint const&, const AK::URL&, String const& target, unsigned modifiers) override; + virtual void page_did_request_image_context_menu(Gfx::IntPoint const&, const AK::URL&, String const& target, unsigned modifiers, Gfx::Bitmap const*) override; + virtual void page_did_click_link(const AK::URL&, String const& target, unsigned modifiers) override; + virtual void page_did_middle_click_link(const AK::URL&, String const& target, unsigned modifiers) override; + virtual void page_did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override; virtual void page_did_leave_tooltip_area() override; virtual void page_did_hover_link(const AK::URL&) override; virtual void page_did_unhover_link() override; - virtual void page_did_invalidate(const Gfx::IntRect&) override; - virtual void page_did_change_favicon(const Gfx::Bitmap&) override; + virtual void page_did_invalidate(Gfx::IntRect const&) override; + virtual void page_did_change_favicon(Gfx::Bitmap const&) override; virtual void page_did_layout() override; - virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override; - virtual void page_did_request_alert(const String&) override; - virtual bool page_did_request_confirm(const String&) override; - virtual String page_did_request_prompt(const String&, const String&) override; + virtual void page_did_request_scroll_into_view(Gfx::IntRect const&) override; + virtual void page_did_request_alert(String const&) override; + virtual bool page_did_request_confirm(String const&) override; + virtual String page_did_request_prompt(String const&, String const&) override; virtual String page_did_request_cookie(const AK::URL&, Cookie::Source) override; - virtual void page_did_set_cookie(const AK::URL&, const Cookie::ParsedCookie&, Cookie::Source) override; + virtual void page_did_set_cookie(const AK::URL&, Cookie::ParsedCookie const&, Cookie::Source) override; void layout_and_sync_size(); diff --git a/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp b/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp index d958c55d3b..e46bbda70d 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockContainer.cpp @@ -27,7 +27,7 @@ bool BlockContainer::is_scrollable() const return computed_values().overflow_y() == CSS::Overflow::Scroll; } -void BlockContainer::set_scroll_offset(const Gfx::FloatPoint& offset) +void BlockContainer::set_scroll_offset(Gfx::FloatPoint const& offset) { // FIXME: If there is horizontal and vertical scroll ignore only part of the new offset if (offset.y() < 0 || m_scroll_offset == offset) diff --git a/Userland/Libraries/LibWeb/Layout/BlockContainer.h b/Userland/Libraries/LibWeb/Layout/BlockContainer.h index fbff185595..0735a45553 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockContainer.h +++ b/Userland/Libraries/LibWeb/Layout/BlockContainer.h @@ -19,13 +19,13 @@ public: virtual ~BlockContainer() override; BlockContainer* previous_sibling() { return verify_cast<BlockContainer>(Node::previous_sibling()); } - const BlockContainer* previous_sibling() const { return verify_cast<BlockContainer>(Node::previous_sibling()); } + BlockContainer const* previous_sibling() const { return verify_cast<BlockContainer>(Node::previous_sibling()); } BlockContainer* next_sibling() { return verify_cast<BlockContainer>(Node::next_sibling()); } - const BlockContainer* next_sibling() const { return verify_cast<BlockContainer>(Node::next_sibling()); } + BlockContainer const* next_sibling() const { return verify_cast<BlockContainer>(Node::next_sibling()); } bool is_scrollable() const; - const Gfx::FloatPoint& scroll_offset() const { return m_scroll_offset; } - void set_scroll_offset(const Gfx::FloatPoint&); + Gfx::FloatPoint const& scroll_offset() const { return m_scroll_offset; } + void set_scroll_offset(Gfx::FloatPoint const&); Painting::PaintableWithLines const* paint_box() const; diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index e8e4cc63eb..995af034dc 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -115,10 +115,10 @@ void BlockFormattingContext::compute_width(Box const& box, LayoutMode layout_mod auto margin_left = CSS::Length::make_auto(); auto margin_right = CSS::Length::make_auto(); - const auto padding_left = computed_values.padding().left.resolved(box, width_of_containing_block_as_length).resolved(box); - const auto padding_right = computed_values.padding().right.resolved(box, width_of_containing_block_as_length).resolved(box); + auto const padding_left = computed_values.padding().left.resolved(box, width_of_containing_block_as_length).resolved(box); + auto const padding_right = computed_values.padding().right.resolved(box, width_of_containing_block_as_length).resolved(box); - auto try_compute_width = [&](const auto& a_width) { + auto try_compute_width = [&](auto const& a_width) { CSS::Length width = a_width; margin_left = computed_values.margin().left.resolved(box, width_of_containing_block_as_length).resolved(box); margin_right = computed_values.margin().right.resolved(box, width_of_containing_block_as_length).resolved(box); @@ -253,8 +253,8 @@ void BlockFormattingContext::compute_width_for_floating_box(Box const& box, Layo auto margin_left = computed_values.margin().left.resolved(box, width_of_containing_block_as_length).resolved(box); auto margin_right = computed_values.margin().right.resolved(box, width_of_containing_block_as_length).resolved(box); - const auto padding_left = computed_values.padding().left.resolved(box, width_of_containing_block_as_length).resolved(box); - const auto padding_right = computed_values.padding().right.resolved(box, width_of_containing_block_as_length).resolved(box); + auto const padding_left = computed_values.padding().left.resolved(box, width_of_containing_block_as_length).resolved(box); + auto const padding_right = computed_values.padding().right.resolved(box, width_of_containing_block_as_length).resolved(box); // If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'. if (margin_left.is_auto()) diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 5dcd1dcfde..603aa176eb 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -29,7 +29,7 @@ FormattingContext::FormattingContext(Type type, FormattingState& state, Box cons FormattingContext::~FormattingContext() = default; -bool FormattingContext::creates_block_formatting_context(const Box& box) +bool FormattingContext::creates_block_formatting_context(Box const& box) { if (box.is_root_element()) return true; @@ -472,12 +472,12 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele auto margin_left = CSS::Length::make_auto(); auto margin_right = CSS::Length::make_auto(); - const auto border_left = computed_values.border_left().width; - const auto border_right = computed_values.border_right().width; - const auto padding_left = computed_values.padding().left.resolved(box, width_of_containing_block).to_px(box); - const auto padding_right = computed_values.padding().right.resolved(box, width_of_containing_block).to_px(box); + auto const border_left = computed_values.border_left().width; + auto const border_right = computed_values.border_right().width; + auto const padding_left = computed_values.padding().left.resolved(box, width_of_containing_block).to_px(box); + auto const padding_right = computed_values.padding().right.resolved(box, width_of_containing_block).to_px(box); - auto try_compute_width = [&](const auto& a_width) { + auto try_compute_width = [&](auto const& a_width) { margin_left = computed_values.margin().left.resolved(box, width_of_containing_block).resolved(box); margin_right = computed_values.margin().right.resolved(box, width_of_containing_block).resolved(box); diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.h b/Userland/Libraries/LibWeb/Layout/FormattingContext.h index da0a787241..fff8e18f28 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.h @@ -29,14 +29,14 @@ public: Box const& context_box() const { return m_context_box; } FormattingContext* parent() { return m_parent; } - const FormattingContext* parent() const { return m_parent; } + FormattingContext const* parent() const { return m_parent; } Type type() const { return m_type; } bool is_block_formatting_context() const { return type() == Type::Block; } virtual bool inhibits_floating() const { return false; } - static bool creates_block_formatting_context(const Box&); + static bool creates_block_formatting_context(Box const&); static float compute_width_for_replaced_element(FormattingState const&, ReplacedBox const&); static float compute_height_for_replaced_element(FormattingState const&, ReplacedBox const&); diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp index ebf27336a7..6063949272 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp @@ -12,7 +12,7 @@ namespace Web::Layout { -ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style, const ImageLoader& image_loader) +ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style, ImageLoader const& image_loader) : ReplacedBox(document, element, move(style)) , m_image_loader(image_loader) { diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.h b/Userland/Libraries/LibWeb/Layout/ImageBox.h index 44a493da48..f03ea9c723 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.h +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.h @@ -16,7 +16,7 @@ class ImageBox : public ReplacedBox , public HTML::BrowsingContext::ViewportClient { public: - ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&); + ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, ImageLoader const&); virtual ~ImageBox() override; virtual void prepare_for_replaced_layout() override; @@ -36,7 +36,7 @@ private: int preferred_width() const; int preferred_height() const; - const ImageLoader& m_image_loader; + ImageLoader const& m_image_loader; }; } diff --git a/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.cpp b/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.cpp index 8bb8b3582f..c76424dffe 100644 --- a/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.cpp +++ b/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.cpp @@ -78,13 +78,13 @@ void InitialContainingBlock::recompute_selection_states() }); } -void InitialContainingBlock::set_selection(const LayoutRange& selection) +void InitialContainingBlock::set_selection(LayoutRange const& selection) { m_selection = selection; recompute_selection_states(); } -void InitialContainingBlock::set_selection_end(const LayoutPosition& position) +void InitialContainingBlock::set_selection_end(LayoutPosition const& position) { m_selection.set_end(position); recompute_selection_states(); diff --git a/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h b/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h index 2c35b82f1c..5d54ada9c0 100644 --- a/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h +++ b/Userland/Libraries/LibWeb/Layout/InitialContainingBlock.h @@ -20,9 +20,9 @@ public: void paint_all_phases(PaintContext&); - const LayoutRange& selection() const { return m_selection; } - void set_selection(const LayoutRange&); - void set_selection_end(const LayoutPosition&); + LayoutRange const& selection() const { return m_selection; } + void set_selection(LayoutRange const&); + void set_selection_end(LayoutPosition const&); void build_stacking_context_tree_if_needed(); void recompute_selection_states(); diff --git a/Userland/Libraries/LibWeb/Layout/Label.cpp b/Userland/Libraries/LibWeb/Layout/Label.cpp index ece03ad1a1..fc8ef56649 100644 --- a/Userland/Libraries/LibWeb/Layout/Label.cpp +++ b/Userland/Libraries/LibWeb/Layout/Label.cpp @@ -65,7 +65,7 @@ void Label::handle_mousemove_on_label(Badge<Painting::TextPaintable>, Gfx::IntPo } } -bool Label::is_inside_associated_label(LabelableNode const& control, const Gfx::IntPoint& position) +bool Label::is_inside_associated_label(LabelableNode const& control, Gfx::IntPoint const& position) { if (auto* label = label_for_control_node(control); label) return enclosing_int_rect(label->paint_box()->absolute_rect()).contains(position); diff --git a/Userland/Libraries/LibWeb/Layout/Label.h b/Userland/Libraries/LibWeb/Layout/Label.h index 1cd942306a..5cee1a986c 100644 --- a/Userland/Libraries/LibWeb/Layout/Label.h +++ b/Userland/Libraries/LibWeb/Layout/Label.h @@ -22,9 +22,9 @@ public: const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); } HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); } - void handle_mousedown_on_label(Badge<Painting::TextPaintable>, const Gfx::IntPoint&, unsigned button); - void handle_mouseup_on_label(Badge<Painting::TextPaintable>, const Gfx::IntPoint&, unsigned button); - void handle_mousemove_on_label(Badge<Painting::TextPaintable>, const Gfx::IntPoint&, unsigned button); + void handle_mousedown_on_label(Badge<Painting::TextPaintable>, Gfx::IntPoint const&, unsigned button); + void handle_mouseup_on_label(Badge<Painting::TextPaintable>, Gfx::IntPoint const&, unsigned button); + void handle_mousemove_on_label(Badge<Painting::TextPaintable>, Gfx::IntPoint const&, unsigned button); LabelableNode* labeled_control(); diff --git a/Userland/Libraries/LibWeb/Layout/LayoutPosition.h b/Userland/Libraries/LibWeb/Layout/LayoutPosition.h index 7f5d221139..f924e75ebb 100644 --- a/Userland/Libraries/LibWeb/Layout/LayoutPosition.h +++ b/Userland/Libraries/LibWeb/Layout/LayoutPosition.h @@ -24,7 +24,7 @@ struct LayoutPosition { class LayoutRange { public: LayoutRange() = default; - LayoutRange(const LayoutPosition& start, const LayoutPosition& end) + LayoutRange(LayoutPosition const& start, LayoutPosition const& end) : m_start(start) , m_end(end) { @@ -32,18 +32,18 @@ public: bool is_valid() const { return m_start.layout_node && m_end.layout_node; } - void set(const LayoutPosition& start, const LayoutPosition& end) + void set(LayoutPosition const& start, LayoutPosition const& end) { m_start = start; m_end = end; } - void set_start(const LayoutPosition& start) { m_start = start; } - void set_end(const LayoutPosition& end) { m_end = end; } + void set_start(LayoutPosition const& start) { m_start = start; } + void set_end(LayoutPosition const& end) { m_end = end; } - const LayoutPosition& start() const { return m_start; } + LayoutPosition const& start() const { return m_start; } LayoutPosition& start() { return m_start; } - const LayoutPosition& end() const { return m_end; } + LayoutPosition const& end() const { return m_end; } LayoutPosition& end() { return m_end; } LayoutRange normalized() const; diff --git a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp index 795c4dad41..6945417dc3 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp +++ b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp @@ -65,7 +65,7 @@ int LineBoxFragment::text_index_at(float x) const return m_start + m_length; } -Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const +Gfx::FloatRect LineBoxFragment::selection_rect(Gfx::Font const& font) const { if (layout_node().selection_state() == Node::SelectionState::None) return {}; @@ -79,8 +79,8 @@ Gfx::FloatRect LineBoxFragment::selection_rect(const Gfx::Font& font) const if (!is<TextNode>(layout_node())) return {}; - const auto start_index = m_start; - const auto end_index = m_start + m_length; + auto const start_index = m_start; + auto const end_index = m_start + m_length; auto text = this->text(); if (layout_node().selection_state() == Node::SelectionState::StartAndEnd) { diff --git a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.h b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.h index 5338b36bee..2a34112309 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.h +++ b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.h @@ -40,14 +40,14 @@ public: const Gfx::FloatRect absolute_rect() const; Type type() const { return m_type; } - const Gfx::FloatPoint& offset() const { return m_offset; } - void set_offset(const Gfx::FloatPoint& offset) { m_offset = offset; } + Gfx::FloatPoint const& offset() const { return m_offset; } + void set_offset(Gfx::FloatPoint const& offset) { m_offset = offset; } // The baseline of a fragment is the number of pixels from the top to the text baseline. void set_baseline(float y) { m_baseline = y; } float baseline() const { return m_baseline; } - const Gfx::FloatSize& size() const { return m_size; } + Gfx::FloatSize const& size() const { return m_size; } void set_width(float width) { m_size.set_width(width); } void set_height(float height) { m_size.set_height(height); } float width() const { return m_size.width(); } @@ -65,7 +65,7 @@ public: int text_index_at(float x) const; - Gfx::FloatRect selection_rect(const Gfx::Font&) const; + Gfx::FloatRect selection_rect(Gfx::Font const&) const; float height_of_inline_level_box(FormattingState const&) const; float top_of_inline_level_box(FormattingState const&) const; diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 242275d5df..99803a25b0 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -54,7 +54,7 @@ bool Node::can_contain_boxes_with_position_absolute() const return computed_values().position() != CSS::Position::Static || is<InitialContainingBlock>(*this); } -const BlockContainer* Node::containing_block() const +BlockContainer const* Node::containing_block() const { if (is<TextNode>(*this)) return first_ancestor_of_type<BlockContainer>(); @@ -67,7 +67,7 @@ const BlockContainer* Node::containing_block() const ancestor = ancestor->parent(); while (ancestor && (!is<BlockContainer>(*ancestor) || ancestor->is_anonymous())) ancestor = ancestor->containing_block(); - return static_cast<const BlockContainer*>(ancestor); + return static_cast<BlockContainer const*>(ancestor); } if (position == CSS::Position::Fixed) @@ -102,7 +102,7 @@ HTML::BrowsingContext& Node::browsing_context() return *document().browsing_context(); } -const InitialContainingBlock& Node::root() const +InitialContainingBlock const& Node::root() const { VERIFY(document().layout_node()); return *document().layout_node(); diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index 0c7bccfbab..e562348cfd 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -57,7 +57,7 @@ public: HTML::BrowsingContext const& browsing_context() const; HTML::BrowsingContext& browsing_context(); - const InitialContainingBlock& root() const; + InitialContainingBlock const& root() const; InitialContainingBlock& root(); bool is_root_element() const; @@ -99,19 +99,19 @@ public: bool is_flex_item() const { return m_is_flex_item; } void set_flex_item(bool b) { m_is_flex_item = b; } - const BlockContainer* containing_block() const; - BlockContainer* containing_block() { return const_cast<BlockContainer*>(const_cast<const Node*>(this)->containing_block()); } + BlockContainer const* containing_block() const; + BlockContainer* containing_block() { return const_cast<BlockContainer*>(const_cast<Node const*>(this)->containing_block()); } bool establishes_stacking_context() const; bool can_contain_boxes_with_position_absolute() const; - const Gfx::Font& font() const; + Gfx::Font const& font() const; const CSS::ImmutableComputedValues& computed_values() const; float line_height() const; NodeWithStyle* parent(); - const NodeWithStyle* parent() const; + NodeWithStyle const* parent() const; void inserted_into(Node&) { } void removed_from(Node&) { } @@ -165,7 +165,7 @@ public: void apply_style(const CSS::StyleProperties&); - const Gfx::Font& font() const { return *m_font; } + Gfx::Font const& font() const { return *m_font; } float line_height() const { return m_line_height; } Vector<CSS::BackgroundLayerData> const& background_layers() const { return computed_values().background_layers(); } const CSS::ImageStyleValue* list_style_image() const { return m_list_style_image; } @@ -197,7 +197,7 @@ private: class NodeWithStyleAndBoxModelMetrics : public NodeWithStyle { public: BoxModelMetrics& box_model() { return m_box_model; } - const BoxModelMetrics& box_model() const { return m_box_model; } + BoxModelMetrics const& box_model() const { return m_box_model; } protected: NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style) @@ -214,17 +214,17 @@ private: BoxModelMetrics m_box_model; }; -inline const Gfx::Font& Node::font() const +inline Gfx::Font const& Node::font() const { if (m_has_style) - return static_cast<const NodeWithStyle*>(this)->font(); + return static_cast<NodeWithStyle const*>(this)->font(); return parent()->font(); } inline const CSS::ImmutableComputedValues& Node::computed_values() const { if (m_has_style) - return static_cast<const NodeWithStyle*>(this)->computed_values(); + return static_cast<NodeWithStyle const*>(this)->computed_values(); return parent()->computed_values(); } @@ -235,9 +235,9 @@ inline float Node::line_height() const return parent()->line_height(); } -inline const NodeWithStyle* Node::parent() const +inline NodeWithStyle const* Node::parent() const { - return static_cast<const NodeWithStyle*>(TreeNode<Node>::parent()); + return static_cast<NodeWithStyle const*>(TreeNode<Node>::parent()); } inline NodeWithStyle* Node::parent() diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.h b/Userland/Libraries/LibWeb/Layout/TableCellBox.h index ab78c133f4..3662c62fa0 100644 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.h +++ b/Userland/Libraries/LibWeb/Layout/TableCellBox.h @@ -17,7 +17,7 @@ public: virtual ~TableCellBox() override; TableCellBox* next_cell() { return next_sibling_of_type<TableCellBox>(); } - const TableCellBox* next_cell() const { return next_sibling_of_type<TableCellBox>(); } + TableCellBox const* next_cell() const { return next_sibling_of_type<TableCellBox>(); } size_t colspan() const; diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.h b/Userland/Libraries/LibWeb/Layout/TextNode.h index f468b87089..18e604edb4 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.h +++ b/Userland/Libraries/LibWeb/Layout/TextNode.h @@ -21,7 +21,7 @@ public: const DOM::Text& dom_node() const { return static_cast<const DOM::Text&>(*Node::dom_node()); } - const String& text_for_rendering() const { return m_text_for_rendering; } + String const& text_for_rendering() const { return m_text_for_rendering; } struct Chunk { Utf8View view; @@ -40,8 +40,8 @@ public: Optional<Chunk> try_commit_chunk(Utf8View::Iterator const& start, Utf8View::Iterator const& end, bool has_breaking_newline, bool must_commit = false) const; const LayoutMode m_layout_mode; - const bool m_wrap_lines; - const bool m_respect_linebreaks; + bool const m_wrap_lines; + bool const m_respect_linebreaks; Utf8View m_utf8_view; Utf8View::Iterator m_iterator; }; diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 38c60284f2..6795a1e3af 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -343,7 +343,7 @@ static bool is_table_track_group(CSS::Display display) || display.is_table_column_group(); } -static bool is_not_proper_table_child(const Node& node) +static bool is_not_proper_table_child(Node const& node) { if (!node.has_style()) return true; @@ -351,7 +351,7 @@ static bool is_not_proper_table_child(const Node& node) return !is_table_track_group(display) && !is_table_track(display) && !display.is_table_caption(); } -static bool is_not_table_row(const Node& node) +static bool is_not_table_row(Node const& node) { if (!node.has_style()) return true; @@ -359,7 +359,7 @@ static bool is_not_table_row(const Node& node) return !display.is_table_row(); } -static bool is_not_table_cell(const Node& node) +static bool is_not_table_cell(Node const& node) { if (!node.has_style()) return true; diff --git a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp index 8c3941d4e9..adce6815a4 100644 --- a/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp +++ b/Userland/Libraries/LibWeb/Loader/ContentFilter.cpp @@ -33,7 +33,7 @@ bool ContentFilter::is_filtered(const AK::URL& url) const return false; } -void ContentFilter::add_pattern(const String& pattern) +void ContentFilter::add_pattern(String const& pattern) { StringBuilder builder; if (!pattern.starts_with('*')) diff --git a/Userland/Libraries/LibWeb/Loader/ContentFilter.h b/Userland/Libraries/LibWeb/Loader/ContentFilter.h index ac7c45d66b..6295364e31 100644 --- a/Userland/Libraries/LibWeb/Loader/ContentFilter.h +++ b/Userland/Libraries/LibWeb/Loader/ContentFilter.h @@ -16,7 +16,7 @@ public: static ContentFilter& the(); bool is_filtered(const AK::URL&) const; - void add_pattern(const String&); + void add_pattern(String const&); private: ContentFilter(); diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 648fbb179a..e690c83155 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -39,7 +39,7 @@ FrameLoader::FrameLoader(HTML::BrowsingContext& browsing_context) FrameLoader::~FrameLoader() = default; -static bool build_markdown_document(DOM::Document& document, const ByteBuffer& data) +static bool build_markdown_document(DOM::Document& document, ByteBuffer const& data) { auto markdown_document = Markdown::Document::parse(data); if (!markdown_document) @@ -50,7 +50,7 @@ static bool build_markdown_document(DOM::Document& document, const ByteBuffer& d return true; } -static bool build_text_document(DOM::Document& document, const ByteBuffer& data) +static bool build_text_document(DOM::Document& document, ByteBuffer const& data) { auto html_element = document.create_element("html").release_value(); document.append_child(html_element); @@ -106,7 +106,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data return true; } -static bool build_gemini_document(DOM::Document& document, const ByteBuffer& data) +static bool build_gemini_document(DOM::Document& document, ByteBuffer const& data) { StringView gemini_data { data }; auto gemini_document = Gemini::Document::parse(gemini_data, document.url()); @@ -120,7 +120,7 @@ static bool build_gemini_document(DOM::Document& document, const ByteBuffer& dat return true; } -static bool build_xml_document(DOM::Document& document, const ByteBuffer& data) +static bool build_xml_document(DOM::Document& document, ByteBuffer const& data) { XML::Parser parser(data, { .resolve_external_resource = resolve_xml_resource }); @@ -129,7 +129,7 @@ static bool build_xml_document(DOM::Document& document, const ByteBuffer& data) return !result.is_error() && !builder.has_error(); } -bool FrameLoader::parse_document(DOM::Document& document, const ByteBuffer& data) +bool FrameLoader::parse_document(DOM::Document& document, ByteBuffer const& data) { auto& mime_type = document.content_type(); if (mime_type == "text/html" || mime_type == "image/svg+xml") { @@ -244,7 +244,7 @@ void FrameLoader::load_html(StringView html, const AK::URL& url) // FIXME: Use an actual templating engine (our own one when it's built, preferably // with a way to check these usages at compile time) -void FrameLoader::load_error_page(const AK::URL& failed_url, const String& error) +void FrameLoader::load_error_page(const AK::URL& failed_url, String const& error) { auto error_page_url = "file:///res/html/error.html"; ResourceLoader::the().load( @@ -285,7 +285,7 @@ void FrameLoader::store_response_cookies(AK::URL const& url, String const& cooki auto set_cookie_json_value = MUST(JsonValue::from_string(cookies)); VERIFY(set_cookie_json_value.type() == JsonValue::Type::Array); - for (const auto& set_cookie_entry : set_cookie_json_value.as_array().values()) { + for (auto const& set_cookie_entry : set_cookie_json_value.as_array().values()) { VERIFY(set_cookie_entry.type() == JsonValue::Type::String); auto cookie = Cookie::parse_cookie(set_cookie_entry.as_string()); diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.h b/Userland/Libraries/LibWeb/Loader/FrameLoader.h index 5fecbce26c..5a0eece55c 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.h +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.h @@ -39,9 +39,9 @@ private: virtual void resource_did_load() override; virtual void resource_did_fail() override; - void load_error_page(const AK::URL& failed_url, const String& error_message); + void load_error_page(const AK::URL& failed_url, String const& error_message); void load_favicon(RefPtr<Gfx::Bitmap> bitmap = nullptr); - bool parse_document(DOM::Document&, const ByteBuffer& data); + bool parse_document(DOM::Document&, ByteBuffer const& data); void store_response_cookies(AK::URL const& url, String const& cookies); diff --git a/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp b/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp index 3b1cd1d48f..b6d00ef408 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ImageLoader.cpp @@ -155,7 +155,7 @@ unsigned ImageLoader::height() const return bitmap(0) ? bitmap(0)->height() : 0; } -const Gfx::Bitmap* ImageLoader::bitmap(size_t frame_index) const +Gfx::Bitmap const* ImageLoader::bitmap(size_t frame_index) const { if (!resource()) return nullptr; diff --git a/Userland/Libraries/LibWeb/Loader/ImageLoader.h b/Userland/Libraries/LibWeb/Loader/ImageLoader.h index ad6ece9c71..23c5344b1f 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ImageLoader.h @@ -20,7 +20,7 @@ public: void load(const AK::URL&); - const Gfx::Bitmap* bitmap(size_t index) const; + Gfx::Bitmap const* bitmap(size_t index) const; size_t current_frame_index() const { return m_current_frame_index; } bool has_image() const; diff --git a/Userland/Libraries/LibWeb/Loader/ImageResource.cpp b/Userland/Libraries/LibWeb/Loader/ImageResource.cpp index 76769c7828..874f4d4ee4 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageResource.cpp +++ b/Userland/Libraries/LibWeb/Loader/ImageResource.cpp @@ -15,7 +15,7 @@ NonnullRefPtr<ImageResource> ImageResource::convert_from_resource(Resource& reso return adopt_ref(*new ImageResource(resource)); } -ImageResource::ImageResource(const LoadRequest& request) +ImageResource::ImageResource(LoadRequest const& request) : Resource(Type::Image, request) { } @@ -63,7 +63,7 @@ void ImageResource::decode_if_needed() const m_has_attempted_decode = true; } -const Gfx::Bitmap* ImageResource::bitmap(size_t frame_index) const +Gfx::Bitmap const* ImageResource::bitmap(size_t frame_index) const { decode_if_needed(); if (frame_index >= m_decoded_frames.size()) diff --git a/Userland/Libraries/LibWeb/Loader/ImageResource.h b/Userland/Libraries/LibWeb/Loader/ImageResource.h index c740010a87..0823a19a74 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageResource.h +++ b/Userland/Libraries/LibWeb/Loader/ImageResource.h @@ -23,7 +23,7 @@ public: size_t duration { 0 }; }; - const Gfx::Bitmap* bitmap(size_t frame_index = 0) const; + Gfx::Bitmap const* bitmap(size_t frame_index = 0) const; int frame_duration(size_t frame_index) const; size_t frame_count() const { @@ -44,7 +44,7 @@ public: void update_volatility(); private: - explicit ImageResource(const LoadRequest&); + explicit ImageResource(LoadRequest const&); explicit ImageResource(Resource&); void decode_if_needed() const; @@ -63,7 +63,7 @@ public: protected: ImageResource* resource() { return static_cast<ImageResource*>(ResourceClient::resource()); } - const ImageResource* resource() const { return static_cast<const ImageResource*>(ResourceClient::resource()); } + ImageResource const* resource() const { return static_cast<ImageResource const*>(ResourceClient::resource()); } private: virtual Resource::Type client_type() const override { return Resource::Type::Image; } diff --git a/Userland/Libraries/LibWeb/Loader/LoadRequest.h b/Userland/Libraries/LibWeb/Loader/LoadRequest.h index d220fddac9..43e9bd3db7 100644 --- a/Userland/Libraries/LibWeb/Loader/LoadRequest.h +++ b/Userland/Libraries/LibWeb/Loader/LoadRequest.h @@ -28,24 +28,24 @@ public: const AK::URL& url() const { return m_url; } void set_url(const AK::URL& url) { m_url = url; } - const String& method() const { return m_method; } - void set_method(const String& method) { m_method = method; } + String const& method() const { return m_method; } + void set_method(String const& method) { m_method = method; } - const ByteBuffer& body() const { return m_body; } - void set_body(const ByteBuffer& body) { m_body = body; } + ByteBuffer const& body() const { return m_body; } + void set_body(ByteBuffer const& body) { m_body = body; } void start_timer() { m_load_timer.start(); }; Time load_time() const { return m_load_timer.elapsed_time(); } unsigned hash() const { - auto body_hash = string_hash((const char*)m_body.data(), m_body.size()); + auto body_hash = string_hash((char const*)m_body.data(), m_body.size()); auto body_and_headers_hash = pair_int_hash(body_hash, m_headers.hash()); auto url_and_method_hash = pair_int_hash(m_url.to_string().hash(), m_method.hash()); return pair_int_hash(body_and_headers_hash, url_and_method_hash); } - bool operator==(const LoadRequest& other) const + bool operator==(LoadRequest const& other) const { if (m_headers.size() != other.m_headers.size()) return false; @@ -59,10 +59,10 @@ public: return m_url == other.m_url && m_method == other.m_method && m_body == other.m_body; } - void set_header(const String& name, const String& value) { m_headers.set(name, value); } - String header(const String& name) const { return m_headers.get(name).value_or({}); } + void set_header(String const& name, String const& value) { m_headers.set(name, value); } + String header(String const& name) const { return m_headers.get(name).value_or({}); } - const HashMap<String, String>& headers() const { return m_headers; } + HashMap<String, String> const& headers() const { return m_headers; } private: AK::URL m_url; @@ -78,7 +78,7 @@ namespace AK { template<> struct Traits<Web::LoadRequest> : public GenericTraits<Web::LoadRequest> { - static unsigned hash(const Web::LoadRequest& request) { return request.hash(); } + static unsigned hash(Web::LoadRequest const& request) { return request.hash(); } }; } diff --git a/Userland/Libraries/LibWeb/Loader/Resource.cpp b/Userland/Libraries/LibWeb/Loader/Resource.cpp index 6682756480..525992697a 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.cpp +++ b/Userland/Libraries/LibWeb/Loader/Resource.cpp @@ -15,14 +15,14 @@ namespace Web { -NonnullRefPtr<Resource> Resource::create(Badge<ResourceLoader>, Type type, const LoadRequest& request) +NonnullRefPtr<Resource> Resource::create(Badge<ResourceLoader>, Type type, LoadRequest const& request) { if (type == Type::Image) return adopt_ref(*new ImageResource(request)); return adopt_ref(*new Resource(type, request)); } -Resource::Resource(Type type, const LoadRequest& request) +Resource::Resource(Type type, LoadRequest const& request) : m_request(request) , m_type(type) { @@ -57,7 +57,7 @@ void Resource::for_each_client(Function<void(ResourceClient&)> callback) } } -static Optional<String> encoding_from_content_type(const String& content_type) +static Optional<String> encoding_from_content_type(String const& content_type) { auto offset = content_type.find("charset="sv); if (offset.has_value()) { @@ -72,7 +72,7 @@ static Optional<String> encoding_from_content_type(const String& content_type) return {}; } -static String mime_type_from_content_type(const String& content_type) +static String mime_type_from_content_type(String const& content_type) { auto offset = content_type.find(';'); if (offset.has_value()) @@ -86,7 +86,7 @@ static bool is_valid_encoding(String const& encoding) return TextCodec::decoder_for(encoding); } -void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap<String, String, CaseInsensitiveStringTraits>& headers, Optional<u32> status_code) +void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<String, String, CaseInsensitiveStringTraits> const& headers, Optional<u32> status_code) { VERIFY(!m_loaded); // FIXME: Handle OOM failure. @@ -131,7 +131,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap }); } -void Resource::did_fail(Badge<ResourceLoader>, const String& error, Optional<u32> status_code) +void Resource::did_fail(Badge<ResourceLoader>, String const& error, Optional<u32> status_code) { m_error = error; m_status_code = move(status_code); diff --git a/Userland/Libraries/LibWeb/Loader/Resource.h b/Userland/Libraries/LibWeb/Loader/Resource.h index ad77e9e611..40edf5e41a 100644 --- a/Userland/Libraries/LibWeb/Loader/Resource.h +++ b/Userland/Libraries/LibWeb/Loader/Resource.h @@ -32,7 +32,7 @@ public: Image, }; - static NonnullRefPtr<Resource> create(Badge<ResourceLoader>, Type, const LoadRequest&); + static NonnullRefPtr<Resource> create(Badge<ResourceLoader>, Type, LoadRequest const&); virtual ~Resource(); Type type() const { return m_type; } @@ -40,14 +40,14 @@ public: bool is_loaded() const { return m_loaded; } bool is_failed() const { return m_failed; } - const String& error() const { return m_error; } + String const& error() const { return m_error; } bool has_encoded_data() const { return !m_encoded_data.is_empty(); } const AK::URL& url() const { return m_request.url(); } - const ByteBuffer& encoded_data() const { return m_encoded_data; } + ByteBuffer const& encoded_data() const { return m_encoded_data; } - const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers() const { return m_response_headers; } + HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; } [[nodiscard]] Optional<u32> status_code() const { return m_status_code; } @@ -55,16 +55,16 @@ public: void unregister_client(Badge<ResourceClient>, ResourceClient&); bool has_encoding() const { return m_encoding.has_value(); } - const Optional<String>& encoding() const { return m_encoding; } - const String& mime_type() const { return m_mime_type; } + Optional<String> const& encoding() const { return m_encoding; } + String const& mime_type() const { return m_mime_type; } void for_each_client(Function<void(ResourceClient&)>); - void did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap<String, String, CaseInsensitiveStringTraits>& headers, Optional<u32> status_code); - void did_fail(Badge<ResourceLoader>, const String& error, Optional<u32> status_code); + void did_load(Badge<ResourceLoader>, ReadonlyBytes data, HashMap<String, String, CaseInsensitiveStringTraits> const& headers, Optional<u32> status_code); + void did_fail(Badge<ResourceLoader>, String const& error, Optional<u32> status_code); protected: - explicit Resource(Type, const LoadRequest&); + explicit Resource(Type, LoadRequest const&); Resource(Type, Resource&); private: @@ -93,7 +93,7 @@ protected: virtual Resource::Type client_type() const { return Resource::Type::Generic; } Resource* resource() { return m_resource; } - const Resource* resource() const { return m_resource; } + Resource const* resource() const { return m_resource; } void set_resource(Resource*); private: diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 327eed13a4..737598cc3d 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -41,7 +41,7 @@ ResourceLoader::ResourceLoader(NonnullRefPtr<Protocol::RequestClient> protocol_c { } -void ResourceLoader::load_sync(LoadRequest& request, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback) +void ResourceLoader::load_sync(LoadRequest& request, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback) { Core::EventLoop loop; @@ -123,7 +123,7 @@ static void emit_signpost(String const& message, int id) static size_t resource_id = 0; -void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback) +void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback) { auto& url = request.url(); request.start_timer(); @@ -133,13 +133,13 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, con emit_signpost(String::formatted("Starting load: {}", url_for_logging), id); dbgln("ResourceLoader: Starting load of: \"{}\"", url_for_logging); - const auto log_success = [url_for_logging, id](const auto& request) { + auto const log_success = [url_for_logging, id](auto const& request) { auto load_time_ms = request.load_time().to_milliseconds(); emit_signpost(String::formatted("Finished load: {}", url_for_logging), id); dbgln("ResourceLoader: Finished load of: \"{}\", Duration: {}ms", url_for_logging, load_time_ms); }; - const auto log_failure = [url_for_logging, id](const auto& request, const auto error_message) { + auto const log_failure = [url_for_logging, id](auto const& request, auto const error_message) { auto load_time_ms = request.load_time().to_milliseconds(); emit_signpost(String::formatted("Failed load: {}", url_for_logging), id); dbgln("ResourceLoader: Failed load of: \"{}\", \033[31;1mError: {}\033[0m, Duration: {}ms", url_for_logging, error_message, load_time_ms); @@ -267,7 +267,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, con error_callback(not_implemented_error, {}); } -void ResourceLoader::load(const AK::URL& url, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback) +void ResourceLoader::load(const AK::URL& url, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback) { LoadRequest request; request.set_url(url); diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h index 4d31d9f9f3..0f3f7f592c 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h @@ -33,9 +33,9 @@ public: RefPtr<Resource> load_resource(Resource::Type, LoadRequest&); - void load(LoadRequest&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); - void load(const AK::URL&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); - void load_sync(LoadRequest&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); + void load(LoadRequest&, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback = nullptr); + void load(const AK::URL&, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback = nullptr); + void load_sync(LoadRequest&, Function<void(ReadonlyBytes, HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> status_code)> success_callback, Function<void(String const&, Optional<u32> status_code)> error_callback = nullptr); void prefetch_dns(AK::URL const&); void preconnect(AK::URL const&); @@ -46,8 +46,8 @@ public: Protocol::RequestClient& protocol_client() { return *m_protocol_client; } - const String& user_agent() const { return m_user_agent; } - void set_user_agent(const String& user_agent) { m_user_agent = user_agent; } + String const& user_agent() const { return m_user_agent; } + void set_user_agent(String const& user_agent) { m_user_agent = user_agent; } void clear_cache(); void evict_from_cache(LoadRequest const&); diff --git a/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp b/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp index ae13e676de..7d36522b53 100644 --- a/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp +++ b/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp @@ -56,7 +56,7 @@ Optional<MimeType> MimeType::from_string(StringView string) // https://fetch.spec.whatwg.org/#http-whitespace // HTTP whitespace is U+000A LF, U+000D CR, or an HTTP tab or space. // An HTTP tab or space is U+0009 TAB or U+0020 SPACE. - constexpr const char* http_whitespace = "\n\r\t "; + constexpr char const* http_whitespace = "\n\r\t "; // 1. Remove any leading and trailing HTTP whitespace from input. auto trimmed_string = string.trim(http_whitespace, TrimMode::Both); diff --git a/Userland/Libraries/LibWeb/Origin.h b/Userland/Libraries/LibWeb/Origin.h index e89be3f9a2..115203ebff 100644 --- a/Userland/Libraries/LibWeb/Origin.h +++ b/Userland/Libraries/LibWeb/Origin.h @@ -14,7 +14,7 @@ namespace Web { class Origin { public: Origin() = default; - Origin(const String& protocol, const String& host, u16 port) + Origin(String const& protocol, String const& host, u16 port) : m_protocol(protocol) , m_host(host) , m_port(port) @@ -24,8 +24,8 @@ public: // https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque bool is_opaque() const { return m_protocol.is_null() && m_host.is_null() && m_port == 0; } - const String& protocol() const { return m_protocol; } - const String& host() const { return m_host; } + String const& protocol() const { return m_protocol; } + String const& host() const { return m_host; } u16 port() const { return m_port; } // https://html.spec.whatwg.org/multipage/origin.html#same-origin diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index 1b838b3691..e3dd13ac99 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -213,7 +213,7 @@ void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 b } } -void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, [[maybe_unused]] const Gfx::IntRect& content_rect) +void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, [[maybe_unused]] Gfx::IntRect const& content_rect) { request_repaint(); } @@ -228,12 +228,12 @@ void OutOfProcessWebView::notify_server_did_request_cursor_change(Badge<WebConte set_override_cursor(cursor); } -void OutOfProcessWebView::notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size) +void OutOfProcessWebView::notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize const& content_size) { set_content_size(content_size); } -void OutOfProcessWebView::notify_server_did_change_title(Badge<WebContentClient>, const String& title) +void OutOfProcessWebView::notify_server_did_change_title(Badge<WebContentClient>, String const& title) { if (on_title_change) on_title_change(title); @@ -251,12 +251,12 @@ void OutOfProcessWebView::notify_server_did_request_scroll_to(Badge<WebContentCl vertical_scrollbar().set_value(scroll_position.y()); } -void OutOfProcessWebView::notify_server_did_request_scroll_into_view(Badge<WebContentClient>, const Gfx::IntRect& rect) +void OutOfProcessWebView::notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const& rect) { scroll_into_view(rect, true, true); } -void OutOfProcessWebView::notify_server_did_enter_tooltip_area(Badge<WebContentClient>, const Gfx::IntPoint&, const String& title) +void OutOfProcessWebView::notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint const&, String const& title) { GUI::Application::the()->show_tooltip(title, nullptr); } @@ -279,13 +279,13 @@ void OutOfProcessWebView::notify_server_did_unhover_link(Badge<WebContentClient> on_link_hover({}); } -void OutOfProcessWebView::notify_server_did_click_link(Badge<WebContentClient>, const AK::URL& url, const String& target, unsigned int modifiers) +void OutOfProcessWebView::notify_server_did_click_link(Badge<WebContentClient>, const AK::URL& url, String const& target, unsigned int modifiers) { if (on_link_click) on_link_click(url, target, modifiers); } -void OutOfProcessWebView::notify_server_did_middle_click_link(Badge<WebContentClient>, const AK::URL& url, const String& target, unsigned int modifiers) +void OutOfProcessWebView::notify_server_did_middle_click_link(Badge<WebContentClient>, const AK::URL& url, String const& target, unsigned int modifiers) { if (on_link_middle_click) on_link_middle_click(url, target, modifiers); @@ -303,36 +303,36 @@ void OutOfProcessWebView::notify_server_did_finish_loading(Badge<WebContentClien on_load_finish(url); } -void OutOfProcessWebView::notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position) +void OutOfProcessWebView::notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position) { if (on_context_menu_request) on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position))); } -void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position, const AK::URL& url, const String&, unsigned) +void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position, const AK::URL& url, String const&, unsigned) { if (on_link_context_menu_request) on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position))); } -void OutOfProcessWebView::notify_server_did_request_image_context_menu(Badge<WebContentClient>, const Gfx::IntPoint& content_position, const AK::URL& url, const String&, unsigned, const Gfx::ShareableBitmap& bitmap) +void OutOfProcessWebView::notify_server_did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position, const AK::URL& url, String const&, unsigned, Gfx::ShareableBitmap const& bitmap) { if (on_image_context_menu_request) on_image_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)), bitmap); } -void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, const String& message) +void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message) { GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information); } -bool OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, const String& message) +bool OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) { auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); return confirm_result == GUI::Dialog::ExecResult::ExecOK; } -String OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, const String& message, const String& default_) +String OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) { String response { default_ }; if (GUI::InputBox::show(window(), response, message, "Prompt") == GUI::InputBox::ExecOK) @@ -340,13 +340,13 @@ String OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentCli return {}; } -void OutOfProcessWebView::notify_server_did_get_source(const AK::URL& url, const String& source) +void OutOfProcessWebView::notify_server_did_get_source(const AK::URL& url, String const& source) { if (on_get_source) on_get_source(url, source); } -void OutOfProcessWebView::notify_server_did_get_dom_tree(const String& dom_tree) +void OutOfProcessWebView::notify_server_did_get_dom_tree(String const& dom_tree) { if (on_get_dom_tree) on_get_dom_tree(dom_tree); @@ -364,13 +364,13 @@ void OutOfProcessWebView::notify_server_did_output_js_console_message(i32 messag on_js_console_new_message(message_index); } -void OutOfProcessWebView::notify_server_did_get_js_console_messages(i32 start_index, const Vector<String>& message_types, const Vector<String>& messages) +void OutOfProcessWebView::notify_server_did_get_js_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages) { if (on_get_js_console_messages) on_get_js_console_messages(start_index, message_types, messages); } -void OutOfProcessWebView::notify_server_did_change_favicon(const Gfx::Bitmap& favicon) +void OutOfProcessWebView::notify_server_did_change_favicon(Gfx::Bitmap const& favicon) { if (on_favicon_change) on_favicon_change(favicon); @@ -383,7 +383,7 @@ String OutOfProcessWebView::notify_server_did_request_cookie(Badge<WebContentCli return {}; } -void OutOfProcessWebView::notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, const Cookie::ParsedCookie& cookie, Cookie::Source source) +void OutOfProcessWebView::notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source) { if (on_set_cookie) on_set_cookie(url, cookie, source); @@ -422,7 +422,7 @@ WebContentClient& OutOfProcessWebView::client() return *m_client_state.client; } -void OutOfProcessWebView::debug_request(const String& request, const String& argument) +void OutOfProcessWebView::debug_request(String const& request, String const& argument) { client().async_debug_request(request, argument); } @@ -460,7 +460,7 @@ i32 OutOfProcessWebView::get_hovered_node_id() return client().get_hovered_node_id(); } -void OutOfProcessWebView::js_console_input(const String& js_source) +void OutOfProcessWebView::js_console_input(String const& js_source) { client().async_js_console_input(js_source); } diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h index a80c757e3c..f996ae2116 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h @@ -31,7 +31,7 @@ public: void load_html(StringView, const AK::URL&); void load_empty_document(); - void debug_request(const String& request, const String& argument = {}); + void debug_request(String const& request, String const& argument = {}); void get_source(); void inspect_dom_tree(); @@ -45,7 +45,7 @@ public: void clear_inspected_dom_node(); i32 get_hovered_node_id(); - void js_console_input(const String& js_source); + void js_console_input(String const& js_source); void js_console_request_messages(i32 start_index); void run_javascript(StringView); @@ -58,37 +58,37 @@ public: void set_content_filters(Vector<String>); void set_preferred_color_scheme(Web::CSS::PreferredColorScheme); - void notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size); + void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize const& content_size); void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id); - void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, const Gfx::IntRect&); + void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, Gfx::IntRect const&); void notify_server_did_change_selection(Badge<WebContentClient>); void notify_server_did_request_cursor_change(Badge<WebContentClient>, Gfx::StandardCursor cursor); - void notify_server_did_change_title(Badge<WebContentClient>, const String&); + void notify_server_did_change_title(Badge<WebContentClient>, String const&); void notify_server_did_request_scroll(Badge<WebContentClient>, i32, i32); void notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint const&); - void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, const Gfx::IntRect&); - void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, const Gfx::IntPoint&, const String&); + void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&); + void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint const&, String const&); void notify_server_did_leave_tooltip_area(Badge<WebContentClient>); void notify_server_did_hover_link(Badge<WebContentClient>, const AK::URL&); void notify_server_did_unhover_link(Badge<WebContentClient>); - void notify_server_did_click_link(Badge<WebContentClient>, const AK::URL&, const String& target, unsigned modifiers); - void notify_server_did_middle_click_link(Badge<WebContentClient>, const AK::URL&, const String& target, unsigned modifiers); + void notify_server_did_click_link(Badge<WebContentClient>, const AK::URL&, String const& target, unsigned modifiers); + void notify_server_did_middle_click_link(Badge<WebContentClient>, const AK::URL&, String const& target, unsigned modifiers); void notify_server_did_start_loading(Badge<WebContentClient>, const AK::URL&); void notify_server_did_finish_loading(Badge<WebContentClient>, const AK::URL&); - void notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&); - void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const AK::URL&, const String& target, unsigned modifiers); - void notify_server_did_request_image_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const AK::URL&, const String& target, unsigned modifiers, const Gfx::ShareableBitmap&); - void notify_server_did_request_alert(Badge<WebContentClient>, const String& message); - bool notify_server_did_request_confirm(Badge<WebContentClient>, const String& message); - String notify_server_did_request_prompt(Badge<WebContentClient>, const String& message, const String& default_); - void notify_server_did_get_source(const AK::URL& url, const String& source); - void notify_server_did_get_dom_tree(const String& dom_tree); + void notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint const&); + void notify_server_did_request_link_context_menu(Badge<WebContentClient>, Gfx::IntPoint const&, const AK::URL&, String const& target, unsigned modifiers); + void notify_server_did_request_image_context_menu(Badge<WebContentClient>, Gfx::IntPoint const&, const AK::URL&, String const& target, unsigned modifiers, Gfx::ShareableBitmap const&); + void notify_server_did_request_alert(Badge<WebContentClient>, String const& message); + bool notify_server_did_request_confirm(Badge<WebContentClient>, String const& message); + String notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_); + void notify_server_did_get_source(const AK::URL& url, String const& source); + void notify_server_did_get_dom_tree(String const& dom_tree); void notify_server_did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing); void notify_server_did_output_js_console_message(i32 message_index); void notify_server_did_get_js_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages); - void notify_server_did_change_favicon(const Gfx::Bitmap& favicon); + void notify_server_did_change_favicon(Gfx::Bitmap const& favicon); String notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::Source source); - void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, const Cookie::ParsedCookie& cookie, Cookie::Source source); + void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source); void notify_server_did_update_resource_count(i32 count_waiting); private: diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 8ac8a32fed..4f92731e6e 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -80,7 +80,7 @@ static Gfx::StandardCursor cursor_css_to_gfx(Optional<CSS::Cursor> cursor) } } -static Gfx::IntPoint compute_mouse_event_offset(const Gfx::IntPoint& position, const Layout::Node& layout_node) +static Gfx::IntPoint compute_mouse_event_offset(Gfx::IntPoint const& position, Layout::Node const& layout_node) { auto top_left_of_layout_node = layout_node.box_type_agnostic_position(); return { @@ -97,7 +97,7 @@ EventHandler::EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext& EventHandler::~EventHandler() = default; -const Layout::InitialContainingBlock* EventHandler::layout_root() const +Layout::InitialContainingBlock const* EventHandler::layout_root() const { if (!m_browsing_context.active_document()) return nullptr; @@ -125,7 +125,7 @@ Painting::PaintableBox const* EventHandler::paint_root() const return const_cast<Painting::PaintableBox*>(m_browsing_context.active_document()->paint_box()); } -bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int buttons, unsigned int modifiers, int wheel_delta_x, int wheel_delta_y) +bool EventHandler::handle_mousewheel(Gfx::IntPoint const& position, unsigned int buttons, unsigned int modifiers, int wheel_delta_x, int wheel_delta_y) { if (m_browsing_context.active_document()) m_browsing_context.active_document()->update_layout(); @@ -150,7 +150,7 @@ bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int return false; } -bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) +bool EventHandler::handle_mouseup(Gfx::IntPoint const& position, unsigned button, unsigned modifiers) { if (m_browsing_context.active_document()) m_browsing_context.active_document()->update_layout(); @@ -247,7 +247,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button return handled_event; } -bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) +bool EventHandler::handle_mousedown(Gfx::IntPoint const& position, unsigned button, unsigned modifiers) { if (m_browsing_context.active_document()) m_browsing_context.active_document()->update_layout(); @@ -341,7 +341,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt return true; } -bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers) +bool EventHandler::handle_mousemove(Gfx::IntPoint const& position, unsigned buttons, unsigned modifiers) { if (m_browsing_context.active_document()) m_browsing_context.active_document()->update_layout(); diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.h b/Userland/Libraries/LibWeb/Page/EventHandler.h index c2244f9b46..255d2503ae 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.h +++ b/Userland/Libraries/LibWeb/Page/EventHandler.h @@ -22,10 +22,10 @@ public: explicit EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&); ~EventHandler(); - bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers); - bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers); - bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); - bool handle_mousewheel(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); + bool handle_mouseup(Gfx::IntPoint const&, unsigned button, unsigned modifiers); + bool handle_mousedown(Gfx::IntPoint const&, unsigned button, unsigned modifiers); + bool handle_mousemove(Gfx::IntPoint const&, unsigned buttons, unsigned modifiers); + bool handle_mousewheel(Gfx::IntPoint const&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); bool handle_keydown(KeyCode, unsigned modifiers, u32 code_point); bool handle_keyup(KeyCode, unsigned modifiers, u32 code_point); @@ -39,7 +39,7 @@ private: bool focus_previous_element(); Layout::InitialContainingBlock* layout_root(); - const Layout::InitialContainingBlock* layout_root() const; + Layout::InitialContainingBlock const* layout_root() const; Painting::PaintableBox* paint_root(); Painting::PaintableBox const* paint_root() const; diff --git a/Userland/Libraries/LibWeb/Page/Page.cpp b/Userland/Libraries/LibWeb/Page/Page.cpp index 70e8f90c6c..98f748d40a 100644 --- a/Userland/Libraries/LibWeb/Page/Page.cpp +++ b/Userland/Libraries/LibWeb/Page/Page.cpp @@ -59,22 +59,22 @@ CSS::PreferredColorScheme Page::preferred_color_scheme() const return m_client.preferred_color_scheme(); } -bool Page::handle_mousewheel(const Gfx::IntPoint& position, unsigned button, unsigned modifiers, int wheel_delta_x, int wheel_delta_y) +bool Page::handle_mousewheel(Gfx::IntPoint const& position, unsigned button, unsigned modifiers, int wheel_delta_x, int wheel_delta_y) { return top_level_browsing_context().event_handler().handle_mousewheel(position, button, modifiers, wheel_delta_x, wheel_delta_y); } -bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) +bool Page::handle_mouseup(Gfx::IntPoint const& position, unsigned button, unsigned modifiers) { return top_level_browsing_context().event_handler().handle_mouseup(position, button, modifiers); } -bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) +bool Page::handle_mousedown(Gfx::IntPoint const& position, unsigned button, unsigned modifiers) { return top_level_browsing_context().event_handler().handle_mousedown(position, button, modifiers); } -bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers) +bool Page::handle_mousemove(Gfx::IntPoint const& position, unsigned buttons, unsigned modifiers) { return top_level_browsing_context().event_handler().handle_mousemove(position, buttons, modifiers); } diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index 3bfe12b0b7..cbf6b1e35b 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -32,7 +32,7 @@ public: ~Page(); PageClient& client() { return m_client; } - const PageClient& client() const { return m_client; } + PageClient const& client() const { return m_client; } HTML::BrowsingContext& top_level_browsing_context() { return *m_top_level_browsing_context; } HTML::BrowsingContext const& top_level_browsing_context() const { return *m_top_level_browsing_context; } @@ -47,10 +47,10 @@ public: void load_html(StringView, const AK::URL&); - bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers); - bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers); - bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); - bool handle_mousewheel(const Gfx::IntPoint&, unsigned button, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); + bool handle_mouseup(Gfx::IntPoint const&, unsigned button, unsigned modifiers); + bool handle_mousedown(Gfx::IntPoint const&, unsigned button, unsigned modifiers); + bool handle_mousemove(Gfx::IntPoint const&, unsigned buttons, unsigned modifiers); + bool handle_mousewheel(Gfx::IntPoint const&, unsigned button, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); bool handle_keydown(KeyCode, unsigned modifiers, u32 code_point); bool handle_keyup(KeyCode, unsigned modifiers, u32 code_point); @@ -83,31 +83,31 @@ public: virtual Gfx::IntRect screen_rect() const = 0; virtual CSS::PreferredColorScheme preferred_color_scheme() const = 0; virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) { } - virtual void page_did_change_title(const String&) { } + virtual void page_did_change_title(String const&) { } virtual void page_did_start_loading(const AK::URL&) { } virtual void page_did_finish_loading(const AK::URL&) { } virtual void page_did_change_selection() { } virtual void page_did_request_cursor_change(Gfx::StandardCursor) { } - virtual void page_did_request_context_menu(const Gfx::IntPoint&) { } - virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const AK::URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } - virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const AK::URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers, const Gfx::Bitmap*) { } - virtual void page_did_click_link(const AK::URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } - virtual void page_did_middle_click_link(const AK::URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } - virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) { } + virtual void page_did_request_context_menu(Gfx::IntPoint const&) { } + virtual void page_did_request_link_context_menu(Gfx::IntPoint const&, const AK::URL&, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_request_image_context_menu(Gfx::IntPoint const&, const AK::URL&, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers, Gfx::Bitmap const*) { } + virtual void page_did_click_link(const AK::URL&, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_middle_click_link(const AK::URL&, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_enter_tooltip_area(Gfx::IntPoint const&, String const&) { } virtual void page_did_leave_tooltip_area() { } virtual void page_did_hover_link(const AK::URL&) { } virtual void page_did_unhover_link() { } - virtual void page_did_invalidate(const Gfx::IntRect&) { } - virtual void page_did_change_favicon(const Gfx::Bitmap&) { } + virtual void page_did_invalidate(Gfx::IntRect const&) { } + virtual void page_did_change_favicon(Gfx::Bitmap const&) { } virtual void page_did_layout() { } virtual void page_did_request_scroll(i32, i32) { } virtual void page_did_request_scroll_to(Gfx::IntPoint const&) { } - virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) { } - virtual void page_did_request_alert(const String&) { } - virtual bool page_did_request_confirm(const String&) { return false; } - virtual String page_did_request_prompt(const String&, const String&) { return {}; } + virtual void page_did_request_scroll_into_view(Gfx::IntRect const&) { } + virtual void page_did_request_alert(String const&) { } + virtual bool page_did_request_confirm(String const&) { return false; } + virtual String page_did_request_prompt(String const&, String const&) { return {}; } virtual String page_did_request_cookie(const AK::URL&, Cookie::Source) { return {}; } - virtual void page_did_set_cookie(const AK::URL&, const Cookie::ParsedCookie&, Cookie::Source) { } + virtual void page_did_set_cookie(const AK::URL&, Cookie::ParsedCookie const&, Cookie::Source) { } virtual void page_did_update_resource_count(i32) { } protected: diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp index b8397438f2..91dabcc73f 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp @@ -45,7 +45,7 @@ void paint_border(PaintContext& context, BorderEdge edge, Gfx::FloatRect const& { auto rect = a_rect.to_rounded<float>(); - const auto& border_data = [&] { + auto const& border_data = [&] { switch (edge) { case BorderEdge::Top: return borders_data.top; @@ -71,7 +71,7 @@ void paint_border(PaintContext& context, BorderEdge edge, Gfx::FloatRect const& Gfx::FloatPoint p2; }; - auto points_for_edge = [](BorderEdge edge, const Gfx::FloatRect& rect) -> Points { + auto points_for_edge = [](BorderEdge edge, Gfx::FloatRect const& rect) -> Points { switch (edge) { case BorderEdge::Top: return { rect.top_left(), rect.top_right() }; diff --git a/Userland/Libraries/LibWeb/Painting/LabelablePaintable.cpp b/Userland/Libraries/LibWeb/Painting/LabelablePaintable.cpp index 9afcff46da..74ce00c66d 100644 --- a/Userland/Libraries/LibWeb/Painting/LabelablePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/LabelablePaintable.cpp @@ -35,7 +35,7 @@ Layout::FormAssociatedLabelableNode& LabelablePaintable::layout_box() return static_cast<Layout::FormAssociatedLabelableNode&>(PaintableBox::layout_box()); } -LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned) +LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned) { if (button != GUI::MouseButton::Primary || !layout_box().dom_node().enabled()) return DispatchEventOfSameName::No; @@ -46,7 +46,7 @@ LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mousedown return DispatchEventOfSameName::Yes; } -LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) +LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const& position, unsigned button, unsigned) { if (!m_tracking_mouse || button != GUI::MouseButton::Primary || !layout_box().dom_node().enabled()) return DispatchEventOfSameName::No; @@ -61,7 +61,7 @@ LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mouseup(B return DispatchEventOfSameName::Yes; } -LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned) +LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const& position, unsigned, unsigned) { if (!m_tracking_mouse || !layout_box().dom_node().enabled()) return DispatchEventOfSameName::No; diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index d272fa185d..2a8b13866a 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -64,12 +64,12 @@ public: // When these methods return true, the DOM event with the same name will be // dispatch at the mouse_event_target if it returns a valid DOM::Node, or // the layout node's associated DOM node if it doesn't. - virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers); - virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers); - virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); + virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers); + virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers); + virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const&, unsigned buttons, unsigned modifiers); virtual DOM::Node* mouse_event_target() const { return nullptr; } - virtual bool handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); + virtual bool handle_mousewheel(Badge<EventHandler>, Gfx::IntPoint const&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y); Layout::Node const& layout_node() const { return m_layout_node; } Layout::Node& layout_node() { return const_cast<Layout::Node&>(m_layout_node); } diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 12bfabb273..86f8f5bee4 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -43,7 +43,7 @@ PaintableWithLines::~PaintableWithLines() { } -void PaintableBox::set_offset(const Gfx::FloatPoint& offset) +void PaintableBox::set_offset(Gfx::FloatPoint const& offset) { m_offset = offset; // FIXME: This const_cast is gross. @@ -527,7 +527,7 @@ Optional<HitTestResult> PaintableBox::hit_test(Gfx::FloatPoint const& position, return {}; } -Optional<HitTestResult> PaintableWithLines::hit_test(const Gfx::FloatPoint& position, HitTestType type) const +Optional<HitTestResult> PaintableWithLines::hit_test(Gfx::FloatPoint const& position, HitTestType type) const { if (!layout_box().children_are_inline()) return PaintableBox::hit_test(position, type); diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.h b/Userland/Libraries/LibWeb/Painting/PaintableBox.h index 028a619fec..7077e814e2 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.h +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.h @@ -163,7 +163,7 @@ public: virtual void paint(PaintContext&, PaintPhase) const override; virtual bool wants_mouse_events() const override { return false; } - virtual bool handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y) override; + virtual bool handle_mousewheel(Badge<EventHandler>, Gfx::IntPoint const&, unsigned buttons, unsigned modifiers, int wheel_delta_x, int wheel_delta_y) override; virtual Optional<HitTestResult> hit_test(Gfx::FloatPoint const&, HitTestType) const override; diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.h b/Userland/Libraries/LibWeb/Painting/StackingContext.h index 9ea3e8ca71..3d0a9df1bc 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.h +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.h @@ -18,7 +18,7 @@ public: StackingContext(Layout::Box&, StackingContext* parent); StackingContext* parent() { return m_parent; } - const StackingContext* parent() const { return m_parent; } + StackingContext const* parent() const { return m_parent; } enum class StackingContextPaintPhase { BackgroundAndBorders, diff --git a/Userland/Libraries/LibWeb/Painting/TextPaintable.cpp b/Userland/Libraries/LibWeb/Painting/TextPaintable.cpp index 37c02f842a..a209e8e481 100644 --- a/Userland/Libraries/LibWeb/Painting/TextPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/TextPaintable.cpp @@ -36,7 +36,7 @@ DOM::Node* TextPaintable::mouse_event_target() const return nullptr; } -TextPaintable::DispatchEventOfSameName TextPaintable::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) +TextPaintable::DispatchEventOfSameName TextPaintable::handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const& position, unsigned button, unsigned) { auto* label = layout_node().first_ancestor_of_type<Layout::Label>(); if (!label) @@ -46,7 +46,7 @@ TextPaintable::DispatchEventOfSameName TextPaintable::handle_mousedown(Badge<Eve return DispatchEventOfSameName::Yes; } -TextPaintable::DispatchEventOfSameName TextPaintable::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) +TextPaintable::DispatchEventOfSameName TextPaintable::handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const& position, unsigned button, unsigned) { auto* label = layout_node().first_ancestor_of_type<Layout::Label>(); if (!label) @@ -57,7 +57,7 @@ TextPaintable::DispatchEventOfSameName TextPaintable::handle_mouseup(Badge<Event return DispatchEventOfSameName::Yes; } -TextPaintable::DispatchEventOfSameName TextPaintable::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned) +TextPaintable::DispatchEventOfSameName TextPaintable::handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const& position, unsigned button, unsigned) { auto* label = layout_node().first_ancestor_of_type<Layout::Label>(); if (!label) diff --git a/Userland/Libraries/LibWeb/Painting/TextPaintable.h b/Userland/Libraries/LibWeb/Painting/TextPaintable.h index 2b61032a1f..5c029062bb 100644 --- a/Userland/Libraries/LibWeb/Painting/TextPaintable.h +++ b/Userland/Libraries/LibWeb/Painting/TextPaintable.h @@ -18,9 +18,9 @@ public: virtual bool wants_mouse_events() const override; virtual DOM::Node* mouse_event_target() const override; - virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override; - virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override; - virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override; + virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override; + virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override; + virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override; private: explicit TextPaintable(Layout::TextNode const&); diff --git a/Userland/Libraries/LibWeb/SVG/SVGContext.h b/Userland/Libraries/LibWeb/SVG/SVGContext.h index 2e073a5cce..1073620137 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGContext.h +++ b/Userland/Libraries/LibWeb/SVG/SVGContext.h @@ -20,8 +20,8 @@ public: m_states.append(State()); } - const Gfx::Color& fill_color() const { return state().fill_color; } - const Gfx::Color& stroke_color() const { return state().stroke_color; } + Gfx::Color const& fill_color() const { return state().fill_color; } + Gfx::Color const& stroke_color() const { return state().stroke_color; } float stroke_width() const { return state().stroke_width; } void set_fill_color(Gfx::Color color) { state().fill_color = color; } @@ -40,7 +40,7 @@ private: float stroke_width { 1.0 }; }; - const State& state() const { return m_states.last(); } + State const& state() const { return m_states.last(); } State& state() { return m_states.last(); } Gfx::FloatRect m_svg_element_bounds; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp index b7a8effc18..0419dbf527 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -15,7 +15,7 @@ namespace Web::SVG { -[[maybe_unused]] static void print_instruction(const PathInstruction& instruction) +[[maybe_unused]] static void print_instruction(PathInstruction const& instruction) { VERIFY(PATH_DEBUG); diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h index 1f1dbfa060..1b3ff0a2aa 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h @@ -20,7 +20,7 @@ public: SVGPathElement(DOM::Document&, DOM::QualifiedName); virtual ~SVGPathElement() override = default; - virtual void parse_attribute(const FlyString& name, const String& value) override; + virtual void parse_attribute(FlyString const& name, String const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/TreeNode.h b/Userland/Libraries/LibWeb/TreeNode.h index 8b5adb9557..1972c4fd05 100644 --- a/Userland/Libraries/LibWeb/TreeNode.h +++ b/Userland/Libraries/LibWeb/TreeNode.h @@ -123,10 +123,10 @@ public: return {}; } - bool is_ancestor_of(const TreeNode&) const; - bool is_inclusive_ancestor_of(const TreeNode&) const; - bool is_descendant_of(const TreeNode&) const; - bool is_inclusive_descendant_of(const TreeNode&) const; + bool is_ancestor_of(TreeNode const&) const; + bool is_inclusive_ancestor_of(TreeNode const&) const; + bool is_descendant_of(TreeNode const&) const; + bool is_inclusive_descendant_of(TreeNode const&) const; bool is_following(TreeNode const&) const; @@ -556,7 +556,7 @@ inline void TreeNode<T>::prepend_child(NonnullRefPtr<T> node) } template<typename T> -inline bool TreeNode<T>::is_ancestor_of(const TreeNode<T>& other) const +inline bool TreeNode<T>::is_ancestor_of(TreeNode<T> const& other) const { for (auto* ancestor = other.parent(); ancestor; ancestor = ancestor->parent()) { if (ancestor == this) @@ -566,19 +566,19 @@ inline bool TreeNode<T>::is_ancestor_of(const TreeNode<T>& other) const } template<typename T> -inline bool TreeNode<T>::is_inclusive_ancestor_of(const TreeNode<T>& other) const +inline bool TreeNode<T>::is_inclusive_ancestor_of(TreeNode<T> const& other) const { return &other == this || is_ancestor_of(other); } template<typename T> -inline bool TreeNode<T>::is_descendant_of(const TreeNode<T>& other) const +inline bool TreeNode<T>::is_descendant_of(TreeNode<T> const& other) const { return other.is_ancestor_of(*this); } template<typename T> -inline bool TreeNode<T>::is_inclusive_descendant_of(const TreeNode<T>& other) const +inline bool TreeNode<T>::is_inclusive_descendant_of(TreeNode<T> const& other) const { return other.is_inclusive_ancestor_of(*this); } diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 8355e9811e..96bad7de8f 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -10,7 +10,7 @@ namespace Web::UIEvents { -MouseEvent::MouseEvent(const FlyString& event_name, double offset_x, double offset_y, double client_x, double client_y) +MouseEvent::MouseEvent(FlyString const& event_name, double offset_x, double offset_y, double client_x, double client_y) : UIEvent(event_name) , m_offset_x(offset_x) , m_offset_y(offset_y) diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 2f3cd652fb..99c2df94f2 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -16,7 +16,7 @@ class MouseEvent final : public UIEvent { public: using WrapperType = Bindings::MouseEventWrapper; - static NonnullRefPtr<MouseEvent> create(const FlyString& event_name, double offset_x, double offset_y, double client_x, double client_y) + static NonnullRefPtr<MouseEvent> create(FlyString const& event_name, double offset_x, double offset_y, double client_x, double client_y) { return adopt_ref(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y)); } @@ -33,7 +33,7 @@ public: double y() const { return client_y(); } protected: - MouseEvent(const FlyString& event_name, double offset_x, double offset_y, double client_x, double client_y); + MouseEvent(FlyString const& event_name, double offset_x, double offset_y, double client_x, double client_y); private: void set_event_characteristics(); diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index 61ba8c3d06..0470e86f1c 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -101,7 +101,7 @@ String URL::username() const return m_url.username(); } -void URL::set_username(const String& username) +void URL::set_username(String const& username) { // 1. If this’s URL cannot have a username/password/port, then return. if (m_url.cannot_have_a_username_or_password_or_port()) @@ -139,7 +139,7 @@ String URL::host() const return String::formatted("{}:{}", url.host(), *url.port()); } -void URL::set_host(const String& host) +void URL::set_host(String const& host) { // 1. If this’s URL’s cannot-be-a-base-URL is true, then return. if (m_url.cannot_be_a_base_url()) diff --git a/Userland/Libraries/LibWeb/URL/URL.h b/Userland/Libraries/LibWeb/URL/URL.h index 0f17dc1c62..15bea032cb 100644 --- a/Userland/Libraries/LibWeb/URL/URL.h +++ b/Userland/Libraries/LibWeb/URL/URL.h @@ -26,7 +26,7 @@ public: return adopt_ref(*new URL(move(url), move(query))); } - static DOM::ExceptionOr<NonnullRefPtr<URL>> create_with_global_object(Bindings::WindowObject&, const String& url, const String& base); + static DOM::ExceptionOr<NonnullRefPtr<URL>> create_with_global_object(Bindings::WindowObject&, String const& url, String const& base); String href() const; DOM::ExceptionOr<void> set_href(String const&); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index 34ca58a0e9..b4ff650856 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -12,7 +12,7 @@ namespace Web::URL { -String url_encode(const Vector<QueryParam>& pairs, AK::URL::PercentEncodeSet percent_encode_set) +String url_encode(Vector<QueryParam> const& pairs, AK::URL::PercentEncodeSet percent_encode_set) { StringBuilder builder; for (size_t i = 0; i < pairs.size(); ++i) { @@ -185,7 +185,7 @@ bool URLSearchParams::has(String const& name) .is_end(); } -void URLSearchParams::set(const String& name, const String& value) +void URLSearchParams::set(String const& name, String const& value) { // 1. If this’s list contains any name-value pairs whose name is name, then set the value of the first such name-value pair to value and remove the others. auto existing = m_list.find_if([&name](auto& entry) { diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h index 7fe3ea8114..a2cfe8c7e5 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h @@ -17,7 +17,7 @@ struct QueryParam { String name; String value; }; -String url_encode(const Vector<QueryParam>&, AK::URL::PercentEncodeSet); +String url_encode(Vector<QueryParam> const&, AK::URL::PercentEncodeSet); Vector<QueryParam> url_decode(StringView); class URLSearchParams : public Bindings::Wrappable diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index a6e083f6f9..d90c092eec 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -33,7 +33,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) auto& cache = this->cache(); for (auto& export_ : instance.exports()) { export_.value().visit( - [&](const Wasm::FunctionAddress& address) { + [&](Wasm::FunctionAddress const& address) { auto object = cache.function_instances.get(address); if (!object.has_value()) { object = create_native_function(global_object, address, export_.name()); @@ -41,7 +41,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); }, - [&](const Wasm::MemoryAddress& address) { + [&](Wasm::MemoryAddress const& address) { auto object = cache.memory_instances.get(address); if (!object.has_value()) { object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, global_object, address); @@ -49,7 +49,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); }, - [&](const auto&) { + [&](auto const&) { // FIXME: Implement other exports! }); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h index b865fab521..38911c36bf 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h @@ -22,7 +22,7 @@ public: virtual ~WebAssemblyModuleObject() override = default; size_t index() const { return m_index; } - const Wasm::Module& module() const { return WebAssemblyObject::s_compiled_modules.at(m_index).module; } + Wasm::Module const& module() const { return WebAssemblyObject::s_compiled_modules.at(m_index).module; } private: size_t m_index { 0 }; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index de27ae907c..b0f6e6e330 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -184,7 +184,7 @@ JS::ThrowCompletionOr<size_t> WebAssemblyObject::instantiate_module(Wasm::Module if (!import_argument.is_undefined()) { auto* import_object = TRY(import_argument.to_object(global_object)); dbgln("Trying to resolve stuff because import object was specified"); - for (const Wasm::Linker::Name& import_name : linker.unresolved_imports()) { + for (Wasm::Linker::Name const& import_name : linker.unresolved_imports()) { dbgln("Trying to resolve {}::{}", import_name.module, import_name.name); auto value_or_error = import_object->get(import_name.module); if (value_or_error.is_error()) @@ -286,7 +286,7 @@ JS::ThrowCompletionOr<size_t> WebAssemblyObject::instantiate_module(Wasm::Module resolved_imports.set(import_name, Wasm::ExternValue { address }); return {}; }, - [&](const auto&) -> JS::ThrowCompletionOr<void> { + [&](auto const&) -> JS::ThrowCompletionOr<void> { // FIXME: Implement these. dbgln("Unimplemented import of non-function attempted"); return vm.throw_completion<JS::TypeError>(global_object, "LinkError: Not Implemented"); @@ -328,7 +328,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate) } auto* buffer = buffer_or_error.release_value(); - const Wasm::Module* module { nullptr }; + Wasm::Module const* module { nullptr }; if (is<JS::ArrayBuffer>(buffer) || is<JS::TypedArrayBase>(buffer)) { auto result = parse_module(global_object, buffer); if (result.is_error()) { @@ -386,7 +386,7 @@ JS::Value to_js_value(JS::GlobalObject& global_object, Wasm::Value& wasm_value) VERIFY_NOT_REACHED(); } -JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::GlobalObject& global_object, JS::Value value, const Wasm::ValueType& type) +JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::GlobalObject& global_object, JS::Value value, Wasm::ValueType const& type) { static ::Crypto::SignedBigInteger two_64 = "1"_sbigint.shift_left(64); auto& vm = global_object.vm(); @@ -439,7 +439,7 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::GlobalObject& global JS::NativeFunction* create_native_function(JS::GlobalObject& global_object, Wasm::FunctionAddress address, String const& name) { Optional<Wasm::FunctionType> type; - WebAssemblyObject::s_abstract_machine.store().get(address)->visit([&](const auto& value) { type = value.type(); }); + WebAssemblyObject::s_abstract_machine.store().get(address)->visit([&](auto const& value) { type = value.type(); }); if (auto entry = WebAssemblyObject::s_global_cache.function_instances.get(address); entry.has_value()) return *entry; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 834c2cc826..481138dd22 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h @@ -17,7 +17,7 @@ class WebAssemblyMemoryObject; JS::ThrowCompletionOr<size_t> parse_module(JS::GlobalObject& global_object, JS::Object* buffer); JS::NativeFunction* create_native_function(JS::GlobalObject& global_object, Wasm::FunctionAddress address, String const& name); JS::Value to_js_value(JS::GlobalObject& global_object, Wasm::Value& wasm_value); -JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::GlobalObject& global_object, JS::Value value, const Wasm::ValueType& type); +JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::GlobalObject& global_object, JS::Value value, Wasm::ValueType const& type); class WebAssemblyObject final : public JS::Object { JS_OBJECT(WebAssemblyObject, JS::Object); diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp index 531cf0cda3..ae75861d6c 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.cpp +++ b/Userland/Libraries/LibWeb/WebContentClient.cpp @@ -23,7 +23,7 @@ void WebContentClient::die() on_web_content_process_crash(); } -void WebContentClient::did_paint(const Gfx::IntRect&, i32 bitmap_id) +void WebContentClient::did_paint(Gfx::IntRect const&, i32 bitmap_id) { m_view.notify_server_did_paint({}, bitmap_id); } diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index ff3bdeba68..c351b95501 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -53,7 +53,7 @@ RefPtr<Protocol::WebSocket> WebSocketClientManager::connect(const AK::URL& url, } // https://websockets.spec.whatwg.org/#dom-websocket-websocket -DOM::ExceptionOr<NonnullRefPtr<WebSocket>> WebSocket::create_with_global_object(Bindings::WindowObject& window, const String& url) +DOM::ExceptionOr<NonnullRefPtr<WebSocket>> WebSocket::create_with_global_object(Bindings::WindowObject& window, String const& url) { AK::URL url_record(url); if (!url_record.is_valid()) @@ -169,7 +169,7 @@ DOM::ExceptionOr<void> WebSocket::close(Optional<u16> code, Optional<String> rea } // https://websockets.spec.whatwg.org/#dom-websocket-send -DOM::ExceptionOr<void> WebSocket::send(const String& data) +DOM::ExceptionOr<void> WebSocket::send(String const& data) { auto state = ready_state(); if (state == WebSocket::ReadyState::Connecting) diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h index cf9c02795c..7d2b292592 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h @@ -64,7 +64,7 @@ public: return adopt_ref(*new WebSocket(window, url)); } - static DOM::ExceptionOr<NonnullRefPtr<WebSocket>> create_with_global_object(Bindings::WindowObject& window, const String& url); + static DOM::ExceptionOr<NonnullRefPtr<WebSocket>> create_with_global_object(Bindings::WindowObject& window, String const& url); virtual ~WebSocket() override; @@ -84,11 +84,11 @@ public: String extensions() const; String protocol() const; - const String& binary_type() { return m_binary_type; }; - void set_binary_type(const String& type) { m_binary_type = type; }; + String const& binary_type() { return m_binary_type; }; + void set_binary_type(String const& type) { m_binary_type = type; }; DOM::ExceptionOr<void> close(Optional<u16> code, Optional<String> reason); - DOM::ExceptionOr<void> send(const String& data); + DOM::ExceptionOr<void> send(String const& data); private: virtual void ref_event_target() override { ref(); } diff --git a/Userland/Libraries/LibWeb/WebViewHooks.h b/Userland/Libraries/LibWeb/WebViewHooks.h index 88f728695f..483255748b 100644 --- a/Userland/Libraries/LibWeb/WebViewHooks.h +++ b/Userland/Libraries/LibWeb/WebViewHooks.h @@ -15,25 +15,25 @@ namespace Web { class WebViewHooks { public: - Function<void(const Gfx::IntPoint& screen_position)> on_context_menu_request; - Function<void(const AK::URL&, const String& target, unsigned modifiers)> on_link_click; - Function<void(const AK::URL&, const Gfx::IntPoint& screen_position)> on_link_context_menu_request; - Function<void(const AK::URL&, const Gfx::IntPoint& screen_position, const Gfx::ShareableBitmap&)> on_image_context_menu_request; - Function<void(const AK::URL&, const String& target, unsigned modifiers)> on_link_middle_click; + Function<void(Gfx::IntPoint const& screen_position)> on_context_menu_request; + Function<void(const AK::URL&, String const& target, unsigned modifiers)> on_link_click; + Function<void(const AK::URL&, Gfx::IntPoint const& screen_position)> on_link_context_menu_request; + Function<void(const AK::URL&, Gfx::IntPoint const& screen_position, Gfx::ShareableBitmap const&)> on_image_context_menu_request; + Function<void(const AK::URL&, String const& target, unsigned modifiers)> on_link_middle_click; Function<void(const AK::URL&)> on_link_hover; - Function<void(const String&)> on_title_change; + Function<void(String const&)> on_title_change; Function<void(const AK::URL&)> on_load_start; Function<void(const AK::URL&)> on_load_finish; - Function<void(const Gfx::Bitmap&)> on_favicon_change; + Function<void(Gfx::Bitmap const&)> on_favicon_change; Function<void(const AK::URL&)> on_url_drop; Function<void(DOM::Document*)> on_set_document; - Function<void(const AK::URL&, const String&)> on_get_source; - Function<void(const String&)> on_get_dom_tree; + Function<void(const AK::URL&, String const&)> on_get_source; + Function<void(String const&)> on_get_dom_tree; Function<void(i32 node_id, String const& specified_style, String const& computed_style, String const& custom_properties, String const& node_box_sizing)> on_get_dom_node_properties; Function<void(i32 message_id)> on_js_console_new_message; Function<void(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages)> on_get_js_console_messages; Function<String(const AK::URL& url, Cookie::Source source)> on_get_cookie; - Function<void(const AK::URL& url, const Cookie::ParsedCookie& cookie, Cookie::Source source)> on_set_cookie; + Function<void(const AK::URL& url, Cookie::ParsedCookie const& cookie, Cookie::Source source)> on_set_cookie; Function<void(i32 count_waiting)> on_resource_status_change; }; diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 3a3acad6ae..3b7a42204c 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -50,7 +50,7 @@ void XMLHttpRequest::set_ready_state(ReadyState ready_state) dispatch_event(DOM::Event::create(EventNames::readystatechange)); } -void XMLHttpRequest::fire_progress_event(const String& event_name, u64 transmitted, u64 length) +void XMLHttpRequest::fire_progress_event(String const& event_name, u64 transmitted, u64 length) { ProgressEventInit event_init {}; event_init.length_computable = true; @@ -371,7 +371,7 @@ Optional<MimeSniff::MimeType> XMLHttpRequest::extract_mime_type(HashMap<String, } // https://fetch.spec.whatwg.org/#forbidden-header-name -static bool is_forbidden_header_name(const String& header_name) +static bool is_forbidden_header_name(String const& header_name) { if (header_name.starts_with("Proxy-", CaseSensitivity::CaseInsensitive) || header_name.starts_with("Sec-", CaseSensitivity::CaseInsensitive)) return true; @@ -381,14 +381,14 @@ static bool is_forbidden_header_name(const String& header_name) } // https://fetch.spec.whatwg.org/#forbidden-method -static bool is_forbidden_method(const String& method) +static bool is_forbidden_method(String const& method) { auto lowercase_method = method.to_lowercase(); return lowercase_method.is_one_of("connect", "trace", "track"); } // https://fetch.spec.whatwg.org/#concept-method-normalize -static String normalize_method(const String& method) +static String normalize_method(String const& method) { auto lowercase_method = method.to_lowercase(); if (lowercase_method.is_one_of("delete", "get", "head", "options", "post", "put")) @@ -397,14 +397,14 @@ static String normalize_method(const String& method) } // https://fetch.spec.whatwg.org/#concept-header-value-normalize -static String normalize_header_value(const String& header_value) +static String normalize_header_value(String const& header_value) { // FIXME: I'm not sure if this is the right trim, it should only be HTML whitespace bytes. return header_value.trim_whitespace(); } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader -DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(const String& header, const String& value) +DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(String const& header, String const& value) { if (m_ready_state != ReadyState::Opened) return DOM::InvalidStateError::create("XHR readyState is not OPENED"); @@ -424,7 +424,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(const String& header, } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open -DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url) +DOM::ExceptionOr<void> XMLHttpRequest::open(String const& method, String const& url) { // FIXME: Let settingsObject be this’s relevant settings object. diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 543b35e81f..268a5d8639 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -54,13 +54,13 @@ public: DOM::ExceptionOr<JS::Value> response(); Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; } - DOM::ExceptionOr<void> open(const String& method, const String& url); + DOM::ExceptionOr<void> open(String const& method, String const& url); DOM::ExceptionOr<void> send(String body); - DOM::ExceptionOr<void> set_request_header(const String& header, const String& value); + DOM::ExceptionOr<void> set_request_header(String const& header, String const& value); void set_response_type(Bindings::XMLHttpRequestResponseType type) { m_response_type = type; } - String get_response_header(const String& name) { return m_response_headers.get(name).value_or({}); } + String get_response_header(String const& name) { return m_response_headers.get(name).value_or({}); } String get_all_response_headers() const; Bindings::CallbackType* onreadystatechange(); @@ -75,7 +75,7 @@ private: void set_ready_state(ReadyState); void set_status(unsigned status) { m_status = status; } - void fire_progress_event(const String&, u64, u64); + void fire_progress_event(String const&, u64, u64); MimeSniff::MimeType get_response_mime_type() const; Optional<StringView> get_final_encoding() const; diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 532d0f695f..7f594c2719 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -9,7 +9,7 @@ #include <LibWeb/XML/XMLDocumentBuilder.h> inline namespace { -extern const char* s_xhtml_unified_dtd; +extern char const* s_xhtml_unified_dtd; } static FlyString s_html_namespace = "http://www.w3.org/1999/xhtml"; @@ -44,7 +44,7 @@ XMLDocumentBuilder::XMLDocumentBuilder(DOM::Document& document, XMLScriptingSupp { } -void XMLDocumentBuilder::element_start(const XML::Name& name, const HashMap<XML::Name, String>& attributes) +void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name, String> const& attributes) { if (m_has_error) return; @@ -116,7 +116,7 @@ void XMLDocumentBuilder::element_end(const XML::Name& name) m_current_node = m_current_node->parent_node(); } -void XMLDocumentBuilder::text(const String& data) +void XMLDocumentBuilder::text(String const& data) { if (m_has_error) return; @@ -133,7 +133,7 @@ void XMLDocumentBuilder::text(const String& data) } } -void XMLDocumentBuilder::comment(const String& data) +void XMLDocumentBuilder::comment(String const& data) { if (m_has_error) return; @@ -244,7 +244,7 @@ void XMLDocumentBuilder::document_end() } inline namespace { -const char* s_xhtml_unified_dtd = R"xmlxmlxml( +char const* s_xhtml_unified_dtd = R"xmlxmlxml( <!ENTITY Tab "	"><!ENTITY NewLine "
"><!ENTITY excl "!"><!ENTITY quot """><!ENTITY QUOT """><!ENTITY num "#"><!ENTITY dollar "$"><!ENTITY percnt "%"><!ENTITY amp "&#x26;"><!ENTITY AMP "&#x26;"><!ENTITY apos "'"><!ENTITY lpar "("><!ENTITY rpar ")"><!ENTITY ast "*"><!ENTITY midast "*"><!ENTITY plus "+"><!ENTITY comma ","><!ENTITY period "."><!ENTITY sol "/"><!ENTITY colon ":"><!ENTITY semi ";"><!ENTITY lt "&#x3C;"><!ENTITY LT "&#x3C;"><!ENTITY nvlt "&#x3C;⃒"><!ENTITY equals "="><!ENTITY bne "=⃥"><!ENTITY gt ">"><!ENTITY GT ">"><!ENTITY nvgt ">⃒"><!ENTITY quest "?"><!ENTITY commat "@"><!ENTITY lsqb "["><!ENTITY lbrack "["><!ENTITY bsol "\"><!ENTITY rsqb "]"><!ENTITY rbrack "]"><!ENTITY Hat "^"><!ENTITY lowbar "_"><!ENTITY UnderBar "_"><!ENTITY grave "`"><!ENTITY DiacriticalGrave "`"><!ENTITY fjlig "fj"><!ENTITY lcub "{"><!ENTITY lbrace "{"><!ENTITY verbar "|"><!ENTITY vert "|"><!ENTITY VerticalLine "|"><!ENTITY rcub "}"><!ENTITY rbrace "}"><!ENTITY nbsp " "><!ENTITY NonBreakingSpace " "><!ENTITY iexcl "¡"><!ENTITY cent "¢"><!ENTITY pound "£"><!ENTITY curren "¤"><!ENTITY yen "¥"><!ENTITY brvbar "¦"><!ENTITY sect "§"><!ENTITY Dot "¨"><!ENTITY die "¨"><!ENTITY DoubleDot "¨"><!ENTITY uml "¨"><!ENTITY copy "©"><!ENTITY COPY "©"><!ENTITY ordf "ª"><!ENTITY laquo "«"><!ENTITY not "¬"><!ENTITY shy "­"><!ENTITY reg "®"><!ENTITY circledR "®"><!ENTITY REG "®"><!ENTITY macr "¯"><!ENTITY strns "¯"><!ENTITY deg "°"><!ENTITY plusmn "±"><!ENTITY pm "±"><!ENTITY PlusMinus "±"><!ENTITY sup2 "²"><!ENTITY sup3 "³"><!ENTITY acute "´"><!ENTITY DiacriticalAcute "´"><!ENTITY micro "µ"><!ENTITY para "¶"><!ENTITY middot "·"><!ENTITY centerdot "·"><!ENTITY CenterDot "·"><!ENTITY cedil "¸"><!ENTITY Cedilla "¸"><!ENTITY sup1 "¹"><!ENTITY ordm "º"><!ENTITY raquo "»"><!ENTITY frac14 "¼"><!ENTITY frac12 "½"><!ENTITY half "½"><!ENTITY frac34 "¾"><!ENTITY iquest "¿"><!ENTITY Agrave "À"><!ENTITY Aacute "Á"><!ENTITY Acirc "Â"><!ENTITY Atilde "Ã"><!ENTITY Auml "Ä"><!ENTITY Aring "Å"><!ENTITY angst "Å"><!ENTITY AElig "Æ"><!ENTITY Ccedil "Ç"><!ENTITY Egrave "È"><!ENTITY Eacute "É"><!ENTITY Ecirc "Ê"><!ENTITY Euml "Ë"><!ENTITY Igrave "Ì"><!ENTITY Iacute "Í"><!ENTITY Icirc "Î"><!ENTITY Iuml "Ï"><!ENTITY ETH "Ð"><!ENTITY Ntilde "Ñ"><!ENTITY Ograve "Ò"><!ENTITY Oacute "Ó"><!ENTITY Ocirc "Ô"><!ENTITY Otilde "Õ"><!ENTITY Ouml "Ö"><!ENTITY times "×"><!ENTITY Oslash "Ø"><!ENTITY Ugrave "Ù"><!ENTITY Uacute "Ú"><!ENTITY Ucirc "Û"><!ENTITY Uuml "Ü"><!ENTITY Yacute "Ý"><!ENTITY THORN "Þ"><!ENTITY szlig "ß"><!ENTITY agrave "à"><!ENTITY aacute "á"><!ENTITY acirc "â"><!ENTITY atilde "ã"><!ENTITY auml "ä"><!ENTITY aring "å"><!ENTITY aelig "æ"><!ENTITY ccedil "ç"><!ENTITY egrave "è"><!ENTITY eacute "é"><!ENTITY ecirc "ê"><!ENTITY euml "ë"><!ENTITY igrave "ì"><!ENTITY iacute "í"><!ENTITY icirc "î"><!ENTITY iuml "ï"><!ENTITY eth "ð"><!ENTITY ntilde "ñ"><!ENTITY ograve "ò"><!ENTITY oacute "ó"><!ENTITY ocirc "ô"><!ENTITY otilde "õ"><!ENTITY ouml "ö"><!ENTITY divide "÷"><!ENTITY div "÷"><!ENTITY oslash "ø"><!ENTITY ugrave "ù"><!ENTITY uacute "ú"><!ENTITY ucirc "û"><!ENTITY uuml "ü"><!ENTITY yacute "ý"><!ENTITY thorn "þ"><!ENTITY yuml "ÿ"><!ENTITY Amacr "Ā"><!ENTITY amacr "ā"><!ENTITY Abreve "Ă"><!ENTITY abreve "ă"><!ENTITY Aogon "Ą"><!ENTITY aogon "ą"><!ENTITY Cacute "Ć"><!ENTITY cacute "ć"><!ENTITY Ccirc "Ĉ"><!ENTITY ccirc "ĉ"><!ENTITY Cdot "Ċ"><!ENTITY cdot "ċ"><!ENTITY Ccaron "Č"><!ENTITY ccaron "č"><!ENTITY Dcaron "Ď"><!ENTITY dcaron "ď"><!ENTITY Dstrok "Đ"><!ENTITY dstrok "đ"><!ENTITY Emacr "Ē"><!ENTITY emacr "ē"><!ENTITY Edot "Ė"><!ENTITY edot "ė"><!ENTITY Eogon "Ę"><!ENTITY eogon "ę"><!ENTITY Ecaron "Ě"><!ENTITY ecaron "ě"><!ENTITY Gcirc "Ĝ"><!ENTITY gcirc "ĝ"><!ENTITY Gbreve "Ğ"><!ENTITY gbreve "ğ"><!ENTITY Gdot "Ġ"><!ENTITY gdot "ġ"><!ENTITY Gcedil "Ģ"><!ENTITY Hcirc "Ĥ"><!ENTITY hcirc "ĥ"><!ENTITY Hstrok "Ħ"><!ENTITY hstrok "ħ"><!ENTITY Itilde "Ĩ"><!ENTITY itilde "ĩ"><!ENTITY Imacr "Ī"><!ENTITY imacr "ī"><!ENTITY Iogon "Į"><!ENTITY iogon "į"><!ENTITY Idot "İ"><!ENTITY imath "ı"><!ENTITY inodot "ı"><!ENTITY IJlig "IJ"><!ENTITY ijlig "ij"><!ENTITY Jcirc "Ĵ"><!ENTITY jcirc "ĵ"><!ENTITY Kcedil "Ķ"><!ENTITY kcedil "ķ"><!ENTITY kgreen "ĸ"><!ENTITY Lacute "Ĺ"><!ENTITY lacute "ĺ"><!ENTITY Lcedil "Ļ"><!ENTITY lcedil "ļ"><!ENTITY Lcaron "Ľ"><!ENTITY lcaron "ľ"><!ENTITY Lmidot "Ŀ"><!ENTITY lmidot "ŀ"><!ENTITY Lstrok "Ł"><!ENTITY lstrok "ł"><!ENTITY Nacute "Ń"><!ENTITY nacute "ń"><!ENTITY Ncedil "Ņ"><!ENTITY ncedil "ņ"><!ENTITY Ncaron "Ň"><!ENTITY ncaron "ň"><!ENTITY napos "ʼn"><!ENTITY ENG "Ŋ"><!ENTITY eng "ŋ"><!ENTITY Omacr "Ō"><!ENTITY omacr "ō"><!ENTITY Odblac "Ő"><!ENTITY odblac "ő"><!ENTITY OElig "Œ"><!ENTITY oelig "œ"><!ENTITY Racute "Ŕ"><!ENTITY racute "ŕ"><!ENTITY Rcedil "Ŗ"><!ENTITY rcedil "ŗ"><!ENTITY Rcaron "Ř"><!ENTITY rcaron "ř"><!ENTITY Sacute "Ś"><!ENTITY sacute "ś"><!ENTITY Scirc "Ŝ"><!ENTITY scirc "ŝ"><!ENTITY Scedil "Ş"><!ENTITY scedil "ş"><!ENTITY Scaron "Š"><!ENTITY scaron "š"><!ENTITY Tcedil "Ţ"><!ENTITY tcedil "ţ"><!ENTITY Tcaron "Ť"><!ENTITY tcaron "ť"><!ENTITY Tstrok "Ŧ"><!ENTITY tstrok "ŧ"><!ENTITY Utilde "Ũ"><!ENTITY utilde "ũ"><!ENTITY Umacr "Ū"><!ENTITY umacr "ū"><!ENTITY Ubreve "Ŭ"><!ENTITY ubreve "ŭ"><!ENTITY Uring "Ů"><!ENTITY uring "ů"><!ENTITY Udblac "Ű"><!ENTITY udblac "ű"><!ENTITY Uogon "Ų"><!ENTITY uogon "ų"><!ENTITY Wcirc "Ŵ"><!ENTITY wcirc "ŵ"><!ENTITY Ycirc "Ŷ"><!ENTITY ycirc "ŷ"><!ENTITY Yuml "Ÿ"><!ENTITY Zacute "Ź"><!ENTITY zacute "ź"><!ENTITY Zdot "Ż"><!ENTITY zdot "ż"><!ENTITY Zcaron "Ž"><!ENTITY zcaron "ž"><!ENTITY fnof "ƒ"><!ENTITY imped "Ƶ"><!ENTITY gacute "ǵ"><!ENTITY jmath "ȷ"><!ENTITY circ "ˆ"><!ENTITY caron "ˇ"><!ENTITY Hacek "ˇ"><!ENTITY breve "˘"><!ENTITY Breve "˘"><!ENTITY dot "˙"><!ENTITY DiacriticalDot "˙"><!ENTITY ring "˚"><!ENTITY ogon "˛"><!ENTITY tilde "˜"><!ENTITY DiacriticalTilde "˜"><!ENTITY dblac "˝"><!ENTITY DiacriticalDoubleAcute "˝"><!ENTITY DownBreve "̑"><!ENTITY Alpha "Α"><!ENTITY Beta "Β"><!ENTITY Gamma "Γ"><!ENTITY Delta "Δ"><!ENTITY Epsilon "Ε"><!ENTITY Zeta "Ζ"><!ENTITY Eta "Η"><!ENTITY Theta "Θ"><!ENTITY Iota "Ι"><!ENTITY Kappa "Κ"><!ENTITY Lambda "Λ"><!ENTITY Mu "Μ"><!ENTITY Nu "Ν"><!ENTITY Xi "Ξ"><!ENTITY Omicron "Ο"><!ENTITY Pi "Π"><!ENTITY Rho "Ρ"><!ENTITY Sigma "Σ"><!ENTITY Tau "Τ"><!ENTITY Upsilon "Υ"><!ENTITY Phi "Φ"><!ENTITY Chi "Χ"><!ENTITY Psi "Ψ"><!ENTITY Omega "Ω"><!ENTITY ohm "Ω"><!ENTITY alpha "α"><!ENTITY beta "β"><!ENTITY gamma "γ"><!ENTITY delta "δ"><!ENTITY epsi "ε"><!ENTITY epsilon "ε"><!ENTITY zeta "ζ"><!ENTITY eta "η"><!ENTITY theta "θ"><!ENTITY iota "ι"><!ENTITY kappa "κ"><!ENTITY lambda "λ"><!ENTITY mu "μ"><!ENTITY nu "ν"><!ENTITY xi "ξ"><!ENTITY omicron "ο"><!ENTITY pi "π"><!ENTITY rho "ρ"><!ENTITY sigmav "ς"><!ENTITY varsigma "ς"><!ENTITY sigmaf "ς"><!ENTITY sigma "σ"><!ENTITY tau "τ"><!ENTITY upsi "υ"><!ENTITY upsilon "υ"><!ENTITY phi "φ"><!ENTITY chi "χ"><!ENTITY psi "ψ"><!ENTITY omega "ω"><!ENTITY thetav "ϑ"><!ENTITY vartheta "ϑ"><!ENTITY thetasym "ϑ"><!ENTITY Upsi "ϒ"><!ENTITY upsih "ϒ"><!ENTITY straightphi "ϕ"><!ENTITY phiv "ϕ"><!ENTITY varphi "ϕ"><!ENTITY piv "ϖ"><!ENTITY varpi "ϖ"><!ENTITY Gammad "Ϝ"><!ENTITY gammad "ϝ"><!ENTITY digamma "ϝ"><!ENTITY kappav "ϰ"><!ENTITY varkappa "ϰ"><!ENTITY rhov "ϱ"><!ENTITY varrho "ϱ"><!ENTITY epsiv "ϵ"><!ENTITY straightepsilon "ϵ"><!ENTITY varepsilon "ϵ"><!ENTITY bepsi "϶"><!ENTITY backepsilon "϶"><!ENTITY IOcy "Ё"><!ENTITY DJcy "Ђ"><!ENTITY GJcy "Ѓ"><!ENTITY Jukcy "Є"><!ENTITY DScy "Ѕ"><!ENTITY Iukcy "І"><!ENTITY YIcy "Ї"><!ENTITY Jsercy "Ј"><!ENTITY LJcy "Љ"><!ENTITY NJcy "Њ"><!ENTITY TSHcy "Ћ"><!ENTITY KJcy "Ќ"><!ENTITY Ubrcy "Ў"><!ENTITY DZcy "Џ"><!ENTITY Acy "А"><!ENTITY Bcy "Б"><!ENTITY Vcy "В"><!ENTITY Gcy "Г"><!ENTITY Dcy "Д"><!ENTITY IEcy "Е"><!ENTITY ZHcy "Ж"><!ENTITY Zcy "З"><!ENTITY Icy "И"><!ENTITY Jcy "Й"><!ENTITY Kcy "К"><!ENTITY Lcy "Л"><!ENTITY Mcy "М"><!ENTITY Ncy "Н"><!ENTITY Ocy "О"><!ENTITY Pcy "П"><!ENTITY Rcy "Р"><!ENTITY Scy "С"><!ENTITY Tcy "Т"><!ENTITY Ucy "У"><!ENTITY Fcy "Ф"><!ENTITY KHcy "Х"><!ENTITY TScy "Ц"><!ENTITY CHcy "Ч"><!ENTITY SHcy "Ш"><!ENTITY SHCHcy "Щ"><!ENTITY HARDcy "Ъ"><!ENTITY Ycy "Ы"><!ENTITY SOFTcy "Ь"><!ENTITY Ecy "Э"><!ENTITY YUcy "Ю"><!ENTITY YAcy "Я"><!ENTITY acy "а"><!ENTITY bcy "б"><!ENTITY vcy "в"><!ENTITY gcy "г"><!ENTITY dcy "д"><!ENTITY iecy "е"><!ENTITY zhcy "ж"><!ENTITY zcy "з"><!ENTITY icy "и"><!ENTITY jcy "й"><!ENTITY kcy "к"><!ENTITY lcy "л"><!ENTITY mcy "м"><!ENTITY ncy "н"><!ENTITY ocy "о"><!ENTITY pcy "п"><!ENTITY rcy "р"><!ENTITY scy "с"><!ENTITY tcy "т"><!ENTITY ucy "у"><!ENTITY fcy "ф"><!ENTITY khcy "х"><!ENTITY tscy "ц"><!ENTITY chcy "ч"><!ENTITY shcy "ш"><!ENTITY shchcy "щ"><!ENTITY hardcy "ъ"><!ENTITY ycy "ы"><!ENTITY softcy "ь"><!ENTITY ecy "э"><!ENTITY yucy "ю"><!ENTITY yacy "я"><!ENTITY iocy "ё"><!ENTITY djcy "ђ"><!ENTITY gjcy "ѓ"><!ENTITY jukcy "є"><!ENTITY dscy "ѕ"><!ENTITY iukcy "і"><!ENTITY yicy "ї"><!ENTITY jsercy "ј"><!ENTITY ljcy "љ"><!ENTITY njcy "њ"><!ENTITY tshcy "ћ"><!ENTITY kjcy "ќ"><!ENTITY ubrcy "ў"><!ENTITY dzcy "џ"><!ENTITY ensp " "><!ENTITY emsp " "><!ENTITY emsp13 " "><!ENTITY emsp14 " "><!ENTITY numsp " "><!ENTITY puncsp " "><!ENTITY thinsp " "><!ENTITY ThinSpace " "><!ENTITY hairsp " "><!ENTITY VeryThinSpace " "><!ENTITY ZeroWidthSpace "​"><!ENTITY NegativeVeryThinSpace "​"><!ENTITY NegativeThinSpace "​"><!ENTITY NegativeMediumSpace "​"><!ENTITY NegativeThickSpace "​"><!ENTITY zwnj "‌"><!ENTITY zwj "‍"><!ENTITY lrm "‎"><!ENTITY rlm "‏"><!ENTITY hyphen "‐"><!ENTITY dash "‐"><!ENTITY ndash "–"><!ENTITY mdash "—"><!ENTITY horbar "―"><!ENTITY Verbar "‖"><!ENTITY Vert "‖"><!ENTITY lsquo "‘"><!ENTITY OpenCurlyQuote "‘"><!ENTITY rsquo "’"><!ENTITY rsquor "’"><!ENTITY CloseCurlyQuote "’"><!ENTITY lsquor "‚"><!ENTITY sbquo "‚"><!ENTITY ldquo "“"><!ENTITY OpenCurlyDoubleQuote "“"><!ENTITY rdquo "”"><!ENTITY rdquor "”"><!ENTITY CloseCurlyDoubleQuote "”"><!ENTITY ldquor "„"><!ENTITY bdquo "„"><!ENTITY dagger "†"><!ENTITY Dagger "‡"><!ENTITY ddagger "‡"><!ENTITY bull "•"><!ENTITY bullet "•"><!ENTITY nldr "‥"><!ENTITY hellip "…"><!ENTITY mldr "…"><!ENTITY permil "‰"><!ENTITY pertenk "‱"><!ENTITY prime "′"><!ENTITY Prime "″"><!ENTITY tprime "‴"><!ENTITY bprime "‵"><!ENTITY backprime "‵"><!ENTITY lsaquo "‹"><!ENTITY rsaquo "›"><!ENTITY oline "‾"><!ENTITY OverBar "‾"><!ENTITY caret "⁁"><!ENTITY hybull "⁃"><!ENTITY frasl "⁄"><!ENTITY bsemi "⁏"><!ENTITY qprime "⁗"><!ENTITY MediumSpace " "><!ENTITY ThickSpace "  "><!ENTITY NoBreak "⁠"><!ENTITY ApplyFunction "⁡"><!ENTITY af "⁡"><!ENTITY InvisibleTimes "⁢"><!ENTITY it "⁢"><!ENTITY InvisibleComma "⁣"><!ENTITY ic "⁣"><!ENTITY euro "€"><!ENTITY tdot "⃛"><!ENTITY TripleDot "⃛"><!ENTITY DotDot "⃜"><!ENTITY Copf "ℂ"><!ENTITY complexes "ℂ"><!ENTITY incare "℅"><!ENTITY gscr "ℊ"><!ENTITY hamilt "ℋ"><!ENTITY HilbertSpace "ℋ"><!ENTITY Hscr "ℋ"><!ENTITY Hfr "ℌ"><!ENTITY Poincareplane "ℌ"><!ENTITY quaternions "ℍ"><!ENTITY Hopf "ℍ"><!ENTITY planckh "ℎ"><!ENTITY planck "ℏ"><!ENTITY hbar "ℏ"><!ENTITY plankv "ℏ"><!ENTITY hslash "ℏ"><!ENTITY Iscr "ℐ"><!ENTITY imagline "ℐ"><!ENTITY image "ℑ"><!ENTITY Im "ℑ"><!ENTITY imagpart "ℑ"><!ENTITY Ifr "ℑ"><!ENTITY Lscr "ℒ"><!ENTITY lagran "ℒ"><!ENTITY Laplacetrf "ℒ"><!ENTITY ell "ℓ"><!ENTITY Nopf "ℕ"><!ENTITY naturals "ℕ"><!ENTITY numero "№"><!ENTITY copysr "℗"><!ENTITY weierp "℘"><!ENTITY wp "℘"><!ENTITY Popf "ℙ"><!ENTITY primes "ℙ"><!ENTITY rationals "ℚ"><!ENTITY Qopf "ℚ"><!ENTITY Rscr "ℛ"><!ENTITY realine "ℛ"><!ENTITY real "ℜ"><!ENTITY Re "ℜ"><!ENTITY realpart "ℜ"><!ENTITY Rfr "ℜ"><!ENTITY reals "ℝ"><!ENTITY Ropf "ℝ"><!ENTITY rx "℞"><!ENTITY trade "™"><!ENTITY TRADE "™"><!ENTITY integers "ℤ"><!ENTITY Zopf "ℤ"><!ENTITY mho "℧"><!ENTITY Zfr "ℨ"><!ENTITY zeetrf "ℨ"><!ENTITY iiota "℩"><!ENTITY bernou "ℬ"><!ENTITY Bernoullis "ℬ"><!ENTITY Bscr "ℬ"><!ENTITY Cfr "ℭ"><!ENTITY Cayleys "ℭ"><!ENTITY escr "ℯ"><!ENTITY Escr "ℰ"><!ENTITY expectation "ℰ"><!ENTITY Fscr "ℱ"><!ENTITY Fouriertrf "ℱ"><!ENTITY phmmat "ℳ"><!ENTITY Mellintrf "ℳ"><!ENTITY Mscr "ℳ"><!ENTITY order "ℴ"><!ENTITY orderof "ℴ"><!ENTITY oscr "ℴ"><!ENTITY alefsym "ℵ"><!ENTITY aleph "ℵ"><!ENTITY beth "ℶ"><!ENTITY gimel "ℷ"><!ENTITY daleth "ℸ"><!ENTITY CapitalDifferentialD "ⅅ"><!ENTITY DD "ⅅ"><!ENTITY DifferentialD "ⅆ"><!ENTITY dd "ⅆ"><!ENTITY ExponentialE "ⅇ"><!ENTITY exponentiale "ⅇ"><!ENTITY ee "ⅇ"><!ENTITY ImaginaryI "ⅈ"><!ENTITY ii "ⅈ"><!ENTITY frac13 "⅓"><!ENTITY frac23 "⅔"><!ENTITY frac15 "⅕"><!ENTITY frac25 "⅖"><!ENTITY frac35 "⅗"><!ENTITY frac45 "⅘"><!ENTITY frac16 "⅙"><!ENTITY frac56 "⅚"><!ENTITY frac18 "⅛"><!ENTITY frac38 "⅜"><!ENTITY frac58 "⅝"><!ENTITY frac78 "⅞"><!ENTITY larr "←"><!ENTITY leftarrow "←"><!ENTITY LeftArrow "←"><!ENTITY slarr "←"><!ENTITY ShortLeftArrow "←"><!ENTITY uarr "↑"><!ENTITY uparrow "↑"><!ENTITY UpArrow "↑"><!ENTITY ShortUpArrow "↑"><!ENTITY rarr "→"><!ENTITY rightarrow "→"><!ENTITY RightArrow "→"><!ENTITY srarr "→"><!ENTITY ShortRightArrow "→"><!ENTITY darr "↓"><!ENTITY downarrow "↓"><!ENTITY DownArrow "↓"><!ENTITY ShortDownArrow "↓"><!ENTITY harr "↔"><!ENTITY leftrightarrow "↔"><!ENTITY LeftRightArrow "↔"><!ENTITY varr "↕"><!ENTITY updownarrow "↕"><!ENTITY UpDownArrow "↕"><!ENTITY nwarr "↖"><!ENTITY UpperLeftArrow "↖"><!ENTITY nwarrow "↖"><!ENTITY nearr "↗"><!ENTITY UpperRightArrow "↗"><!ENTITY nearrow "↗"><!ENTITY searr "↘"><!ENTITY searrow "↘"><!ENTITY LowerRightArrow "↘"><!ENTITY swarr "↙"><!ENTITY swarrow "↙"><!ENTITY LowerLeftArrow "↙"><!ENTITY nlarr "↚"><!ENTITY nleftarrow "↚"><!ENTITY nrarr "↛"><!ENTITY nrightarrow "↛"><!ENTITY rarrw "↝"><!ENTITY rightsquigarrow "↝"><!ENTITY nrarrw "↝̸"><!ENTITY Larr "↞"><!ENTITY twoheadleftarrow "↞"><!ENTITY Uarr "↟"><!ENTITY Rarr "↠"><!ENTITY twoheadrightarrow "↠"><!ENTITY Darr "↡"><!ENTITY larrtl "↢"><!ENTITY leftarrowtail "↢"><!ENTITY rarrtl "↣"><!ENTITY rightarrowtail "↣"><!ENTITY LeftTeeArrow "↤"><!ENTITY mapstoleft "↤"><!ENTITY UpTeeArrow "↥"><!ENTITY mapstoup "↥"><!ENTITY map "↦"><!ENTITY RightTeeArrow "↦"><!ENTITY mapsto "↦"><!ENTITY DownTeeArrow "↧"><!ENTITY mapstodown "↧"><!ENTITY larrhk "↩"><!ENTITY hookleftarrow "↩"><!ENTITY rarrhk "↪"><!ENTITY hookrightarrow "↪"><!ENTITY larrlp "↫"><!ENTITY looparrowleft "↫"><!ENTITY rarrlp "↬"><!ENTITY looparrowright "↬"><!ENTITY harrw "↭"><!ENTITY leftrightsquigarrow "↭"><!ENTITY nharr "↮"><!ENTITY nleftrightarrow "↮"><!ENTITY lsh "↰"><!ENTITY Lsh "↰"><!ENTITY rsh "↱"><!ENTITY Rsh "↱"><!ENTITY ldsh "↲"><!ENTITY rdsh "↳"><!ENTITY crarr "↵"><!ENTITY cularr "↶"><!ENTITY curvearrowleft "↶"><!ENTITY curarr "↷"><!ENTITY curvearrowright "↷"><!ENTITY olarr "↺"><!ENTITY circlearrowleft "↺"><!ENTITY orarr "↻"><!ENTITY circlearrowright "↻"><!ENTITY lharu "↼"><!ENTITY LeftVector "↼"><!ENTITY leftharpoonup "↼"><!ENTITY lhard "↽"><!ENTITY leftharpoondown "↽"><!ENTITY DownLeftVector "↽"><!ENTITY uharr "↾"><!ENTITY upharpoonright "↾"><!ENTITY RightUpVector "↾"><!ENTITY uharl "↿"><!ENTITY upharpoonleft "↿"><!ENTITY LeftUpVector "↿"><!ENTITY rharu "⇀"><!ENTITY RightVector "⇀"><!ENTITY rightharpoonup "⇀"><!ENTITY rhard "⇁"><!ENTITY rightharpoondown "⇁"><!ENTITY DownRightVector "⇁"><!ENTITY dharr "⇂"><!ENTITY RightDownVector "⇂"><!ENTITY downharpoonright "⇂"><!ENTITY dharl "⇃"><!ENTITY LeftDownVector "⇃"><!ENTITY downharpoonleft "⇃"><!ENTITY rlarr "⇄"><!ENTITY rightleftarrows "⇄"><!ENTITY RightArrowLeftArrow "⇄"><!ENTITY udarr "⇅"><!ENTITY UpArrowDownArrow "⇅"><!ENTITY lrarr "⇆"><!ENTITY leftrightarrows "⇆"><!ENTITY LeftArrowRightArrow "⇆"><!ENTITY llarr "⇇"><!ENTITY leftleftarrows "⇇"><!ENTITY uuarr "⇈"><!ENTITY upuparrows "⇈"><!ENTITY rrarr "⇉"><!ENTITY rightrightarrows "⇉"><!ENTITY ddarr "⇊"><!ENTITY downdownarrows "⇊"><!ENTITY lrhar "⇋"><!ENTITY ReverseEquilibrium "⇋"><!ENTITY leftrightharpoons "⇋"><!ENTITY rlhar "⇌"><!ENTITY rightleftharpoons "⇌"><!ENTITY Equilibrium "⇌"><!ENTITY nlArr "⇍"><!ENTITY nLeftarrow "⇍"><!ENTITY nhArr "⇎"><!ENTITY nLeftrightarrow "⇎"><!ENTITY nrArr "⇏"><!ENTITY nRightarrow "⇏"><!ENTITY lArr "⇐"><!ENTITY Leftarrow "⇐"><!ENTITY DoubleLeftArrow "⇐"><!ENTITY uArr "⇑"><!ENTITY Uparrow "⇑"><!ENTITY DoubleUpArrow "⇑"><!ENTITY rArr "⇒"><!ENTITY Rightarrow "⇒"><!ENTITY Implies "⇒"><!ENTITY DoubleRightArrow "⇒"><!ENTITY dArr "⇓"><!ENTITY Downarrow "⇓"><!ENTITY DoubleDownArrow "⇓"><!ENTITY hArr "⇔"><!ENTITY Leftrightarrow "⇔"><!ENTITY DoubleLeftRightArrow "⇔"><!ENTITY iff "⇔"><!ENTITY vArr "⇕"><!ENTITY Updownarrow "⇕"><!ENTITY DoubleUpDownArrow "⇕"><!ENTITY nwArr "⇖"><!ENTITY neArr "⇗"><!ENTITY seArr "⇘"><!ENTITY swArr "⇙"><!ENTITY lAarr "⇚"><!ENTITY Lleftarrow "⇚"><!ENTITY rAarr "⇛"><!ENTITY Rrightarrow "⇛"><!ENTITY zigrarr "⇝"><!ENTITY larrb "⇤"><!ENTITY LeftArrowBar "⇤"><!ENTITY rarrb "⇥"><!ENTITY RightArrowBar "⇥"><!ENTITY duarr "⇵"><!ENTITY DownArrowUpArrow "⇵"><!ENTITY loarr "⇽"><!ENTITY roarr "⇾"><!ENTITY hoarr "⇿"><!ENTITY forall "∀"><!ENTITY ForAll "∀"><!ENTITY comp "∁"><!ENTITY complement "∁"><!ENTITY part "∂"><!ENTITY PartialD "∂"><!ENTITY npart "∂̸"><!ENTITY exist "∃"><!ENTITY Exists "∃"><!ENTITY nexist "∄"><!ENTITY NotExists "∄"><!ENTITY nexists "∄"><!ENTITY empty "∅"><!ENTITY emptyset "∅"><!ENTITY emptyv "∅"><!ENTITY varnothing "∅"><!ENTITY nabla "∇"><!ENTITY Del "∇"><!ENTITY isin "∈"><!ENTITY isinv "∈"><!ENTITY Element "∈"><!ENTITY in "∈"><!ENTITY notin "∉"><!ENTITY NotElement "∉"><!ENTITY notinva "∉"><!ENTITY niv "∋"><!ENTITY ReverseElement "∋"><!ENTITY ni "∋"><!ENTITY SuchThat "∋"><!ENTITY notni "∌"><!ENTITY notniva "∌"><!ENTITY NotReverseElement "∌"><!ENTITY prod "∏"><!ENTITY Product "∏"><!ENTITY coprod "∐"><!ENTITY Coproduct "∐"><!ENTITY sum "∑"><!ENTITY Sum "∑"><!ENTITY minus "−"><!ENTITY mnplus "∓"><!ENTITY mp "∓"><!ENTITY MinusPlus "∓"><!ENTITY plusdo "∔"><!ENTITY dotplus "∔"><!ENTITY setmn "∖"><!ENTITY setminus "∖"><!ENTITY Backslash "∖"><!ENTITY ssetmn "∖"><!ENTITY smallsetminus "∖"><!ENTITY lowast "∗"><!ENTITY compfn "∘"><!ENTITY SmallCircle "∘"><!ENTITY radic "√"><!ENTITY Sqrt "√"><!ENTITY prop "∝"><!ENTITY propto "∝"><!ENTITY Proportional "∝"><!ENTITY vprop "∝"><!ENTITY varpropto "∝"><!ENTITY infin "∞"><!ENTITY angrt "∟"><!ENTITY ang "∠"><!ENTITY angle "∠"><!ENTITY nang "∠⃒"><!ENTITY angmsd "∡"><!ENTITY measuredangle "∡"><!ENTITY angsph "∢"><!ENTITY mid "∣"><!ENTITY VerticalBar "∣"><!ENTITY smid "∣"><!ENTITY shortmid "∣"><!ENTITY nmid "∤"><!ENTITY NotVerticalBar "∤"><!ENTITY nsmid "∤"><!ENTITY nshortmid "∤"><!ENTITY par "∥"><!ENTITY parallel "∥"><!ENTITY DoubleVerticalBar "∥"><!ENTITY spar "∥"><!ENTITY shortparallel "∥"><!ENTITY npar "∦"><!ENTITY nparallel "∦"><!ENTITY NotDoubleVerticalBar "∦"><!ENTITY nspar "∦"><!ENTITY nshortparallel "∦"><!ENTITY and "∧"><!ENTITY wedge "∧"><!ENTITY or "∨"><!ENTITY vee "∨"><!ENTITY cap "∩"><!ENTITY caps "∩︀"><!ENTITY cup "∪"><!ENTITY cups "∪︀"><!ENTITY int "∫"><!ENTITY Integral "∫"><!ENTITY Int "∬"><!ENTITY tint "∭"><!ENTITY iiint "∭"><!ENTITY conint "∮"><!ENTITY oint "∮"><!ENTITY ContourIntegral "∮"><!ENTITY Conint "∯"><!ENTITY DoubleContourIntegral "∯"><!ENTITY Cconint "∰"><!ENTITY cwint "∱"><!ENTITY cwconint "∲"><!ENTITY ClockwiseContourIntegral "∲"><!ENTITY awconint "∳"><!ENTITY CounterClockwiseContourIntegral "∳"><!ENTITY there4 "∴"><!ENTITY therefore "∴"><!ENTITY Therefore "∴"><!ENTITY becaus "∵"><!ENTITY because "∵"><!ENTITY Because "∵"><!ENTITY ratio "∶"><!ENTITY Colon "∷"><!ENTITY Proportion "∷"><!ENTITY minusd "∸"><!ENTITY dotminus "∸"><!ENTITY mDDot "∺"><!ENTITY homtht "∻"><!ENTITY sim "∼"><!ENTITY Tilde "∼"><!ENTITY thksim "∼"><!ENTITY thicksim "∼"><!ENTITY nvsim "∼⃒"><!ENTITY bsim "∽"><!ENTITY backsim "∽"><!ENTITY race "∽̱"><!ENTITY ac "∾"><!ENTITY mstpos "∾"><!ENTITY acE "∾̳"><!ENTITY acd "∿"><!ENTITY wreath "≀"><!ENTITY VerticalTilde "≀"><!ENTITY wr "≀"><!ENTITY nsim "≁"><!ENTITY NotTilde "≁"><!ENTITY esim "≂"><!ENTITY EqualTilde "≂"><!ENTITY eqsim "≂"><!ENTITY NotEqualTilde "≂̸"><!ENTITY nesim "≂̸"><!ENTITY sime "≃"><!ENTITY TildeEqual "≃"><!ENTITY simeq "≃"><!ENTITY nsime "≄"><!ENTITY nsimeq "≄"><!ENTITY NotTildeEqual "≄"><!ENTITY cong "≅"><!ENTITY TildeFullEqual "≅"><!ENTITY simne "≆"><!ENTITY ncong "≇"><!ENTITY NotTildeFullEqual "≇"><!ENTITY asymp "≈"><!ENTITY ap "≈"><!ENTITY TildeTilde "≈"><!ENTITY approx "≈"><!ENTITY thkap "≈"><!ENTITY thickapprox "≈"><!ENTITY nap "≉"><!ENTITY NotTildeTilde "≉"><!ENTITY napprox "≉"><!ENTITY ape "≊"><!ENTITY approxeq "≊"><!ENTITY apid "≋"><!ENTITY napid "≋̸"><!ENTITY bcong "≌"><!ENTITY backcong "≌"><!ENTITY asympeq "≍"><!ENTITY CupCap "≍"><!ENTITY nvap "≍⃒"><!ENTITY bump "≎"><!ENTITY HumpDownHump "≎"><!ENTITY Bumpeq "≎"><!ENTITY NotHumpDownHump "≎̸"><!ENTITY nbump "≎̸"><!ENTITY bumpe "≏"><!ENTITY HumpEqual "≏"><!ENTITY bumpeq "≏"><!ENTITY nbumpe "≏̸"><!ENTITY NotHumpEqual "≏̸"><!ENTITY esdot "≐"><!ENTITY DotEqual "≐"><!ENTITY doteq "≐"><!ENTITY nedot "≐̸"><!ENTITY eDot "≑"><!ENTITY doteqdot "≑"><!ENTITY efDot "≒"><!ENTITY fallingdotseq "≒"><!ENTITY erDot "≓"><!ENTITY risingdotseq "≓"><!ENTITY colone "≔"><!ENTITY coloneq "≔"><!ENTITY Assign "≔"><!ENTITY ecolon "≕"><!ENTITY eqcolon "≕"><!ENTITY ecir "≖"><!ENTITY eqcirc "≖"><!ENTITY cire "≗"><!ENTITY circeq "≗"><!ENTITY wedgeq "≙"><!ENTITY veeeq "≚"><!ENTITY trie "≜"><!ENTITY triangleq "≜"><!ENTITY equest "≟"><!ENTITY questeq "≟"><!ENTITY ne "≠"><!ENTITY NotEqual "≠"><!ENTITY equiv "≡"><!ENTITY Congruent "≡"><!ENTITY bnequiv "≡⃥"><!ENTITY nequiv "≢"><!ENTITY NotCongruent "≢"><!ENTITY le "≤"><!ENTITY leq "≤"><!ENTITY nvle "≤⃒"><!ENTITY ge "≥"><!ENTITY GreaterEqual "≥"><!ENTITY geq "≥"><!ENTITY nvge "≥⃒"><!ENTITY lE "≦"><!ENTITY LessFullEqual "≦"><!ENTITY leqq "≦"><!ENTITY nlE "≦̸"><!ENTITY nleqq "≦̸"><!ENTITY gE "≧"><!ENTITY GreaterFullEqual "≧"><!ENTITY geqq "≧"><!ENTITY ngE "≧̸"><!ENTITY ngeqq "≧̸"><!ENTITY NotGreaterFullEqual "≧̸"><!ENTITY lnE "≨"><!ENTITY lneqq "≨"><!ENTITY lvnE "≨︀"><!ENTITY lvertneqq "≨︀"><!ENTITY gnE "≩"><!ENTITY gneqq "≩"><!ENTITY gvnE "≩︀"><!ENTITY gvertneqq "≩︀"><!ENTITY Lt "≪"><!ENTITY NestedLessLess "≪"><!ENTITY ll "≪"><!ENTITY nLtv "≪̸"><!ENTITY NotLessLess "≪̸"><!ENTITY nLt "≪⃒"><!ENTITY Gt "≫"><!ENTITY NestedGreaterGreater "≫"><!ENTITY gg "≫"><!ENTITY nGtv "≫̸"><!ENTITY NotGreaterGreater "≫̸"><!ENTITY nGt "≫⃒"><!ENTITY twixt "≬"><!ENTITY between "≬"><!ENTITY NotCupCap "≭"><!ENTITY nlt "≮"><!ENTITY NotLess "≮"><!ENTITY nless "≮"><!ENTITY ngt "≯"><!ENTITY NotGreater "≯"><!ENTITY ngtr "≯"><!ENTITY nle "≰"><!ENTITY NotLessEqual "≰"><!ENTITY nleq "≰"><!ENTITY nge "≱"><!ENTITY NotGreaterEqual "≱"><!ENTITY ngeq "≱"><!ENTITY lsim "≲"><!ENTITY LessTilde "≲"><!ENTITY lesssim "≲"><!ENTITY gsim "≳"><!ENTITY gtrsim "≳"><!ENTITY GreaterTilde "≳"><!ENTITY nlsim "≴"><!ENTITY NotLessTilde "≴"><!ENTITY ngsim "≵"><!ENTITY NotGreaterTilde "≵"><!ENTITY lg "≶"><!ENTITY lessgtr "≶"><!ENTITY LessGreater "≶"><!ENTITY gl "≷"><!ENTITY gtrless "≷"><!ENTITY GreaterLess "≷"><!ENTITY ntlg "≸"><!ENTITY NotLessGreater "≸"><!ENTITY ntgl "≹"><!ENTITY NotGreaterLess "≹"><!ENTITY pr "≺"><!ENTITY Precedes "≺"><!ENTITY prec "≺"><!ENTITY sc "≻"><!ENTITY Succeeds "≻"><!ENTITY succ "≻"><!ENTITY prcue "≼"><!ENTITY PrecedesSlantEqual "≼"><!ENTITY preccurlyeq "≼"><!ENTITY sccue "≽"><!ENTITY SucceedsSlantEqual "≽"><!ENTITY succcurlyeq "≽"><!ENTITY prsim "≾"><!ENTITY precsim "≾"><!ENTITY PrecedesTilde "≾"><!ENTITY scsim "≿"><!ENTITY succsim "≿"><!ENTITY SucceedsTilde "≿"><!ENTITY NotSucceedsTilde "≿̸"><!ENTITY npr "⊀"><!ENTITY nprec "⊀"><!ENTITY NotPrecedes "⊀"><!ENTITY nsc "⊁"><!ENTITY nsucc "⊁"><!ENTITY NotSucceeds "⊁"><!ENTITY sub "⊂"><!ENTITY subset "⊂"><!ENTITY vnsub "⊂⃒"><!ENTITY nsubset "⊂⃒"><!ENTITY NotSubset "⊂⃒"><!ENTITY sup "⊃"><!ENTITY supset "⊃"><!ENTITY Superset "⊃"><!ENTITY vnsup "⊃⃒"><!ENTITY nsupset "⊃⃒"><!ENTITY NotSuperset "⊃⃒"><!ENTITY nsub "⊄"><!ENTITY nsup "⊅"><!ENTITY sube "⊆"><!ENTITY SubsetEqual "⊆"><!ENTITY subseteq "⊆"><!ENTITY supe "⊇"><!ENTITY supseteq "⊇"><!ENTITY SupersetEqual "⊇"><!ENTITY nsube "⊈"><!ENTITY nsubseteq "⊈"><!ENTITY NotSubsetEqual "⊈"><!ENTITY nsupe "⊉"><!ENTITY nsupseteq "⊉"><!ENTITY NotSupersetEqual "⊉"><!ENTITY subne "⊊"><!ENTITY subsetneq "⊊"><!ENTITY vsubne "⊊︀"><!ENTITY varsubsetneq "⊊︀"><!ENTITY supne "⊋"><!ENTITY supsetneq "⊋"><!ENTITY vsupne "⊋︀"><!ENTITY varsupsetneq "⊋︀"><!ENTITY cupdot "⊍"><!ENTITY uplus "⊎"><!ENTITY UnionPlus "⊎"><!ENTITY sqsub "⊏"><!ENTITY SquareSubset "⊏"><!ENTITY sqsubset "⊏"><!ENTITY NotSquareSubset "⊏̸"><!ENTITY sqsup "⊐"><!ENTITY SquareSuperset "⊐"><!ENTITY sqsupset "⊐"><!ENTITY NotSquareSuperset "⊐̸"><!ENTITY sqsube "⊑"><!ENTITY SquareSubsetEqual "⊑"><!ENTITY sqsubseteq "⊑"><!ENTITY sqsupe "⊒"><!ENTITY SquareSupersetEqual "⊒"><!ENTITY sqsupseteq "⊒"><!ENTITY sqcap "⊓"><!ENTITY SquareIntersection "⊓"><!ENTITY sqcaps "⊓︀"><!ENTITY sqcup "⊔"><!ENTITY SquareUnion "⊔"><!ENTITY sqcups "⊔︀"><!ENTITY oplus "⊕"><!ENTITY CirclePlus "⊕"><!ENTITY ominus "⊖"><!ENTITY CircleMinus "⊖"><!ENTITY otimes "⊗"><!ENTITY CircleTimes "⊗"><!ENTITY osol "⊘"><!ENTITY odot "⊙"><!ENTITY CircleDot "⊙"><!ENTITY ocir "⊚"><!ENTITY circledcirc "⊚"><!ENTITY oast "⊛"><!ENTITY circledast "⊛"><!ENTITY odash "⊝"><!ENTITY circleddash "⊝"><!ENTITY plusb "⊞"><!ENTITY boxplus "⊞"><!ENTITY minusb "⊟"><!ENTITY boxminus "⊟"><!ENTITY timesb "⊠"><!ENTITY boxtimes "⊠"><!ENTITY sdotb "⊡"><!ENTITY dotsquare "⊡"><!ENTITY vdash "⊢"><!ENTITY RightTee "⊢"><!ENTITY dashv "⊣"><!ENTITY LeftTee "⊣"><!ENTITY top "⊤"><!ENTITY DownTee "⊤"><!ENTITY bottom "⊥"><!ENTITY bot "⊥"><!ENTITY perp "⊥"><!ENTITY UpTee "⊥"><!ENTITY models "⊧"><!ENTITY vDash "⊨"><!ENTITY DoubleRightTee "⊨"><!ENTITY Vdash "⊩"><!ENTITY Vvdash "⊪"><!ENTITY VDash "⊫"><!ENTITY nvdash "⊬"><!ENTITY nvDash "⊭"><!ENTITY nVdash "⊮"><!ENTITY nVDash "⊯"><!ENTITY prurel "⊰"><!ENTITY vltri "⊲"><!ENTITY vartriangleleft "⊲"><!ENTITY LeftTriangle "⊲"><!ENTITY vrtri "⊳"><!ENTITY vartriangleright "⊳"><!ENTITY RightTriangle "⊳"><!ENTITY ltrie "⊴"><!ENTITY trianglelefteq "⊴"><!ENTITY LeftTriangleEqual "⊴"><!ENTITY nvltrie "⊴⃒"><!ENTITY rtrie "⊵"><!ENTITY trianglerighteq "⊵"><!ENTITY RightTriangleEqual "⊵"><!ENTITY nvrtrie "⊵⃒"><!ENTITY origof "⊶"><!ENTITY imof "⊷"><!ENTITY mumap "⊸"><!ENTITY multimap "⊸"><!ENTITY hercon "⊹"><!ENTITY intcal "⊺"><!ENTITY intercal "⊺"><!ENTITY veebar "⊻"><!ENTITY barvee "⊽"><!ENTITY angrtvb "⊾"><!ENTITY lrtri "⊿"><!ENTITY xwedge "⋀"><!ENTITY Wedge "⋀"><!ENTITY bigwedge "⋀"><!ENTITY xvee "⋁"><!ENTITY Vee "⋁"><!ENTITY bigvee "⋁"><!ENTITY xcap "⋂"><!ENTITY Intersection "⋂"><!ENTITY bigcap "⋂"><!ENTITY xcup "⋃"><!ENTITY Union "⋃"><!ENTITY bigcup "⋃"><!ENTITY diam "⋄"><!ENTITY diamond "⋄"><!ENTITY Diamond "⋄"><!ENTITY sdot "⋅"><!ENTITY sstarf "⋆"><!ENTITY Star "⋆"><!ENTITY divonx "⋇"><!ENTITY divideontimes "⋇"><!ENTITY bowtie "⋈"><!ENTITY ltimes "⋉"><!ENTITY rtimes "⋊"><!ENTITY lthree "⋋"><!ENTITY leftthreetimes "⋋"><!ENTITY rthree "⋌"><!ENTITY rightthreetimes "⋌"><!ENTITY bsime "⋍"><!ENTITY backsimeq "⋍"><!ENTITY cuvee "⋎"><!ENTITY curlyvee "⋎"><!ENTITY cuwed "⋏"><!ENTITY curlywedge "⋏"><!ENTITY Sub "⋐"><!ENTITY Subset "⋐"><!ENTITY Sup "⋑"><!ENTITY Supset "⋑"><!ENTITY Cap "⋒"><!ENTITY Cup "⋓"><!ENTITY fork "⋔"><!ENTITY pitchfork "⋔"><!ENTITY epar "⋕"><!ENTITY ltdot "⋖"><!ENTITY lessdot "⋖"><!ENTITY gtdot "⋗"><!ENTITY gtrdot "⋗"><!ENTITY Ll "⋘"><!ENTITY nLl "⋘̸"><!ENTITY Gg "⋙"><!ENTITY ggg "⋙"><!ENTITY nGg "⋙̸"><!ENTITY leg "⋚"><!ENTITY LessEqualGreater "⋚"><!ENTITY lesseqgtr "⋚"><!ENTITY lesg "⋚︀"><!ENTITY gel "⋛"><!ENTITY gtreqless "⋛"><!ENTITY GreaterEqualLess "⋛"><!ENTITY gesl "⋛︀"><!ENTITY cuepr "⋞"><!ENTITY curlyeqprec "⋞"><!ENTITY cuesc "⋟"><!ENTITY curlyeqsucc "⋟"><!ENTITY nprcue "⋠"><!ENTITY NotPrecedesSlantEqual "⋠"><!ENTITY nsccue "⋡"><!ENTITY NotSucceedsSlantEqual "⋡"><!ENTITY nsqsube "⋢"><!ENTITY NotSquareSubsetEqual "⋢"><!ENTITY nsqsupe "⋣"><!ENTITY NotSquareSupersetEqual "⋣"><!ENTITY lnsim "⋦"><!ENTITY gnsim "⋧"><!ENTITY prnsim "⋨"><!ENTITY precnsim "⋨"><!ENTITY scnsim "⋩"><!ENTITY succnsim "⋩"><!ENTITY nltri "⋪"><!ENTITY ntriangleleft "⋪"><!ENTITY NotLeftTriangle "⋪"><!ENTITY nrtri "⋫"><!ENTITY ntriangleright "⋫"><!ENTITY NotRightTriangle "⋫"><!ENTITY nltrie "⋬"><!ENTITY ntrianglelefteq "⋬"><!ENTITY NotLeftTriangleEqual "⋬"><!ENTITY nrtrie "⋭"><!ENTITY ntrianglerighteq "⋭"><!ENTITY NotRightTriangleEqual "⋭"><!ENTITY vellip "⋮"><!ENTITY ctdot "⋯"><!ENTITY utdot "⋰"><!ENTITY dtdot "⋱"><!ENTITY disin "⋲"><!ENTITY isinsv "⋳"><!ENTITY isins "⋴"><!ENTITY isindot "⋵"><!ENTITY notindot "⋵̸"><!ENTITY notinvc "⋶"><!ENTITY notinvb "⋷"><!ENTITY isinE "⋹"><!ENTITY notinE "⋹̸"><!ENTITY nisd "⋺"><!ENTITY xnis "⋻"><!ENTITY nis "⋼"><!ENTITY notnivc "⋽"><!ENTITY notnivb "⋾"><!ENTITY barwed "⌅"><!ENTITY barwedge "⌅"><!ENTITY Barwed "⌆"><!ENTITY doublebarwedge "⌆"><!ENTITY lceil "⌈"><!ENTITY LeftCeiling "⌈"><!ENTITY rceil "⌉"><!ENTITY RightCeiling "⌉"><!ENTITY lfloor "⌊"><!ENTITY LeftFloor "⌊"><!ENTITY rfloor "⌋"><!ENTITY RightFloor "⌋"><!ENTITY drcrop "⌌"><!ENTITY dlcrop "⌍"><!ENTITY urcrop "⌎"><!ENTITY ulcrop "⌏"><!ENTITY bnot "⌐"><!ENTITY profline "⌒"><!ENTITY profsurf "⌓"><!ENTITY telrec "⌕"><!ENTITY target "⌖"><!ENTITY ulcorn "⌜"><!ENTITY ulcorner "⌜"><!ENTITY urcorn "⌝"><!ENTITY urcorner "⌝"><!ENTITY dlcorn "⌞"><!ENTITY llcorner "⌞"><!ENTITY drcorn "⌟"><!ENTITY lrcorner "⌟"><!ENTITY frown "⌢"><!ENTITY sfrown "⌢"><!ENTITY smile "⌣"><!ENTITY ssmile "⌣"><!ENTITY cylcty "⌭"><!ENTITY profalar "⌮"><!ENTITY topbot "⌶"><!ENTITY ovbar "⌽"><!ENTITY solbar "⌿"><!ENTITY angzarr "⍼"><!ENTITY lmoust "⎰"><!ENTITY lmoustache "⎰"><!ENTITY rmoust "⎱"><!ENTITY rmoustache "⎱"><!ENTITY tbrk "⎴"><!ENTITY OverBracket "⎴"><!ENTITY bbrk "⎵"><!ENTITY UnderBracket "⎵"><!ENTITY bbrktbrk "⎶"><!ENTITY OverParenthesis "⏜"><!ENTITY UnderParenthesis "⏝"><!ENTITY OverBrace "⏞"><!ENTITY UnderBrace "⏟"><!ENTITY trpezium "⏢"><!ENTITY elinters "⏧"><!ENTITY blank "␣"><!ENTITY oS "Ⓢ"><!ENTITY circledS "Ⓢ"><!ENTITY boxh "─"><!ENTITY HorizontalLine "─"><!ENTITY boxv "│"><!ENTITY boxdr "┌"><!ENTITY boxdl "┐"><!ENTITY boxur "└"><!ENTITY boxul "┘"><!ENTITY boxvr "├"><!ENTITY boxvl "┤"><!ENTITY boxhd "┬"><!ENTITY boxhu "┴"><!ENTITY boxvh "┼"><!ENTITY boxH "═"><!ENTITY boxV "║"><!ENTITY boxdR "╒"><!ENTITY boxDr "╓"><!ENTITY boxDR "╔"><!ENTITY boxdL "╕"><!ENTITY boxDl "╖"><!ENTITY boxDL "╗"><!ENTITY boxuR "╘"><!ENTITY boxUr "╙"><!ENTITY boxUR "╚"><!ENTITY boxuL "╛"><!ENTITY boxUl "╜"><!ENTITY boxUL "╝"><!ENTITY boxvR "╞"><!ENTITY boxVr "╟"><!ENTITY boxVR "╠"><!ENTITY boxvL "╡"><!ENTITY boxVl "╢"><!ENTITY boxVL "╣"><!ENTITY boxHd "╤"><!ENTITY boxhD "╥"><!ENTITY boxHD "╦"><!ENTITY boxHu "╧"><!ENTITY boxhU "╨"><!ENTITY boxHU "╩"><!ENTITY boxvH "╪"><!ENTITY boxVh "╫"><!ENTITY boxVH "╬"><!ENTITY uhblk "▀"><!ENTITY lhblk "▄"><!ENTITY block "█"><!ENTITY blk14 "░"><!ENTITY blk12 "▒"><!ENTITY blk34 "▓"><!ENTITY squ "□"><!ENTITY square "□"><!ENTITY Square "□"><!ENTITY squf "▪"><!ENTITY squarf "▪"><!ENTITY blacksquare "▪"><!ENTITY FilledVerySmallSquare "▪"><!ENTITY EmptyVerySmallSquare "▫"><!ENTITY rect "▭"><!ENTITY marker "▮"><!ENTITY fltns "▱"><!ENTITY xutri "△"><!ENTITY bigtriangleup "△"><!ENTITY utrif "▴"><!ENTITY blacktriangle "▴"><!ENTITY utri "▵"><!ENTITY triangle "▵"><!ENTITY rtrif "▸"><!ENTITY blacktriangleright "▸"><!ENTITY rtri "▹"><!ENTITY triangleright "▹"><!ENTITY xdtri "▽"><!ENTITY bigtriangledown "▽"><!ENTITY dtrif "▾"><!ENTITY blacktriangledown "▾"><!ENTITY dtri "▿"><!ENTITY triangledown "▿"><!ENTITY ltrif "◂"><!ENTITY blacktriangleleft "◂"><!ENTITY ltri "◃"><!ENTITY triangleleft "◃"><!ENTITY loz "◊"><!ENTITY lozenge "◊"><!ENTITY cir "○"><!ENTITY tridot "◬"><!ENTITY xcirc "◯"><!ENTITY bigcirc "◯"><!ENTITY ultri "◸"><!ENTITY urtri "◹"><!ENTITY lltri "◺"><!ENTITY EmptySmallSquare "◻"><!ENTITY FilledSmallSquare "◼"><!ENTITY starf "★"><!ENTITY bigstar "★"><!ENTITY star "☆"><!ENTITY phone "☎"><!ENTITY female "♀"><!ENTITY male "♂"><!ENTITY spades "♠"><!ENTITY spadesuit "♠"><!ENTITY clubs "♣"><!ENTITY clubsuit "♣"><!ENTITY hearts "♥"><!ENTITY heartsuit "♥"><!ENTITY diams "♦"><!ENTITY diamondsuit "♦"><!ENTITY sung "♪"><!ENTITY flat "♭"><!ENTITY natur "♮"><!ENTITY natural "♮"><!ENTITY sharp "♯"><!ENTITY check "✓"><!ENTITY checkmark "✓"><!ENTITY cross "✗"><!ENTITY malt "✠"><!ENTITY maltese "✠"><!ENTITY sext "✶"><!ENTITY VerticalSeparator "❘"><!ENTITY lbbrk "❲"><!ENTITY rbbrk "❳"><!ENTITY bsolhsub "⟈"><!ENTITY suphsol "⟉"><!ENTITY lobrk "⟦"><!ENTITY LeftDoubleBracket "⟦"><!ENTITY robrk "⟧"><!ENTITY RightDoubleBracket "⟧"><!ENTITY lang "⟨"><!ENTITY LeftAngleBracket "⟨"><!ENTITY langle "⟨"><!ENTITY rang "⟩"><!ENTITY RightAngleBracket "⟩"><!ENTITY rangle "⟩"><!ENTITY Lang "⟪"><!ENTITY Rang "⟫"><!ENTITY loang "⟬"><!ENTITY roang "⟭"><!ENTITY xlarr "⟵"><!ENTITY longleftarrow "⟵"><!ENTITY LongLeftArrow "⟵"><!ENTITY xrarr "⟶"><!ENTITY longrightarrow "⟶"><!ENTITY LongRightArrow "⟶"><!ENTITY xharr "⟷"><!ENTITY longleftrightarrow "⟷"><!ENTITY LongLeftRightArrow "⟷"><!ENTITY xlArr "⟸"><!ENTITY Longleftarrow "⟸"><!ENTITY DoubleLongLeftArrow "⟸"><!ENTITY xrArr "⟹"><!ENTITY Longrightarrow "⟹"><!ENTITY DoubleLongRightArrow "⟹"><!ENTITY xhArr "⟺"><!ENTITY Longleftrightarrow "⟺"><!ENTITY DoubleLongLeftRightArrow "⟺"><!ENTITY xmap "⟼"><!ENTITY longmapsto "⟼"><!ENTITY dzigrarr "⟿"><!ENTITY nvlArr "⤂"><!ENTITY nvrArr "⤃"><!ENTITY nvHarr "⤄"><!ENTITY Map "⤅"><!ENTITY lbarr "⤌"><!ENTITY rbarr "⤍"><!ENTITY bkarow "⤍"><!ENTITY lBarr "⤎"><!ENTITY rBarr "⤏"><!ENTITY dbkarow "⤏"><!ENTITY RBarr "⤐"><!ENTITY drbkarow "⤐"><!ENTITY DDotrahd "⤑"><!ENTITY UpArrowBar "⤒"><!ENTITY DownArrowBar "⤓"><!ENTITY Rarrtl "⤖"><!ENTITY latail "⤙"><!ENTITY ratail "⤚"><!ENTITY lAtail "⤛"><!ENTITY rAtail "⤜"><!ENTITY larrfs "⤝"><!ENTITY rarrfs "⤞"><!ENTITY larrbfs "⤟"><!ENTITY rarrbfs "⤠"><!ENTITY nwarhk "⤣"><!ENTITY nearhk "⤤"><!ENTITY searhk "⤥"><!ENTITY hksearow "⤥"><!ENTITY swarhk "⤦"><!ENTITY hkswarow "⤦"><!ENTITY nwnear "⤧"><!ENTITY nesear "⤨"><!ENTITY toea "⤨"><!ENTITY seswar "⤩"><!ENTITY tosa "⤩"><!ENTITY swnwar "⤪"><!ENTITY rarrc "⤳"><!ENTITY nrarrc "⤳̸"><!ENTITY cudarrr "⤵"><!ENTITY ldca "⤶"><!ENTITY rdca "⤷"><!ENTITY cudarrl "⤸"><!ENTITY larrpl "⤹"><!ENTITY curarrm "⤼"><!ENTITY cularrp "⤽"><!ENTITY rarrpl "⥅"><!ENTITY harrcir "⥈"><!ENTITY Uarrocir "⥉"><!ENTITY lurdshar "⥊"><!ENTITY ldrushar "⥋"><!ENTITY LeftRightVector "⥎"><!ENTITY RightUpDownVector "⥏"><!ENTITY DownLeftRightVector "⥐"><!ENTITY LeftUpDownVector "⥑"><!ENTITY LeftVectorBar "⥒"><!ENTITY RightVectorBar "⥓"><!ENTITY RightUpVectorBar "⥔"><!ENTITY RightDownVectorBar "⥕"><!ENTITY DownLeftVectorBar "⥖"><!ENTITY DownRightVectorBar "⥗"><!ENTITY LeftUpVectorBar "⥘"><!ENTITY LeftDownVectorBar "⥙"><!ENTITY LeftTeeVector "⥚"><!ENTITY RightTeeVector "⥛"><!ENTITY RightUpTeeVector "⥜"><!ENTITY RightDownTeeVector "⥝"><!ENTITY DownLeftTeeVector "⥞"><!ENTITY DownRightTeeVector "⥟"><!ENTITY LeftUpTeeVector "⥠"><!ENTITY LeftDownTeeVector "⥡"><!ENTITY lHar "⥢"><!ENTITY uHar "⥣"><!ENTITY rHar "⥤"><!ENTITY dHar "⥥"><!ENTITY luruhar "⥦"><!ENTITY ldrdhar "⥧"><!ENTITY ruluhar "⥨"><!ENTITY rdldhar "⥩"><!ENTITY lharul "⥪"><!ENTITY llhard "⥫"><!ENTITY rharul "⥬"><!ENTITY lrhard "⥭"><!ENTITY udhar "⥮"><!ENTITY UpEquilibrium "⥮"><!ENTITY duhar "⥯"><!ENTITY ReverseUpEquilibrium "⥯"><!ENTITY RoundImplies "⥰"><!ENTITY erarr "⥱"><!ENTITY simrarr "⥲"><!ENTITY larrsim "⥳"><!ENTITY rarrsim "⥴"><!ENTITY rarrap "⥵"><!ENTITY ltlarr "⥶"><!ENTITY gtrarr "⥸"><!ENTITY subrarr "⥹"><!ENTITY suplarr "⥻"><!ENTITY lfisht "⥼"><!ENTITY rfisht "⥽"><!ENTITY ufisht "⥾"><!ENTITY dfisht "⥿"><!ENTITY lopar "⦅"><!ENTITY ropar "⦆"><!ENTITY lbrke "⦋"><!ENTITY rbrke "⦌"><!ENTITY lbrkslu "⦍"><!ENTITY rbrksld "⦎"><!ENTITY lbrksld "⦏"><!ENTITY rbrkslu "⦐"><!ENTITY langd "⦑"><!ENTITY rangd "⦒"><!ENTITY lparlt "⦓"><!ENTITY rpargt "⦔"><!ENTITY gtlPar "⦕"><!ENTITY ltrPar "⦖"><!ENTITY vzigzag "⦚"><!ENTITY vangrt "⦜"><!ENTITY angrtvbd "⦝"><!ENTITY ange "⦤"><!ENTITY range "⦥"><!ENTITY dwangle "⦦"><!ENTITY uwangle "⦧"><!ENTITY angmsdaa "⦨"><!ENTITY angmsdab "⦩"><!ENTITY angmsdac "⦪"><!ENTITY angmsdad "⦫"><!ENTITY angmsdae "⦬"><!ENTITY angmsdaf "⦭"><!ENTITY angmsdag "⦮"><!ENTITY angmsdah "⦯"><!ENTITY bemptyv "⦰"><!ENTITY demptyv "⦱"><!ENTITY cemptyv "⦲"><!ENTITY raemptyv "⦳"><!ENTITY laemptyv "⦴"><!ENTITY ohbar "⦵"><!ENTITY omid "⦶"><!ENTITY opar "⦷"><!ENTITY operp "⦹"><!ENTITY olcross "⦻"><!ENTITY odsold "⦼"><!ENTITY olcir "⦾"><!ENTITY ofcir "⦿"><!ENTITY olt "⧀"><!ENTITY ogt "⧁"><!ENTITY cirscir "⧂"><!ENTITY cirE "⧃"><!ENTITY solb "⧄"><!ENTITY bsolb "⧅"><!ENTITY boxbox "⧉"><!ENTITY trisb "⧍"><!ENTITY rtriltri "⧎"><!ENTITY LeftTriangleBar "⧏"><!ENTITY NotLeftTriangleBar "⧏̸"><!ENTITY RightTriangleBar "⧐"><!ENTITY NotRightTriangleBar "⧐̸"><!ENTITY iinfin "⧜"><!ENTITY infintie "⧝"><!ENTITY nvinfin "⧞"><!ENTITY eparsl "⧣"><!ENTITY smeparsl "⧤"><!ENTITY eqvparsl "⧥"><!ENTITY lozf "⧫"><!ENTITY blacklozenge "⧫"><!ENTITY RuleDelayed "⧴"><!ENTITY dsol "⧶"><!ENTITY xodot "⨀"><!ENTITY bigodot "⨀"><!ENTITY xoplus "⨁"><!ENTITY bigoplus "⨁"><!ENTITY xotime "⨂"><!ENTITY bigotimes "⨂"><!ENTITY xuplus "⨄"><!ENTITY biguplus "⨄"><!ENTITY xsqcup "⨆"><!ENTITY bigsqcup "⨆"><!ENTITY qint "⨌"><!ENTITY iiiint "⨌"><!ENTITY fpartint "⨍"><!ENTITY cirfnint "⨐"><!ENTITY awint "⨑"><!ENTITY rppolint "⨒"><!ENTITY scpolint "⨓"><!ENTITY npolint "⨔"><!ENTITY pointint "⨕"><!ENTITY quatint "⨖"><!ENTITY intlarhk "⨗"><!ENTITY pluscir "⨢"><!ENTITY plusacir "⨣"><!ENTITY simplus "⨤"><!ENTITY plusdu "⨥"><!ENTITY plussim "⨦"><!ENTITY plustwo "⨧"><!ENTITY mcomma "⨩"><!ENTITY minusdu "⨪"><!ENTITY loplus "⨭"><!ENTITY roplus "⨮"><!ENTITY Cross "⨯"><!ENTITY timesd "⨰"><!ENTITY timesbar "⨱"><!ENTITY smashp "⨳"><!ENTITY lotimes "⨴"><!ENTITY rotimes "⨵"><!ENTITY otimesas "⨶"><!ENTITY Otimes "⨷"><!ENTITY odiv "⨸"><!ENTITY triplus "⨹"><!ENTITY triminus "⨺"><!ENTITY tritime "⨻"><!ENTITY iprod "⨼"><!ENTITY intprod "⨼"><!ENTITY amalg "⨿"><!ENTITY capdot "⩀"><!ENTITY ncup "⩂"><!ENTITY ncap "⩃"><!ENTITY capand "⩄"><!ENTITY cupor "⩅"><!ENTITY cupcap "⩆"><!ENTITY capcup "⩇"><!ENTITY cupbrcap "⩈"><!ENTITY capbrcup "⩉"><!ENTITY cupcup "⩊"><!ENTITY capcap "⩋"><!ENTITY ccups "⩌"><!ENTITY ccaps "⩍"><!ENTITY ccupssm "⩐"><!ENTITY And "⩓"><!ENTITY Or "⩔"><!ENTITY andand "⩕"><!ENTITY oror "⩖"><!ENTITY orslope "⩗"><!ENTITY andslope "⩘"><!ENTITY andv "⩚"><!ENTITY orv "⩛"><!ENTITY andd "⩜"><!ENTITY ord "⩝"><!ENTITY wedbar "⩟"><!ENTITY sdote "⩦"><!ENTITY simdot "⩪"><!ENTITY congdot "⩭"><!ENTITY ncongdot "⩭̸"><!ENTITY easter "⩮"><!ENTITY apacir "⩯"><!ENTITY apE "⩰"><!ENTITY napE "⩰̸"><!ENTITY eplus "⩱"><!ENTITY pluse "⩲"><!ENTITY Esim "⩳"><!ENTITY Colone "⩴"><!ENTITY Equal "⩵"><!ENTITY eDDot "⩷"><!ENTITY ddotseq "⩷"><!ENTITY equivDD "⩸"><!ENTITY ltcir "⩹"><!ENTITY gtcir "⩺"><!ENTITY ltquest "⩻"><!ENTITY gtquest "⩼"><!ENTITY les "⩽"><!ENTITY LessSlantEqual "⩽"><!ENTITY leqslant "⩽"><!ENTITY nles "⩽̸"><!ENTITY NotLessSlantEqual "⩽̸"><!ENTITY nleqslant "⩽̸"><!ENTITY ges "⩾"><!ENTITY GreaterSlantEqual "⩾"><!ENTITY geqslant "⩾"><!ENTITY nges "⩾̸"><!ENTITY NotGreaterSlantEqual "⩾̸"><!ENTITY ngeqslant "⩾̸"><!ENTITY lesdot "⩿"><!ENTITY gesdot "⪀"><!ENTITY lesdoto "⪁"><!ENTITY gesdoto "⪂"><!ENTITY lesdotor "⪃"><!ENTITY gesdotol "⪄"><!ENTITY lap "⪅"><!ENTITY lessapprox "⪅"><!ENTITY gap "⪆"><!ENTITY gtrapprox "⪆"><!ENTITY lne "⪇"><!ENTITY lneq "⪇"><!ENTITY gne "⪈"><!ENTITY gneq "⪈"><!ENTITY lnap "⪉"><!ENTITY lnapprox "⪉"><!ENTITY gnap "⪊"><!ENTITY gnapprox "⪊"><!ENTITY lEg "⪋"><!ENTITY lesseqqgtr "⪋"><!ENTITY gEl "⪌"><!ENTITY gtreqqless "⪌"><!ENTITY lsime "⪍"><!ENTITY gsime "⪎"><!ENTITY lsimg "⪏"><!ENTITY gsiml "⪐"><!ENTITY lgE "⪑"><!ENTITY glE "⪒"><!ENTITY lesges "⪓"><!ENTITY gesles "⪔"><!ENTITY els "⪕"><!ENTITY eqslantless "⪕"><!ENTITY egs "⪖"><!ENTITY eqslantgtr "⪖"><!ENTITY elsdot "⪗"><!ENTITY egsdot "⪘"><!ENTITY el "⪙"><!ENTITY eg "⪚"><!ENTITY siml "⪝"><!ENTITY simg "⪞"><!ENTITY simlE "⪟"><!ENTITY simgE "⪠"><!ENTITY LessLess "⪡"><!ENTITY NotNestedLessLess "⪡̸"><!ENTITY GreaterGreater "⪢"><!ENTITY NotNestedGreaterGreater "⪢̸"><!ENTITY glj "⪤"><!ENTITY gla "⪥"><!ENTITY ltcc "⪦"><!ENTITY gtcc "⪧"><!ENTITY lescc "⪨"><!ENTITY gescc "⪩"><!ENTITY smt "⪪"><!ENTITY lat "⪫"><!ENTITY smte "⪬"><!ENTITY smtes "⪬︀"><!ENTITY late "⪭"><!ENTITY lates "⪭︀"><!ENTITY bumpE "⪮"><!ENTITY pre "⪯"><!ENTITY preceq "⪯"><!ENTITY PrecedesEqual "⪯"><!ENTITY npre "⪯̸"><!ENTITY npreceq "⪯̸"><!ENTITY NotPrecedesEqual "⪯̸"><!ENTITY sce "⪰"><!ENTITY succeq "⪰"><!ENTITY SucceedsEqual "⪰"><!ENTITY nsce "⪰̸"><!ENTITY nsucceq "⪰̸"><!ENTITY NotSucceedsEqual "⪰̸"><!ENTITY prE "⪳"><!ENTITY scE "⪴"><!ENTITY prnE "⪵"><!ENTITY precneqq "⪵"><!ENTITY scnE "⪶"><!ENTITY succneqq "⪶"><!ENTITY prap "⪷"><!ENTITY precapprox "⪷"><!ENTITY scap "⪸"><!ENTITY succapprox "⪸"><!ENTITY prnap "⪹"><!ENTITY precnapprox "⪹"><!ENTITY scnap "⪺"><!ENTITY succnapprox "⪺"><!ENTITY Pr "⪻"><!ENTITY Sc "⪼"><!ENTITY subdot "⪽"><!ENTITY supdot "⪾"><!ENTITY subplus "⪿"><!ENTITY supplus "⫀"><!ENTITY submult "⫁"><!ENTITY supmult "⫂"><!ENTITY subedot "⫃"><!ENTITY supedot "⫄"><!ENTITY subE "⫅"><!ENTITY subseteqq "⫅"><!ENTITY nsubE "⫅̸"><!ENTITY nsubseteqq "⫅̸"><!ENTITY supE "⫆"><!ENTITY supseteqq "⫆"><!ENTITY nsupE "⫆̸"><!ENTITY nsupseteqq "⫆̸"><!ENTITY subsim "⫇"><!ENTITY supsim "⫈"><!ENTITY subnE "⫋"><!ENTITY subsetneqq "⫋"><!ENTITY vsubnE "⫋︀"><!ENTITY varsubsetneqq "⫋︀"><!ENTITY supnE "⫌"><!ENTITY supsetneqq "⫌"><!ENTITY vsupnE "⫌︀"><!ENTITY varsupsetneqq "⫌︀"><!ENTITY csub "⫏"><!ENTITY csup "⫐"><!ENTITY csube "⫑"><!ENTITY csupe "⫒"><!ENTITY subsup "⫓"><!ENTITY supsub "⫔"><!ENTITY subsub "⫕"><!ENTITY supsup "⫖"><!ENTITY suphsub "⫗"><!ENTITY supdsub "⫘"><!ENTITY forkv "⫙"><!ENTITY topfork "⫚"><!ENTITY mlcp "⫛"><!ENTITY Dashv "⫤"><!ENTITY DoubleLeftTee "⫤"><!ENTITY Vdashl "⫦"><!ENTITY Barv "⫧"><!ENTITY vBar "⫨"><!ENTITY vBarv "⫩"><!ENTITY Vbar "⫫"><!ENTITY Not "⫬"><!ENTITY bNot "⫭"><!ENTITY rnmid "⫮"><!ENTITY cirmid "⫯"><!ENTITY midcir "⫰"><!ENTITY topcir "⫱"><!ENTITY nhpar "⫲"><!ENTITY parsim "⫳"><!ENTITY parsl "⫽"><!ENTITY nparsl "⫽⃥"><!ENTITY fflig "ff"><!ENTITY filig "fi"><!ENTITY fllig "fl"><!ENTITY ffilig "ffi"><!ENTITY ffllig "ffl"><!ENTITY Ascr "𝒜"><!ENTITY Cscr "𝒞"><!ENTITY Dscr "𝒟"><!ENTITY Gscr "𝒢"><!ENTITY Jscr "𝒥"><!ENTITY Kscr "𝒦"><!ENTITY Nscr "𝒩"><!ENTITY Oscr "𝒪"><!ENTITY Pscr "𝒫"><!ENTITY Qscr "𝒬"><!ENTITY Sscr "𝒮"><!ENTITY Tscr "𝒯"><!ENTITY Uscr "𝒰"><!ENTITY Vscr "𝒱"><!ENTITY Wscr "𝒲"><!ENTITY Xscr "𝒳"><!ENTITY Yscr "𝒴"><!ENTITY Zscr "𝒵"><!ENTITY ascr "𝒶"><!ENTITY bscr "𝒷"><!ENTITY cscr "𝒸"><!ENTITY dscr "𝒹"><!ENTITY fscr "𝒻"><!ENTITY hscr "𝒽"><!ENTITY iscr "𝒾"><!ENTITY jscr "𝒿"><!ENTITY kscr "𝓀"><!ENTITY lscr "𝓁"><!ENTITY mscr "𝓂"><!ENTITY nscr "𝓃"><!ENTITY pscr "𝓅"><!ENTITY qscr "𝓆"><!ENTITY rscr "𝓇"><!ENTITY sscr "𝓈"><!ENTITY tscr "𝓉"><!ENTITY uscr "𝓊"><!ENTITY vscr "𝓋"><!ENTITY wscr "𝓌"><!ENTITY xscr "𝓍"><!ENTITY yscr "𝓎"><!ENTITY zscr "𝓏"><!ENTITY Afr "𝔄"><!ENTITY Bfr "𝔅"><!ENTITY Dfr "𝔇"><!ENTITY Efr "𝔈"><!ENTITY Ffr "𝔉"><!ENTITY Gfr "𝔊"><!ENTITY Jfr "𝔍"><!ENTITY Kfr "𝔎"><!ENTITY Lfr "𝔏"><!ENTITY Mfr "𝔐"><!ENTITY Nfr "𝔑"><!ENTITY Ofr "𝔒"><!ENTITY Pfr "𝔓"><!ENTITY Qfr "𝔔"><!ENTITY Sfr "𝔖"><!ENTITY Tfr "𝔗"><!ENTITY Ufr "𝔘"><!ENTITY Vfr "𝔙"><!ENTITY Wfr "𝔚"><!ENTITY Xfr "𝔛"><!ENTITY Yfr "𝔜"><!ENTITY afr "𝔞"><!ENTITY bfr "𝔟"><!ENTITY cfr "𝔠"><!ENTITY dfr "𝔡"><!ENTITY efr "𝔢"><!ENTITY ffr "𝔣"><!ENTITY gfr "𝔤"><!ENTITY hfr "𝔥"><!ENTITY ifr "𝔦"><!ENTITY jfr "𝔧"><!ENTITY kfr "𝔨"><!ENTITY lfr "𝔩"><!ENTITY mfr "𝔪"><!ENTITY nfr "𝔫"><!ENTITY ofr "𝔬"><!ENTITY pfr "𝔭"><!ENTITY qfr "𝔮"><!ENTITY rfr "𝔯"><!ENTITY sfr "𝔰"><!ENTITY tfr "𝔱"><!ENTITY ufr "𝔲"><!ENTITY vfr "𝔳"><!ENTITY wfr "𝔴"><!ENTITY xfr "𝔵"><!ENTITY yfr "𝔶"><!ENTITY zfr "𝔷"><!ENTITY Aopf "𝔸"><!ENTITY Bopf "𝔹"><!ENTITY Dopf "𝔻"><!ENTITY Eopf "𝔼"><!ENTITY Fopf "𝔽"><!ENTITY Gopf "𝔾"><!ENTITY Iopf "𝕀"><!ENTITY Jopf "𝕁"><!ENTITY Kopf "𝕂"><!ENTITY Lopf "𝕃"><!ENTITY Mopf "𝕄"><!ENTITY Oopf "𝕆"><!ENTITY Sopf "𝕊"><!ENTITY Topf "𝕋"><!ENTITY Uopf "𝕌"><!ENTITY Vopf "𝕍"><!ENTITY Wopf "𝕎"><!ENTITY Xopf "𝕏"><!ENTITY Yopf "𝕐"><!ENTITY aopf "𝕒"><!ENTITY bopf "𝕓"><!ENTITY copf "𝕔"><!ENTITY dopf "𝕕"><!ENTITY eopf "𝕖"><!ENTITY fopf "𝕗"><!ENTITY gopf "𝕘"><!ENTITY hopf "𝕙"><!ENTITY iopf "𝕚"><!ENTITY jopf "𝕛"><!ENTITY kopf "𝕜"><!ENTITY lopf "𝕝"><!ENTITY mopf "𝕞"><!ENTITY nopf "𝕟"><!ENTITY oopf "𝕠"><!ENTITY popf "𝕡"><!ENTITY qopf "𝕢"><!ENTITY ropf "𝕣"><!ENTITY sopf "𝕤"><!ENTITY topf "𝕥"><!ENTITY uopf "𝕦"><!ENTITY vopf "𝕧"><!ENTITY wopf "𝕨"><!ENTITY xopf "𝕩"><!ENTITY yopf "𝕪"><!ENTITY zopf "𝕫"> )xmlxmlxml"; } diff --git a/Userland/Libraries/LibX86/Instruction.cpp b/Userland/Libraries/LibX86/Instruction.cpp index 4907fd72a0..acc82b06c1 100644 --- a/Userland/Libraries/LibX86/Instruction.cpp +++ b/Userland/Libraries/LibX86/Instruction.cpp @@ -33,7 +33,7 @@ static bool opcode_has_register_index(u8 op) return false; } -static void build(InstructionDescriptor* table, u8 op, const char* mnemonic, InstructionFormat format, InstructionHandler handler, IsLockPrefixAllowed lock_prefix_allowed) +static void build(InstructionDescriptor* table, u8 op, char const* mnemonic, InstructionFormat format, InstructionHandler handler, IsLockPrefixAllowed lock_prefix_allowed) { InstructionDescriptor& d = table[op]; @@ -111,7 +111,7 @@ static void build(InstructionDescriptor* table, u8 op, const char* mnemonic, Ins case OP_NEAR_imm: d.imm1_bytes = CurrentAddressSize; break; - //default: + // default: case InvalidFormat: case MultibyteWithSlash: case InstructionPrefix: @@ -202,7 +202,7 @@ static void build(InstructionDescriptor* table, u8 op, const char* mnemonic, Ins } } -static void build_slash(InstructionDescriptor* table, u8 op, u8 slash, const char* mnemonic, InstructionFormat format, InstructionHandler handler, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_slash(InstructionDescriptor* table, u8 op, u8 slash, char const* mnemonic, InstructionFormat format, InstructionHandler handler, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { InstructionDescriptor& d = table[op]; VERIFY(d.handler == nullptr); @@ -214,7 +214,7 @@ static void build_slash(InstructionDescriptor* table, u8 op, u8 slash, const cha build(d.slashes, slash, mnemonic, format, handler, lock_prefix_allowed); } -static void build_slash_rm(InstructionDescriptor* table, u8 op, u8 slash, u8 rm, const char* mnemonic, InstructionFormat format, InstructionHandler handler) +static void build_slash_rm(InstructionDescriptor* table, u8 op, u8 slash, u8 rm, char const* mnemonic, InstructionFormat format, InstructionHandler handler) { VERIFY((rm & 0xc0) == 0xc0); VERIFY(((rm >> 3) & 7) == slash); @@ -235,79 +235,79 @@ static void build_slash_rm(InstructionDescriptor* table, u8 op, u8 slash, u8 rm, build(d.slashes, rm & 7, mnemonic, format, handler, LockPrefixNotAllowed); } -static void build_0f(u8 op, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_0f(u8 op, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build(s_0f_table16, op, mnemonic, format, impl, lock_prefix_allowed); build(s_0f_table32, op, mnemonic, format, impl, lock_prefix_allowed); } -static void build(u8 op, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build(u8 op, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build(s_table16, op, mnemonic, format, impl, lock_prefix_allowed); build(s_table32, op, mnemonic, format, impl, lock_prefix_allowed); } -static void build(u8 op, const char* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build(u8 op, char const* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build(s_table16, op, mnemonic, format16, impl16, lock_prefix_allowed); build(s_table32, op, mnemonic, format32, impl32, lock_prefix_allowed); } -static void build_0f(u8 op, const char* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_0f(u8 op, char const* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build(s_0f_table16, op, mnemonic, format16, impl16, lock_prefix_allowed); build(s_0f_table32, op, mnemonic, format32, impl32, lock_prefix_allowed); } -static void build(u8 op, const char* mnemonic16, InstructionFormat format16, InstructionHandler impl16, const char* mnemonic32, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build(u8 op, char const* mnemonic16, InstructionFormat format16, InstructionHandler impl16, char const* mnemonic32, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build(s_table16, op, mnemonic16, format16, impl16, lock_prefix_allowed); build(s_table32, op, mnemonic32, format32, impl32, lock_prefix_allowed); } -static void build_0f(u8 op, const char* mnemonic16, InstructionFormat format16, InstructionHandler impl16, const char* mnemonic32, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_0f(u8 op, char const* mnemonic16, InstructionFormat format16, InstructionHandler impl16, char const* mnemonic32, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build(s_0f_table16, op, mnemonic16, format16, impl16, lock_prefix_allowed); build(s_0f_table32, op, mnemonic32, format32, impl32, lock_prefix_allowed); } -static void build_slash(u8 op, u8 slash, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_slash(u8 op, u8 slash, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build_slash(s_table16, op, slash, mnemonic, format, impl, lock_prefix_allowed); build_slash(s_table32, op, slash, mnemonic, format, impl, lock_prefix_allowed); } -static void build_slash(u8 op, u8 slash, const char* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_slash(u8 op, u8 slash, char const* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build_slash(s_table16, op, slash, mnemonic, format16, impl16, lock_prefix_allowed); build_slash(s_table32, op, slash, mnemonic, format32, impl32, lock_prefix_allowed); } -static void build_0f_slash(u8 op, u8 slash, const char* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_0f_slash(u8 op, u8 slash, char const* mnemonic, InstructionFormat format16, InstructionHandler impl16, InstructionFormat format32, InstructionHandler impl32, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build_slash(s_0f_table16, op, slash, mnemonic, format16, impl16, lock_prefix_allowed); build_slash(s_0f_table32, op, slash, mnemonic, format32, impl32, lock_prefix_allowed); } -static void build_0f_slash(u8 op, u8 slash, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_0f_slash(u8 op, u8 slash, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { build_slash(s_0f_table16, op, slash, mnemonic, format, impl, lock_prefix_allowed); build_slash(s_0f_table32, op, slash, mnemonic, format, impl, lock_prefix_allowed); } -static void build_slash_rm(u8 op, u8 slash, u8 rm, const char* mnemonic, InstructionFormat format, InstructionHandler impl) +static void build_slash_rm(u8 op, u8 slash, u8 rm, char const* mnemonic, InstructionFormat format, InstructionHandler impl) { build_slash_rm(s_table16, op, slash, rm, mnemonic, format, impl); build_slash_rm(s_table32, op, slash, rm, mnemonic, format, impl); } -static void build_slash_reg(u8 op, u8 slash, const char* mnemonic, InstructionFormat format, InstructionHandler impl) +static void build_slash_reg(u8 op, u8 slash, char const* mnemonic, InstructionFormat format, InstructionHandler impl) { for (int i = 0; i < 8; ++i) build_slash_rm(op, slash, 0xc0 | (slash << 3) | i, mnemonic, format, impl); } -static void build_sse_np(u8 op, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_sse_np(u8 op, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { if (s_0f_table32[op].format == InvalidFormat) { build_0f(op, mnemonic, format, impl, lock_prefix_allowed); @@ -321,7 +321,7 @@ static void build_sse_np(u8 op, const char* mnemonic, InstructionFormat format, build(s_sse_table_np, op, mnemonic, format, impl, lock_prefix_allowed); } -static void build_sse_66(u8 op, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_sse_66(u8 op, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { if (s_0f_table32[op].format != __SSE) build_0f(op, "__SSE_temp", __SSE, nullptr, lock_prefix_allowed); @@ -329,7 +329,7 @@ static void build_sse_66(u8 op, const char* mnemonic, InstructionFormat format, build(s_sse_table_66, op, mnemonic, format, impl, lock_prefix_allowed); } -static void build_sse_f3(u8 op, const char* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) +static void build_sse_f3(u8 op, char const* mnemonic, InstructionFormat format, InstructionHandler impl, IsLockPrefixAllowed lock_prefix_allowed = LockPrefixNotAllowed) { if (s_0f_table32[op].format != __SSE) build_0f(op, "__SSE_temp", __SSE, nullptr, lock_prefix_allowed); @@ -1086,44 +1086,44 @@ static void build_sse_f3(u8 op, const char* mnemonic, InstructionFormat format, build_0f(0xFF, "UD0", OP, &Interpreter::UD0); } -static const char* register_name(RegisterIndex8); -static const char* register_name(RegisterIndex16); -static const char* register_name(RegisterIndex32); -static const char* register_name(FpuRegisterIndex); -static const char* register_name(SegmentRegister); -static const char* register_name(MMXRegisterIndex); -static const char* register_name(XMMRegisterIndex); +static char const* register_name(RegisterIndex8); +static char const* register_name(RegisterIndex16); +static char const* register_name(RegisterIndex32); +static char const* register_name(FpuRegisterIndex); +static char const* register_name(SegmentRegister); +static char const* register_name(MMXRegisterIndex); +static char const* register_name(XMMRegisterIndex); -const char* Instruction::reg8_name() const +char const* Instruction::reg8_name() const { return register_name(static_cast<RegisterIndex8>(register_index())); } -const char* Instruction::reg16_name() const +char const* Instruction::reg16_name() const { return register_name(static_cast<RegisterIndex16>(register_index())); } -const char* Instruction::reg32_name() const +char const* Instruction::reg32_name() const { return register_name(static_cast<RegisterIndex32>(register_index())); } -String MemoryOrRegisterReference::to_string_o8(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_o8(Instruction const& insn) const { if (is_register()) return register_name(reg8()); return String::formatted("[{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_o16(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_o16(Instruction const& insn) const { if (is_register()) return register_name(reg16()); return String::formatted("[{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_o32(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_o32(Instruction const& insn) const { if (is_register()) return register_name(reg32()); @@ -1136,7 +1136,7 @@ String MemoryOrRegisterReference::to_string_fpu_reg() const return register_name(reg_fpu()); } -String MemoryOrRegisterReference::to_string_fpu_mem(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_fpu_mem(Instruction const& insn) const { VERIFY(!is_register()); return String::formatted("[{}]", to_string(insn)); @@ -1148,46 +1148,46 @@ String MemoryOrRegisterReference::to_string_fpu_ax16() const return register_name(reg16()); } -String MemoryOrRegisterReference::to_string_fpu16(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_fpu16(Instruction const& insn) const { if (is_register()) return register_name(reg_fpu()); return String::formatted("word ptr [{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_fpu32(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_fpu32(Instruction const& insn) const { if (is_register()) return register_name(reg_fpu()); return String::formatted("dword ptr [{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_fpu64(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_fpu64(Instruction const& insn) const { if (is_register()) return register_name(reg_fpu()); return String::formatted("qword ptr [{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_fpu80(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_fpu80(Instruction const& insn) const { VERIFY(!is_register()); return String::formatted("tbyte ptr [{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_mm(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_mm(Instruction const& insn) const { if (is_register()) return register_name(static_cast<MMXRegisterIndex>(m_register_index)); return String::formatted("[{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string_xmm(const Instruction& insn) const +String MemoryOrRegisterReference::to_string_xmm(Instruction const& insn) const { if (is_register()) return register_name(static_cast<XMMRegisterIndex>(m_register_index)); return String::formatted("[{}]", to_string(insn)); } -String MemoryOrRegisterReference::to_string(const Instruction& insn) const +String MemoryOrRegisterReference::to_string(Instruction const& insn) const { if (insn.a32()) return to_string_a32(); @@ -1407,7 +1407,7 @@ static String relative_address(u32 origin, bool x32, i32 imm) return String::formatted("{:#04x}", w + si); } -String Instruction::to_string(u32 origin, const SymbolProvider* symbol_provider, bool x32) const +String Instruction::to_string(u32 origin, SymbolProvider const* symbol_provider, bool x32) const { StringBuilder builder; if (has_segment_prefix()) @@ -1424,7 +1424,7 @@ String Instruction::to_string(u32 origin, const SymbolProvider* symbol_provider, return builder.to_string(); } -void Instruction::to_string_internal(StringBuilder& builder, u32 origin, const SymbolProvider* symbol_provider, bool x32) const +void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolProvider const* symbol_provider, bool x32) const { if (!m_descriptor) { builder.appendff("db {:02x}", m_op); @@ -2215,45 +2215,45 @@ String Instruction::mnemonic() const return m_descriptor->mnemonic; } -const char* register_name(SegmentRegister index) +char const* register_name(SegmentRegister index) { - static constexpr const char* names[] = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" }; + static constexpr char const* names[] = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" }; return names[(int)index & 7]; } -const char* register_name(RegisterIndex8 register_index) +char const* register_name(RegisterIndex8 register_index) { - static constexpr const char* names[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" }; + static constexpr char const* names[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" }; return names[register_index & 7]; } -const char* register_name(RegisterIndex16 register_index) +char const* register_name(RegisterIndex16 register_index) { - static constexpr const char* names[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" }; + static constexpr char const* names[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" }; return names[register_index & 7]; } -const char* register_name(RegisterIndex32 register_index) +char const* register_name(RegisterIndex32 register_index) { - static constexpr const char* names[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" }; + static constexpr char const* names[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" }; return names[register_index & 7]; } -const char* register_name(FpuRegisterIndex register_index) +char const* register_name(FpuRegisterIndex register_index) { - static constexpr const char* names[] = { "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7" }; + static constexpr char const* names[] = { "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7" }; return names[register_index & 7]; } -const char* register_name(MMXRegisterIndex register_index) +char const* register_name(MMXRegisterIndex register_index) { - static constexpr const char* names[] = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }; + static constexpr char const* names[] = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }; return names[register_index & 7]; } -const char* register_name(XMMRegisterIndex register_index) +char const* register_name(XMMRegisterIndex register_index) { - static constexpr const char* names[] = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" }; + static constexpr char const* names[] = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" }; return names[register_index & 7]; } diff --git a/Userland/Libraries/LibX86/Instruction.h b/Userland/Libraries/LibX86/Instruction.h index 60a797091e..b70287d925 100644 --- a/Userland/Libraries/LibX86/Instruction.h +++ b/Userland/Libraries/LibX86/Instruction.h @@ -17,7 +17,7 @@ namespace X86 { class Instruction; class Interpreter; -typedef void (Interpreter::*InstructionHandler)(const Instruction&); +typedef void (Interpreter::*InstructionHandler)(Instruction const&); class SymbolProvider { public: @@ -194,7 +194,7 @@ static constexpr unsigned CurrentAddressSize = 0xB33FBABE; struct InstructionDescriptor { InstructionHandler handler { nullptr }; bool opcode_has_register_index { false }; - const char* mnemonic { nullptr }; + char const* mnemonic { nullptr }; InstructionFormat format { InvalidFormat }; bool has_rm { false }; unsigned imm1_bytes { 0 }; @@ -352,7 +352,7 @@ protected: class SimpleInstructionStream final : public InstructionStream { public: - SimpleInstructionStream(const u8* data, size_t size) + SimpleInstructionStream(u8 const* data, size_t size) : m_data(data) , m_size(size) { @@ -389,7 +389,7 @@ public: size_t offset() const { return m_offset; } private: - const u8* m_data { nullptr }; + u8 const* m_data { nullptr }; size_t m_offset { 0 }; size_t m_size { 0 }; }; @@ -398,18 +398,18 @@ class MemoryOrRegisterReference { friend class Instruction; public: - String to_string_o8(const Instruction&) const; - String to_string_o16(const Instruction&) const; - String to_string_o32(const Instruction&) const; + String to_string_o8(Instruction const&) const; + String to_string_o16(Instruction const&) const; + String to_string_o32(Instruction const&) const; String to_string_fpu_reg() const; - String to_string_fpu_mem(const Instruction&) const; + String to_string_fpu_mem(Instruction const&) const; String to_string_fpu_ax16() const; - String to_string_fpu16(const Instruction&) const; - String to_string_fpu32(const Instruction&) const; - String to_string_fpu64(const Instruction&) const; - String to_string_fpu80(const Instruction&) const; - String to_string_mm(const Instruction&) const; - String to_string_xmm(const Instruction&) const; + String to_string_fpu16(Instruction const&) const; + String to_string_fpu32(Instruction const&) const; + String to_string_fpu64(Instruction const&) const; + String to_string_fpu80(Instruction const&) const; + String to_string_mm(Instruction const&) const; + String to_string_xmm(Instruction const&) const; bool is_register() const { return m_register_index != 0x7f; } @@ -425,38 +425,38 @@ public: u8 rm() const { return m_rm_byte & 0b111; } template<typename CPU, typename T> - void write8(CPU&, const Instruction&, T); + void write8(CPU&, Instruction const&, T); template<typename CPU, typename T> - void write16(CPU&, const Instruction&, T); + void write16(CPU&, Instruction const&, T); template<typename CPU, typename T> - void write32(CPU&, const Instruction&, T); + void write32(CPU&, Instruction const&, T); template<typename CPU, typename T> - void write64(CPU&, const Instruction&, T); + void write64(CPU&, Instruction const&, T); template<typename CPU, typename T> - void write128(CPU&, const Instruction&, T); + void write128(CPU&, Instruction const&, T); template<typename CPU, typename T> - void write256(CPU&, const Instruction&, T); + void write256(CPU&, Instruction const&, T); template<typename CPU> - typename CPU::ValueWithShadowType8 read8(CPU&, const Instruction&); + typename CPU::ValueWithShadowType8 read8(CPU&, Instruction const&); template<typename CPU> - typename CPU::ValueWithShadowType16 read16(CPU&, const Instruction&); + typename CPU::ValueWithShadowType16 read16(CPU&, Instruction const&); template<typename CPU> - typename CPU::ValueWithShadowType32 read32(CPU&, const Instruction&); + typename CPU::ValueWithShadowType32 read32(CPU&, Instruction const&); template<typename CPU> - typename CPU::ValueWithShadowType64 read64(CPU&, const Instruction&); + typename CPU::ValueWithShadowType64 read64(CPU&, Instruction const&); template<typename CPU> - typename CPU::ValueWithShadowType128 read128(CPU&, const Instruction&); + typename CPU::ValueWithShadowType128 read128(CPU&, Instruction const&); template<typename CPU> - typename CPU::ValueWithShadowType256 read256(CPU&, const Instruction&); + typename CPU::ValueWithShadowType256 read256(CPU&, Instruction const&); template<typename CPU> - LogicalAddress resolve(const CPU&, const Instruction&); + LogicalAddress resolve(const CPU&, Instruction const&); private: MemoryOrRegisterReference() = default; - String to_string(const Instruction&) const; + String to_string(Instruction const&) const; String to_string_a16() const; String to_string_a32() const; @@ -550,17 +550,17 @@ public: bool a32() const { return m_a32; } - String to_string(u32 origin, const SymbolProvider* = nullptr, bool x32 = true) const; + String to_string(u32 origin, SymbolProvider const* = nullptr, bool x32 = true) const; private: template<typename InstructionStreamType> Instruction(InstructionStreamType&, bool o32, bool a32); - void to_string_internal(StringBuilder&, u32 origin, const SymbolProvider*, bool x32) const; + void to_string_internal(StringBuilder&, u32 origin, SymbolProvider const*, bool x32) const; - const char* reg8_name() const; - const char* reg16_name() const; - const char* reg32_name() const; + char const* reg8_name() const; + char const* reg16_name() const; + char const* reg32_name() const; InstructionDescriptor* m_descriptor { nullptr }; mutable MemoryOrRegisterReference m_modrm; @@ -697,7 +697,7 @@ ALWAYS_INLINE u32 MemoryOrRegisterReference::evaluate_sib(const CPU& cpu, Segmen } template<typename CPU, typename T> -ALWAYS_INLINE void MemoryOrRegisterReference::write8(CPU& cpu, const Instruction& insn, T value) +ALWAYS_INLINE void MemoryOrRegisterReference::write8(CPU& cpu, Instruction const& insn, T value) { if (is_register()) { cpu.gpr8(reg8()) = value; @@ -709,7 +709,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::write8(CPU& cpu, const Instruction } template<typename CPU, typename T> -ALWAYS_INLINE void MemoryOrRegisterReference::write16(CPU& cpu, const Instruction& insn, T value) +ALWAYS_INLINE void MemoryOrRegisterReference::write16(CPU& cpu, Instruction const& insn, T value) { if (is_register()) { cpu.gpr16(reg16()) = value; @@ -721,7 +721,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::write16(CPU& cpu, const Instructio } template<typename CPU, typename T> -ALWAYS_INLINE void MemoryOrRegisterReference::write32(CPU& cpu, const Instruction& insn, T value) +ALWAYS_INLINE void MemoryOrRegisterReference::write32(CPU& cpu, Instruction const& insn, T value) { if (is_register()) { cpu.gpr32(reg32()) = value; @@ -733,7 +733,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::write32(CPU& cpu, const Instructio } template<typename CPU, typename T> -ALWAYS_INLINE void MemoryOrRegisterReference::write64(CPU& cpu, const Instruction& insn, T value) +ALWAYS_INLINE void MemoryOrRegisterReference::write64(CPU& cpu, Instruction const& insn, T value) { VERIFY(!is_register()); auto address = resolve(cpu, insn); @@ -741,7 +741,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::write64(CPU& cpu, const Instructio } template<typename CPU, typename T> -ALWAYS_INLINE void MemoryOrRegisterReference::write128(CPU& cpu, const Instruction& insn, T value) +ALWAYS_INLINE void MemoryOrRegisterReference::write128(CPU& cpu, Instruction const& insn, T value) { VERIFY(!is_register()); auto address = resolve(cpu, insn); @@ -749,7 +749,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::write128(CPU& cpu, const Instructi } template<typename CPU, typename T> -ALWAYS_INLINE void MemoryOrRegisterReference::write256(CPU& cpu, const Instruction& insn, T value) +ALWAYS_INLINE void MemoryOrRegisterReference::write256(CPU& cpu, Instruction const& insn, T value) { VERIFY(!is_register()); auto address = resolve(cpu, insn); @@ -757,7 +757,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::write256(CPU& cpu, const Instructi } template<typename CPU> -ALWAYS_INLINE typename CPU::ValueWithShadowType8 MemoryOrRegisterReference::read8(CPU& cpu, const Instruction& insn) +ALWAYS_INLINE typename CPU::ValueWithShadowType8 MemoryOrRegisterReference::read8(CPU& cpu, Instruction const& insn) { if (is_register()) return cpu.const_gpr8(reg8()); @@ -767,7 +767,7 @@ ALWAYS_INLINE typename CPU::ValueWithShadowType8 MemoryOrRegisterReference::read } template<typename CPU> -ALWAYS_INLINE typename CPU::ValueWithShadowType16 MemoryOrRegisterReference::read16(CPU& cpu, const Instruction& insn) +ALWAYS_INLINE typename CPU::ValueWithShadowType16 MemoryOrRegisterReference::read16(CPU& cpu, Instruction const& insn) { if (is_register()) return cpu.const_gpr16(reg16()); @@ -777,7 +777,7 @@ ALWAYS_INLINE typename CPU::ValueWithShadowType16 MemoryOrRegisterReference::rea } template<typename CPU> -ALWAYS_INLINE typename CPU::ValueWithShadowType32 MemoryOrRegisterReference::read32(CPU& cpu, const Instruction& insn) +ALWAYS_INLINE typename CPU::ValueWithShadowType32 MemoryOrRegisterReference::read32(CPU& cpu, Instruction const& insn) { if (is_register()) return cpu.const_gpr32(reg32()); @@ -787,7 +787,7 @@ ALWAYS_INLINE typename CPU::ValueWithShadowType32 MemoryOrRegisterReference::rea } template<typename CPU> -ALWAYS_INLINE typename CPU::ValueWithShadowType64 MemoryOrRegisterReference::read64(CPU& cpu, const Instruction& insn) +ALWAYS_INLINE typename CPU::ValueWithShadowType64 MemoryOrRegisterReference::read64(CPU& cpu, Instruction const& insn) { VERIFY(!is_register()); auto address = resolve(cpu, insn); @@ -795,7 +795,7 @@ ALWAYS_INLINE typename CPU::ValueWithShadowType64 MemoryOrRegisterReference::rea } template<typename CPU> -ALWAYS_INLINE typename CPU::ValueWithShadowType128 MemoryOrRegisterReference::read128(CPU& cpu, const Instruction& insn) +ALWAYS_INLINE typename CPU::ValueWithShadowType128 MemoryOrRegisterReference::read128(CPU& cpu, Instruction const& insn) { VERIFY(!is_register()); auto address = resolve(cpu, insn); @@ -803,7 +803,7 @@ ALWAYS_INLINE typename CPU::ValueWithShadowType128 MemoryOrRegisterReference::re } template<typename CPU> -ALWAYS_INLINE typename CPU::ValueWithShadowType256 MemoryOrRegisterReference::read256(CPU& cpu, const Instruction& insn) +ALWAYS_INLINE typename CPU::ValueWithShadowType256 MemoryOrRegisterReference::read256(CPU& cpu, Instruction const& insn) { VERIFY(!is_register()); auto address = resolve(cpu, insn); @@ -1085,7 +1085,7 @@ ALWAYS_INLINE void MemoryOrRegisterReference::decode32(InstructionStreamType& st } template<typename CPU> -ALWAYS_INLINE LogicalAddress MemoryOrRegisterReference::resolve(const CPU& cpu, const Instruction& insn) +ALWAYS_INLINE LogicalAddress MemoryOrRegisterReference::resolve(const CPU& cpu, Instruction const& insn) { if (insn.a32()) return resolve32(cpu, insn.segment_prefix()); diff --git a/Userland/Libraries/LibX86/Interpreter.h b/Userland/Libraries/LibX86/Interpreter.h index aee9093500..d8fa0623a2 100644 --- a/Userland/Libraries/LibX86/Interpreter.h +++ b/Userland/Libraries/LibX86/Interpreter.h @@ -14,648 +14,648 @@ class Instruction; class Interpreter { public: - virtual void AAA(const Instruction&) = 0; - virtual void AAD(const Instruction&) = 0; - virtual void AAM(const Instruction&) = 0; - virtual void AAS(const Instruction&) = 0; - virtual void ADC_AL_imm8(const Instruction&) = 0; - virtual void ADC_AX_imm16(const Instruction&) = 0; - virtual void ADC_EAX_imm32(const Instruction&) = 0; - virtual void ADC_RM16_imm16(const Instruction&) = 0; - virtual void ADC_RM16_imm8(const Instruction&) = 0; - virtual void ADC_RM16_reg16(const Instruction&) = 0; - virtual void ADC_RM32_imm32(const Instruction&) = 0; - virtual void ADC_RM32_imm8(const Instruction&) = 0; - virtual void ADC_RM32_reg32(const Instruction&) = 0; - virtual void ADC_RM8_imm8(const Instruction&) = 0; - virtual void ADC_RM8_reg8(const Instruction&) = 0; - virtual void ADC_reg16_RM16(const Instruction&) = 0; - virtual void ADC_reg32_RM32(const Instruction&) = 0; - virtual void ADC_reg8_RM8(const Instruction&) = 0; - virtual void ADD_AL_imm8(const Instruction&) = 0; - virtual void ADD_AX_imm16(const Instruction&) = 0; - virtual void ADD_EAX_imm32(const Instruction&) = 0; - virtual void ADD_RM16_imm16(const Instruction&) = 0; - virtual void ADD_RM16_imm8(const Instruction&) = 0; - virtual void ADD_RM16_reg16(const Instruction&) = 0; - virtual void ADD_RM32_imm32(const Instruction&) = 0; - virtual void ADD_RM32_imm8(const Instruction&) = 0; - virtual void ADD_RM32_reg32(const Instruction&) = 0; - virtual void ADD_RM8_imm8(const Instruction&) = 0; - virtual void ADD_RM8_reg8(const Instruction&) = 0; - virtual void ADD_reg16_RM16(const Instruction&) = 0; - virtual void ADD_reg32_RM32(const Instruction&) = 0; - virtual void ADD_reg8_RM8(const Instruction&) = 0; - virtual void AND_AL_imm8(const Instruction&) = 0; - virtual void AND_AX_imm16(const Instruction&) = 0; - virtual void AND_EAX_imm32(const Instruction&) = 0; - virtual void AND_RM16_imm16(const Instruction&) = 0; - virtual void AND_RM16_imm8(const Instruction&) = 0; - virtual void AND_RM16_reg16(const Instruction&) = 0; - virtual void AND_RM32_imm32(const Instruction&) = 0; - virtual void AND_RM32_imm8(const Instruction&) = 0; - virtual void AND_RM32_reg32(const Instruction&) = 0; - virtual void AND_RM8_imm8(const Instruction&) = 0; - virtual void AND_RM8_reg8(const Instruction&) = 0; - virtual void AND_reg16_RM16(const Instruction&) = 0; - virtual void AND_reg32_RM32(const Instruction&) = 0; - virtual void AND_reg8_RM8(const Instruction&) = 0; - virtual void ARPL(const Instruction&) = 0; - virtual void BOUND(const Instruction&) = 0; - virtual void BSF_reg16_RM16(const Instruction&) = 0; - virtual void BSF_reg32_RM32(const Instruction&) = 0; - virtual void BSR_reg16_RM16(const Instruction&) = 0; - virtual void BSR_reg32_RM32(const Instruction&) = 0; - virtual void BSWAP_reg32(const Instruction&) = 0; - virtual void BTC_RM16_imm8(const Instruction&) = 0; - virtual void BTC_RM16_reg16(const Instruction&) = 0; - virtual void BTC_RM32_imm8(const Instruction&) = 0; - virtual void BTC_RM32_reg32(const Instruction&) = 0; - virtual void BTR_RM16_imm8(const Instruction&) = 0; - virtual void BTR_RM16_reg16(const Instruction&) = 0; - virtual void BTR_RM32_imm8(const Instruction&) = 0; - virtual void BTR_RM32_reg32(const Instruction&) = 0; - virtual void BTS_RM16_imm8(const Instruction&) = 0; - virtual void BTS_RM16_reg16(const Instruction&) = 0; - virtual void BTS_RM32_imm8(const Instruction&) = 0; - virtual void BTS_RM32_reg32(const Instruction&) = 0; - virtual void BT_RM16_imm8(const Instruction&) = 0; - virtual void BT_RM16_reg16(const Instruction&) = 0; - virtual void BT_RM32_imm8(const Instruction&) = 0; - virtual void BT_RM32_reg32(const Instruction&) = 0; - virtual void CALL_FAR_mem16(const Instruction&) = 0; - virtual void CALL_FAR_mem32(const Instruction&) = 0; - virtual void CALL_RM16(const Instruction&) = 0; - virtual void CALL_RM32(const Instruction&) = 0; - virtual void CALL_imm16(const Instruction&) = 0; - virtual void CALL_imm16_imm16(const Instruction&) = 0; - virtual void CALL_imm16_imm32(const Instruction&) = 0; - virtual void CALL_imm32(const Instruction&) = 0; - virtual void CBW(const Instruction&) = 0; - virtual void CDQ(const Instruction&) = 0; - virtual void CLC(const Instruction&) = 0; - virtual void CLD(const Instruction&) = 0; - virtual void CLI(const Instruction&) = 0; - virtual void CLTS(const Instruction&) = 0; - virtual void CMC(const Instruction&) = 0; - virtual void CMOVcc_reg16_RM16(const Instruction&) = 0; - virtual void CMOVcc_reg32_RM32(const Instruction&) = 0; - virtual void CMPSB(const Instruction&) = 0; - virtual void CMPSD(const Instruction&) = 0; - virtual void CMPSW(const Instruction&) = 0; - virtual void CMPXCHG_RM16_reg16(const Instruction&) = 0; - virtual void CMPXCHG_RM32_reg32(const Instruction&) = 0; - virtual void CMPXCHG_RM8_reg8(const Instruction&) = 0; - virtual void CMP_AL_imm8(const Instruction&) = 0; - virtual void CMP_AX_imm16(const Instruction&) = 0; - virtual void CMP_EAX_imm32(const Instruction&) = 0; - virtual void CMP_RM16_imm16(const Instruction&) = 0; - virtual void CMP_RM16_imm8(const Instruction&) = 0; - virtual void CMP_RM16_reg16(const Instruction&) = 0; - virtual void CMP_RM32_imm32(const Instruction&) = 0; - virtual void CMP_RM32_imm8(const Instruction&) = 0; - virtual void CMP_RM32_reg32(const Instruction&) = 0; - virtual void CMP_RM8_imm8(const Instruction&) = 0; - virtual void CMP_RM8_reg8(const Instruction&) = 0; - virtual void CMP_reg16_RM16(const Instruction&) = 0; - virtual void CMP_reg32_RM32(const Instruction&) = 0; - virtual void CMP_reg8_RM8(const Instruction&) = 0; - virtual void CPUID(const Instruction&) = 0; - virtual void CWD(const Instruction&) = 0; - virtual void CWDE(const Instruction&) = 0; - virtual void DAA(const Instruction&) = 0; - virtual void DAS(const Instruction&) = 0; - virtual void DEC_RM16(const Instruction&) = 0; - virtual void DEC_RM32(const Instruction&) = 0; - virtual void DEC_RM8(const Instruction&) = 0; - virtual void DEC_reg16(const Instruction&) = 0; - virtual void DEC_reg32(const Instruction&) = 0; - virtual void DIV_RM16(const Instruction&) = 0; - virtual void DIV_RM32(const Instruction&) = 0; - virtual void DIV_RM8(const Instruction&) = 0; - virtual void ENTER16(const Instruction&) = 0; - virtual void ENTER32(const Instruction&) = 0; - virtual void ESCAPE(const Instruction&) = 0; - virtual void FADD_RM32(const Instruction&) = 0; - virtual void FMUL_RM32(const Instruction&) = 0; - virtual void FCOM_RM32(const Instruction&) = 0; - virtual void FCOMP_RM32(const Instruction&) = 0; - virtual void FSUB_RM32(const Instruction&) = 0; - virtual void FSUBR_RM32(const Instruction&) = 0; - virtual void FDIV_RM32(const Instruction&) = 0; - virtual void FDIVR_RM32(const Instruction&) = 0; - virtual void FLD_RM32(const Instruction&) = 0; - virtual void FXCH(const Instruction&) = 0; - virtual void FST_RM32(const Instruction&) = 0; - virtual void FNOP(const Instruction&) = 0; - virtual void FSTP_RM32(const Instruction&) = 0; - virtual void FLDENV(const Instruction&) = 0; - virtual void FCHS(const Instruction&) = 0; - virtual void FABS(const Instruction&) = 0; - virtual void FTST(const Instruction&) = 0; - virtual void FXAM(const Instruction&) = 0; - virtual void FLDCW(const Instruction&) = 0; - virtual void FLD1(const Instruction&) = 0; - virtual void FLDL2T(const Instruction&) = 0; - virtual void FLDL2E(const Instruction&) = 0; - virtual void FLDPI(const Instruction&) = 0; - virtual void FLDLG2(const Instruction&) = 0; - virtual void FLDLN2(const Instruction&) = 0; - virtual void FLDZ(const Instruction&) = 0; - virtual void FNSTENV(const Instruction&) = 0; - virtual void F2XM1(const Instruction&) = 0; - virtual void FYL2X(const Instruction&) = 0; - virtual void FPTAN(const Instruction&) = 0; - virtual void FPATAN(const Instruction&) = 0; - virtual void FXTRACT(const Instruction&) = 0; - virtual void FPREM1(const Instruction&) = 0; - virtual void FDECSTP(const Instruction&) = 0; - virtual void FINCSTP(const Instruction&) = 0; - virtual void FNSTCW(const Instruction&) = 0; - virtual void FPREM(const Instruction&) = 0; - virtual void FYL2XP1(const Instruction&) = 0; - virtual void FSQRT(const Instruction&) = 0; - virtual void FSINCOS(const Instruction&) = 0; - virtual void FRNDINT(const Instruction&) = 0; - virtual void FSCALE(const Instruction&) = 0; - virtual void FSIN(const Instruction&) = 0; - virtual void FCOS(const Instruction&) = 0; - virtual void FIADD_RM32(const Instruction&) = 0; - virtual void FADDP(const Instruction&) = 0; - virtual void FIMUL_RM32(const Instruction&) = 0; - virtual void FCMOVE(const Instruction&) = 0; - virtual void FICOM_RM32(const Instruction&) = 0; - virtual void FCMOVBE(const Instruction&) = 0; - virtual void FICOMP_RM32(const Instruction&) = 0; - virtual void FCMOVU(const Instruction&) = 0; - virtual void FISUB_RM32(const Instruction&) = 0; - virtual void FISUBR_RM32(const Instruction&) = 0; - virtual void FUCOMPP(const Instruction&) = 0; - virtual void FIDIV_RM32(const Instruction&) = 0; - virtual void FIDIVR_RM32(const Instruction&) = 0; - virtual void FILD_RM32(const Instruction&) = 0; - virtual void FCMOVNB(const Instruction&) = 0; - virtual void FISTTP_RM32(const Instruction&) = 0; - virtual void FCMOVNE(const Instruction&) = 0; - virtual void FIST_RM32(const Instruction&) = 0; - virtual void FCMOVNBE(const Instruction&) = 0; - virtual void FISTP_RM32(const Instruction&) = 0; - virtual void FCMOVNU(const Instruction&) = 0; - virtual void FNENI(const Instruction&) = 0; - virtual void FNDISI(const Instruction&) = 0; - virtual void FNCLEX(const Instruction&) = 0; - virtual void FNINIT(const Instruction&) = 0; - virtual void FNSETPM(const Instruction&) = 0; - virtual void FLD_RM80(const Instruction&) = 0; - virtual void FUCOMI(const Instruction&) = 0; - virtual void FCOMI(const Instruction&) = 0; - virtual void FSTP_RM80(const Instruction&) = 0; - virtual void FADD_RM64(const Instruction&) = 0; - virtual void FMUL_RM64(const Instruction&) = 0; - virtual void FCOM_RM64(const Instruction&) = 0; - virtual void FCOMP_RM64(const Instruction&) = 0; - virtual void FSUB_RM64(const Instruction&) = 0; - virtual void FSUBR_RM64(const Instruction&) = 0; - virtual void FDIV_RM64(const Instruction&) = 0; - virtual void FDIVR_RM64(const Instruction&) = 0; - virtual void FLD_RM64(const Instruction&) = 0; - virtual void FFREE(const Instruction&) = 0; - virtual void FISTTP_RM64(const Instruction&) = 0; - virtual void FST_RM64(const Instruction&) = 0; - virtual void FSTP_RM64(const Instruction&) = 0; - virtual void FRSTOR(const Instruction&) = 0; - virtual void FUCOM(const Instruction&) = 0; - virtual void FUCOMP(const Instruction&) = 0; - virtual void FNSAVE(const Instruction&) = 0; - virtual void FNSTSW(const Instruction&) = 0; - virtual void FIADD_RM16(const Instruction&) = 0; - virtual void FCMOVB(const Instruction&) = 0; - virtual void FIMUL_RM16(const Instruction&) = 0; - virtual void FMULP(const Instruction&) = 0; - virtual void FICOM_RM16(const Instruction&) = 0; - virtual void FICOMP_RM16(const Instruction&) = 0; - virtual void FCOMPP(const Instruction&) = 0; - virtual void FISUB_RM16(const Instruction&) = 0; - virtual void FSUBRP(const Instruction&) = 0; - virtual void FISUBR_RM16(const Instruction&) = 0; - virtual void FSUBP(const Instruction&) = 0; - virtual void FIDIV_RM16(const Instruction&) = 0; - virtual void FDIVRP(const Instruction&) = 0; - virtual void FIDIVR_RM16(const Instruction&) = 0; - virtual void FDIVP(const Instruction&) = 0; - virtual void FILD_RM16(const Instruction&) = 0; - virtual void FFREEP(const Instruction&) = 0; - virtual void FISTTP_RM16(const Instruction&) = 0; - virtual void FIST_RM16(const Instruction&) = 0; - virtual void FISTP_RM16(const Instruction&) = 0; - virtual void FBLD_M80(const Instruction&) = 0; - virtual void FNSTSW_AX(const Instruction&) = 0; - virtual void FILD_RM64(const Instruction&) = 0; - virtual void FUCOMIP(const Instruction&) = 0; - virtual void FBSTP_M80(const Instruction&) = 0; - virtual void FCOMIP(const Instruction&) = 0; - virtual void FISTP_RM64(const Instruction&) = 0; - virtual void HLT(const Instruction&) = 0; - virtual void IDIV_RM16(const Instruction&) = 0; - virtual void IDIV_RM32(const Instruction&) = 0; - virtual void IDIV_RM8(const Instruction&) = 0; - virtual void IMUL_RM16(const Instruction&) = 0; - virtual void IMUL_RM32(const Instruction&) = 0; - virtual void IMUL_RM8(const Instruction&) = 0; - virtual void IMUL_reg16_RM16(const Instruction&) = 0; - virtual void IMUL_reg16_RM16_imm16(const Instruction&) = 0; - virtual void IMUL_reg16_RM16_imm8(const Instruction&) = 0; - virtual void IMUL_reg32_RM32(const Instruction&) = 0; - virtual void IMUL_reg32_RM32_imm32(const Instruction&) = 0; - virtual void IMUL_reg32_RM32_imm8(const Instruction&) = 0; - virtual void INC_RM16(const Instruction&) = 0; - virtual void INC_RM32(const Instruction&) = 0; - virtual void INC_RM8(const Instruction&) = 0; - virtual void INC_reg16(const Instruction&) = 0; - virtual void INC_reg32(const Instruction&) = 0; - virtual void INSB(const Instruction&) = 0; - virtual void INSD(const Instruction&) = 0; - virtual void INSW(const Instruction&) = 0; - virtual void INT1(const Instruction&) = 0; - virtual void INT3(const Instruction&) = 0; - virtual void INTO(const Instruction&) = 0; - virtual void INT_imm8(const Instruction&) = 0; - virtual void INVLPG(const Instruction&) = 0; - virtual void IN_AL_DX(const Instruction&) = 0; - virtual void IN_AL_imm8(const Instruction&) = 0; - virtual void IN_AX_DX(const Instruction&) = 0; - virtual void IN_AX_imm8(const Instruction&) = 0; - virtual void IN_EAX_DX(const Instruction&) = 0; - virtual void IN_EAX_imm8(const Instruction&) = 0; - virtual void IRET(const Instruction&) = 0; - virtual void JCXZ_imm8(const Instruction&) = 0; - virtual void JMP_FAR_mem16(const Instruction&) = 0; - virtual void JMP_FAR_mem32(const Instruction&) = 0; - virtual void JMP_RM16(const Instruction&) = 0; - virtual void JMP_RM32(const Instruction&) = 0; - virtual void JMP_imm16(const Instruction&) = 0; - virtual void JMP_imm16_imm16(const Instruction&) = 0; - virtual void JMP_imm16_imm32(const Instruction&) = 0; - virtual void JMP_imm32(const Instruction&) = 0; - virtual void JMP_short_imm8(const Instruction&) = 0; - virtual void Jcc_NEAR_imm(const Instruction&) = 0; - virtual void Jcc_imm8(const Instruction&) = 0; - virtual void LAHF(const Instruction&) = 0; - virtual void LAR_reg16_RM16(const Instruction&) = 0; - virtual void LAR_reg32_RM32(const Instruction&) = 0; - virtual void LDS_reg16_mem16(const Instruction&) = 0; - virtual void LDS_reg32_mem32(const Instruction&) = 0; - virtual void LEAVE16(const Instruction&) = 0; - virtual void LEAVE32(const Instruction&) = 0; - virtual void LEA_reg16_mem16(const Instruction&) = 0; - virtual void LEA_reg32_mem32(const Instruction&) = 0; - virtual void LES_reg16_mem16(const Instruction&) = 0; - virtual void LES_reg32_mem32(const Instruction&) = 0; - virtual void LFS_reg16_mem16(const Instruction&) = 0; - virtual void LFS_reg32_mem32(const Instruction&) = 0; - virtual void LGDT(const Instruction&) = 0; - virtual void LGS_reg16_mem16(const Instruction&) = 0; - virtual void LGS_reg32_mem32(const Instruction&) = 0; - virtual void LIDT(const Instruction&) = 0; - virtual void LLDT_RM16(const Instruction&) = 0; - virtual void LMSW_RM16(const Instruction&) = 0; - virtual void LODSB(const Instruction&) = 0; - virtual void LODSD(const Instruction&) = 0; - virtual void LODSW(const Instruction&) = 0; - virtual void LOOPNZ_imm8(const Instruction&) = 0; - virtual void LOOPZ_imm8(const Instruction&) = 0; - virtual void LOOP_imm8(const Instruction&) = 0; - virtual void LSL_reg16_RM16(const Instruction&) = 0; - virtual void LSL_reg32_RM32(const Instruction&) = 0; - virtual void LSS_reg16_mem16(const Instruction&) = 0; - virtual void LSS_reg32_mem32(const Instruction&) = 0; - virtual void LTR_RM16(const Instruction&) = 0; - virtual void MOVSB(const Instruction&) = 0; - virtual void MOVSD(const Instruction&) = 0; - virtual void MOVSW(const Instruction&) = 0; - virtual void MOVSX_reg16_RM8(const Instruction&) = 0; - virtual void MOVSX_reg32_RM16(const Instruction&) = 0; - virtual void MOVSX_reg32_RM8(const Instruction&) = 0; - virtual void MOVZX_reg16_RM8(const Instruction&) = 0; - virtual void MOVZX_reg32_RM16(const Instruction&) = 0; - virtual void MOVZX_reg32_RM8(const Instruction&) = 0; - virtual void MOV_AL_moff8(const Instruction&) = 0; - virtual void MOV_AX_moff16(const Instruction&) = 0; - virtual void MOV_CR_reg32(const Instruction&) = 0; - virtual void MOV_DR_reg32(const Instruction&) = 0; - virtual void MOV_EAX_moff32(const Instruction&) = 0; - virtual void MOV_RM16_imm16(const Instruction&) = 0; - virtual void MOV_RM16_reg16(const Instruction&) = 0; - virtual void MOV_RM16_seg(const Instruction&) = 0; - virtual void MOV_RM32_imm32(const Instruction&) = 0; - virtual void MOV_RM32_reg32(const Instruction&) = 0; - virtual void MOV_RM8_imm8(const Instruction&) = 0; - virtual void MOV_RM8_reg8(const Instruction&) = 0; - virtual void MOV_moff16_AX(const Instruction&) = 0; - virtual void MOV_moff32_EAX(const Instruction&) = 0; - virtual void MOV_moff8_AL(const Instruction&) = 0; - virtual void MOV_reg16_RM16(const Instruction&) = 0; - virtual void MOV_reg16_imm16(const Instruction&) = 0; - virtual void MOV_reg32_CR(const Instruction&) = 0; - virtual void MOV_reg32_DR(const Instruction&) = 0; - virtual void MOV_reg32_RM32(const Instruction&) = 0; - virtual void MOV_reg32_imm32(const Instruction&) = 0; - virtual void MOV_reg8_RM8(const Instruction&) = 0; - virtual void MOV_reg8_imm8(const Instruction&) = 0; - virtual void MOV_seg_RM16(const Instruction&) = 0; - virtual void MOV_seg_RM32(const Instruction&) = 0; - virtual void MUL_RM16(const Instruction&) = 0; - virtual void MUL_RM32(const Instruction&) = 0; - virtual void MUL_RM8(const Instruction&) = 0; - virtual void NEG_RM16(const Instruction&) = 0; - virtual void NEG_RM32(const Instruction&) = 0; - virtual void NEG_RM8(const Instruction&) = 0; - virtual void NOP(const Instruction&) = 0; - virtual void NOT_RM16(const Instruction&) = 0; - virtual void NOT_RM32(const Instruction&) = 0; - virtual void NOT_RM8(const Instruction&) = 0; - virtual void OR_AL_imm8(const Instruction&) = 0; - virtual void OR_AX_imm16(const Instruction&) = 0; - virtual void OR_EAX_imm32(const Instruction&) = 0; - virtual void OR_RM16_imm16(const Instruction&) = 0; - virtual void OR_RM16_imm8(const Instruction&) = 0; - virtual void OR_RM16_reg16(const Instruction&) = 0; - virtual void OR_RM32_imm32(const Instruction&) = 0; - virtual void OR_RM32_imm8(const Instruction&) = 0; - virtual void OR_RM32_reg32(const Instruction&) = 0; - virtual void OR_RM8_imm8(const Instruction&) = 0; - virtual void OR_RM8_reg8(const Instruction&) = 0; - virtual void OR_reg16_RM16(const Instruction&) = 0; - virtual void OR_reg32_RM32(const Instruction&) = 0; - virtual void OR_reg8_RM8(const Instruction&) = 0; - virtual void OUTSB(const Instruction&) = 0; - virtual void OUTSD(const Instruction&) = 0; - virtual void OUTSW(const Instruction&) = 0; - virtual void OUT_DX_AL(const Instruction&) = 0; - virtual void OUT_DX_AX(const Instruction&) = 0; - virtual void OUT_DX_EAX(const Instruction&) = 0; - virtual void OUT_imm8_AL(const Instruction&) = 0; - virtual void OUT_imm8_AX(const Instruction&) = 0; - virtual void OUT_imm8_EAX(const Instruction&) = 0; - virtual void PACKSSDW_mm1_mm2m64(const Instruction&) = 0; - virtual void PACKSSWB_mm1_mm2m64(const Instruction&) = 0; - virtual void PACKUSWB_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDB_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDW_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDD_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDSB_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDSW_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDUSB_mm1_mm2m64(const Instruction&) = 0; - virtual void PADDUSW_mm1_mm2m64(const Instruction&) = 0; - virtual void PAND_mm1_mm2m64(const Instruction&) = 0; - virtual void PANDN_mm1_mm2m64(const Instruction&) = 0; - virtual void PCMPEQB_mm1_mm2m64(const Instruction&) = 0; - virtual void PCMPEQW_mm1_mm2m64(const Instruction&) = 0; - virtual void PCMPEQD_mm1_mm2m64(const Instruction&) = 0; - virtual void PCMPGTB_mm1_mm2m64(const Instruction&) = 0; - virtual void PCMPGTW_mm1_mm2m64(const Instruction&) = 0; - virtual void PCMPGTD_mm1_mm2m64(const Instruction&) = 0; - virtual void PMADDWD_mm1_mm2m64(const Instruction&) = 0; - virtual void PMULHW_mm1_mm2m64(const Instruction&) = 0; - virtual void PMULLW_mm1_mm2m64(const Instruction&) = 0; - virtual void POPA(const Instruction&) = 0; - virtual void POPAD(const Instruction&) = 0; - virtual void POPF(const Instruction&) = 0; - virtual void POPFD(const Instruction&) = 0; - virtual void POP_DS(const Instruction&) = 0; - virtual void POP_ES(const Instruction&) = 0; - virtual void POP_FS(const Instruction&) = 0; - virtual void POP_GS(const Instruction&) = 0; - virtual void POP_RM16(const Instruction&) = 0; - virtual void POP_RM32(const Instruction&) = 0; - virtual void POP_SS(const Instruction&) = 0; - virtual void POP_reg16(const Instruction&) = 0; - virtual void POP_reg32(const Instruction&) = 0; - virtual void POR_mm1_mm2m64(const Instruction&) = 0; - virtual void PSLLW_mm1_mm2m64(const Instruction&) = 0; - virtual void PSLLW_mm1_imm8(const Instruction&) = 0; - virtual void PSLLD_mm1_mm2m64(const Instruction&) = 0; - virtual void PSLLD_mm1_imm8(const Instruction&) = 0; - virtual void PSLLQ_mm1_mm2m64(const Instruction&) = 0; - virtual void PSLLQ_mm1_imm8(const Instruction&) = 0; - virtual void PSRAW_mm1_mm2m64(const Instruction&) = 0; - virtual void PSRAW_mm1_imm8(const Instruction&) = 0; - virtual void PSRAD_mm1_mm2m64(const Instruction&) = 0; - virtual void PSRAD_mm1_imm8(const Instruction&) = 0; - virtual void PSRLW_mm1_mm2m64(const Instruction&) = 0; - virtual void PSRLW_mm1_imm8(const Instruction&) = 0; - virtual void PSRLD_mm1_mm2m64(const Instruction&) = 0; - virtual void PSRLD_mm1_imm8(const Instruction&) = 0; - virtual void PSRLQ_mm1_mm2m64(const Instruction&) = 0; - virtual void PSRLQ_mm1_imm8(const Instruction&) = 0; - virtual void PSUBB_mm1_mm2m64(const Instruction&) = 0; - virtual void PSUBW_mm1_mm2m64(const Instruction&) = 0; - virtual void PSUBD_mm1_mm2m64(const Instruction&) = 0; - virtual void PSUBSB_mm1_mm2m64(const Instruction&) = 0; - virtual void PSUBSW_mm1_mm2m64(const Instruction&) = 0; - virtual void PSUBUSB_mm1_mm2m64(const Instruction&) = 0; - virtual void PSUBUSW_mm1_mm2m64(const Instruction&) = 0; - virtual void PUNPCKHBW_mm1_mm2m64(const Instruction&) = 0; - virtual void PUNPCKHWD_mm1_mm2m64(const Instruction&) = 0; - virtual void PUNPCKHDQ_mm1_mm2m64(const Instruction&) = 0; - virtual void PUNPCKLBW_mm1_mm2m32(const Instruction&) = 0; - virtual void PUNPCKLWD_mm1_mm2m32(const Instruction&) = 0; - virtual void PUNPCKLDQ_mm1_mm2m32(const Instruction&) = 0; - virtual void PUSHA(const Instruction&) = 0; - virtual void PUSHAD(const Instruction&) = 0; - virtual void PUSHF(const Instruction&) = 0; - virtual void PUSHFD(const Instruction&) = 0; - virtual void PUSH_CS(const Instruction&) = 0; - virtual void PUSH_DS(const Instruction&) = 0; - virtual void PUSH_ES(const Instruction&) = 0; - virtual void PUSH_FS(const Instruction&) = 0; - virtual void PUSH_GS(const Instruction&) = 0; - virtual void PUSH_RM16(const Instruction&) = 0; - virtual void PUSH_RM32(const Instruction&) = 0; - virtual void PUSH_SP_8086_80186(const Instruction&) = 0; - virtual void PUSH_SS(const Instruction&) = 0; - virtual void PUSH_imm16(const Instruction&) = 0; - virtual void PUSH_imm32(const Instruction&) = 0; - virtual void PUSH_imm8(const Instruction&) = 0; - virtual void PUSH_reg16(const Instruction&) = 0; - virtual void PUSH_reg32(const Instruction&) = 0; - virtual void PXOR_mm1_mm2m64(const Instruction&) = 0; - virtual void RCL_RM16_1(const Instruction&) = 0; - virtual void RCL_RM16_CL(const Instruction&) = 0; - virtual void RCL_RM16_imm8(const Instruction&) = 0; - virtual void RCL_RM32_1(const Instruction&) = 0; - virtual void RCL_RM32_CL(const Instruction&) = 0; - virtual void RCL_RM32_imm8(const Instruction&) = 0; - virtual void RCL_RM8_1(const Instruction&) = 0; - virtual void RCL_RM8_CL(const Instruction&) = 0; - virtual void RCL_RM8_imm8(const Instruction&) = 0; - virtual void RCR_RM16_1(const Instruction&) = 0; - virtual void RCR_RM16_CL(const Instruction&) = 0; - virtual void RCR_RM16_imm8(const Instruction&) = 0; - virtual void RCR_RM32_1(const Instruction&) = 0; - virtual void RCR_RM32_CL(const Instruction&) = 0; - virtual void RCR_RM32_imm8(const Instruction&) = 0; - virtual void RCR_RM8_1(const Instruction&) = 0; - virtual void RCR_RM8_CL(const Instruction&) = 0; - virtual void RCR_RM8_imm8(const Instruction&) = 0; - virtual void RDTSC(const Instruction&) = 0; - virtual void RET(const Instruction&) = 0; - virtual void RETF(const Instruction&) = 0; - virtual void RETF_imm16(const Instruction&) = 0; - virtual void RET_imm16(const Instruction&) = 0; - virtual void ROL_RM16_1(const Instruction&) = 0; - virtual void ROL_RM16_CL(const Instruction&) = 0; - virtual void ROL_RM16_imm8(const Instruction&) = 0; - virtual void ROL_RM32_1(const Instruction&) = 0; - virtual void ROL_RM32_CL(const Instruction&) = 0; - virtual void ROL_RM32_imm8(const Instruction&) = 0; - virtual void ROL_RM8_1(const Instruction&) = 0; - virtual void ROL_RM8_CL(const Instruction&) = 0; - virtual void ROL_RM8_imm8(const Instruction&) = 0; - virtual void ROR_RM16_1(const Instruction&) = 0; - virtual void ROR_RM16_CL(const Instruction&) = 0; - virtual void ROR_RM16_imm8(const Instruction&) = 0; - virtual void ROR_RM32_1(const Instruction&) = 0; - virtual void ROR_RM32_CL(const Instruction&) = 0; - virtual void ROR_RM32_imm8(const Instruction&) = 0; - virtual void ROR_RM8_1(const Instruction&) = 0; - virtual void ROR_RM8_CL(const Instruction&) = 0; - virtual void ROR_RM8_imm8(const Instruction&) = 0; - virtual void SAHF(const Instruction&) = 0; - virtual void SALC(const Instruction&) = 0; - virtual void SAR_RM16_1(const Instruction&) = 0; - virtual void SAR_RM16_CL(const Instruction&) = 0; - virtual void SAR_RM16_imm8(const Instruction&) = 0; - virtual void SAR_RM32_1(const Instruction&) = 0; - virtual void SAR_RM32_CL(const Instruction&) = 0; - virtual void SAR_RM32_imm8(const Instruction&) = 0; - virtual void SAR_RM8_1(const Instruction&) = 0; - virtual void SAR_RM8_CL(const Instruction&) = 0; - virtual void SAR_RM8_imm8(const Instruction&) = 0; - virtual void SBB_AL_imm8(const Instruction&) = 0; - virtual void SBB_AX_imm16(const Instruction&) = 0; - virtual void SBB_EAX_imm32(const Instruction&) = 0; - virtual void SBB_RM16_imm16(const Instruction&) = 0; - virtual void SBB_RM16_imm8(const Instruction&) = 0; - virtual void SBB_RM16_reg16(const Instruction&) = 0; - virtual void SBB_RM32_imm32(const Instruction&) = 0; - virtual void SBB_RM32_imm8(const Instruction&) = 0; - virtual void SBB_RM32_reg32(const Instruction&) = 0; - virtual void SBB_RM8_imm8(const Instruction&) = 0; - virtual void SBB_RM8_reg8(const Instruction&) = 0; - virtual void SBB_reg16_RM16(const Instruction&) = 0; - virtual void SBB_reg32_RM32(const Instruction&) = 0; - virtual void SBB_reg8_RM8(const Instruction&) = 0; - virtual void SCASB(const Instruction&) = 0; - virtual void SCASD(const Instruction&) = 0; - virtual void SCASW(const Instruction&) = 0; - virtual void SETcc_RM8(const Instruction&) = 0; - virtual void SGDT(const Instruction&) = 0; - virtual void SHLD_RM16_reg16_CL(const Instruction&) = 0; - virtual void SHLD_RM16_reg16_imm8(const Instruction&) = 0; - virtual void SHLD_RM32_reg32_CL(const Instruction&) = 0; - virtual void SHLD_RM32_reg32_imm8(const Instruction&) = 0; - virtual void SHL_RM16_1(const Instruction&) = 0; - virtual void SHL_RM16_CL(const Instruction&) = 0; - virtual void SHL_RM16_imm8(const Instruction&) = 0; - virtual void SHL_RM32_1(const Instruction&) = 0; - virtual void SHL_RM32_CL(const Instruction&) = 0; - virtual void SHL_RM32_imm8(const Instruction&) = 0; - virtual void SHL_RM8_1(const Instruction&) = 0; - virtual void SHL_RM8_CL(const Instruction&) = 0; - virtual void SHL_RM8_imm8(const Instruction&) = 0; - virtual void SHRD_RM16_reg16_CL(const Instruction&) = 0; - virtual void SHRD_RM16_reg16_imm8(const Instruction&) = 0; - virtual void SHRD_RM32_reg32_CL(const Instruction&) = 0; - virtual void SHRD_RM32_reg32_imm8(const Instruction&) = 0; - virtual void SHR_RM16_1(const Instruction&) = 0; - virtual void SHR_RM16_CL(const Instruction&) = 0; - virtual void SHR_RM16_imm8(const Instruction&) = 0; - virtual void SHR_RM32_1(const Instruction&) = 0; - virtual void SHR_RM32_CL(const Instruction&) = 0; - virtual void SHR_RM32_imm8(const Instruction&) = 0; - virtual void SHR_RM8_1(const Instruction&) = 0; - virtual void SHR_RM8_CL(const Instruction&) = 0; - virtual void SHR_RM8_imm8(const Instruction&) = 0; - virtual void SIDT(const Instruction&) = 0; - virtual void SLDT_RM16(const Instruction&) = 0; - virtual void SMSW_RM16(const Instruction&) = 0; - virtual void STC(const Instruction&) = 0; - virtual void STD(const Instruction&) = 0; - virtual void STI(const Instruction&) = 0; - virtual void STOSB(const Instruction&) = 0; - virtual void STOSD(const Instruction&) = 0; - virtual void STOSW(const Instruction&) = 0; - virtual void STR_RM16(const Instruction&) = 0; - virtual void SUB_AL_imm8(const Instruction&) = 0; - virtual void SUB_AX_imm16(const Instruction&) = 0; - virtual void SUB_EAX_imm32(const Instruction&) = 0; - virtual void SUB_RM16_imm16(const Instruction&) = 0; - virtual void SUB_RM16_imm8(const Instruction&) = 0; - virtual void SUB_RM16_reg16(const Instruction&) = 0; - virtual void SUB_RM32_imm32(const Instruction&) = 0; - virtual void SUB_RM32_imm8(const Instruction&) = 0; - virtual void SUB_RM32_reg32(const Instruction&) = 0; - virtual void SUB_RM8_imm8(const Instruction&) = 0; - virtual void SUB_RM8_reg8(const Instruction&) = 0; - virtual void SUB_reg16_RM16(const Instruction&) = 0; - virtual void SUB_reg32_RM32(const Instruction&) = 0; - virtual void SUB_reg8_RM8(const Instruction&) = 0; - virtual void TEST_AL_imm8(const Instruction&) = 0; - virtual void TEST_AX_imm16(const Instruction&) = 0; - virtual void TEST_EAX_imm32(const Instruction&) = 0; - virtual void TEST_RM16_imm16(const Instruction&) = 0; - virtual void TEST_RM16_reg16(const Instruction&) = 0; - virtual void TEST_RM32_imm32(const Instruction&) = 0; - virtual void TEST_RM32_reg32(const Instruction&) = 0; - virtual void TEST_RM8_imm8(const Instruction&) = 0; - virtual void TEST_RM8_reg8(const Instruction&) = 0; - virtual void UD0(const Instruction&) = 0; - virtual void UD1(const Instruction&) = 0; - virtual void UD2(const Instruction&) = 0; - virtual void VERR_RM16(const Instruction&) = 0; - virtual void VERW_RM16(const Instruction&) = 0; - virtual void WAIT(const Instruction&) = 0; - virtual void WBINVD(const Instruction&) = 0; - virtual void XADD_RM16_reg16(const Instruction&) = 0; - virtual void XADD_RM32_reg32(const Instruction&) = 0; - virtual void XADD_RM8_reg8(const Instruction&) = 0; - virtual void XCHG_AX_reg16(const Instruction&) = 0; - virtual void XCHG_EAX_reg32(const Instruction&) = 0; - virtual void XCHG_reg16_RM16(const Instruction&) = 0; - virtual void XCHG_reg32_RM32(const Instruction&) = 0; - virtual void XCHG_reg8_RM8(const Instruction&) = 0; - virtual void XLAT(const Instruction&) = 0; - virtual void XOR_AL_imm8(const Instruction&) = 0; - virtual void XOR_AX_imm16(const Instruction&) = 0; - virtual void XOR_EAX_imm32(const Instruction&) = 0; - virtual void XOR_RM16_imm16(const Instruction&) = 0; - virtual void XOR_RM16_imm8(const Instruction&) = 0; - virtual void XOR_RM16_reg16(const Instruction&) = 0; - virtual void XOR_RM32_imm32(const Instruction&) = 0; - virtual void XOR_RM32_imm8(const Instruction&) = 0; - virtual void XOR_RM32_reg32(const Instruction&) = 0; - virtual void XOR_RM8_imm8(const Instruction&) = 0; - virtual void XOR_RM8_reg8(const Instruction&) = 0; - virtual void XOR_reg16_RM16(const Instruction&) = 0; - virtual void XOR_reg32_RM32(const Instruction&) = 0; - virtual void XOR_reg8_RM8(const Instruction&) = 0; - virtual void MOVQ_mm1_mm2m64(const Instruction&) = 0; - virtual void MOVQ_mm1m64_mm2(const Instruction&) = 0; - virtual void MOVD_mm1_rm32(const Instruction&) = 0; - virtual void MOVQ_mm1_rm64(const Instruction&) = 0; // long mode - virtual void MOVD_rm32_mm2(const Instruction&) = 0; - virtual void MOVQ_rm64_mm2(const Instruction&) = 0; // long mode - virtual void EMMS(const Instruction&) = 0; - virtual void wrap_0xC0(const Instruction&) = 0; - virtual void wrap_0xC1_16(const Instruction&) = 0; - virtual void wrap_0xC1_32(const Instruction&) = 0; - virtual void wrap_0xD0(const Instruction&) = 0; - virtual void wrap_0xD1_16(const Instruction&) = 0; - virtual void wrap_0xD1_32(const Instruction&) = 0; - virtual void wrap_0xD2(const Instruction&) = 0; - virtual void wrap_0xD3_16(const Instruction&) = 0; - virtual void wrap_0xD3_32(const Instruction&) = 0; + virtual void AAA(Instruction const&) = 0; + virtual void AAD(Instruction const&) = 0; + virtual void AAM(Instruction const&) = 0; + virtual void AAS(Instruction const&) = 0; + virtual void ADC_AL_imm8(Instruction const&) = 0; + virtual void ADC_AX_imm16(Instruction const&) = 0; + virtual void ADC_EAX_imm32(Instruction const&) = 0; + virtual void ADC_RM16_imm16(Instruction const&) = 0; + virtual void ADC_RM16_imm8(Instruction const&) = 0; + virtual void ADC_RM16_reg16(Instruction const&) = 0; + virtual void ADC_RM32_imm32(Instruction const&) = 0; + virtual void ADC_RM32_imm8(Instruction const&) = 0; + virtual void ADC_RM32_reg32(Instruction const&) = 0; + virtual void ADC_RM8_imm8(Instruction const&) = 0; + virtual void ADC_RM8_reg8(Instruction const&) = 0; + virtual void ADC_reg16_RM16(Instruction const&) = 0; + virtual void ADC_reg32_RM32(Instruction const&) = 0; + virtual void ADC_reg8_RM8(Instruction const&) = 0; + virtual void ADD_AL_imm8(Instruction const&) = 0; + virtual void ADD_AX_imm16(Instruction const&) = 0; + virtual void ADD_EAX_imm32(Instruction const&) = 0; + virtual void ADD_RM16_imm16(Instruction const&) = 0; + virtual void ADD_RM16_imm8(Instruction const&) = 0; + virtual void ADD_RM16_reg16(Instruction const&) = 0; + virtual void ADD_RM32_imm32(Instruction const&) = 0; + virtual void ADD_RM32_imm8(Instruction const&) = 0; + virtual void ADD_RM32_reg32(Instruction const&) = 0; + virtual void ADD_RM8_imm8(Instruction const&) = 0; + virtual void ADD_RM8_reg8(Instruction const&) = 0; + virtual void ADD_reg16_RM16(Instruction const&) = 0; + virtual void ADD_reg32_RM32(Instruction const&) = 0; + virtual void ADD_reg8_RM8(Instruction const&) = 0; + virtual void AND_AL_imm8(Instruction const&) = 0; + virtual void AND_AX_imm16(Instruction const&) = 0; + virtual void AND_EAX_imm32(Instruction const&) = 0; + virtual void AND_RM16_imm16(Instruction const&) = 0; + virtual void AND_RM16_imm8(Instruction const&) = 0; + virtual void AND_RM16_reg16(Instruction const&) = 0; + virtual void AND_RM32_imm32(Instruction const&) = 0; + virtual void AND_RM32_imm8(Instruction const&) = 0; + virtual void AND_RM32_reg32(Instruction const&) = 0; + virtual void AND_RM8_imm8(Instruction const&) = 0; + virtual void AND_RM8_reg8(Instruction const&) = 0; + virtual void AND_reg16_RM16(Instruction const&) = 0; + virtual void AND_reg32_RM32(Instruction const&) = 0; + virtual void AND_reg8_RM8(Instruction const&) = 0; + virtual void ARPL(Instruction const&) = 0; + virtual void BOUND(Instruction const&) = 0; + virtual void BSF_reg16_RM16(Instruction const&) = 0; + virtual void BSF_reg32_RM32(Instruction const&) = 0; + virtual void BSR_reg16_RM16(Instruction const&) = 0; + virtual void BSR_reg32_RM32(Instruction const&) = 0; + virtual void BSWAP_reg32(Instruction const&) = 0; + virtual void BTC_RM16_imm8(Instruction const&) = 0; + virtual void BTC_RM16_reg16(Instruction const&) = 0; + virtual void BTC_RM32_imm8(Instruction const&) = 0; + virtual void BTC_RM32_reg32(Instruction const&) = 0; + virtual void BTR_RM16_imm8(Instruction const&) = 0; + virtual void BTR_RM16_reg16(Instruction const&) = 0; + virtual void BTR_RM32_imm8(Instruction const&) = 0; + virtual void BTR_RM32_reg32(Instruction const&) = 0; + virtual void BTS_RM16_imm8(Instruction const&) = 0; + virtual void BTS_RM16_reg16(Instruction const&) = 0; + virtual void BTS_RM32_imm8(Instruction const&) = 0; + virtual void BTS_RM32_reg32(Instruction const&) = 0; + virtual void BT_RM16_imm8(Instruction const&) = 0; + virtual void BT_RM16_reg16(Instruction const&) = 0; + virtual void BT_RM32_imm8(Instruction const&) = 0; + virtual void BT_RM32_reg32(Instruction const&) = 0; + virtual void CALL_FAR_mem16(Instruction const&) = 0; + virtual void CALL_FAR_mem32(Instruction const&) = 0; + virtual void CALL_RM16(Instruction const&) = 0; + virtual void CALL_RM32(Instruction const&) = 0; + virtual void CALL_imm16(Instruction const&) = 0; + virtual void CALL_imm16_imm16(Instruction const&) = 0; + virtual void CALL_imm16_imm32(Instruction const&) = 0; + virtual void CALL_imm32(Instruction const&) = 0; + virtual void CBW(Instruction const&) = 0; + virtual void CDQ(Instruction const&) = 0; + virtual void CLC(Instruction const&) = 0; + virtual void CLD(Instruction const&) = 0; + virtual void CLI(Instruction const&) = 0; + virtual void CLTS(Instruction const&) = 0; + virtual void CMC(Instruction const&) = 0; + virtual void CMOVcc_reg16_RM16(Instruction const&) = 0; + virtual void CMOVcc_reg32_RM32(Instruction const&) = 0; + virtual void CMPSB(Instruction const&) = 0; + virtual void CMPSD(Instruction const&) = 0; + virtual void CMPSW(Instruction const&) = 0; + virtual void CMPXCHG_RM16_reg16(Instruction const&) = 0; + virtual void CMPXCHG_RM32_reg32(Instruction const&) = 0; + virtual void CMPXCHG_RM8_reg8(Instruction const&) = 0; + virtual void CMP_AL_imm8(Instruction const&) = 0; + virtual void CMP_AX_imm16(Instruction const&) = 0; + virtual void CMP_EAX_imm32(Instruction const&) = 0; + virtual void CMP_RM16_imm16(Instruction const&) = 0; + virtual void CMP_RM16_imm8(Instruction const&) = 0; + virtual void CMP_RM16_reg16(Instruction const&) = 0; + virtual void CMP_RM32_imm32(Instruction const&) = 0; + virtual void CMP_RM32_imm8(Instruction const&) = 0; + virtual void CMP_RM32_reg32(Instruction const&) = 0; + virtual void CMP_RM8_imm8(Instruction const&) = 0; + virtual void CMP_RM8_reg8(Instruction const&) = 0; + virtual void CMP_reg16_RM16(Instruction const&) = 0; + virtual void CMP_reg32_RM32(Instruction const&) = 0; + virtual void CMP_reg8_RM8(Instruction const&) = 0; + virtual void CPUID(Instruction const&) = 0; + virtual void CWD(Instruction const&) = 0; + virtual void CWDE(Instruction const&) = 0; + virtual void DAA(Instruction const&) = 0; + virtual void DAS(Instruction const&) = 0; + virtual void DEC_RM16(Instruction const&) = 0; + virtual void DEC_RM32(Instruction const&) = 0; + virtual void DEC_RM8(Instruction const&) = 0; + virtual void DEC_reg16(Instruction const&) = 0; + virtual void DEC_reg32(Instruction const&) = 0; + virtual void DIV_RM16(Instruction const&) = 0; + virtual void DIV_RM32(Instruction const&) = 0; + virtual void DIV_RM8(Instruction const&) = 0; + virtual void ENTER16(Instruction const&) = 0; + virtual void ENTER32(Instruction const&) = 0; + virtual void ESCAPE(Instruction const&) = 0; + virtual void FADD_RM32(Instruction const&) = 0; + virtual void FMUL_RM32(Instruction const&) = 0; + virtual void FCOM_RM32(Instruction const&) = 0; + virtual void FCOMP_RM32(Instruction const&) = 0; + virtual void FSUB_RM32(Instruction const&) = 0; + virtual void FSUBR_RM32(Instruction const&) = 0; + virtual void FDIV_RM32(Instruction const&) = 0; + virtual void FDIVR_RM32(Instruction const&) = 0; + virtual void FLD_RM32(Instruction const&) = 0; + virtual void FXCH(Instruction const&) = 0; + virtual void FST_RM32(Instruction const&) = 0; + virtual void FNOP(Instruction const&) = 0; + virtual void FSTP_RM32(Instruction const&) = 0; + virtual void FLDENV(Instruction const&) = 0; + virtual void FCHS(Instruction const&) = 0; + virtual void FABS(Instruction const&) = 0; + virtual void FTST(Instruction const&) = 0; + virtual void FXAM(Instruction const&) = 0; + virtual void FLDCW(Instruction const&) = 0; + virtual void FLD1(Instruction const&) = 0; + virtual void FLDL2T(Instruction const&) = 0; + virtual void FLDL2E(Instruction const&) = 0; + virtual void FLDPI(Instruction const&) = 0; + virtual void FLDLG2(Instruction const&) = 0; + virtual void FLDLN2(Instruction const&) = 0; + virtual void FLDZ(Instruction const&) = 0; + virtual void FNSTENV(Instruction const&) = 0; + virtual void F2XM1(Instruction const&) = 0; + virtual void FYL2X(Instruction const&) = 0; + virtual void FPTAN(Instruction const&) = 0; + virtual void FPATAN(Instruction const&) = 0; + virtual void FXTRACT(Instruction const&) = 0; + virtual void FPREM1(Instruction const&) = 0; + virtual void FDECSTP(Instruction const&) = 0; + virtual void FINCSTP(Instruction const&) = 0; + virtual void FNSTCW(Instruction const&) = 0; + virtual void FPREM(Instruction const&) = 0; + virtual void FYL2XP1(Instruction const&) = 0; + virtual void FSQRT(Instruction const&) = 0; + virtual void FSINCOS(Instruction const&) = 0; + virtual void FRNDINT(Instruction const&) = 0; + virtual void FSCALE(Instruction const&) = 0; + virtual void FSIN(Instruction const&) = 0; + virtual void FCOS(Instruction const&) = 0; + virtual void FIADD_RM32(Instruction const&) = 0; + virtual void FADDP(Instruction const&) = 0; + virtual void FIMUL_RM32(Instruction const&) = 0; + virtual void FCMOVE(Instruction const&) = 0; + virtual void FICOM_RM32(Instruction const&) = 0; + virtual void FCMOVBE(Instruction const&) = 0; + virtual void FICOMP_RM32(Instruction const&) = 0; + virtual void FCMOVU(Instruction const&) = 0; + virtual void FISUB_RM32(Instruction const&) = 0; + virtual void FISUBR_RM32(Instruction const&) = 0; + virtual void FUCOMPP(Instruction const&) = 0; + virtual void FIDIV_RM32(Instruction const&) = 0; + virtual void FIDIVR_RM32(Instruction const&) = 0; + virtual void FILD_RM32(Instruction const&) = 0; + virtual void FCMOVNB(Instruction const&) = 0; + virtual void FISTTP_RM32(Instruction const&) = 0; + virtual void FCMOVNE(Instruction const&) = 0; + virtual void FIST_RM32(Instruction const&) = 0; + virtual void FCMOVNBE(Instruction const&) = 0; + virtual void FISTP_RM32(Instruction const&) = 0; + virtual void FCMOVNU(Instruction const&) = 0; + virtual void FNENI(Instruction const&) = 0; + virtual void FNDISI(Instruction const&) = 0; + virtual void FNCLEX(Instruction const&) = 0; + virtual void FNINIT(Instruction const&) = 0; + virtual void FNSETPM(Instruction const&) = 0; + virtual void FLD_RM80(Instruction const&) = 0; + virtual void FUCOMI(Instruction const&) = 0; + virtual void FCOMI(Instruction const&) = 0; + virtual void FSTP_RM80(Instruction const&) = 0; + virtual void FADD_RM64(Instruction const&) = 0; + virtual void FMUL_RM64(Instruction const&) = 0; + virtual void FCOM_RM64(Instruction const&) = 0; + virtual void FCOMP_RM64(Instruction const&) = 0; + virtual void FSUB_RM64(Instruction const&) = 0; + virtual void FSUBR_RM64(Instruction const&) = 0; + virtual void FDIV_RM64(Instruction const&) = 0; + virtual void FDIVR_RM64(Instruction const&) = 0; + virtual void FLD_RM64(Instruction const&) = 0; + virtual void FFREE(Instruction const&) = 0; + virtual void FISTTP_RM64(Instruction const&) = 0; + virtual void FST_RM64(Instruction const&) = 0; + virtual void FSTP_RM64(Instruction const&) = 0; + virtual void FRSTOR(Instruction const&) = 0; + virtual void FUCOM(Instruction const&) = 0; + virtual void FUCOMP(Instruction const&) = 0; + virtual void FNSAVE(Instruction const&) = 0; + virtual void FNSTSW(Instruction const&) = 0; + virtual void FIADD_RM16(Instruction const&) = 0; + virtual void FCMOVB(Instruction const&) = 0; + virtual void FIMUL_RM16(Instruction const&) = 0; + virtual void FMULP(Instruction const&) = 0; + virtual void FICOM_RM16(Instruction const&) = 0; + virtual void FICOMP_RM16(Instruction const&) = 0; + virtual void FCOMPP(Instruction const&) = 0; + virtual void FISUB_RM16(Instruction const&) = 0; + virtual void FSUBRP(Instruction const&) = 0; + virtual void FISUBR_RM16(Instruction const&) = 0; + virtual void FSUBP(Instruction const&) = 0; + virtual void FIDIV_RM16(Instruction const&) = 0; + virtual void FDIVRP(Instruction const&) = 0; + virtual void FIDIVR_RM16(Instruction const&) = 0; + virtual void FDIVP(Instruction const&) = 0; + virtual void FILD_RM16(Instruction const&) = 0; + virtual void FFREEP(Instruction const&) = 0; + virtual void FISTTP_RM16(Instruction const&) = 0; + virtual void FIST_RM16(Instruction const&) = 0; + virtual void FISTP_RM16(Instruction const&) = 0; + virtual void FBLD_M80(Instruction const&) = 0; + virtual void FNSTSW_AX(Instruction const&) = 0; + virtual void FILD_RM64(Instruction const&) = 0; + virtual void FUCOMIP(Instruction const&) = 0; + virtual void FBSTP_M80(Instruction const&) = 0; + virtual void FCOMIP(Instruction const&) = 0; + virtual void FISTP_RM64(Instruction const&) = 0; + virtual void HLT(Instruction const&) = 0; + virtual void IDIV_RM16(Instruction const&) = 0; + virtual void IDIV_RM32(Instruction const&) = 0; + virtual void IDIV_RM8(Instruction const&) = 0; + virtual void IMUL_RM16(Instruction const&) = 0; + virtual void IMUL_RM32(Instruction const&) = 0; + virtual void IMUL_RM8(Instruction const&) = 0; + virtual void IMUL_reg16_RM16(Instruction const&) = 0; + virtual void IMUL_reg16_RM16_imm16(Instruction const&) = 0; + virtual void IMUL_reg16_RM16_imm8(Instruction const&) = 0; + virtual void IMUL_reg32_RM32(Instruction const&) = 0; + virtual void IMUL_reg32_RM32_imm32(Instruction const&) = 0; + virtual void IMUL_reg32_RM32_imm8(Instruction const&) = 0; + virtual void INC_RM16(Instruction const&) = 0; + virtual void INC_RM32(Instruction const&) = 0; + virtual void INC_RM8(Instruction const&) = 0; + virtual void INC_reg16(Instruction const&) = 0; + virtual void INC_reg32(Instruction const&) = 0; + virtual void INSB(Instruction const&) = 0; + virtual void INSD(Instruction const&) = 0; + virtual void INSW(Instruction const&) = 0; + virtual void INT1(Instruction const&) = 0; + virtual void INT3(Instruction const&) = 0; + virtual void INTO(Instruction const&) = 0; + virtual void INT_imm8(Instruction const&) = 0; + virtual void INVLPG(Instruction const&) = 0; + virtual void IN_AL_DX(Instruction const&) = 0; + virtual void IN_AL_imm8(Instruction const&) = 0; + virtual void IN_AX_DX(Instruction const&) = 0; + virtual void IN_AX_imm8(Instruction const&) = 0; + virtual void IN_EAX_DX(Instruction const&) = 0; + virtual void IN_EAX_imm8(Instruction const&) = 0; + virtual void IRET(Instruction const&) = 0; + virtual void JCXZ_imm8(Instruction const&) = 0; + virtual void JMP_FAR_mem16(Instruction const&) = 0; + virtual void JMP_FAR_mem32(Instruction const&) = 0; + virtual void JMP_RM16(Instruction const&) = 0; + virtual void JMP_RM32(Instruction const&) = 0; + virtual void JMP_imm16(Instruction const&) = 0; + virtual void JMP_imm16_imm16(Instruction const&) = 0; + virtual void JMP_imm16_imm32(Instruction const&) = 0; + virtual void JMP_imm32(Instruction const&) = 0; + virtual void JMP_short_imm8(Instruction const&) = 0; + virtual void Jcc_NEAR_imm(Instruction const&) = 0; + virtual void Jcc_imm8(Instruction const&) = 0; + virtual void LAHF(Instruction const&) = 0; + virtual void LAR_reg16_RM16(Instruction const&) = 0; + virtual void LAR_reg32_RM32(Instruction const&) = 0; + virtual void LDS_reg16_mem16(Instruction const&) = 0; + virtual void LDS_reg32_mem32(Instruction const&) = 0; + virtual void LEAVE16(Instruction const&) = 0; + virtual void LEAVE32(Instruction const&) = 0; + virtual void LEA_reg16_mem16(Instruction const&) = 0; + virtual void LEA_reg32_mem32(Instruction const&) = 0; + virtual void LES_reg16_mem16(Instruction const&) = 0; + virtual void LES_reg32_mem32(Instruction const&) = 0; + virtual void LFS_reg16_mem16(Instruction const&) = 0; + virtual void LFS_reg32_mem32(Instruction const&) = 0; + virtual void LGDT(Instruction const&) = 0; + virtual void LGS_reg16_mem16(Instruction const&) = 0; + virtual void LGS_reg32_mem32(Instruction const&) = 0; + virtual void LIDT(Instruction const&) = 0; + virtual void LLDT_RM16(Instruction const&) = 0; + virtual void LMSW_RM16(Instruction const&) = 0; + virtual void LODSB(Instruction const&) = 0; + virtual void LODSD(Instruction const&) = 0; + virtual void LODSW(Instruction const&) = 0; + virtual void LOOPNZ_imm8(Instruction const&) = 0; + virtual void LOOPZ_imm8(Instruction const&) = 0; + virtual void LOOP_imm8(Instruction const&) = 0; + virtual void LSL_reg16_RM16(Instruction const&) = 0; + virtual void LSL_reg32_RM32(Instruction const&) = 0; + virtual void LSS_reg16_mem16(Instruction const&) = 0; + virtual void LSS_reg32_mem32(Instruction const&) = 0; + virtual void LTR_RM16(Instruction const&) = 0; + virtual void MOVSB(Instruction const&) = 0; + virtual void MOVSD(Instruction const&) = 0; + virtual void MOVSW(Instruction const&) = 0; + virtual void MOVSX_reg16_RM8(Instruction const&) = 0; + virtual void MOVSX_reg32_RM16(Instruction const&) = 0; + virtual void MOVSX_reg32_RM8(Instruction const&) = 0; + virtual void MOVZX_reg16_RM8(Instruction const&) = 0; + virtual void MOVZX_reg32_RM16(Instruction const&) = 0; + virtual void MOVZX_reg32_RM8(Instruction const&) = 0; + virtual void MOV_AL_moff8(Instruction const&) = 0; + virtual void MOV_AX_moff16(Instruction const&) = 0; + virtual void MOV_CR_reg32(Instruction const&) = 0; + virtual void MOV_DR_reg32(Instruction const&) = 0; + virtual void MOV_EAX_moff32(Instruction const&) = 0; + virtual void MOV_RM16_imm16(Instruction const&) = 0; + virtual void MOV_RM16_reg16(Instruction const&) = 0; + virtual void MOV_RM16_seg(Instruction const&) = 0; + virtual void MOV_RM32_imm32(Instruction const&) = 0; + virtual void MOV_RM32_reg32(Instruction const&) = 0; + virtual void MOV_RM8_imm8(Instruction const&) = 0; + virtual void MOV_RM8_reg8(Instruction const&) = 0; + virtual void MOV_moff16_AX(Instruction const&) = 0; + virtual void MOV_moff32_EAX(Instruction const&) = 0; + virtual void MOV_moff8_AL(Instruction const&) = 0; + virtual void MOV_reg16_RM16(Instruction const&) = 0; + virtual void MOV_reg16_imm16(Instruction const&) = 0; + virtual void MOV_reg32_CR(Instruction const&) = 0; + virtual void MOV_reg32_DR(Instruction const&) = 0; + virtual void MOV_reg32_RM32(Instruction const&) = 0; + virtual void MOV_reg32_imm32(Instruction const&) = 0; + virtual void MOV_reg8_RM8(Instruction const&) = 0; + virtual void MOV_reg8_imm8(Instruction const&) = 0; + virtual void MOV_seg_RM16(Instruction const&) = 0; + virtual void MOV_seg_RM32(Instruction const&) = 0; + virtual void MUL_RM16(Instruction const&) = 0; + virtual void MUL_RM32(Instruction const&) = 0; + virtual void MUL_RM8(Instruction const&) = 0; + virtual void NEG_RM16(Instruction const&) = 0; + virtual void NEG_RM32(Instruction const&) = 0; + virtual void NEG_RM8(Instruction const&) = 0; + virtual void NOP(Instruction const&) = 0; + virtual void NOT_RM16(Instruction const&) = 0; + virtual void NOT_RM32(Instruction const&) = 0; + virtual void NOT_RM8(Instruction const&) = 0; + virtual void OR_AL_imm8(Instruction const&) = 0; + virtual void OR_AX_imm16(Instruction const&) = 0; + virtual void OR_EAX_imm32(Instruction const&) = 0; + virtual void OR_RM16_imm16(Instruction const&) = 0; + virtual void OR_RM16_imm8(Instruction const&) = 0; + virtual void OR_RM16_reg16(Instruction const&) = 0; + virtual void OR_RM32_imm32(Instruction const&) = 0; + virtual void OR_RM32_imm8(Instruction const&) = 0; + virtual void OR_RM32_reg32(Instruction const&) = 0; + virtual void OR_RM8_imm8(Instruction const&) = 0; + virtual void OR_RM8_reg8(Instruction const&) = 0; + virtual void OR_reg16_RM16(Instruction const&) = 0; + virtual void OR_reg32_RM32(Instruction const&) = 0; + virtual void OR_reg8_RM8(Instruction const&) = 0; + virtual void OUTSB(Instruction const&) = 0; + virtual void OUTSD(Instruction const&) = 0; + virtual void OUTSW(Instruction const&) = 0; + virtual void OUT_DX_AL(Instruction const&) = 0; + virtual void OUT_DX_AX(Instruction const&) = 0; + virtual void OUT_DX_EAX(Instruction const&) = 0; + virtual void OUT_imm8_AL(Instruction const&) = 0; + virtual void OUT_imm8_AX(Instruction const&) = 0; + virtual void OUT_imm8_EAX(Instruction const&) = 0; + virtual void PACKSSDW_mm1_mm2m64(Instruction const&) = 0; + virtual void PACKSSWB_mm1_mm2m64(Instruction const&) = 0; + virtual void PACKUSWB_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDB_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDW_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDD_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDSB_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDSW_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDUSB_mm1_mm2m64(Instruction const&) = 0; + virtual void PADDUSW_mm1_mm2m64(Instruction const&) = 0; + virtual void PAND_mm1_mm2m64(Instruction const&) = 0; + virtual void PANDN_mm1_mm2m64(Instruction const&) = 0; + virtual void PCMPEQB_mm1_mm2m64(Instruction const&) = 0; + virtual void PCMPEQW_mm1_mm2m64(Instruction const&) = 0; + virtual void PCMPEQD_mm1_mm2m64(Instruction const&) = 0; + virtual void PCMPGTB_mm1_mm2m64(Instruction const&) = 0; + virtual void PCMPGTW_mm1_mm2m64(Instruction const&) = 0; + virtual void PCMPGTD_mm1_mm2m64(Instruction const&) = 0; + virtual void PMADDWD_mm1_mm2m64(Instruction const&) = 0; + virtual void PMULHW_mm1_mm2m64(Instruction const&) = 0; + virtual void PMULLW_mm1_mm2m64(Instruction const&) = 0; + virtual void POPA(Instruction const&) = 0; + virtual void POPAD(Instruction const&) = 0; + virtual void POPF(Instruction const&) = 0; + virtual void POPFD(Instruction const&) = 0; + virtual void POP_DS(Instruction const&) = 0; + virtual void POP_ES(Instruction const&) = 0; + virtual void POP_FS(Instruction const&) = 0; + virtual void POP_GS(Instruction const&) = 0; + virtual void POP_RM16(Instruction const&) = 0; + virtual void POP_RM32(Instruction const&) = 0; + virtual void POP_SS(Instruction const&) = 0; + virtual void POP_reg16(Instruction const&) = 0; + virtual void POP_reg32(Instruction const&) = 0; + virtual void POR_mm1_mm2m64(Instruction const&) = 0; + virtual void PSLLW_mm1_mm2m64(Instruction const&) = 0; + virtual void PSLLW_mm1_imm8(Instruction const&) = 0; + virtual void PSLLD_mm1_mm2m64(Instruction const&) = 0; + virtual void PSLLD_mm1_imm8(Instruction const&) = 0; + virtual void PSLLQ_mm1_mm2m64(Instruction const&) = 0; + virtual void PSLLQ_mm1_imm8(Instruction const&) = 0; + virtual void PSRAW_mm1_mm2m64(Instruction const&) = 0; + virtual void PSRAW_mm1_imm8(Instruction const&) = 0; + virtual void PSRAD_mm1_mm2m64(Instruction const&) = 0; + virtual void PSRAD_mm1_imm8(Instruction const&) = 0; + virtual void PSRLW_mm1_mm2m64(Instruction const&) = 0; + virtual void PSRLW_mm1_imm8(Instruction const&) = 0; + virtual void PSRLD_mm1_mm2m64(Instruction const&) = 0; + virtual void PSRLD_mm1_imm8(Instruction const&) = 0; + virtual void PSRLQ_mm1_mm2m64(Instruction const&) = 0; + virtual void PSRLQ_mm1_imm8(Instruction const&) = 0; + virtual void PSUBB_mm1_mm2m64(Instruction const&) = 0; + virtual void PSUBW_mm1_mm2m64(Instruction const&) = 0; + virtual void PSUBD_mm1_mm2m64(Instruction const&) = 0; + virtual void PSUBSB_mm1_mm2m64(Instruction const&) = 0; + virtual void PSUBSW_mm1_mm2m64(Instruction const&) = 0; + virtual void PSUBUSB_mm1_mm2m64(Instruction const&) = 0; + virtual void PSUBUSW_mm1_mm2m64(Instruction const&) = 0; + virtual void PUNPCKHBW_mm1_mm2m64(Instruction const&) = 0; + virtual void PUNPCKHWD_mm1_mm2m64(Instruction const&) = 0; + virtual void PUNPCKHDQ_mm1_mm2m64(Instruction const&) = 0; + virtual void PUNPCKLBW_mm1_mm2m32(Instruction const&) = 0; + virtual void PUNPCKLWD_mm1_mm2m32(Instruction const&) = 0; + virtual void PUNPCKLDQ_mm1_mm2m32(Instruction const&) = 0; + virtual void PUSHA(Instruction const&) = 0; + virtual void PUSHAD(Instruction const&) = 0; + virtual void PUSHF(Instruction const&) = 0; + virtual void PUSHFD(Instruction const&) = 0; + virtual void PUSH_CS(Instruction const&) = 0; + virtual void PUSH_DS(Instruction const&) = 0; + virtual void PUSH_ES(Instruction const&) = 0; + virtual void PUSH_FS(Instruction const&) = 0; + virtual void PUSH_GS(Instruction const&) = 0; + virtual void PUSH_RM16(Instruction const&) = 0; + virtual void PUSH_RM32(Instruction const&) = 0; + virtual void PUSH_SP_8086_80186(Instruction const&) = 0; + virtual void PUSH_SS(Instruction const&) = 0; + virtual void PUSH_imm16(Instruction const&) = 0; + virtual void PUSH_imm32(Instruction const&) = 0; + virtual void PUSH_imm8(Instruction const&) = 0; + virtual void PUSH_reg16(Instruction const&) = 0; + virtual void PUSH_reg32(Instruction const&) = 0; + virtual void PXOR_mm1_mm2m64(Instruction const&) = 0; + virtual void RCL_RM16_1(Instruction const&) = 0; + virtual void RCL_RM16_CL(Instruction const&) = 0; + virtual void RCL_RM16_imm8(Instruction const&) = 0; + virtual void RCL_RM32_1(Instruction const&) = 0; + virtual void RCL_RM32_CL(Instruction const&) = 0; + virtual void RCL_RM32_imm8(Instruction const&) = 0; + virtual void RCL_RM8_1(Instruction const&) = 0; + virtual void RCL_RM8_CL(Instruction const&) = 0; + virtual void RCL_RM8_imm8(Instruction const&) = 0; + virtual void RCR_RM16_1(Instruction const&) = 0; + virtual void RCR_RM16_CL(Instruction const&) = 0; + virtual void RCR_RM16_imm8(Instruction const&) = 0; + virtual void RCR_RM32_1(Instruction const&) = 0; + virtual void RCR_RM32_CL(Instruction const&) = 0; + virtual void RCR_RM32_imm8(Instruction const&) = 0; + virtual void RCR_RM8_1(Instruction const&) = 0; + virtual void RCR_RM8_CL(Instruction const&) = 0; + virtual void RCR_RM8_imm8(Instruction const&) = 0; + virtual void RDTSC(Instruction const&) = 0; + virtual void RET(Instruction const&) = 0; + virtual void RETF(Instruction const&) = 0; + virtual void RETF_imm16(Instruction const&) = 0; + virtual void RET_imm16(Instruction const&) = 0; + virtual void ROL_RM16_1(Instruction const&) = 0; + virtual void ROL_RM16_CL(Instruction const&) = 0; + virtual void ROL_RM16_imm8(Instruction const&) = 0; + virtual void ROL_RM32_1(Instruction const&) = 0; + virtual void ROL_RM32_CL(Instruction const&) = 0; + virtual void ROL_RM32_imm8(Instruction const&) = 0; + virtual void ROL_RM8_1(Instruction const&) = 0; + virtual void ROL_RM8_CL(Instruction const&) = 0; + virtual void ROL_RM8_imm8(Instruction const&) = 0; + virtual void ROR_RM16_1(Instruction const&) = 0; + virtual void ROR_RM16_CL(Instruction const&) = 0; + virtual void ROR_RM16_imm8(Instruction const&) = 0; + virtual void ROR_RM32_1(Instruction const&) = 0; + virtual void ROR_RM32_CL(Instruction const&) = 0; + virtual void ROR_RM32_imm8(Instruction const&) = 0; + virtual void ROR_RM8_1(Instruction const&) = 0; + virtual void ROR_RM8_CL(Instruction const&) = 0; + virtual void ROR_RM8_imm8(Instruction const&) = 0; + virtual void SAHF(Instruction const&) = 0; + virtual void SALC(Instruction const&) = 0; + virtual void SAR_RM16_1(Instruction const&) = 0; + virtual void SAR_RM16_CL(Instruction const&) = 0; + virtual void SAR_RM16_imm8(Instruction const&) = 0; + virtual void SAR_RM32_1(Instruction const&) = 0; + virtual void SAR_RM32_CL(Instruction const&) = 0; + virtual void SAR_RM32_imm8(Instruction const&) = 0; + virtual void SAR_RM8_1(Instruction const&) = 0; + virtual void SAR_RM8_CL(Instruction const&) = 0; + virtual void SAR_RM8_imm8(Instruction const&) = 0; + virtual void SBB_AL_imm8(Instruction const&) = 0; + virtual void SBB_AX_imm16(Instruction const&) = 0; + virtual void SBB_EAX_imm32(Instruction const&) = 0; + virtual void SBB_RM16_imm16(Instruction const&) = 0; + virtual void SBB_RM16_imm8(Instruction const&) = 0; + virtual void SBB_RM16_reg16(Instruction const&) = 0; + virtual void SBB_RM32_imm32(Instruction const&) = 0; + virtual void SBB_RM32_imm8(Instruction const&) = 0; + virtual void SBB_RM32_reg32(Instruction const&) = 0; + virtual void SBB_RM8_imm8(Instruction const&) = 0; + virtual void SBB_RM8_reg8(Instruction const&) = 0; + virtual void SBB_reg16_RM16(Instruction const&) = 0; + virtual void SBB_reg32_RM32(Instruction const&) = 0; + virtual void SBB_reg8_RM8(Instruction const&) = 0; + virtual void SCASB(Instruction const&) = 0; + virtual void SCASD(Instruction const&) = 0; + virtual void SCASW(Instruction const&) = 0; + virtual void SETcc_RM8(Instruction const&) = 0; + virtual void SGDT(Instruction const&) = 0; + virtual void SHLD_RM16_reg16_CL(Instruction const&) = 0; + virtual void SHLD_RM16_reg16_imm8(Instruction const&) = 0; + virtual void SHLD_RM32_reg32_CL(Instruction const&) = 0; + virtual void SHLD_RM32_reg32_imm8(Instruction const&) = 0; + virtual void SHL_RM16_1(Instruction const&) = 0; + virtual void SHL_RM16_CL(Instruction const&) = 0; + virtual void SHL_RM16_imm8(Instruction const&) = 0; + virtual void SHL_RM32_1(Instruction const&) = 0; + virtual void SHL_RM32_CL(Instruction const&) = 0; + virtual void SHL_RM32_imm8(Instruction const&) = 0; + virtual void SHL_RM8_1(Instruction const&) = 0; + virtual void SHL_RM8_CL(Instruction const&) = 0; + virtual void SHL_RM8_imm8(Instruction const&) = 0; + virtual void SHRD_RM16_reg16_CL(Instruction const&) = 0; + virtual void SHRD_RM16_reg16_imm8(Instruction const&) = 0; + virtual void SHRD_RM32_reg32_CL(Instruction const&) = 0; + virtual void SHRD_RM32_reg32_imm8(Instruction const&) = 0; + virtual void SHR_RM16_1(Instruction const&) = 0; + virtual void SHR_RM16_CL(Instruction const&) = 0; + virtual void SHR_RM16_imm8(Instruction const&) = 0; + virtual void SHR_RM32_1(Instruction const&) = 0; + virtual void SHR_RM32_CL(Instruction const&) = 0; + virtual void SHR_RM32_imm8(Instruction const&) = 0; + virtual void SHR_RM8_1(Instruction const&) = 0; + virtual void SHR_RM8_CL(Instruction const&) = 0; + virtual void SHR_RM8_imm8(Instruction const&) = 0; + virtual void SIDT(Instruction const&) = 0; + virtual void SLDT_RM16(Instruction const&) = 0; + virtual void SMSW_RM16(Instruction const&) = 0; + virtual void STC(Instruction const&) = 0; + virtual void STD(Instruction const&) = 0; + virtual void STI(Instruction const&) = 0; + virtual void STOSB(Instruction const&) = 0; + virtual void STOSD(Instruction const&) = 0; + virtual void STOSW(Instruction const&) = 0; + virtual void STR_RM16(Instruction const&) = 0; + virtual void SUB_AL_imm8(Instruction const&) = 0; + virtual void SUB_AX_imm16(Instruction const&) = 0; + virtual void SUB_EAX_imm32(Instruction const&) = 0; + virtual void SUB_RM16_imm16(Instruction const&) = 0; + virtual void SUB_RM16_imm8(Instruction const&) = 0; + virtual void SUB_RM16_reg16(Instruction const&) = 0; + virtual void SUB_RM32_imm32(Instruction const&) = 0; + virtual void SUB_RM32_imm8(Instruction const&) = 0; + virtual void SUB_RM32_reg32(Instruction const&) = 0; + virtual void SUB_RM8_imm8(Instruction const&) = 0; + virtual void SUB_RM8_reg8(Instruction const&) = 0; + virtual void SUB_reg16_RM16(Instruction const&) = 0; + virtual void SUB_reg32_RM32(Instruction const&) = 0; + virtual void SUB_reg8_RM8(Instruction const&) = 0; + virtual void TEST_AL_imm8(Instruction const&) = 0; + virtual void TEST_AX_imm16(Instruction const&) = 0; + virtual void TEST_EAX_imm32(Instruction const&) = 0; + virtual void TEST_RM16_imm16(Instruction const&) = 0; + virtual void TEST_RM16_reg16(Instruction const&) = 0; + virtual void TEST_RM32_imm32(Instruction const&) = 0; + virtual void TEST_RM32_reg32(Instruction const&) = 0; + virtual void TEST_RM8_imm8(Instruction const&) = 0; + virtual void TEST_RM8_reg8(Instruction const&) = 0; + virtual void UD0(Instruction const&) = 0; + virtual void UD1(Instruction const&) = 0; + virtual void UD2(Instruction const&) = 0; + virtual void VERR_RM16(Instruction const&) = 0; + virtual void VERW_RM16(Instruction const&) = 0; + virtual void WAIT(Instruction const&) = 0; + virtual void WBINVD(Instruction const&) = 0; + virtual void XADD_RM16_reg16(Instruction const&) = 0; + virtual void XADD_RM32_reg32(Instruction const&) = 0; + virtual void XADD_RM8_reg8(Instruction const&) = 0; + virtual void XCHG_AX_reg16(Instruction const&) = 0; + virtual void XCHG_EAX_reg32(Instruction const&) = 0; + virtual void XCHG_reg16_RM16(Instruction const&) = 0; + virtual void XCHG_reg32_RM32(Instruction const&) = 0; + virtual void XCHG_reg8_RM8(Instruction const&) = 0; + virtual void XLAT(Instruction const&) = 0; + virtual void XOR_AL_imm8(Instruction const&) = 0; + virtual void XOR_AX_imm16(Instruction const&) = 0; + virtual void XOR_EAX_imm32(Instruction const&) = 0; + virtual void XOR_RM16_imm16(Instruction const&) = 0; + virtual void XOR_RM16_imm8(Instruction const&) = 0; + virtual void XOR_RM16_reg16(Instruction const&) = 0; + virtual void XOR_RM32_imm32(Instruction const&) = 0; + virtual void XOR_RM32_imm8(Instruction const&) = 0; + virtual void XOR_RM32_reg32(Instruction const&) = 0; + virtual void XOR_RM8_imm8(Instruction const&) = 0; + virtual void XOR_RM8_reg8(Instruction const&) = 0; + virtual void XOR_reg16_RM16(Instruction const&) = 0; + virtual void XOR_reg32_RM32(Instruction const&) = 0; + virtual void XOR_reg8_RM8(Instruction const&) = 0; + virtual void MOVQ_mm1_mm2m64(Instruction const&) = 0; + virtual void MOVQ_mm1m64_mm2(Instruction const&) = 0; + virtual void MOVD_mm1_rm32(Instruction const&) = 0; + virtual void MOVQ_mm1_rm64(Instruction const&) = 0; // long mode + virtual void MOVD_rm32_mm2(Instruction const&) = 0; + virtual void MOVQ_rm64_mm2(Instruction const&) = 0; // long mode + virtual void EMMS(Instruction const&) = 0; + virtual void wrap_0xC0(Instruction const&) = 0; + virtual void wrap_0xC1_16(Instruction const&) = 0; + virtual void wrap_0xC1_32(Instruction const&) = 0; + virtual void wrap_0xD0(Instruction const&) = 0; + virtual void wrap_0xD1_16(Instruction const&) = 0; + virtual void wrap_0xD1_32(Instruction const&) = 0; + virtual void wrap_0xD2(Instruction const&) = 0; + virtual void wrap_0xD3_16(Instruction const&) = 0; + virtual void wrap_0xD3_32(Instruction const&) = 0; virtual void PREFETCHTNTA(Instruction const&) = 0; virtual void PREFETCHT0(Instruction const&) = 0; @@ -740,6 +740,6 @@ protected: virtual ~Interpreter() = default; }; -typedef void (Interpreter::*InstructionHandler)(const Instruction&); +typedef void (Interpreter::*InstructionHandler)(Instruction const&); } diff --git a/Userland/Services/ChessEngine/ChessEngine.cpp b/Userland/Services/ChessEngine/ChessEngine.cpp index 7183aa6b2d..66a1fae8f1 100644 --- a/Userland/Services/ChessEngine/ChessEngine.cpp +++ b/Userland/Services/ChessEngine/ChessEngine.cpp @@ -18,7 +18,7 @@ void ChessEngine::handle_uci() send_command(UCIOkCommand()); } -void ChessEngine::handle_position(const PositionCommand& command) +void ChessEngine::handle_position(PositionCommand const& command) { // FIXME: Implement fen board position. VERIFY(!command.fen().has_value()); @@ -28,7 +28,7 @@ void ChessEngine::handle_position(const PositionCommand& command) } } -void ChessEngine::handle_go(const GoCommand& command) +void ChessEngine::handle_go(GoCommand const& command) { // FIXME: A better algorithm than naive mcts. // FIXME: Add different ways to terminate search. diff --git a/Userland/Services/ChessEngine/ChessEngine.h b/Userland/Services/ChessEngine/ChessEngine.h index 766a39aa3b..94c61a86ae 100644 --- a/Userland/Services/ChessEngine/ChessEngine.h +++ b/Userland/Services/ChessEngine/ChessEngine.h @@ -15,8 +15,8 @@ public: virtual ~ChessEngine() override = default; virtual void handle_uci() override; - virtual void handle_position(const Chess::UCI::PositionCommand&) override; - virtual void handle_go(const Chess::UCI::GoCommand&) override; + virtual void handle_position(Chess::UCI::PositionCommand const&) override; + virtual void handle_go(Chess::UCI::GoCommand const&) override; private: ChessEngine() = default; diff --git a/Userland/Services/ChessEngine/MCTSTree.cpp b/Userland/Services/ChessEngine/MCTSTree.cpp index e331784a9d..a06fa62d41 100644 --- a/Userland/Services/ChessEngine/MCTSTree.cpp +++ b/Userland/Services/ChessEngine/MCTSTree.cpp @@ -8,7 +8,7 @@ #include <AK/String.h> #include <stdlib.h> -MCTSTree::MCTSTree(const Chess::Board& board, MCTSTree* parent) +MCTSTree::MCTSTree(Chess::Board const& board, MCTSTree* parent) : m_parent(parent) , m_board(make<Chess::Board>(board)) , m_last_move(board.last_move()) diff --git a/Userland/Services/ChessEngine/MCTSTree.h b/Userland/Services/ChessEngine/MCTSTree.h index 6d522ccaf4..8c7c0dd776 100644 --- a/Userland/Services/ChessEngine/MCTSTree.h +++ b/Userland/Services/ChessEngine/MCTSTree.h @@ -19,7 +19,7 @@ public: Heuristic, }; - MCTSTree(const Chess::Board& board, MCTSTree* parent = nullptr); + MCTSTree(Chess::Board const& board, MCTSTree* parent = nullptr); MCTSTree& select_leaf(); MCTSTree& expand(); diff --git a/Userland/Services/Clipboard/Storage.cpp b/Userland/Services/Clipboard/Storage.cpp index 9740d03b12..29c027fa82 100644 --- a/Userland/Services/Clipboard/Storage.cpp +++ b/Userland/Services/Clipboard/Storage.cpp @@ -14,7 +14,7 @@ Storage& Storage::the() return s_the; } -void Storage::set_data(Core::AnonymousBuffer data, const String& mime_type, const HashMap<String, String>& metadata) +void Storage::set_data(Core::AnonymousBuffer data, String const& mime_type, HashMap<String, String> const& metadata) { m_buffer = move(data); m_data_size = data.size(); diff --git a/Userland/Services/Clipboard/Storage.h b/Userland/Services/Clipboard/Storage.h index 07cfb46bf4..ecd4f510c4 100644 --- a/Userland/Services/Clipboard/Storage.h +++ b/Userland/Services/Clipboard/Storage.h @@ -20,10 +20,10 @@ public: bool has_data() const { return m_buffer.is_valid(); } - const String& mime_type() const { return m_mime_type; } - const HashMap<String, String>& metadata() const { return m_metadata; } + String const& mime_type() const { return m_mime_type; } + HashMap<String, String> const& metadata() const { return m_metadata; } - const u8* data() const + u8 const* data() const { if (!has_data()) return nullptr; @@ -37,11 +37,11 @@ public: return 0; } - void set_data(Core::AnonymousBuffer, const String& mime_type, const HashMap<String, String>& metadata); + void set_data(Core::AnonymousBuffer, String const& mime_type, HashMap<String, String> const& metadata); Function<void()> on_content_change; - const Core::AnonymousBuffer& buffer() const { return m_buffer; } + Core::AnonymousBuffer const& buffer() const { return m_buffer; } private: Storage() = default; diff --git a/Userland/Services/CrashDaemon/main.cpp b/Userland/Services/CrashDaemon/main.cpp index 927157ac59..d14c33497d 100644 --- a/Userland/Services/CrashDaemon/main.cpp +++ b/Userland/Services/CrashDaemon/main.cpp @@ -16,7 +16,7 @@ #include <time.h> #include <unistd.h> -static void wait_until_coredump_is_ready(const String& coredump_path) +static void wait_until_coredump_is_ready(String const& coredump_path) { while (true) { struct stat statbuf; @@ -31,10 +31,10 @@ static void wait_until_coredump_is_ready(const String& coredump_path) } } -static void launch_crash_reporter(const String& coredump_path, bool unlink_on_exit) +static void launch_crash_reporter(String const& coredump_path, bool unlink_on_exit) { pid_t child; - const char* argv[4] = { "CrashReporter" }; + char const* argv[4] = { "CrashReporter" }; if (unlink_on_exit) { argv[1] = "--unlink"; argv[2] = coredump_path.characters(); diff --git a/Userland/Services/DHCPClient/DHCPv4.cpp b/Userland/Services/DHCPClient/DHCPv4.cpp index 2806cf5bed..9abf5ed9a3 100644 --- a/Userland/Services/DHCPClient/DHCPv4.cpp +++ b/Userland/Services/DHCPClient/DHCPv4.cpp @@ -11,7 +11,7 @@ ParsedDHCPv4Options DHCPv4Packet::parse_options() const { ParsedDHCPv4Options options; for (size_t index = 4; index < DHCPV4_OPTION_FIELD_MAX_LENGTH; ++index) { - auto opt_name = *(const DHCPOption*)&m_options[index]; + auto opt_name = *(DHCPOption const*)&m_options[index]; switch (opt_name) { case DHCPOption::Pad: continue; diff --git a/Userland/Services/DHCPClient/DHCPv4.h b/Userland/Services/DHCPClient/DHCPv4.h index b6cdc1bda3..de00f46c6d 100644 --- a/Userland/Services/DHCPClient/DHCPv4.h +++ b/Userland/Services/DHCPClient/DHCPv4.h @@ -159,7 +159,7 @@ struct ParsedDHCPv4Options { for (auto& opt : options) { builder.appendff("\toption {} ({} bytes):", (u8)opt.key, (u8)opt.value.length); for (auto i = 0; i < opt.value.length; ++i) - builder.appendff(" {} ", ((const u8*)opt.value.value)[i]); + builder.appendff(" {} ", ((u8 const*)opt.value.value)[i]); builder.append('\n'); } return builder.build(); @@ -167,7 +167,7 @@ struct ParsedDHCPv4Options { struct DHCPOptionValue { u8 length; - const void* value; + void const* value; }; HashMap<DHCPOption, DHCPOptionValue> options; @@ -198,10 +198,10 @@ public: u16 flags() const { return m_flags; } void set_flags(DHCPv4Flags flags) { m_flags = (u16)flags; } - const IPv4Address& ciaddr() const { return m_ciaddr; } - const IPv4Address& yiaddr() const { return m_yiaddr; } - const IPv4Address& siaddr() const { return m_siaddr; } - const IPv4Address& giaddr() const { return m_giaddr; } + IPv4Address const& ciaddr() const { return m_ciaddr; } + IPv4Address const& yiaddr() const { return m_yiaddr; } + IPv4Address const& siaddr() const { return m_siaddr; } + IPv4Address const& giaddr() const { return m_giaddr; } IPv4Address& ciaddr() { return m_ciaddr; } IPv4Address& yiaddr() { return m_yiaddr; } @@ -211,11 +211,11 @@ public: u8* options() { return m_options; } ParsedDHCPv4Options parse_options() const; - const MACAddress& chaddr() const { return *(const MACAddress*)&m_chaddr[0]; } - void set_chaddr(const MACAddress& mac) { *(MACAddress*)&m_chaddr[0] = mac; } + MACAddress const& chaddr() const { return *(MACAddress const*)&m_chaddr[0]; } + void set_chaddr(MACAddress const& mac) { *(MACAddress*)&m_chaddr[0] = mac; } - StringView sname() const { return { (const char*)&m_sname[0] }; } - StringView file() const { return { (const char*)&m_file[0] }; } + StringView sname() const { return { (char const*)&m_sname[0] }; } + StringView file() const { return { (char const*)&m_file[0] }; } private: NetworkOrdered<u8> m_op; @@ -247,7 +247,7 @@ public: options[3] = 99; } - void add_option(DHCPOption option, u8 length, const void* data) + void add_option(DHCPOption option, u8 length, void const* data) { VERIFY(m_can_add); // we need enough space to fit the option value, its length, and its data diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index b9a4a0a2f8..35b8ea2028 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -15,14 +15,14 @@ #include <LibCore/Timer.h> #include <stdio.h> -static u8 mac_part(const Vector<String>& parts, size_t index) +static u8 mac_part(Vector<String> const& parts, size_t index) { auto result = AK::StringUtils::convert_to_uint_from_hex(parts.at(index)); VERIFY(result.has_value()); return result.value(); } -static MACAddress mac_from_string(const String& str) +static MACAddress mac_from_string(String const& str) { auto chunks = str.split(':'); VERIFY(chunks.size() == 6); // should we...worry about this? @@ -32,7 +32,7 @@ static MACAddress mac_from_string(const String& str) }; } -static bool send(const InterfaceDescriptor& iface, const DHCPv4Packet& packet, Core::Object*) +static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, Core::Object*) { int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (fd < 0) { @@ -63,7 +63,7 @@ static bool send(const InterfaceDescriptor& iface, const DHCPv4Packet& packet, C return true; } -static void set_params(const InterfaceDescriptor& iface, const IPv4Address& ipv4_addr, const IPv4Address& netmask, const IPv4Address& gateway) +static void set_params(InterfaceDescriptor const& iface, IPv4Address const& ipv4_addr, IPv4Address const& netmask, IPv4Address const& gateway) { int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (fd < 0) { @@ -201,7 +201,7 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces() }; } -void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options) +void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options) { dbgln("We were offered {} for {}", packet.yiaddr().to_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0)); auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr)); @@ -221,7 +221,7 @@ void DHCPv4Client::handle_offer(const DHCPv4Packet& packet, const ParsedDHCPv4Op dhcp_request(*transaction, packet); } -void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options) +void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options) { if constexpr (DHCPV4CLIENT_DEBUG) { dbgln("The DHCP server handed us {}", packet.yiaddr().to_string()); @@ -250,7 +250,7 @@ void DHCPv4Client::handle_ack(const DHCPv4Packet& packet, const ParsedDHCPv4Opti set_params(transaction->interface, new_ip, options.get<IPv4Address>(DHCPOption::SubnetMask).value(), options.get_many<IPv4Address>(DHCPOption::Router, 1).first()); } -void DHCPv4Client::handle_nak(const DHCPv4Packet& packet, const ParsedDHCPv4Options& options) +void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options) { dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_string()); dbgln("Here are the options: {}", options.to_string()); @@ -271,7 +271,7 @@ void DHCPv4Client::handle_nak(const DHCPv4Packet& packet, const ParsedDHCPv4Opti this); } -void DHCPv4Client::process_incoming(const DHCPv4Packet& packet) +void DHCPv4Client::process_incoming(DHCPv4Packet const& packet) { auto options = packet.parse_options(); @@ -307,7 +307,7 @@ void DHCPv4Client::process_incoming(const DHCPv4Packet& packet) } } -void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface) +void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface) { auto transaction_id = get_random<u32>(); @@ -339,7 +339,7 @@ void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface) m_ongoing_transactions.set(transaction_id, make<DHCPv4Transaction>(iface)); } -void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, const DHCPv4Packet& offer) +void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& offer) { auto& iface = transaction.interface; dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_string(), iface.ifname); diff --git a/Userland/Services/DHCPClient/DHCPv4Client.h b/Userland/Services/DHCPClient/DHCPv4Client.h index ba2498e483..d14deebd16 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.h +++ b/Userland/Services/DHCPClient/DHCPv4Client.h @@ -42,10 +42,10 @@ class DHCPv4Client final : public Core::Object { public: virtual ~DHCPv4Client() override = default; - void dhcp_discover(const InterfaceDescriptor& ifname); - void dhcp_request(DHCPv4Transaction& transaction, const DHCPv4Packet& packet); + void dhcp_discover(InterfaceDescriptor const& ifname); + void dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& packet); - void process_incoming(const DHCPv4Packet& packet); + void process_incoming(DHCPv4Packet const& packet); bool id_is_registered(u32 id) { return m_ongoing_transactions.contains(id); } @@ -65,7 +65,7 @@ private: RefPtr<Core::Timer> m_check_timer; int m_max_timer_backoff_interval { 600000 }; // 10 minutes - void handle_offer(const DHCPv4Packet&, const ParsedDHCPv4Options&); - void handle_ack(const DHCPv4Packet&, const ParsedDHCPv4Options&); - void handle_nak(const DHCPv4Packet&, const ParsedDHCPv4Options&); + void handle_offer(DHCPv4Packet const&, ParsedDHCPv4Options const&); + void handle_ack(DHCPv4Packet const&, ParsedDHCPv4Options const&); + void handle_nak(DHCPv4Packet const&, ParsedDHCPv4Options const&); }; diff --git a/Userland/Services/KeyboardPreferenceLoader/main.cpp b/Userland/Services/KeyboardPreferenceLoader/main.cpp index cfd231d13c..247421e782 100644 --- a/Userland/Services/KeyboardPreferenceLoader/main.cpp +++ b/Userland/Services/KeyboardPreferenceLoader/main.cpp @@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments) exit(1); pid_t child_pid; - const char* argv[] = { "/bin/keymap", "-m", keymaps_vector.first().characters(), nullptr }; + char const* argv[] = { "/bin/keymap", "-m", keymaps_vector.first().characters(), nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); exit(1); diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index a7bedbb473..5eadeb180f 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -23,7 +23,7 @@ namespace LaunchServer { static Launcher* s_the; -static bool spawn(String executable, const Vector<String>& arguments); +static bool spawn(String executable, Vector<String> const& arguments); String Handler::name_from_executable(StringView executable) { @@ -35,7 +35,7 @@ String Handler::name_from_executable(StringView executable) return executable; } -void Handler::from_executable(Type handler_type, const String& executable) +void Handler::from_executable(Type handler_type, String const& executable) { this->handler_type = handler_type; this->name = name_from_executable(executable); @@ -77,7 +77,7 @@ Launcher& Launcher::the() return *s_the; } -void Launcher::load_handlers(const String& af_dir) +void Launcher::load_handlers(String const& af_dir) { Desktop::AppFile::for_each([&](auto af) { auto app_name = af->name(); @@ -94,7 +94,7 @@ void Launcher::load_handlers(const String& af_dir) af_dir); } -void Launcher::load_config(const Core::ConfigFile& cfg) +void Launcher::load_config(Core::ConfigFile const& cfg) { for (auto key : cfg.keys("FileType")) { auto handler = cfg.read_entry("FileType", key).trim_whitespace(); @@ -124,7 +124,7 @@ Vector<String> Launcher::handlers_for_url(const URL& url) return true; }); } else { - for_each_handler(url.protocol(), m_protocol_handlers, [&](const auto& handler) -> bool { + for_each_handler(url.protocol(), m_protocol_handlers, [&](auto const& handler) -> bool { if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.protocol())) { handlers.append(handler.executable); return true; @@ -144,7 +144,7 @@ Vector<String> Launcher::handlers_with_details_for_url(const URL& url) return true; }); } else { - for_each_handler(url.protocol(), m_protocol_handlers, [&](const auto& handler) -> bool { + for_each_handler(url.protocol(), m_protocol_handlers, [&](auto const& handler) -> bool { if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.protocol())) { handlers.append(handler.to_details_str()); return true; @@ -155,7 +155,7 @@ Vector<String> Launcher::handlers_with_details_for_url(const URL& url) return handlers; } -bool Launcher::open_url(const URL& url, const String& handler_name) +bool Launcher::open_url(const URL& url, String const& handler_name) { if (!handler_name.is_null()) return open_with_handler_name(url, handler_name); @@ -166,7 +166,7 @@ bool Launcher::open_url(const URL& url, const String& handler_name) return open_with_user_preferences(m_protocol_handlers, url.protocol(), { url.to_string() }); } -bool Launcher::open_with_handler_name(const URL& url, const String& handler_name) +bool Launcher::open_with_handler_name(const URL& url, String const& handler_name) { auto handler_optional = m_handlers.get(handler_name); if (!handler_optional.has_value()) @@ -181,9 +181,9 @@ bool Launcher::open_with_handler_name(const URL& url, const String& handler_name return spawn(handler.executable, { argument }); } -bool spawn(String executable, const Vector<String>& arguments) +bool spawn(String executable, Vector<String> const& arguments) { - Vector<const char*> argv { executable.characters() }; + Vector<char const*> argv { executable.characters() }; for (auto& arg : arguments) argv.append(arg.characters()); argv.append(nullptr); @@ -199,7 +199,7 @@ bool spawn(String executable, const Vector<String>& arguments) return true; } -Handler Launcher::get_handler_for_executable(Handler::Type handler_type, const String& executable) const +Handler Launcher::get_handler_for_executable(Handler::Type handler_type, String const& executable) const { Handler handler; auto existing_handler = m_handlers.get(executable); @@ -212,7 +212,7 @@ Handler Launcher::get_handler_for_executable(Handler::Type handler_type, const S return handler; } -bool Launcher::open_with_user_preferences(const HashMap<String, String>& user_preferences, const String& key, const Vector<String>& arguments, const String& default_program) +bool Launcher::open_with_user_preferences(HashMap<String, String> const& user_preferences, String const& key, Vector<String> const& arguments, String const& default_program) { auto program_path = user_preferences.get(key); if (program_path.has_value()) @@ -230,7 +230,7 @@ bool Launcher::open_with_user_preferences(const HashMap<String, String>& user_pr return false; } -void Launcher::for_each_handler(const String& key, HashMap<String, String>& user_preference, Function<bool(const Handler&)> f) +void Launcher::for_each_handler(String const& key, HashMap<String, String>& user_preference, Function<bool(Handler const&)> f) { auto user_preferred = user_preference.get(key); if (user_preferred.has_value()) @@ -250,7 +250,7 @@ void Launcher::for_each_handler(const String& key, HashMap<String, String>& user f(get_handler_for_executable(Handler::Type::UserDefault, user_default.value())); } -void Launcher::for_each_handler_for_path(const String& path, Function<bool(const Handler&)> f) +void Launcher::for_each_handler_for_path(String const& path, Function<bool(Handler const&)> f) { struct stat st; if (lstat(path.characters(), &st) < 0) { @@ -278,7 +278,7 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const auto link_target = LexicalPath { link_target_or_error.release_value() }; LexicalPath absolute_link_target = link_target.is_absolute() ? link_target : LexicalPath::join(LexicalPath::dirname(path), link_target.string()); auto real_path = Core::File::real_path_for(absolute_link_target.string()); - return for_each_handler_for_path(real_path, [&](const auto& handler) -> bool { + return for_each_handler_for_path(real_path, [&](auto const& handler) -> bool { return f(handler); }); } @@ -288,7 +288,7 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const auto extension = LexicalPath::extension(path).to_lowercase(); - for_each_handler(extension, m_file_handlers, [&](const auto& handler) -> bool { + for_each_handler(extension, m_file_handlers, [&](auto const& handler) -> bool { if (handler.handler_type != Handler::Type::Default || handler.file_types.contains(extension)) return f(handler); return false; diff --git a/Userland/Services/LaunchServer/Launcher.h b/Userland/Services/LaunchServer/Launcher.h index bc1dacdb57..e9f918775e 100644 --- a/Userland/Services/LaunchServer/Launcher.h +++ b/Userland/Services/LaunchServer/Launcher.h @@ -28,7 +28,7 @@ struct Handler { HashTable<String> protocols {}; static String name_from_executable(StringView); - void from_executable(Type, const String&); + void from_executable(Type, String const&); String to_details_str() const; }; @@ -37,9 +37,9 @@ public: Launcher(); static Launcher& the(); - void load_handlers(const String& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY); - void load_config(const Core::ConfigFile&); - bool open_url(const URL&, const String& handler_name); + void load_handlers(String const& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY); + void load_config(Core::ConfigFile const&); + bool open_url(const URL&, String const& handler_name); Vector<String> handlers_for_url(const URL&); Vector<String> handlers_with_details_for_url(const URL&); @@ -48,11 +48,11 @@ private: HashMap<String, String> m_protocol_handlers; HashMap<String, String> m_file_handlers; - Handler get_handler_for_executable(Handler::Type, const String&) const; - void for_each_handler(const String& key, HashMap<String, String>& user_preferences, Function<bool(const Handler&)> f); - void for_each_handler_for_path(const String&, Function<bool(const Handler&)> f); + Handler get_handler_for_executable(Handler::Type, String const&) const; + void for_each_handler(String const& key, HashMap<String, String>& user_preferences, Function<bool(Handler const&)> f); + void for_each_handler_for_path(String const&, Function<bool(Handler const&)> f); bool open_file_url(const URL&); - bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String& key, const Vector<String>& arguments, const String& default_program = {}); - bool open_with_handler_name(const URL&, const String& handler_name); + bool open_with_user_preferences(HashMap<String, String> const& user_preferences, String const& key, Vector<String> const& arguments, String const& default_program = {}); + bool open_with_handler_name(const URL&, String const& handler_name); }; } diff --git a/Userland/Services/LookupServer/ConnectionFromClient.cpp b/Userland/Services/LookupServer/ConnectionFromClient.cpp index 2b3f68e8a5..6212e9af9e 100644 --- a/Userland/Services/LookupServer/ConnectionFromClient.cpp +++ b/Userland/Services/LookupServer/ConnectionFromClient.cpp @@ -44,7 +44,7 @@ Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_addre { if (address.length() != 4) return { 1, String() }; - IPv4Address ip_address { (const u8*)address.characters() }; + IPv4Address ip_address { (u8 const*)address.characters() }; auto name = String::formatted("{}.{}.{}.{}.in-addr.arpa", ip_address[3], ip_address[2], diff --git a/Userland/Services/LookupServer/DNSAnswer.cpp b/Userland/Services/LookupServer/DNSAnswer.cpp index 5479117581..06f8b516c0 100644 --- a/Userland/Services/LookupServer/DNSAnswer.cpp +++ b/Userland/Services/LookupServer/DNSAnswer.cpp @@ -10,7 +10,7 @@ namespace LookupServer { -DNSAnswer::DNSAnswer(const DNSName& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, const String& record_data, bool mdns_cache_flush) +DNSAnswer::DNSAnswer(DNSName const& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, String const& record_data, bool mdns_cache_flush) : m_name(name) , m_type(type) , m_class_code(class_code) diff --git a/Userland/Services/LookupServer/DNSAnswer.h b/Userland/Services/LookupServer/DNSAnswer.h index 4cf3db4df6..4a65dad0db 100644 --- a/Userland/Services/LookupServer/DNSAnswer.h +++ b/Userland/Services/LookupServer/DNSAnswer.h @@ -33,15 +33,15 @@ enum class DNSRecordClass : u16 { class DNSAnswer { public: - DNSAnswer(const DNSName& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, const String& record_data, bool mdns_cache_flush); + DNSAnswer(DNSName const& name, DNSRecordType type, DNSRecordClass class_code, u32 ttl, String const& record_data, bool mdns_cache_flush); - const DNSName& name() const { return m_name; } + DNSName const& name() const { return m_name; } DNSRecordType type() const { return m_type; } DNSRecordClass class_code() const { return m_class_code; } u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_cache_flush ? MDNS_CACHE_FLUSH : 0); } u32 ttl() const { return m_ttl; } time_t received_time() const { return m_received_time; } - const String& record_data() const { return m_record_data; } + String const& record_data() const { return m_record_data; } bool mdns_cache_flush() const { return m_mdns_cache_flush; } bool has_expired() const; diff --git a/Userland/Services/LookupServer/DNSName.cpp b/Userland/Services/LookupServer/DNSName.cpp index fde5575bca..a29cbec521 100644 --- a/Userland/Services/LookupServer/DNSName.cpp +++ b/Userland/Services/LookupServer/DNSName.cpp @@ -12,7 +12,7 @@ namespace LookupServer { -DNSName::DNSName(const String& name) +DNSName::DNSName(String const& name) { if (name.ends_with('.')) m_name = name.substring(0, name.length() - 1); @@ -20,7 +20,7 @@ DNSName::DNSName(const String& name) m_name = name; } -DNSName DNSName::parse(const u8* data, size_t& offset, size_t max_offset, size_t recursion_level) +DNSName DNSName::parse(u8 const* data, size_t& offset, size_t max_offset, size_t recursion_level) { if (recursion_level > 4) return DNSName({}); @@ -45,7 +45,7 @@ DNSName DNSName::parse(const u8* data, size_t& offset, size_t max_offset, size_t // This is the length of a part. if (offset + b >= max_offset) return DNSName({}); - builder.append((const char*)&data[offset], (size_t)b); + builder.append((char const*)&data[offset], (size_t)b); builder.append('.'); offset += b; } @@ -75,7 +75,7 @@ void DNSName::randomize_case() m_name = builder.to_string(); } -OutputStream& operator<<(OutputStream& stream, const DNSName& name) +OutputStream& operator<<(OutputStream& stream, DNSName const& name) { auto parts = name.as_string().split_view('.'); for (auto& part : parts) { @@ -86,12 +86,12 @@ OutputStream& operator<<(OutputStream& stream, const DNSName& name) return stream; } -unsigned DNSName::Traits::hash(const DNSName& name) +unsigned DNSName::Traits::hash(DNSName const& name) { return CaseInsensitiveStringTraits::hash(name.as_string()); } -bool DNSName::Traits::equals(const DNSName& a, const DNSName& b) +bool DNSName::Traits::equals(DNSName const& a, DNSName const& b) { return CaseInsensitiveStringTraits::equals(a.as_string(), b.as_string()); } diff --git a/Userland/Services/LookupServer/DNSName.h b/Userland/Services/LookupServer/DNSName.h index 3a2cb4ba1d..375f61c1b7 100644 --- a/Userland/Services/LookupServer/DNSName.h +++ b/Userland/Services/LookupServer/DNSName.h @@ -14,28 +14,28 @@ namespace LookupServer { class DNSName { public: - DNSName(const String&); + DNSName(String const&); - static DNSName parse(const u8* data, size_t& offset, size_t max_offset, size_t recursion_level = 0); + static DNSName parse(u8 const* data, size_t& offset, size_t max_offset, size_t recursion_level = 0); size_t serialized_size() const; - const String& as_string() const { return m_name; } + String const& as_string() const { return m_name; } void randomize_case(); - bool operator==(const DNSName& other) const { return Traits::equals(*this, other); } + bool operator==(DNSName const& other) const { return Traits::equals(*this, other); } class Traits : public AK::Traits<DNSName> { public: - static unsigned hash(const DNSName& name); - static bool equals(const DNSName&, const DNSName&); + static unsigned hash(DNSName const& name); + static bool equals(DNSName const&, DNSName const&); }; private: String m_name; }; -OutputStream& operator<<(OutputStream& stream, const DNSName&); +OutputStream& operator<<(OutputStream& stream, DNSName const&); } diff --git a/Userland/Services/LookupServer/DNSPacket.cpp b/Userland/Services/LookupServer/DNSPacket.cpp index 47d89929d8..90753cde26 100644 --- a/Userland/Services/LookupServer/DNSPacket.cpp +++ b/Userland/Services/LookupServer/DNSPacket.cpp @@ -16,14 +16,14 @@ namespace LookupServer { -void DNSPacket::add_question(const DNSQuestion& question) +void DNSPacket::add_question(DNSQuestion const& question) { m_questions.empend(question); VERIFY(m_questions.size() <= UINT16_MAX); } -void DNSPacket::add_answer(const DNSAnswer& answer) +void DNSPacket::add_answer(DNSAnswer const& answer) { m_answers.empend(answer); @@ -85,7 +85,7 @@ public: u16 data_length() const { return m_data_length; } void* data() { return this + 1; } - const void* data() const { return this + 1; } + void const* data() const { return this + 1; } private: NetworkOrdered<u16> m_type; @@ -96,14 +96,14 @@ private: static_assert(sizeof(DNSRecordWithoutName) == 10); -Optional<DNSPacket> DNSPacket::from_raw_packet(const u8* raw_data, size_t raw_size) +Optional<DNSPacket> DNSPacket::from_raw_packet(u8 const* raw_data, size_t raw_size) { if (raw_size < sizeof(DNSPacketHeader)) { dbgln("DNS response not large enough ({} out of {}) to be a DNS packet.", raw_size, sizeof(DNSPacketHeader)); return {}; } - auto& header = *(const DNSPacketHeader*)(raw_data); + auto& header = *(DNSPacketHeader const*)(raw_data); dbgln_if(LOOKUPSERVER_DEBUG, "Got packet (ID: {})", header.id()); dbgln_if(LOOKUPSERVER_DEBUG, " Question count: {}", header.question_count()); dbgln_if(LOOKUPSERVER_DEBUG, " Answer count: {}", header.answer_count()); @@ -127,7 +127,7 @@ Optional<DNSPacket> DNSPacket::from_raw_packet(const u8* raw_data, size_t raw_si NetworkOrdered<u16> record_type; NetworkOrdered<u16> class_code; }; - auto& record_and_class = *(const RawDNSAnswerQuestion*)&raw_data[offset]; + auto& record_and_class = *(RawDNSAnswerQuestion const*)&raw_data[offset]; u16 class_code = record_and_class.class_code & ~MDNS_WANTS_UNICAST_RESPONSE; bool mdns_wants_unicast_response = record_and_class.class_code & MDNS_WANTS_UNICAST_RESPONSE; packet.m_questions.empend(name, (DNSRecordType)(u16)record_and_class.record_type, (DNSRecordClass)class_code, mdns_wants_unicast_response); @@ -139,7 +139,7 @@ Optional<DNSPacket> DNSPacket::from_raw_packet(const u8* raw_data, size_t raw_si for (u16 i = 0; i < header.answer_count(); ++i) { auto name = DNSName::parse(raw_data, offset, raw_size); - auto& record = *(const DNSRecordWithoutName*)(&raw_data[offset]); + auto& record = *(DNSRecordWithoutName const*)(&raw_data[offset]); String data; diff --git a/Userland/Services/LookupServer/DNSPacket.h b/Userland/Services/LookupServer/DNSPacket.h index 2d665ac10a..60225cec0c 100644 --- a/Userland/Services/LookupServer/DNSPacket.h +++ b/Userland/Services/LookupServer/DNSPacket.h @@ -24,7 +24,7 @@ class DNSPacket { public: DNSPacket() = default; - static Optional<DNSPacket> from_raw_packet(const u8*, size_t); + static Optional<DNSPacket> from_raw_packet(u8 const*, size_t); ByteBuffer to_byte_buffer() const; bool is_query() const { return !m_query_or_response; } @@ -41,8 +41,8 @@ public: u16 id() const { return m_id; } void set_id(u16 id) { m_id = id; } - const Vector<DNSQuestion>& questions() const { return m_questions; } - const Vector<DNSAnswer>& answers() const { return m_answers; } + Vector<DNSQuestion> const& questions() const { return m_questions; } + Vector<DNSAnswer> const& answers() const { return m_answers; } u16 question_count() const { @@ -56,8 +56,8 @@ public: return m_answers.size(); } - void add_question(const DNSQuestion&); - void add_answer(const DNSAnswer&); + void add_question(DNSQuestion const&); + void add_answer(DNSAnswer const&); enum class Code : u8 { NOERROR = 0, diff --git a/Userland/Services/LookupServer/DNSPacketHeader.h b/Userland/Services/LookupServer/DNSPacketHeader.h index a45602aa66..9b3f627122 100644 --- a/Userland/Services/LookupServer/DNSPacketHeader.h +++ b/Userland/Services/LookupServer/DNSPacketHeader.h @@ -72,7 +72,7 @@ public: void set_additional_count(u16 w) { m_additional_count = w; } void* payload() { return this + 1; } - const void* payload() const { return this + 1; } + void const* payload() const { return this + 1; } private: NetworkOrdered<u16> m_id; diff --git a/Userland/Services/LookupServer/DNSQuestion.h b/Userland/Services/LookupServer/DNSQuestion.h index 89d5c76ff8..eaa83bb566 100644 --- a/Userland/Services/LookupServer/DNSQuestion.h +++ b/Userland/Services/LookupServer/DNSQuestion.h @@ -15,7 +15,7 @@ namespace LookupServer { class DNSQuestion { public: - DNSQuestion(const DNSName& name, DNSRecordType record_type, DNSRecordClass class_code, bool mdns_wants_unicast_response) + DNSQuestion(DNSName const& name, DNSRecordType record_type, DNSRecordClass class_code, bool mdns_wants_unicast_response) : m_name(name) , m_record_type(record_type) , m_class_code(class_code) @@ -26,7 +26,7 @@ public: DNSRecordType record_type() const { return m_record_type; } DNSRecordClass class_code() const { return m_class_code; } u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_wants_unicast_response ? MDNS_WANTS_UNICAST_RESPONSE : 0); } - const DNSName& name() const { return m_name; } + DNSName const& name() const { return m_name; } bool mdns_wants_unicast_response() const { return m_mdns_wants_unicast_response; } private: diff --git a/Userland/Services/LookupServer/LookupServer.cpp b/Userland/Services/LookupServer/LookupServer.cpp index 463f1b2782..e45bd6e697 100644 --- a/Userland/Services/LookupServer/LookupServer.cpp +++ b/Userland/Services/LookupServer/LookupServer.cpp @@ -78,7 +78,7 @@ LookupServer::LookupServer() void LookupServer::load_etc_hosts() { m_etc_hosts.clear(); - auto add_answer = [this](const DNSName& name, DNSRecordType record_type, String data) { + auto add_answer = [this](DNSName const& name, DNSRecordType record_type, String data) { m_etc_hosts.ensure(name).empend(name, record_type, DNSRecordClass::IN, s_static_ttl, move(data), false); }; @@ -115,7 +115,7 @@ void LookupServer::load_etc_hosts() auto raw_addr = maybe_address->to_in_addr_t(); DNSName name { fields[1] }; - add_answer(name, DNSRecordType::A, String { (const char*)&raw_addr, sizeof(raw_addr) }); + add_answer(name, DNSRecordType::A, String { (char const*)&raw_addr, sizeof(raw_addr) }); StringBuilder builder; builder.append(maybe_address->to_string_reversed()); @@ -131,12 +131,12 @@ static String get_hostname() return buffer; } -ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, DNSRecordType record_type) +ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(DNSName const& name, DNSRecordType record_type) { dbgln_if(LOOKUPSERVER_DEBUG, "Got request for '{}'", name.as_string()); Vector<DNSAnswer> answers; - auto add_answer = [&](const DNSAnswer& answer) { + auto add_answer = [&](DNSAnswer const& answer) { DNSAnswer answer_with_original_case { name, answer.type(), @@ -163,7 +163,7 @@ ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, DNSRecordTy if (record_type == DNSRecordType::A && get_hostname() == name) { IPv4Address address = { 127, 0, 0, 1 }; auto raw_address = address.to_in_addr_t(); - DNSAnswer answer { name, DNSRecordType::A, DNSRecordClass::IN, s_static_ttl, String { (const char*)&raw_address, sizeof(raw_address) }, false }; + DNSAnswer answer { name, DNSRecordType::A, DNSRecordClass::IN, s_static_ttl, String { (char const*)&raw_address, sizeof(raw_address) }, false }; answers.append(move(answer)); return answers; } @@ -221,7 +221,7 @@ ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, DNSRecordTy return answers; } -ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, const String& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase should_randomize_case) +ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(DNSName const& name, String const& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase should_randomize_case) { DNSPacket request; request.set_is_query(); @@ -300,7 +300,7 @@ ErrorOr<Vector<DNSAnswer>> LookupServer::lookup(const DNSName& name, const Strin return answers; } -void LookupServer::put_in_cache(const DNSAnswer& answer) +void LookupServer::put_in_cache(DNSAnswer const& answer) { if (answer.has_expired()) return; diff --git a/Userland/Services/LookupServer/LookupServer.h b/Userland/Services/LookupServer/LookupServer.h index 88c7fcc740..6f5a90d904 100644 --- a/Userland/Services/LookupServer/LookupServer.h +++ b/Userland/Services/LookupServer/LookupServer.h @@ -24,15 +24,15 @@ class LookupServer final : public Core::Object { public: static LookupServer& the(); - ErrorOr<Vector<DNSAnswer>> lookup(const DNSName& name, DNSRecordType record_type); + ErrorOr<Vector<DNSAnswer>> lookup(DNSName const& name, DNSRecordType record_type); private: LookupServer(); void load_etc_hosts(); - void put_in_cache(const DNSAnswer&); + void put_in_cache(DNSAnswer const&); - ErrorOr<Vector<DNSAnswer>> lookup(const DNSName& hostname, const String& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes); + ErrorOr<Vector<DNSAnswer>> lookup(DNSName const& hostname, String const& nameserver, bool& did_get_response, DNSRecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes); OwnPtr<IPC::MultiServer<ConnectionFromClient>> m_server; RefPtr<DNSServer> m_dns_server; diff --git a/Userland/Services/LookupServer/MulticastDNS.cpp b/Userland/Services/LookupServer/MulticastDNS.cpp index 6f01c7acaf..b7b4a4490e 100644 --- a/Userland/Services/LookupServer/MulticastDNS.cpp +++ b/Userland/Services/LookupServer/MulticastDNS.cpp @@ -64,7 +64,7 @@ void MulticastDNS::handle_packet() handle_query(packet); } -void MulticastDNS::handle_query(const DNSPacket& packet) +void MulticastDNS::handle_query(DNSPacket const& packet) { bool should_reply = false; @@ -94,7 +94,7 @@ void MulticastDNS::announce() DNSRecordType::A, DNSRecordClass::IN, 120, - String { (const char*)&raw_addr, sizeof(raw_addr) }, + String { (char const*)&raw_addr, sizeof(raw_addr) }, true, }; response.add_answer(answer); @@ -104,7 +104,7 @@ void MulticastDNS::announce() perror("Failed to emit response packet"); } -ErrorOr<size_t> MulticastDNS::emit_packet(const DNSPacket& packet, const sockaddr_in* destination) +ErrorOr<size_t> MulticastDNS::emit_packet(DNSPacket const& packet, sockaddr_in const* destination) { auto buffer = packet.to_byte_buffer(); if (!destination) @@ -142,7 +142,7 @@ Vector<IPv4Address> MulticastDNS::local_addresses() const return addresses; } -Vector<DNSAnswer> MulticastDNS::lookup(const DNSName& name, DNSRecordType record_type) +Vector<DNSAnswer> MulticastDNS::lookup(DNSName const& name, DNSRecordType record_type) { DNSPacket request; request.set_is_query(); diff --git a/Userland/Services/LookupServer/MulticastDNS.h b/Userland/Services/LookupServer/MulticastDNS.h index 37b98db9bd..23fc71d430 100644 --- a/Userland/Services/LookupServer/MulticastDNS.h +++ b/Userland/Services/LookupServer/MulticastDNS.h @@ -18,16 +18,16 @@ namespace LookupServer { class MulticastDNS : public Core::UDPServer { C_OBJECT(MulticastDNS) public: - Vector<DNSAnswer> lookup(const DNSName&, DNSRecordType record_type); + Vector<DNSAnswer> lookup(DNSName const&, DNSRecordType record_type); private: explicit MulticastDNS(Object* parent = nullptr); void announce(); - ErrorOr<size_t> emit_packet(const DNSPacket&, const sockaddr_in* destination = nullptr); + ErrorOr<size_t> emit_packet(DNSPacket const&, sockaddr_in const* destination = nullptr); void handle_packet(); - void handle_query(const DNSPacket&); + void handle_query(DNSPacket const&); Vector<IPv4Address> local_addresses() const; diff --git a/Userland/Services/NotificationServer/NotificationWindow.cpp b/Userland/Services/NotificationServer/NotificationWindow.cpp index 0c87849ce8..7ab7847c97 100644 --- a/Userland/Services/NotificationServer/NotificationWindow.cpp +++ b/Userland/Services/NotificationServer/NotificationWindow.cpp @@ -19,7 +19,7 @@ namespace NotificationServer { static HashMap<u32, RefPtr<NotificationWindow>> s_windows; -static void update_notification_window_locations(const Gfx::IntRect& screen_rect) +static void update_notification_window_locations(Gfx::IntRect const& screen_rect) { Gfx::IntRect last_window_rect; for (auto& window_entry : s_windows) { @@ -37,7 +37,7 @@ static void update_notification_window_locations(const Gfx::IntRect& screen_rect } } -NotificationWindow::NotificationWindow(i32 client_id, const String& text, const String& title, const Gfx::ShareableBitmap& icon) +NotificationWindow::NotificationWindow(i32 client_id, String const& text, String const& title, Gfx::ShareableBitmap const& icon) { m_id = client_id; s_windows.set(m_id, this); diff --git a/Userland/Services/NotificationServer/NotificationWindow.h b/Userland/Services/NotificationServer/NotificationWindow.h index a6ca12686b..cae0bd505a 100644 --- a/Userland/Services/NotificationServer/NotificationWindow.h +++ b/Userland/Services/NotificationServer/NotificationWindow.h @@ -18,9 +18,9 @@ public: virtual ~NotificationWindow() override = default; void set_original_rect(Gfx::IntRect original_rect) { m_original_rect = original_rect; }; - void set_text(const String&); - void set_title(const String&); - void set_image(const Gfx::ShareableBitmap&); + void set_text(String const&); + void set_title(String const&); + void set_image(Gfx::ShareableBitmap const&); static RefPtr<NotificationWindow> get_window_by_id(i32 id); @@ -29,7 +29,7 @@ protected: virtual void leave_event(Core::Event&) override; private: - NotificationWindow(i32 client_id, const String& text, const String& title, const Gfx::ShareableBitmap&); + NotificationWindow(i32 client_id, String const& text, String const& title, Gfx::ShareableBitmap const&); virtual void screen_rects_change_event(GUI::ScreenRectsChangeEvent&) override; diff --git a/Userland/Services/RequestServer/GeminiProtocol.cpp b/Userland/Services/RequestServer/GeminiProtocol.cpp index 2232e67635..befe40903d 100644 --- a/Userland/Services/RequestServer/GeminiProtocol.cpp +++ b/Userland/Services/RequestServer/GeminiProtocol.cpp @@ -17,7 +17,7 @@ GeminiProtocol::GeminiProtocol() { } -OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, const String&, const URL& url, const HashMap<String, String>&, ReadonlyBytes) +OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, String const&, const URL& url, HashMap<String, String> const&, ReadonlyBytes) { Gemini::GeminiRequest request; request.set_url(url); diff --git a/Userland/Services/RequestServer/GeminiProtocol.h b/Userland/Services/RequestServer/GeminiProtocol.h index 37d0e35091..4ecf29a070 100644 --- a/Userland/Services/RequestServer/GeminiProtocol.h +++ b/Userland/Services/RequestServer/GeminiProtocol.h @@ -15,7 +15,7 @@ public: GeminiProtocol(); virtual ~GeminiProtocol() override = default; - virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>&, ReadonlyBytes body) override; + virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const&, ReadonlyBytes body) override; }; } diff --git a/Userland/Services/RequestServer/HttpCommon.h b/Userland/Services/RequestServer/HttpCommon.h index f7bd86b9d5..7ea0a18573 100644 --- a/Userland/Services/RequestServer/HttpCommon.h +++ b/Userland/Services/RequestServer/HttpCommon.h @@ -61,7 +61,7 @@ void init(TSelf* self, TJob job) } template<typename TBadgedProtocol, typename TPipeResult> -OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body, TPipeResult&& pipe_result) +OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, String const& method, const URL& url, HashMap<String, String> const& headers, ReadonlyBytes body, TPipeResult&& pipe_result) { using TJob = typename TBadgedProtocol::Type::JobType; using TRequest = typename TBadgedProtocol::Type::RequestType; diff --git a/Userland/Services/RequestServer/HttpProtocol.cpp b/Userland/Services/RequestServer/HttpProtocol.cpp index 4778547a97..fdfc4971d5 100644 --- a/Userland/Services/RequestServer/HttpProtocol.cpp +++ b/Userland/Services/RequestServer/HttpProtocol.cpp @@ -22,7 +22,7 @@ HttpProtocol::HttpProtocol() { } -OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body) +OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, String const& method, const URL& url, HashMap<String, String> const& headers, ReadonlyBytes body) { return Detail::start_request(Badge<HttpProtocol> {}, client, method, url, headers, body, get_pipe_for_request()); } diff --git a/Userland/Services/RequestServer/HttpProtocol.h b/Userland/Services/RequestServer/HttpProtocol.h index cfedf92cfe..012e6bc033 100644 --- a/Userland/Services/RequestServer/HttpProtocol.h +++ b/Userland/Services/RequestServer/HttpProtocol.h @@ -27,7 +27,7 @@ public: HttpProtocol(); ~HttpProtocol() override = default; - virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override; + virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const& headers, ReadonlyBytes body) override; }; } diff --git a/Userland/Services/RequestServer/HttpsProtocol.cpp b/Userland/Services/RequestServer/HttpsProtocol.cpp index 5cd18ca74a..0580bff44b 100644 --- a/Userland/Services/RequestServer/HttpsProtocol.cpp +++ b/Userland/Services/RequestServer/HttpsProtocol.cpp @@ -22,7 +22,7 @@ HttpsProtocol::HttpsProtocol() { } -OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, const String& method, const URL& url, const HashMap<String, String>& headers, ReadonlyBytes body) +OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, String const& method, const URL& url, HashMap<String, String> const& headers, ReadonlyBytes body) { return Detail::start_request(Badge<HttpsProtocol> {}, client, method, url, headers, body, get_pipe_for_request()); } diff --git a/Userland/Services/RequestServer/HttpsProtocol.h b/Userland/Services/RequestServer/HttpsProtocol.h index 6c13cd76f2..c1083b684a 100644 --- a/Userland/Services/RequestServer/HttpsProtocol.h +++ b/Userland/Services/RequestServer/HttpsProtocol.h @@ -27,7 +27,7 @@ public: HttpsProtocol(); ~HttpsProtocol() override = default; - virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) override; + virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const& headers, ReadonlyBytes body) override; }; } diff --git a/Userland/Services/RequestServer/Protocol.cpp b/Userland/Services/RequestServer/Protocol.cpp index c7b385b22d..f9f2fe1692 100644 --- a/Userland/Services/RequestServer/Protocol.cpp +++ b/Userland/Services/RequestServer/Protocol.cpp @@ -19,12 +19,12 @@ static HashMap<String, Protocol*>& all_protocols() return map; } -Protocol* Protocol::find_by_name(const String& name) +Protocol* Protocol::find_by_name(String const& name) { return all_protocols().get(name).value_or(nullptr); } -Protocol::Protocol(const String& name) +Protocol::Protocol(String const& name) { all_protocols().set(name, this); } diff --git a/Userland/Services/RequestServer/Protocol.h b/Userland/Services/RequestServer/Protocol.h index cd8a969c32..e0ab1493fc 100644 --- a/Userland/Services/RequestServer/Protocol.h +++ b/Userland/Services/RequestServer/Protocol.h @@ -16,13 +16,13 @@ class Protocol { public: virtual ~Protocol(); - const String& name() const { return m_name; } - virtual OwnPtr<Request> start_request(ConnectionFromClient&, const String& method, const URL&, const HashMap<String, String>& headers, ReadonlyBytes body) = 0; + String const& name() const { return m_name; } + virtual OwnPtr<Request> start_request(ConnectionFromClient&, String const& method, const URL&, HashMap<String, String> const& headers, ReadonlyBytes body) = 0; - static Protocol* find_by_name(const String&); + static Protocol* find_by_name(String const&); protected: - explicit Protocol(const String& name); + explicit Protocol(String const& name); struct Pipe { int read_fd { -1 }; int write_fd { -1 }; diff --git a/Userland/Services/RequestServer/Request.cpp b/Userland/Services/RequestServer/Request.cpp index f733115ee1..752a3c2b9a 100644 --- a/Userland/Services/RequestServer/Request.cpp +++ b/Userland/Services/RequestServer/Request.cpp @@ -24,7 +24,7 @@ void Request::stop() m_client.did_finish_request({}, *this, false); } -void Request::set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers) +void Request::set_response_headers(HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers) { m_response_headers = response_headers; m_client.did_receive_headers({}, *this); diff --git a/Userland/Services/RequestServer/Request.h b/Userland/Services/RequestServer/Request.h index 8c16399463..562e8254c9 100644 --- a/Userland/Services/RequestServer/Request.h +++ b/Userland/Services/RequestServer/Request.h @@ -26,7 +26,7 @@ public: Optional<u32> status_code() const { return m_status_code; } Optional<u32> total_size() const { return m_total_size; } size_t downloaded_size() const { return m_downloaded_size; } - const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers() const { return m_response_headers; } + HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; } void stop(); virtual void set_certificate(String, String); @@ -39,9 +39,9 @@ public: void did_progress(Optional<u32> total_size, u32 downloaded_size); void set_status_code(u32 status_code) { m_status_code = status_code; } void did_request_certificates(); - void set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>&); + void set_response_headers(HashMap<String, String, CaseInsensitiveStringTraits> const&); void set_downloaded_size(size_t size) { m_downloaded_size = size; } - const Core::Stream::File& output_stream() const { return *m_output_stream; } + Core::Stream::File const& output_stream() const { return *m_output_stream; } protected: explicit Request(ConnectionFromClient&, NonnullOwnPtr<Core::Stream::File>&&); diff --git a/Userland/Services/SpiceAgent/SpiceAgent.cpp b/Userland/Services/SpiceAgent/SpiceAgent.cpp index 38919ed138..2e39f330f8 100644 --- a/Userland/Services/SpiceAgent/SpiceAgent.cpp +++ b/Userland/Services/SpiceAgent/SpiceAgent.cpp @@ -41,7 +41,7 @@ SpiceAgent::SpiceAgent(int fd, ConnectionToClipboardServer& connection) send_message(buffer); } -Optional<SpiceAgent::ClipboardType> SpiceAgent::mime_type_to_clipboard_type(const String& mime) +Optional<SpiceAgent::ClipboardType> SpiceAgent::mime_type_to_clipboard_type(String const& mime) { if (mime == "text/plain") return ClipboardType::Text; @@ -120,7 +120,7 @@ void SpiceAgent::on_message_received() auto type = (ClipboardType)clipboard_message->type; auto data_buffer = ByteBuffer::create_uninitialized(message->size - sizeof(u32)).release_value_but_fixme_should_propagate_errors(); // FIXME: Handle possible OOM situation. - const auto total_bytes = message->size - sizeof(Clipboard); + auto const total_bytes = message->size - sizeof(Clipboard); auto bytes_copied = header.size - sizeof(Message) - sizeof(Clipboard); memcpy(data_buffer.data(), clipboard_message->data, bytes_copied); @@ -206,7 +206,7 @@ SpiceAgent::Message* SpiceAgent::initialize_headers(u8* data, size_t additional_ return message; } -ByteBuffer SpiceAgent::AnnounceCapabilities::make_buffer(bool request, const Vector<Capability>& capabilities) +ByteBuffer SpiceAgent::AnnounceCapabilities::make_buffer(bool request, Vector<Capability> const& capabilities) { size_t required_size = sizeof(ChunkHeader) + sizeof(Message) + sizeof(AnnounceCapabilities); auto buffer = ByteBuffer::create_uninitialized(required_size).release_value_but_fixme_should_propagate_errors(); // FIXME: Handle possible OOM situation. @@ -226,7 +226,7 @@ ByteBuffer SpiceAgent::AnnounceCapabilities::make_buffer(bool request, const Vec return buffer; } -ByteBuffer SpiceAgent::ClipboardGrab::make_buffer(const Vector<ClipboardType>& types) +ByteBuffer SpiceAgent::ClipboardGrab::make_buffer(Vector<ClipboardType> const& types) { VERIFY(types.size() > 0); size_t variable_data_size = sizeof(u32) * types.size(); diff --git a/Userland/Services/SpiceAgent/SpiceAgent.h b/Userland/Services/SpiceAgent/SpiceAgent.h index 44c5474395..9ef81d7ed1 100644 --- a/Userland/Services/SpiceAgent/SpiceAgent.h +++ b/Userland/Services/SpiceAgent/SpiceAgent.h @@ -92,7 +92,7 @@ public: u32 request; u32 caps[CAPABILITIES_SIZE]; - static ByteBuffer make_buffer(bool request, const Vector<Capability>& capabilities); + static ByteBuffer make_buffer(bool request, Vector<Capability> const& capabilities); }; struct [[gnu::packed]] ClipboardGrab { @@ -120,9 +120,9 @@ private: ConnectionToClipboardServer& m_clipboard_connection; void on_message_received(); - void send_message(const ByteBuffer& buffer); + void send_message(ByteBuffer const& buffer); bool m_just_set_clip { false }; void read_n(void* dest, size_t n); static Message* initialize_headers(u8* data, size_t additional_data_size, MessageType type); - static Optional<ClipboardType> mime_type_to_clipboard_type(const String& mime); + static Optional<ClipboardType> mime_type_to_clipboard_type(String const& mime); }; diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp index df8b50b3e1..4147595966 100644 --- a/Userland/Services/SystemServer/Service.cpp +++ b/Userland/Services/SystemServer/Service.cpp @@ -61,7 +61,7 @@ void Service::setup_socket(SocketDescriptor& socket) auto un = un_optional.value(); // FIXME: Propagate errors - MUST(Core::System::bind(socket_fd, (const sockaddr*)&un, sizeof(un))); + MUST(Core::System::bind(socket_fd, (sockaddr const*)&un, sizeof(un))); // FIXME: Propagate errors MUST(Core::System::listen(socket_fd, 16)); } @@ -270,7 +270,7 @@ void Service::did_exit(int exit_code) activate(); } -Service::Service(const Core::ConfigFile& config, StringView name) +Service::Service(Core::ConfigFile const& config, StringView name) : Core::Object(nullptr) { VERIFY(config.has_group(name)); diff --git a/Userland/Services/SystemServer/Service.h b/Userland/Services/SystemServer/Service.h index dcc22a7244..cccd691efe 100644 --- a/Userland/Services/SystemServer/Service.h +++ b/Userland/Services/SystemServer/Service.h @@ -27,7 +27,7 @@ public: void save_to(JsonObject&); private: - Service(const Core::ConfigFile&, StringView name); + Service(Core::ConfigFile const&, StringView name); void spawn(int socket_fd = -1); diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp index 97c07259f0..a593b6d8d3 100644 --- a/Userland/Services/SystemServer/main.cpp +++ b/Userland/Services/SystemServer/main.cpp @@ -85,14 +85,14 @@ static ErrorOr<void> determine_system_mode() return {}; } -static void chown_wrapper(const char* path, uid_t uid, gid_t gid) +static void chown_wrapper(char const* path, uid_t uid, gid_t gid) { int rc = chown(path, uid, gid); if (rc < 0 && errno != ENOENT) { VERIFY_NOT_REACHED(); } } -static void chmod_wrapper(const char* path, mode_t mode) +static void chmod_wrapper(char const* path, mode_t mode) { int rc = chmod(path, mode); if (rc < 0 && errno != ENOENT) { diff --git a/Userland/Services/Taskbar/ClockWidget.cpp b/Userland/Services/Taskbar/ClockWidget.cpp index 97708de897..87a0282530 100644 --- a/Userland/Services/Taskbar/ClockWidget.cpp +++ b/Userland/Services/Taskbar/ClockWidget.cpp @@ -169,11 +169,11 @@ void ClockWidget::paint_event(GUI::PaintEvent& event) // Render string center-left aligned, but attempt to center the string based on a constant // "ideal" time string (i.e., the same one used to size this widget in the initializer). // This prevents the rest of the string from shifting around while seconds tick. - const Gfx::Font& font = Gfx::FontDatabase::default_font(); - const int frame_width = frame_thickness(); - const int ideal_width = m_time_width; - const int widget_width = max_width(); - const int translation_x = (widget_width - ideal_width) / 2 - frame_width; + Gfx::Font const& font = Gfx::FontDatabase::default_font(); + int const frame_width = frame_thickness(); + int const ideal_width = m_time_width; + int const widget_width = max_width(); + int const translation_x = (widget_width - ideal_width) / 2 - frame_width; painter.draw_text(frame_inner_rect().translated(translation_x, frame_width), time_text, font, Gfx::TextAlignment::CenterLeft, palette().window_text()); } diff --git a/Userland/Services/Taskbar/ShutdownDialog.cpp b/Userland/Services/Taskbar/ShutdownDialog.cpp index 1a11985198..45af703058 100644 --- a/Userland/Services/Taskbar/ShutdownDialog.cpp +++ b/Userland/Services/Taskbar/ShutdownDialog.cpp @@ -23,7 +23,7 @@ struct Option { bool default_action; }; -static const Vector<Option> options = { +static Vector<Option> const options = { { "Power off computer", { "/bin/shutdown", "--now", nullptr }, true, true }, { "Reboot", { "/bin/reboot", nullptr }, true, false }, { "Log out", { "/bin/logout", nullptr }, true, false }, diff --git a/Userland/Services/Taskbar/TaskbarButton.cpp b/Userland/Services/Taskbar/TaskbarButton.cpp index 94a01ed82a..00f4c0a6af 100644 --- a/Userland/Services/Taskbar/TaskbarButton.cpp +++ b/Userland/Services/Taskbar/TaskbarButton.cpp @@ -14,7 +14,7 @@ #include <LibGfx/Palette.h> #include <LibGfx/StylePainter.h> -TaskbarButton::TaskbarButton(const WindowIdentifier& identifier) +TaskbarButton::TaskbarButton(WindowIdentifier const& identifier) : m_identifier(identifier) { } @@ -49,7 +49,7 @@ void TaskbarButton::resize_event(GUI::ResizeEvent& event) return GUI::Button::resize_event(event); } -static void paint_custom_progressbar(GUI::Painter& painter, const Gfx::IntRect& rect, const Gfx::IntRect& text_rect, const Palette& palette, int min, int max, int value, StringView text, const Gfx::Font& font, Gfx::TextAlignment text_alignment) +static void paint_custom_progressbar(GUI::Painter& painter, Gfx::IntRect const& rect, Gfx::IntRect const& text_rect, Palette const& palette, int min, int max, int value, StringView text, Gfx::Font const& font, Gfx::TextAlignment text_alignment) { float range_size = max - min; float progress = (value - min) / range_size; diff --git a/Userland/Services/Taskbar/TaskbarButton.h b/Userland/Services/Taskbar/TaskbarButton.h index 1947a92bd8..e766803dc8 100644 --- a/Userland/Services/Taskbar/TaskbarButton.h +++ b/Userland/Services/Taskbar/TaskbarButton.h @@ -18,7 +18,7 @@ public: void clear_taskbar_rect(); private: - explicit TaskbarButton(const WindowIdentifier&); + explicit TaskbarButton(WindowIdentifier const&); virtual void context_menu_event(GUI::ContextMenuEvent&) override; virtual void resize_event(GUI::ResizeEvent&) override; diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index dbae8ac3c8..e3cf43dcf8 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -104,9 +104,9 @@ void TaskbarWindow::show_desktop_button_clicked(unsigned) GUI::ConnectionToWindowMangerServer::the().async_toggle_show_desktop(); } -void TaskbarWindow::on_screen_rects_change(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index) +void TaskbarWindow::on_screen_rects_change(Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index) { - const auto& rect = rects[main_screen_index]; + auto const& rect = rects[main_screen_index]; Gfx::IntRect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() }; set_rect(new_rect); update_applet_area(); @@ -123,7 +123,7 @@ void TaskbarWindow::update_applet_area() GUI::ConnectionToWindowMangerServer::the().async_set_applet_area_position(new_rect.location()); } -NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier) +NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(WindowIdentifier const& identifier) { auto& button = m_task_button_container->add<TaskbarButton>(identifier); button.set_min_size(20, 21); @@ -133,7 +133,7 @@ NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& return button; } -void TaskbarWindow::add_window_button(::Window& window, const WindowIdentifier& identifier) +void TaskbarWindow::add_window_button(::Window& window, WindowIdentifier const& identifier) { if (window.button()) return; @@ -200,7 +200,7 @@ void TaskbarWindow::event(Core::Event& event) // we adjust it so that the nearest button ends up being clicked anyways. auto& mouse_event = static_cast<GUI::MouseEvent&>(event); - const int ADJUSTMENT = 4; + int const ADJUSTMENT = 4; auto adjusted_x = AK::clamp(mouse_event.x(), ADJUSTMENT, width() - ADJUSTMENT); auto adjusted_y = AK::min(mouse_event.y(), height() - ADJUSTMENT); Gfx::IntPoint adjusted_point = { adjusted_x, adjusted_y }; diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h index 813a0c61e4..bfc0ceb6fa 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.h +++ b/Userland/Services/Taskbar/TaskbarWindow.h @@ -27,9 +27,9 @@ private: explicit TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu); static void show_desktop_button_clicked(unsigned); void set_quick_launch_button_data(GUI::Button&, String const&, NonnullRefPtr<Desktop::AppFile>); - void on_screen_rects_change(const Vector<Gfx::IntRect, 4>&, size_t); - NonnullRefPtr<GUI::Button> create_button(const WindowIdentifier&); - void add_window_button(::Window&, const WindowIdentifier&); + void on_screen_rects_change(Vector<Gfx::IntRect, 4> const&, size_t); + NonnullRefPtr<GUI::Button> create_button(WindowIdentifier const&); + void add_window_button(::Window&, WindowIdentifier const&); void remove_window_button(::Window&, bool); void update_window_button(::Window&, bool); ::Window* find_window_owner(::Window&) const; diff --git a/Userland/Services/Taskbar/WindowIdentifier.h b/Userland/Services/Taskbar/WindowIdentifier.h index 5313421419..98a5212240 100644 --- a/Userland/Services/Taskbar/WindowIdentifier.h +++ b/Userland/Services/Taskbar/WindowIdentifier.h @@ -20,7 +20,7 @@ public: int client_id() const { return m_client_id; } int window_id() const { return m_window_id; } - bool operator==(const WindowIdentifier& other) const + bool operator==(WindowIdentifier const& other) const { return m_client_id == other.m_client_id && m_window_id == other.m_window_id; } @@ -38,6 +38,6 @@ private: namespace AK { template<> struct Traits<WindowIdentifier> : public GenericTraits<WindowIdentifier> { - static unsigned hash(const WindowIdentifier& w) { return pair_int_hash(w.client_id(), w.window_id()); } + static unsigned hash(WindowIdentifier const& w) { return pair_int_hash(w.client_id(), w.window_id()); } }; } diff --git a/Userland/Services/Taskbar/WindowList.cpp b/Userland/Services/Taskbar/WindowList.cpp index 0af99bf5b0..e033aa9090 100644 --- a/Userland/Services/Taskbar/WindowList.cpp +++ b/Userland/Services/Taskbar/WindowList.cpp @@ -12,7 +12,7 @@ WindowList& WindowList::the() return s_the; } -Window* WindowList::find_parent(const Window& window) +Window* WindowList::find_parent(Window const& window) { if (!window.parent_identifier().is_valid()) return nullptr; @@ -24,7 +24,7 @@ Window* WindowList::find_parent(const Window& window) return nullptr; } -Window* WindowList::window(const WindowIdentifier& identifier) +Window* WindowList::window(WindowIdentifier const& identifier) { auto it = m_windows.find(identifier); if (it != m_windows.end()) @@ -32,7 +32,7 @@ Window* WindowList::window(const WindowIdentifier& identifier) return nullptr; } -Window& WindowList::ensure_window(const WindowIdentifier& identifier) +Window& WindowList::ensure_window(WindowIdentifier const& identifier) { auto it = m_windows.find(identifier); if (it != m_windows.end()) @@ -43,7 +43,7 @@ Window& WindowList::ensure_window(const WindowIdentifier& identifier) return window_ref; } -void WindowList::remove_window(const WindowIdentifier& identifier) +void WindowList::remove_window(WindowIdentifier const& identifier) { m_windows.remove(identifier); } diff --git a/Userland/Services/Taskbar/WindowList.h b/Userland/Services/Taskbar/WindowList.h index a297db1939..62065ca752 100644 --- a/Userland/Services/Taskbar/WindowList.h +++ b/Userland/Services/Taskbar/WindowList.h @@ -14,7 +14,7 @@ class Window { public: - explicit Window(const WindowIdentifier& identifier) + explicit Window(WindowIdentifier const& identifier) : m_identifier(identifier) { } @@ -25,16 +25,16 @@ public: m_button->remove_from_parent(); } - const WindowIdentifier& identifier() const { return m_identifier; } + WindowIdentifier const& identifier() const { return m_identifier; } - void set_parent_identifier(const WindowIdentifier& parent_identifier) { m_parent_identifier = parent_identifier; } - const WindowIdentifier& parent_identifier() const { return m_parent_identifier; } + void set_parent_identifier(WindowIdentifier const& parent_identifier) { m_parent_identifier = parent_identifier; } + WindowIdentifier const& parent_identifier() const { return m_parent_identifier; } String title() const { return m_title; } - void set_title(const String& title) { m_title = title; } + void set_title(String const& title) { m_title = title; } Gfx::IntRect rect() const { return m_rect; } - void set_rect(const Gfx::IntRect& rect) { m_rect = rect; } + void set_rect(Gfx::IntRect const& rect) { m_rect = rect; } GUI::Button* button() { return m_button; } void set_button(GUI::Button* button) { m_button = button; } @@ -67,7 +67,7 @@ public: Optional<int> progress() const { return m_progress; } - const Gfx::Bitmap* icon() const { return m_icon.ptr(); } + Gfx::Bitmap const* icon() const { return m_icon.ptr(); } private: WindowIdentifier m_identifier; @@ -95,10 +95,10 @@ public: callback(*it.value); } - Window* find_parent(const Window&); - Window* window(const WindowIdentifier&); - Window& ensure_window(const WindowIdentifier&); - void remove_window(const WindowIdentifier&); + Window* find_parent(Window const&); + Window* window(WindowIdentifier const&); + Window& ensure_window(WindowIdentifier const&); + void remove_window(WindowIdentifier const&); private: HashMap<WindowIdentifier, NonnullOwnPtr<Window>> m_windows; diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp index aa62e6b38f..29b3eb5453 100644 --- a/Userland/Services/Taskbar/main.cpp +++ b/Userland/Services/Taskbar/main.cpp @@ -156,14 +156,14 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu() app_category_menus.set(category, category_menu); }; - for (const auto& category : sorted_app_categories) { + for (auto const& category : sorted_app_categories) { if (category != "Settings"sv) create_category_menu(category); } // Then we create and insert all the app menu items into the right place. int app_identifier = 0; - for (const auto& app : g_apps) { + for (auto const& app : g_apps) { if (app.category == "Settings"sv) { ++app_identifier; continue; diff --git a/Userland/Services/TelnetServer/Client.cpp b/Userland/Services/TelnetServer/Client.cpp index aab4b4f7d0..d45800975c 100644 --- a/Userland/Services/TelnetServer/Client.cpp +++ b/Userland/Services/TelnetServer/Client.cpp @@ -39,7 +39,7 @@ Client::Client(int id, NonnullOwnPtr<Core::Stream::TCPSocket> socket, int ptm_fd } }; - m_parser.on_command = [this](const Command& command) { + m_parser.on_command = [this](Command const& command) { auto result = handle_command(command); if (result.is_error()) { dbgln("Failed to handle the command: {}", result.error()); @@ -110,7 +110,7 @@ void Client::handle_data(StringView data) write(m_ptm_fd, data.characters_without_null_termination(), data.length()); } -ErrorOr<void> Client::handle_command(const Command& command) +ErrorOr<void> Client::handle_command(Command const& command) { switch (command.command) { case CMD_DO: diff --git a/Userland/Services/TelnetServer/Parser.h b/Userland/Services/TelnetServer/Parser.h index fdc416b336..de0990aed1 100644 --- a/Userland/Services/TelnetServer/Parser.h +++ b/Userland/Services/TelnetServer/Parser.h @@ -17,7 +17,7 @@ class Parser { public: - Function<void(const Command&)> on_command; + Function<void(Command const&)> on_command; Function<void(StringView)> on_data; Function<void()> on_error; @@ -31,7 +31,7 @@ protected: Error, }; - void write(const String& str); + void write(String const& str); private: State m_state { State::Free }; diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 6bd2887e70..a2c5891cae 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -51,12 +51,12 @@ Web::Page& ConnectionFromClient::page() return m_page_host->page(); } -const Web::Page& ConnectionFromClient::page() const +Web::Page const& ConnectionFromClient::page() const { return m_page_host->page(); } -void ConnectionFromClient::update_system_theme(const Core::AnonymousBuffer& theme_buffer) +void ConnectionFromClient::update_system_theme(Core::AnonymousBuffer const& theme_buffer) { Gfx::set_system_theme(theme_buffer); auto impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme_buffer); @@ -69,7 +69,7 @@ void ConnectionFromClient::update_system_fonts(String const& default_font_query, Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query); } -void ConnectionFromClient::update_screen_rects(const Vector<Gfx::IntRect>& rects, u32 main_screen) +void ConnectionFromClient::update_screen_rects(Vector<Gfx::IntRect> const& rects, u32 main_screen) { m_page_host->set_screen_rects(rects, main_screen); } @@ -89,19 +89,19 @@ void ConnectionFromClient::load_url(const URL& url) page().load(url); } -void ConnectionFromClient::load_html(const String& html, const URL& url) +void ConnectionFromClient::load_html(String const& html, const URL& url) { dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadHTML: html={}, url={}", html, url); page().load_html(html, url); } -void ConnectionFromClient::set_viewport_rect(const Gfx::IntRect& rect) +void ConnectionFromClient::set_viewport_rect(Gfx::IntRect const& rect) { dbgln_if(SPAM_DEBUG, "handle: WebContentServer::SetViewportRect: rect={}", rect); m_page_host->set_viewport_rect(rect); } -void ConnectionFromClient::add_backing_store(i32 backing_store_id, const Gfx::ShareableBitmap& bitmap) +void ConnectionFromClient::add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap const& bitmap) { m_backing_stores.set(backing_store_id, *bitmap.bitmap()); } @@ -111,7 +111,7 @@ void ConnectionFromClient::remove_backing_store(i32 backing_store_id) m_backing_stores.remove(backing_store_id); } -void ConnectionFromClient::paint(const Gfx::IntRect& content_rect, i32 backing_store_id) +void ConnectionFromClient::paint(Gfx::IntRect const& content_rect, i32 backing_store_id) { for (auto& pending_paint : m_pending_paint_requests) { if (pending_paint.bitmap_id == backing_store_id) { @@ -140,22 +140,22 @@ void ConnectionFromClient::flush_pending_paint_requests() m_pending_paint_requests.clear(); } -void ConnectionFromClient::mouse_down(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers) +void ConnectionFromClient::mouse_down(Gfx::IntPoint const& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers) { page().handle_mousedown(position, button, modifiers); } -void ConnectionFromClient::mouse_move(const Gfx::IntPoint& position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers) +void ConnectionFromClient::mouse_move(Gfx::IntPoint const& position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers) { page().handle_mousemove(position, buttons, modifiers); } -void ConnectionFromClient::mouse_up(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers) +void ConnectionFromClient::mouse_up(Gfx::IntPoint const& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers) { page().handle_mouseup(position, button, modifiers); } -void ConnectionFromClient::mouse_wheel(const Gfx::IntPoint& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y) +void ConnectionFromClient::mouse_wheel(Gfx::IntPoint const& position, unsigned int button, [[maybe_unused]] unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y) { page().handle_mousewheel(position, button, modifiers, wheel_delta_x, wheel_delta_y); } @@ -170,7 +170,7 @@ void ConnectionFromClient::key_up(i32 key, unsigned int modifiers, u32 code_poin page().handle_keyup((KeyCode)key, modifiers, code_point); } -void ConnectionFromClient::debug_request(const String& request, const String& argument) +void ConnectionFromClient::debug_request(String const& request, String const& argument) { if (request == "dump-dom-tree") { if (auto* doc = page().top_level_browsing_context().active_document()) @@ -384,7 +384,7 @@ void ConnectionFromClient::initialize_js_console(Badge<PageHost>) interpreter->global_object().console().set_client(*m_console_client.ptr()); } -void ConnectionFromClient::js_console_input(const String& js_source) +void ConnectionFromClient::js_console_input(String const& js_source) { if (m_console_client) m_console_client->handle_input(js_source); diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index f0a4a3f34b..00063a939b 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -35,7 +35,7 @@ private: explicit ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>); Web::Page& page(); - const Web::Page& page() const; + Web::Page const& page() const; virtual void update_system_theme(Core::AnonymousBuffer const&) override; virtual void update_system_fonts(String const&, String const&) override; diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index de45226257..e7cd81d63b 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -50,7 +50,7 @@ Gfx::Palette PageHost::palette() const return Gfx::Palette(*m_palette_impl); } -void PageHost::set_palette_impl(const Gfx::PaletteImpl& impl) +void PageHost::set_palette_impl(Gfx::PaletteImpl const& impl) { m_palette_impl = impl; } @@ -75,7 +75,7 @@ Web::Layout::InitialContainingBlock* PageHost::layout_root() return document->layout_node(); } -void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target) +void PageHost::paint(Gfx::IntRect const& content_rect, Gfx::Bitmap& target) { Gfx::Painter painter(target); Gfx::IntRect bitmap_rect { {}, content_rect.size() }; @@ -96,7 +96,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target) layout_root->paint_all_phases(context); } -void PageHost::set_viewport_rect(const Gfx::IntRect& rect) +void PageHost::set_viewport_rect(Gfx::IntRect const& rect) { page().top_level_browsing_context().set_viewport_rect(rect); } @@ -130,7 +130,7 @@ void PageHost::page_did_layout() m_client.async_did_layout(content_size); } -void PageHost::page_did_change_title(const String& title) +void PageHost::page_did_change_title(String const& title) { m_client.async_did_change_title(title); } @@ -145,12 +145,12 @@ void PageHost::page_did_request_scroll_to(Gfx::IntPoint const& scroll_position) m_client.async_did_request_scroll_to(scroll_position); } -void PageHost::page_did_request_scroll_into_view(const Gfx::IntRect& rect) +void PageHost::page_did_request_scroll_into_view(Gfx::IntRect const& rect) { m_client.async_did_request_scroll_into_view(rect); } -void PageHost::page_did_enter_tooltip_area(const Gfx::IntPoint& content_position, const String& title) +void PageHost::page_did_enter_tooltip_area(Gfx::IntPoint const& content_position, String const& title) { m_client.async_did_enter_tooltip_area(content_position, title); } @@ -170,12 +170,12 @@ void PageHost::page_did_unhover_link() m_client.async_did_unhover_link(); } -void PageHost::page_did_click_link(const URL& url, const String& target, unsigned modifiers) +void PageHost::page_did_click_link(const URL& url, String const& target, unsigned modifiers) { m_client.async_did_click_link(url, target, modifiers); } -void PageHost::page_did_middle_click_link(const URL& url, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) +void PageHost::page_did_middle_click_link(const URL& url, [[maybe_unused]] String const& target, [[maybe_unused]] unsigned modifiers) { m_client.async_did_middle_click_link(url, target, modifiers); } @@ -193,17 +193,17 @@ void PageHost::page_did_finish_loading(const URL& url) m_client.async_did_finish_loading(url); } -void PageHost::page_did_request_context_menu(const Gfx::IntPoint& content_position) +void PageHost::page_did_request_context_menu(Gfx::IntPoint const& content_position) { m_client.async_did_request_context_menu(content_position); } -void PageHost::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const URL& url, const String& target, unsigned modifiers) +void PageHost::page_did_request_link_context_menu(Gfx::IntPoint const& content_position, const URL& url, String const& target, unsigned modifiers) { m_client.async_did_request_link_context_menu(content_position, url, target, modifiers); } -void PageHost::page_did_request_alert(const String& message) +void PageHost::page_did_request_alert(String const& message) { auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestAlert>(message); if (!response) { @@ -212,7 +212,7 @@ void PageHost::page_did_request_alert(const String& message) } } -bool PageHost::page_did_request_confirm(const String& message) +bool PageHost::page_did_request_confirm(String const& message) { auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestConfirm>(message); if (!response) { @@ -222,7 +222,7 @@ bool PageHost::page_did_request_confirm(const String& message) return response->take_result(); } -String PageHost::page_did_request_prompt(const String& message, const String& default_) +String PageHost::page_did_request_prompt(String const& message, String const& default_) { auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestPrompt>(message, default_); if (!response) { @@ -232,12 +232,12 @@ String PageHost::page_did_request_prompt(const String& message, const String& de return response->take_response(); } -void PageHost::page_did_change_favicon(const Gfx::Bitmap& favicon) +void PageHost::page_did_change_favicon(Gfx::Bitmap const& favicon) { m_client.async_did_change_favicon(favicon.to_shareable_bitmap()); } -void PageHost::page_did_request_image_context_menu(const Gfx::IntPoint& content_position, const URL& url, const String& target, unsigned modifiers, const Gfx::Bitmap* bitmap_pointer) +void PageHost::page_did_request_image_context_menu(Gfx::IntPoint const& content_position, const URL& url, String const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer) { auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap(); m_client.async_did_request_image_context_menu(content_position, url, target, modifiers, bitmap); @@ -253,7 +253,7 @@ String PageHost::page_did_request_cookie(const URL& url, Web::Cookie::Source sou return response->take_cookie(); } -void PageHost::page_did_set_cookie(const URL& url, const Web::Cookie::ParsedCookie& cookie, Web::Cookie::Source source) +void PageHost::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) { m_client.async_did_set_cookie(url, cookie, static_cast<u8>(source)); } diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index 6ccc38d04c..a9815f2fec 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -22,13 +22,13 @@ public: virtual ~PageHost() = default; Web::Page& page() { return *m_page; } - const Web::Page& page() const { return *m_page; } + Web::Page const& page() const { return *m_page; } - void paint(const Gfx::IntRect& content_rect, Gfx::Bitmap&); + void paint(Gfx::IntRect const& content_rect, Gfx::Bitmap&); - void set_palette_impl(const Gfx::PaletteImpl&); - void set_viewport_rect(const Gfx::IntRect&); - void set_screen_rects(const Vector<Gfx::IntRect, 4>& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index]; }; + void set_palette_impl(Gfx::PaletteImpl const&); + void set_viewport_rect(Gfx::IntRect const&); + void set_screen_rects(Vector<Gfx::IntRect, 4> const& rects, size_t main_screen_index) { m_screen_rect = rects[main_screen_index]; }; void set_preferred_color_scheme(Web::CSS::PreferredColorScheme); void set_should_show_line_box_borders(bool b) { m_should_show_line_box_borders = b; } @@ -40,31 +40,31 @@ private: virtual Gfx::Palette palette() const override; virtual Gfx::IntRect screen_rect() const override { return m_screen_rect; } virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override { return m_preferred_color_scheme; } - virtual void page_did_invalidate(const Gfx::IntRect&) override; + virtual void page_did_invalidate(Gfx::IntRect const&) override; virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(Gfx::StandardCursor) override; virtual void page_did_layout() override; - virtual void page_did_change_title(const String&) override; + virtual void page_did_change_title(String const&) override; virtual void page_did_request_scroll(i32, i32) override; virtual void page_did_request_scroll_to(Gfx::IntPoint const&) override; - virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override; - virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override; + virtual void page_did_request_scroll_into_view(Gfx::IntRect const&) override; + virtual void page_did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override; virtual void page_did_leave_tooltip_area() override; virtual void page_did_hover_link(const URL&) override; virtual void page_did_unhover_link() override; - virtual void page_did_click_link(const URL&, const String& target, unsigned modifiers) override; - virtual void page_did_middle_click_link(const URL&, const String& target, unsigned modifiers) override; - virtual void page_did_request_context_menu(const Gfx::IntPoint&) override; - virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override; + virtual void page_did_click_link(const URL&, String const& target, unsigned modifiers) override; + virtual void page_did_middle_click_link(const URL&, String const& target, unsigned modifiers) override; + virtual void page_did_request_context_menu(Gfx::IntPoint const&) override; + virtual void page_did_request_link_context_menu(Gfx::IntPoint const&, const URL&, String const& target, unsigned modifiers) override; virtual void page_did_start_loading(const URL&) override; virtual void page_did_finish_loading(const URL&) override; - virtual void page_did_request_alert(const String&) override; - virtual bool page_did_request_confirm(const String&) override; - virtual String page_did_request_prompt(const String&, const String&) override; - virtual void page_did_change_favicon(const Gfx::Bitmap&) override; - virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers, const Gfx::Bitmap*) override; + virtual void page_did_request_alert(String const&) override; + virtual bool page_did_request_confirm(String const&) override; + virtual String page_did_request_prompt(String const&, String const&) override; + virtual void page_did_change_favicon(Gfx::Bitmap const&) override; + virtual void page_did_request_image_context_menu(Gfx::IntPoint const&, const URL&, String const& target, unsigned modifiers, Gfx::Bitmap const*) override; virtual String page_did_request_cookie(const URL&, Web::Cookie::Source) override; - virtual void page_did_set_cookie(const URL&, const Web::Cookie::ParsedCookie&, Web::Cookie::Source) override; + virtual void page_did_set_cookie(const URL&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override; virtual void page_did_update_resource_count(i32) override; explicit PageHost(ConnectionFromClient&); diff --git a/Userland/Services/WindowServer/AppletManager.cpp b/Userland/Services/WindowServer/AppletManager.cpp index c4a6c74e56..b3dc601af1 100644 --- a/Userland/Services/WindowServer/AppletManager.cpp +++ b/Userland/Services/WindowServer/AppletManager.cpp @@ -31,7 +31,7 @@ AppletManager& AppletManager::the() return *s_the; } -void AppletManager::set_position(const Gfx::IntPoint& position) +void AppletManager::set_position(Gfx::IntPoint const& position) { m_window->move_to(position); m_window->set_visible(true); @@ -169,7 +169,7 @@ void AppletManager::draw() } } -void AppletManager::draw_applet(const Window& applet) +void AppletManager::draw_applet(Window const& applet) { if (!applet.backing_store()) return; @@ -181,7 +181,7 @@ void AppletManager::draw_applet(const Window& applet) painter.blit(applet.rect_in_applet_area().location(), *applet.backing_store(), applet.backing_store()->rect()); } -void AppletManager::invalidate_applet(const Window& applet, const Gfx::IntRect&) +void AppletManager::invalidate_applet(Window const& applet, Gfx::IntRect const&) { draw_applet(applet); draw(); diff --git a/Userland/Services/WindowServer/AppletManager.h b/Userland/Services/WindowServer/AppletManager.h index 3fabbd4506..6bdfb6eadd 100644 --- a/Userland/Services/WindowServer/AppletManager.h +++ b/Userland/Services/WindowServer/AppletManager.h @@ -23,13 +23,13 @@ public: void add_applet(Window& applet); void remove_applet(Window& applet); void draw(); - void invalidate_applet(const Window& applet, const Gfx::IntRect& rect); + void invalidate_applet(Window const& applet, Gfx::IntRect const& rect); void relayout(); - void set_position(const Gfx::IntPoint&); + void set_position(Gfx::IntPoint const&); Window* window() { return m_window; } - const Window* window() const { return m_window; } + Window const* window() const { return m_window; } void did_change_theme(); @@ -37,7 +37,7 @@ private: AppletManager(); void repaint(); - void draw_applet(const Window& applet); + void draw_applet(Window const& applet); void set_hovered_applet(Window*); Vector<WeakPtr<Window>> m_applets; diff --git a/Userland/Services/WindowServer/Button.cpp b/Userland/Services/WindowServer/Button.cpp index 128d72aefc..ea05391042 100644 --- a/Userland/Services/WindowServer/Button.cpp +++ b/Userland/Services/WindowServer/Button.cpp @@ -38,7 +38,7 @@ void Button::paint(Screen& screen, Gfx::Painter& painter) } } -void Button::on_mouse_event(const MouseEvent& event) +void Button::on_mouse_event(MouseEvent const& event) { auto interesting_button = false; diff --git a/Userland/Services/WindowServer/Button.h b/Userland/Services/WindowServer/Button.h index 0b54211e6d..eed6bd290d 100644 --- a/Userland/Services/WindowServer/Button.h +++ b/Userland/Services/WindowServer/Button.h @@ -25,14 +25,14 @@ public: ~Button(); Gfx::IntRect relative_rect() const { return m_relative_rect; } - void set_relative_rect(const Gfx::IntRect& rect) { m_relative_rect = rect; } + void set_relative_rect(Gfx::IntRect const& rect) { m_relative_rect = rect; } Gfx::IntRect rect() const { return { {}, m_relative_rect.size() }; } Gfx::IntRect screen_rect() const; void paint(Screen&, Gfx::Painter&); - void on_mouse_event(const MouseEvent&); + void on_mouse_event(MouseEvent const&); Function<void(Button&)> on_click; Function<void(Button&)> on_secondary_click; @@ -40,7 +40,7 @@ public: bool is_visible() const { return m_visible; } - void set_icon(const RefPtr<MultiScaleBitmaps>& icon) { m_icon = icon; } + void set_icon(RefPtr<MultiScaleBitmaps> const& icon) { m_icon = icon; } private: WindowFrame& m_frame; diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 2ca7f3ef52..d8abc2dd07 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -30,7 +30,7 @@ Compositor& Compositor::the() return s_the; } -static WallpaperMode mode_to_enum(const String& name) +static WallpaperMode mode_to_enum(String const& name) { if (name == "tile") return WallpaperMode::Tile; @@ -66,14 +66,14 @@ Compositor::Compositor() init_bitmaps(); } -const Gfx::Bitmap* Compositor::cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const +Gfx::Bitmap const* Compositor::cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const { if (!m_current_cursor) return nullptr; return &m_current_cursor->bitmap(screen.scale_factor()); } -const Gfx::Bitmap& Compositor::front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const +Gfx::Bitmap const& Compositor::front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen& screen) const { return *screen.compositor_screen_data().m_front_bitmap; } @@ -255,7 +255,7 @@ void Compositor::compose() bool need_to_draw_cursor = false; Gfx::IntRect previous_cursor_rect; Screen* previous_cursor_screen = nullptr; - auto check_restore_cursor_back = [&](Screen& screen, const Gfx::IntRect& rect) { + auto check_restore_cursor_back = [&](Screen& screen, Gfx::IntRect const& rect) { if (&screen == &cursor_screen && !previous_cursor_screen && !need_to_draw_cursor && rect.intersects(cursor_rect)) { // Restore what's behind the cursor if anything touches the area of the cursor need_to_draw_cursor = true; @@ -274,7 +274,7 @@ void Compositor::compose() m_current_cursor_screen = &cursor_screen; } - auto prepare_rect = [&](Screen& screen, const Gfx::IntRect& rect) { + auto prepare_rect = [&](Screen& screen, Gfx::IntRect const& rect) { auto& screen_data = screen.compositor_screen_data(); dbgln_if(COMPOSE_DEBUG, " -> flush opaque: {}", rect); VERIFY(!screen_data.m_flush_rects.intersects(rect)); @@ -284,7 +284,7 @@ void Compositor::compose() check_restore_cursor_back(screen, rect); }; - auto prepare_transparency_rect = [&](Screen& screen, const Gfx::IntRect& rect) { + auto prepare_transparency_rect = [&](Screen& screen, Gfx::IntRect const& rect) { auto& screen_data = screen.compositor_screen_data(); dbgln_if(COMPOSE_DEBUG, " -> flush transparent: {}", rect); VERIFY(!screen_data.m_flush_rects.intersects(rect)); @@ -301,7 +301,7 @@ void Compositor::compose() if (!cursor_screen.compositor_screen_data().m_cursor_back_bitmap || m_invalidated_cursor) check_restore_cursor_back(cursor_screen, cursor_rect); - auto paint_wallpaper = [&](Screen& screen, Gfx::Painter& painter, const Gfx::IntRect& rect, const Gfx::IntRect& screen_rect) { + auto paint_wallpaper = [&](Screen& screen, Gfx::Painter& painter, Gfx::IntRect const& rect, Gfx::IntRect const& screen_rect) { // FIXME: If the wallpaper is opaque and covers the whole rect, no need to fill with color! painter.fill_rect(rect, background_color); if (m_wallpaper) { @@ -728,7 +728,7 @@ void Compositor::invalidate_screen() invalidate_screen(Screen::bounding_rect()); } -void Compositor::invalidate_screen(const Gfx::IntRect& screen_rect) +void Compositor::invalidate_screen(Gfx::IntRect const& screen_rect) { m_dirty_screen_rects.add(screen_rect.intersected(Screen::bounding_rect())); @@ -773,7 +773,7 @@ void Compositor::start_compose_async_timer() } } -bool Compositor::set_background_color(const String& background_color) +bool Compositor::set_background_color(String const& background_color) { auto color = Color::from_string(background_color); if (!color.has_value()) @@ -791,7 +791,7 @@ bool Compositor::set_background_color(const String& background_color) return succeeded; } -bool Compositor::set_wallpaper_mode(const String& mode) +bool Compositor::set_wallpaper_mode(String const& mode) { auto& wm = WindowManager::the(); wm.config()->write_entry("Background", "Mode", mode); @@ -856,7 +856,7 @@ void Compositor::invalidate_cursor(bool compose_immediately) start_compose_async_timer(); } -void Compositor::change_cursor(const Cursor* cursor) +void Compositor::change_cursor(Cursor const* cursor) { if (m_current_cursor == cursor) return; @@ -935,7 +935,7 @@ void Compositor::remove_overlay(Overlay& overlay) overlay_rects_changed(); } -void CompositorScreenData::draw_cursor(Screen& screen, const Gfx::IntRect& cursor_rect) +void CompositorScreenData::draw_cursor(Screen& screen, Gfx::IntRect const& cursor_rect) { auto& wm = WindowManager::the(); diff --git a/Userland/Services/WindowServer/Compositor.h b/Userland/Services/WindowServer/Compositor.h index 187e9ab272..8a9b238fd2 100644 --- a/Userland/Services/WindowServer/Compositor.h +++ b/Userland/Services/WindowServer/Compositor.h @@ -58,7 +58,7 @@ struct CompositorScreenData { void init_bitmaps(Compositor&, Screen&); void flip_buffers(Screen&); - void draw_cursor(Screen&, const Gfx::IntRect&); + void draw_cursor(Screen&, Gfx::IntRect const&); bool restore_cursor_back(Screen&, Gfx::IntRect&); template<typename F> @@ -96,22 +96,22 @@ public: void compose(); void invalidate_window(); void invalidate_screen(); - void invalidate_screen(const Gfx::IntRect&); + void invalidate_screen(Gfx::IntRect const&); void invalidate_screen(Gfx::DisjointRectSet const&); void screen_resolution_changed(); - bool set_background_color(const String& background_color); + bool set_background_color(String const& background_color); - bool set_wallpaper_mode(const String& mode); + bool set_wallpaper_mode(String const& mode); bool set_wallpaper(RefPtr<Gfx::Bitmap>); RefPtr<Gfx::Bitmap> wallpaper_bitmap() const { return m_wallpaper; } void invalidate_cursor(bool = false); Gfx::IntRect current_cursor_rect() const; - const Cursor* current_cursor() const { return m_current_cursor; } - void current_cursor_was_reloaded(const Cursor* new_cursor) { m_current_cursor = new_cursor; } + Cursor const* current_cursor() const { return m_current_cursor; } + void current_cursor_was_reloaded(Cursor const* new_cursor) { m_current_cursor = new_cursor; } void increment_display_link_count(Badge<ConnectionFromClient>); void decrement_display_link_count(Badge<ConnectionFromClient>); @@ -174,8 +174,8 @@ public: void did_construct_window_manager(Badge<WindowManager>); - const Gfx::Bitmap* cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const; - const Gfx::Bitmap& front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const; + Gfx::Bitmap const* cursor_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const; + Gfx::Bitmap const& front_bitmap_for_screenshot(Badge<ConnectionFromClient>, Screen&) const; Gfx::Color color_at_position(Badge<ConnectionFromClient>, Screen&, Gfx::IntPoint const&) const; void register_animation(Badge<Animation>, Animation&); @@ -202,7 +202,7 @@ private: void start_compose_async_timer(); void recompute_overlay_rects(); void recompute_occlusions(); - void change_cursor(const Cursor*); + void change_cursor(Cursor const*); void flush(Screen&); Gfx::IntPoint window_transition_offset(Window&); void update_animations(Screen&, Gfx::DisjointRectSet& flush_rects); @@ -230,7 +230,7 @@ private: WallpaperMode m_wallpaper_mode { WallpaperMode::Unchecked }; RefPtr<Gfx::Bitmap> m_wallpaper; - const Cursor* m_current_cursor { nullptr }; + Cursor const* m_current_cursor { nullptr }; Screen* m_current_cursor_screen { nullptr }; unsigned m_current_cursor_frame { 0 }; RefPtr<Core::Timer> m_cursor_timer; diff --git a/Userland/Services/WindowServer/ConnectionFromClient.h b/Userland/Services/WindowServer/ConnectionFromClient.h index ce9e587701..6b12169355 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.h +++ b/Userland/Services/WindowServer/ConnectionFromClient.h @@ -53,7 +53,7 @@ public: return nullptr; return menu.value(); } - const Menu* find_menu_by_id(int menu_id) const + Menu const* find_menu_by_id(int menu_id) const { auto menu = m_menus.get(menu_id); if (!menu.has_value()) diff --git a/Userland/Services/WindowServer/Cursor.h b/Userland/Services/WindowServer/Cursor.h index 8991432dce..83e769a5ba 100644 --- a/Userland/Services/WindowServer/Cursor.h +++ b/Userland/Services/WindowServer/Cursor.h @@ -20,8 +20,8 @@ public: static RefPtr<Cursor> create(Gfx::StandardCursor); ~Cursor() = default; - const Gfx::CursorParams& params() const { return m_params; } - const Gfx::Bitmap& bitmap(int scale_factor) const + Gfx::CursorParams const& params() const { return m_params; } + Gfx::Bitmap const& bitmap(int scale_factor) const { auto it = m_bitmaps.find(scale_factor); if (it == m_bitmaps.end()) { @@ -47,7 +47,7 @@ public: private: Cursor() = default; - Cursor(NonnullRefPtr<Gfx::Bitmap>&&, int, const Gfx::CursorParams&); + Cursor(NonnullRefPtr<Gfx::Bitmap>&&, int, Gfx::CursorParams const&); bool load(StringView, StringView); void update_rect_if_animated(); diff --git a/Userland/Services/WindowServer/Event.h b/Userland/Services/WindowServer/Event.h index d5a72f3643..6ab2bc59b4 100644 --- a/Userland/Services/WindowServer/Event.h +++ b/Userland/Services/WindowServer/Event.h @@ -88,7 +88,7 @@ private: class MouseEvent final : public Event { public: - MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x = 0, int wheel_delta_y = 0, int wheel_raw_delta_x = 0, int wheel_raw_delta_y = 0) + MouseEvent(Type type, Gfx::IntPoint const& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x = 0, int wheel_delta_y = 0, int wheel_raw_delta_x = 0, int wheel_raw_delta_y = 0) : Event(type) , m_position(position) , m_buttons(buttons) @@ -101,7 +101,7 @@ public: { } - const Gfx::IntPoint& position() const { return m_position; } + Gfx::IntPoint const& position() const { return m_position; } int x() const { return m_position.x(); } int y() const { return m_position.y(); } MouseButton button() const { return m_button; } @@ -121,7 +121,7 @@ public: } void set_drag(bool b) { m_drag = b; } - void set_mime_data(const Core::MimeData& mime_data) { m_mime_data = mime_data; } + void set_mime_data(Core::MimeData const& mime_data) { m_mime_data = mime_data; } MouseEvent translated(Gfx::IntPoint const& delta) const { @@ -145,13 +145,13 @@ private: class ResizeEvent final : public Event { public: - ResizeEvent(const Gfx::IntRect& rect) + ResizeEvent(Gfx::IntRect const& rect) : Event(Event::WindowResized) , m_rect(rect) { } - const Gfx::IntRect& rect() const { return m_rect; } + Gfx::IntRect const& rect() const { return m_rect; } private: Gfx::IntRect m_rect; diff --git a/Userland/Services/WindowServer/KeymapSwitcher.cpp b/Userland/Services/WindowServer/KeymapSwitcher.cpp index 2781dd7145..f329c15bfa 100644 --- a/Userland/Services/WindowServer/KeymapSwitcher.cpp +++ b/Userland/Services/WindowServer/KeymapSwitcher.cpp @@ -67,7 +67,7 @@ void KeymapSwitcher::next_keymap() dbgln("Current system keymap: {}", current_keymap_name); - auto it = m_keymaps.find_if([&](const auto& enumerator) { + auto it = m_keymaps.find_if([&](auto const& enumerator) { return enumerator == current_keymap_name; }); @@ -102,7 +102,7 @@ String KeymapSwitcher::get_current_keymap() const void KeymapSwitcher::setkeymap(const AK::String& keymap) { pid_t child_pid; - const char* argv[] = { "/bin/keymap", "-m", keymap.characters(), nullptr }; + char const* argv[] = { "/bin/keymap", "-m", keymap.characters(), nullptr }; if ((errno = posix_spawn(&child_pid, "/bin/keymap", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); dbgln("Failed to call /bin/keymap, error: {} ({})", errno, strerror(errno)); diff --git a/Userland/Services/WindowServer/KeymapSwitcher.h b/Userland/Services/WindowServer/KeymapSwitcher.h index bbae14c1a3..fde86465c9 100644 --- a/Userland/Services/WindowServer/KeymapSwitcher.h +++ b/Userland/Services/WindowServer/KeymapSwitcher.h @@ -38,7 +38,7 @@ private: RefPtr<Core::FileWatcher> m_file_watcher; - const char* m_keyboard_config = "/etc/Keyboard.ini"; + char const* m_keyboard_config = "/etc/Keyboard.ini"; }; } diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index 98e77aaa8e..9529baab06 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -47,7 +47,7 @@ Menu::Menu(ConnectionFromClient* client, int menu_id, String name) m_alt_shortcut_character = find_ampersand_shortcut_character(m_name); } -const Gfx::Font& Menu::font() const +Gfx::Font const& Menu::font() const { return Gfx::FontDatabase::default_font(); } @@ -332,7 +332,7 @@ void Menu::descend_into_submenu_at_hovered_item() VERIFY(submenu->hovered_item()->type() != MenuItem::Separator); } -void Menu::handle_mouse_move_event(const MouseEvent& mouse_event) +void Menu::handle_mouse_move_event(MouseEvent const& mouse_event) { VERIFY(menu_window()); MenuManager::the().set_current_menu(this); @@ -357,7 +357,7 @@ void Menu::handle_mouse_move_event(const MouseEvent& mouse_event) void Menu::event(Core::Event& event) { if (event.type() == Event::MouseMove) { - handle_mouse_move_event(static_cast<const MouseEvent&>(event)); + handle_mouse_move_event(static_cast<MouseEvent const&>(event)); return; } @@ -368,7 +368,7 @@ void Menu::event(Core::Event& event) if (event.type() == Event::MouseWheel && is_scrollable()) { VERIFY(menu_window()); - auto& mouse_event = static_cast<const MouseEvent&>(event); + auto& mouse_event = static_cast<MouseEvent const&>(event); auto previous_scroll_offset = m_scroll_offset; m_scroll_offset += mouse_event.wheel_delta_y(); m_scroll_offset = clamp(m_scroll_offset, 0, m_max_scroll_offset); @@ -402,7 +402,7 @@ void Menu::event(Core::Event& event) } else { // Default to the first enabled, non-separator item on key press if one has not been selected yet int counter = 0; - for (const auto& item : m_items) { + for (auto const& item : m_items) { if (item.type() != MenuItem::Separator && item.is_enabled()) { set_hovered_index(counter, key == Key_Right); break; @@ -567,7 +567,7 @@ bool Menu::remove_item_with_identifier(unsigned identifier) return m_items.remove_first_matching([&](auto& item) { return item->identifier() == identifier; }); } -int Menu::item_index_at(const Gfx::IntPoint& position) +int Menu::item_index_at(Gfx::IntPoint const& position) { int i = 0; for (auto& item : m_items) { @@ -589,12 +589,12 @@ void Menu::redraw_if_theme_changed() redraw(); } -void Menu::popup(const Gfx::IntPoint& position) +void Menu::popup(Gfx::IntPoint const& position) { do_popup(position, true); } -void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_submenu) +void Menu::do_popup(Gfx::IntPoint const& position, bool make_input, bool as_submenu) { if (is_empty()) { dbgln("Menu: Empty menu popup"); @@ -605,7 +605,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_subm auto& window = ensure_menu_window(position); redraw_if_theme_changed(); - const int margin = 30; + int const margin = 30; Gfx::IntPoint adjusted_pos = position; if (adjusted_pos.x() + window.width() > screen.rect().right() - margin) { @@ -624,7 +624,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_subm WindowManager::the().did_popup_a_menu({}); } -bool Menu::is_menu_ancestor_of(const Menu& other) const +bool Menu::is_menu_ancestor_of(Menu const& other) const { for (auto& item : m_items) { if (!item.is_submenu()) @@ -657,7 +657,7 @@ void Menu::add_item(NonnullOwnPtr<MenuItem> item) m_items.append(move(item)); } -const Vector<size_t>* Menu::items_with_alt_shortcut(u32 alt_shortcut) const +Vector<size_t> const* Menu::items_with_alt_shortcut(u32 alt_shortcut) const { auto it = m_alt_shortcut_character_to_item_indices.find(to_ascii_lowercase(alt_shortcut)); if (it == m_alt_shortcut_character_to_item_indices.end()) diff --git a/Userland/Services/WindowServer/Menu.h b/Userland/Services/WindowServer/Menu.h index 8b1b40abf6..4052bfee2e 100644 --- a/Userland/Services/WindowServer/Menu.h +++ b/Userland/Services/WindowServer/Menu.h @@ -31,7 +31,7 @@ public: virtual ~Menu() override = default; ConnectionFromClient* client() { return m_client; } - const ConnectionFromClient* client() const { return m_client; } + ConnectionFromClient const* client() const { return m_client; } int menu_id() const { return m_menu_id; } bool is_open() const; @@ -40,7 +40,7 @@ public: bool is_empty() const { return m_items.is_empty(); } size_t item_count() const { return m_items.size(); } - const MenuItem& item(size_t index) const { return m_items.at(index); } + MenuItem const& item(size_t index) const { return m_items.at(index); } MenuItem& item(size_t index) { return m_items.at(index); } MenuItem* item_by_identifier(unsigned identifier) @@ -72,7 +72,7 @@ public: } Gfx::IntRect rect_in_window_menubar() const { return m_rect_in_window_menubar; } - void set_rect_in_window_menubar(const Gfx::IntRect& rect) { m_rect_in_window_menubar = rect; } + void set_rect_in_window_menubar(Gfx::IntRect const& rect) { m_rect_in_window_menubar = rect; } Window* menu_window() { return m_menu_window.ptr(); } Window& ensure_menu_window(Gfx::IntPoint const&); @@ -94,7 +94,7 @@ public: void draw(); void draw(MenuItem const&, bool = false); - const Gfx::Font& font() const; + Gfx::Font const& font() const; MenuItem* item_with_identifier(unsigned); bool remove_item_with_identifier(unsigned); @@ -113,10 +113,10 @@ public: void set_visible(bool); - void popup(const Gfx::IntPoint&); - void do_popup(const Gfx::IntPoint&, bool make_input, bool as_submenu = false); + void popup(Gfx::IntPoint const&); + void do_popup(Gfx::IntPoint const&, bool make_input, bool as_submenu = false); - bool is_menu_ancestor_of(const Menu&) const; + bool is_menu_ancestor_of(Menu const&) const; void redraw_if_theme_changed(); @@ -126,18 +126,18 @@ public: void descend_into_submenu_at_hovered_item(); void open_hovered_item(bool leave_menu_open); - const Vector<size_t>* items_with_alt_shortcut(u32 alt_shortcut) const; + Vector<size_t> const* items_with_alt_shortcut(u32 alt_shortcut) const; private: Menu(ConnectionFromClient*, int menu_id, String name); virtual void event(Core::Event&) override; - void handle_mouse_move_event(const MouseEvent&); + void handle_mouse_move_event(MouseEvent const&); size_t visible_item_count() const; Gfx::IntRect stripe_rect(); - int item_index_at(const Gfx::IntPoint&); + int item_index_at(Gfx::IntPoint const&); static constexpr int padding_between_text_and_shortcut() { return 50; } void did_activate(MenuItem&, bool leave_menu_open); void update_for_new_hovered_item(bool make_input = false); diff --git a/Userland/Services/WindowServer/MenuItem.cpp b/Userland/Services/WindowServer/MenuItem.cpp index 707a365327..2d79f818b8 100644 --- a/Userland/Services/WindowServer/MenuItem.cpp +++ b/Userland/Services/WindowServer/MenuItem.cpp @@ -12,7 +12,7 @@ namespace WindowServer { -MenuItem::MenuItem(Menu& menu, unsigned identifier, const String& text, const String& shortcut_text, bool enabled, bool checkable, bool checked, const Gfx::Bitmap* icon) +MenuItem::MenuItem(Menu& menu, unsigned identifier, String const& text, String const& shortcut_text, bool enabled, bool checkable, bool checked, Gfx::Bitmap const* icon) : m_menu(menu) , m_type(Text) , m_enabled(enabled) @@ -62,7 +62,7 @@ Menu* MenuItem::submenu() return m_menu.client()->find_menu_by_id(m_submenu_id); } -const Menu* MenuItem::submenu() const +Menu const* MenuItem::submenu() const { VERIFY(is_submenu()); VERIFY(m_menu.client()); @@ -76,7 +76,7 @@ Gfx::IntRect MenuItem::rect() const return m_rect.translated(0, m_menu.item_height() - (m_menu.scroll_offset() * m_menu.item_height())); } -void MenuItem::set_icon(const Gfx::Bitmap* icon) +void MenuItem::set_icon(Gfx::Bitmap const* icon) { if (m_icon == icon) return; diff --git a/Userland/Services/WindowServer/MenuItem.h b/Userland/Services/WindowServer/MenuItem.h index cb9d640dff..f5d3d74b72 100644 --- a/Userland/Services/WindowServer/MenuItem.h +++ b/Userland/Services/WindowServer/MenuItem.h @@ -23,7 +23,7 @@ public: Separator, }; - MenuItem(Menu&, unsigned identifier, const String& text, const String& shortcut_text = {}, bool enabled = true, bool checkable = false, bool checked = false, const Gfx::Bitmap* icon = nullptr); + MenuItem(Menu&, unsigned identifier, String const& text, String const& shortcut_text = {}, bool enabled = true, bool checkable = false, bool checked = false, Gfx::Bitmap const* icon = nullptr); MenuItem(Menu&, Type); ~MenuItem() = default; @@ -47,20 +47,20 @@ public: String shortcut_text() const { return m_shortcut_text; } void set_shortcut_text(String text) { m_shortcut_text = move(text); } - void set_rect(const Gfx::IntRect& rect) { m_rect = rect; } + void set_rect(Gfx::IntRect const& rect) { m_rect = rect; } Gfx::IntRect rect() const; unsigned identifier() const { return m_identifier; } - const Gfx::Bitmap* icon() const { return m_icon; } - void set_icon(const Gfx::Bitmap*); + Gfx::Bitmap const* icon() const { return m_icon; } + void set_icon(Gfx::Bitmap const*); bool is_submenu() const { return m_submenu_id != -1; } int submenu_id() const { return m_submenu_id; } void set_submenu_id(int submenu_id) { m_submenu_id = submenu_id; } Menu* submenu(); - const Menu* submenu() const; + Menu const* submenu() const; bool is_exclusive() const { return m_exclusive; } void set_exclusive(bool exclusive) { m_exclusive = exclusive; } diff --git a/Userland/Services/WindowServer/MenuManager.cpp b/Userland/Services/WindowServer/MenuManager.cpp index e511befaf4..3a882c7b46 100644 --- a/Userland/Services/WindowServer/MenuManager.cpp +++ b/Userland/Services/WindowServer/MenuManager.cpp @@ -26,7 +26,7 @@ MenuManager::MenuManager() s_the = this; } -bool MenuManager::is_open(const Menu& menu) const +bool MenuManager::is_open(Menu const& menu) const { for (size_t i = 0; i < m_open_menu_stack.size(); ++i) { if (&menu == m_open_menu_stack[i].ptr()) @@ -55,7 +55,7 @@ void MenuManager::event(Core::Event& event) } if (static_cast<Event&>(event).is_key_event()) { - auto& key_event = static_cast<const KeyEvent&>(event); + auto& key_event = static_cast<KeyEvent const&>(event); if (key_event.type() == Event::KeyUp && key_event.key() == Key_Escape) { close_everyone(); @@ -85,7 +85,7 @@ void MenuManager::event(Core::Event& event) if (event.type() == Event::KeyDown) { if (key_event.key() == Key_Left) { - auto it = m_open_menu_stack.find_if([&](const auto& other) { return m_current_menu == other.ptr(); }); + auto it = m_open_menu_stack.find_if([&](auto const& other) { return m_current_menu == other.ptr(); }); VERIFY(!it.is_end()); // Going "back" a menu should be the previous menu in the stack diff --git a/Userland/Services/WindowServer/MenuManager.h b/Userland/Services/WindowServer/MenuManager.h index c5177073f7..90312238e5 100644 --- a/Userland/Services/WindowServer/MenuManager.h +++ b/Userland/Services/WindowServer/MenuManager.h @@ -22,7 +22,7 @@ public: virtual ~MenuManager() override = default; - bool is_open(const Menu&) const; + bool is_open(Menu const&) const; bool has_open_menu() const { return !m_open_menu_stack.is_empty(); } Menu* current_menu() { return m_current_menu.ptr(); } diff --git a/Userland/Services/WindowServer/MultiScaleBitmaps.cpp b/Userland/Services/WindowServer/MultiScaleBitmaps.cpp index 937f1bf028..c0d33509d7 100644 --- a/Userland/Services/WindowServer/MultiScaleBitmaps.cpp +++ b/Userland/Services/WindowServer/MultiScaleBitmaps.cpp @@ -9,7 +9,7 @@ namespace WindowServer { -const Gfx::Bitmap& MultiScaleBitmaps::bitmap(int scale_factor) const +Gfx::Bitmap const& MultiScaleBitmaps::bitmap(int scale_factor) const { auto it = m_bitmaps.find(scale_factor); if (it == m_bitmaps.end()) { diff --git a/Userland/Services/WindowServer/Overlays.h b/Userland/Services/WindowServer/Overlays.h index f94a870bd0..a0c171c2ac 100644 --- a/Userland/Services/WindowServer/Overlays.h +++ b/Userland/Services/WindowServer/Overlays.h @@ -184,10 +184,10 @@ public: private: Gfx::IntSize m_content_size; - const int m_rows; - const int m_columns; - const int m_target_row; - const int m_target_column; + int const m_rows; + int const m_columns; + int const m_target_row; + int const m_target_column; }; } diff --git a/Userland/Services/WindowServer/Screen.cpp b/Userland/Services/WindowServer/Screen.cpp index faa44d96c1..62d20ca56b 100644 --- a/Userland/Services/WindowServer/Screen.cpp +++ b/Userland/Services/WindowServer/Screen.cpp @@ -43,7 +43,7 @@ Screen& ScreenInput::cursor_location_screen() return *screen; } -const Screen& ScreenInput::cursor_location_screen() const +Screen const& ScreenInput::cursor_location_screen() const { auto* screen = Screen::find_by_location(m_cursor_location); VERIFY(screen); @@ -271,7 +271,7 @@ void Screen::scale_factor_changed() constrain_pending_flush_rects(); } -Screen& Screen::closest_to_rect(const Gfx::IntRect& rect) +Screen& Screen::closest_to_rect(Gfx::IntRect const& rect) { Screen* best_screen = nullptr; int best_area = 0; @@ -290,7 +290,7 @@ Screen& Screen::closest_to_rect(const Gfx::IntRect& rect) return *best_screen; } -Screen& Screen::closest_to_location(const Gfx::IntPoint& point) +Screen& Screen::closest_to_location(Gfx::IntPoint const& point) { for (auto& screen : s_screens) { if (screen.rect().contains(point)) @@ -421,7 +421,7 @@ void ScreenInput::set_scroll_step_size(unsigned step_size) m_scroll_step_size = step_size; } -void ScreenInput::on_receive_mouse_data(const MousePacket& packet) +void ScreenInput::on_receive_mouse_data(MousePacket const& packet) { auto& current_screen = cursor_location_screen(); auto prev_location = m_cursor_location; diff --git a/Userland/Services/WindowServer/Screen.h b/Userland/Services/WindowServer/Screen.h index f8e41caeb2..ddfa225142 100644 --- a/Userland/Services/WindowServer/Screen.h +++ b/Userland/Services/WindowServer/Screen.h @@ -35,7 +35,7 @@ public: static ScreenInput& the(); Screen& cursor_location_screen(); - const Screen& cursor_location_screen() const; + Screen const& cursor_location_screen() const; unsigned mouse_button_state() const { return m_mouse_button_state; } double acceleration_factor() const { return m_acceleration_factor; } @@ -44,7 +44,7 @@ public: unsigned scroll_step_size() const { return m_scroll_step_size; } void set_scroll_step_size(unsigned); - void on_receive_mouse_data(const MousePacket&); + void on_receive_mouse_data(MousePacket const&); void on_receive_keyboard_data(::KeyEvent); Gfx::IntPoint cursor_location() const { return m_cursor_location; } @@ -80,7 +80,7 @@ public: ~Screen(); static bool apply_layout(ScreenLayout&&, String&); - static const ScreenLayout& layout() { return s_layout; } + static ScreenLayout const& layout() { return s_layout; } static Screen& main() { @@ -88,8 +88,8 @@ public: return *s_main_screen; } - static Screen& closest_to_rect(const Gfx::IntRect&); - static Screen& closest_to_location(const Gfx::IntPoint&); + static Screen& closest_to_rect(Gfx::IntRect const&); + static Screen& closest_to_location(Gfx::IntPoint const&); static Screen* find_by_index(size_t index) { @@ -106,7 +106,7 @@ public: return rects; } - static Screen* find_by_location(const Gfx::IntPoint& point) + static Screen* find_by_location(Gfx::IntPoint const& point) { for (auto& screen : s_screens) { if (screen.rect().contains(point)) @@ -115,7 +115,7 @@ public: return nullptr; } - static const Gfx::IntRect& bounding_rect() { return s_bounding_screens_rect; } + static Gfx::IntRect const& bounding_rect() { return s_bounding_screens_rect; } static size_t count() { return s_screens.size(); } size_t index() const { return m_index; } diff --git a/Userland/Services/WindowServer/ScreenLayout.h b/Userland/Services/WindowServer/ScreenLayout.h index a1983b2842..4e4becc7bf 100644 --- a/Userland/Services/WindowServer/ScreenLayout.h +++ b/Userland/Services/WindowServer/ScreenLayout.h @@ -28,7 +28,7 @@ public: return { location, { resolution.width() / scale_factor, resolution.height() / scale_factor } }; } - bool operator==(const Screen&) const = default; + bool operator==(Screen const&) const = default; }; Vector<Screen> screens; @@ -36,13 +36,13 @@ public: bool is_valid(String* error_msg = nullptr) const; bool normalize(); - bool load_config(const Core::ConfigFile& config_file, String* error_msg = nullptr); + bool load_config(Core::ConfigFile const& config_file, String* error_msg = nullptr); bool save_config(Core::ConfigFile& config_file, bool sync = true) const; bool try_auto_add_framebuffer(String const&); // TODO: spaceship operator - bool operator!=(const ScreenLayout& other) const; - bool operator==(const ScreenLayout& other) const + bool operator!=(ScreenLayout const& other) const; + bool operator==(ScreenLayout const& other) const { return !(*this != other); } @@ -52,9 +52,9 @@ public: namespace IPC { -bool encode(Encoder&, const WindowServer::ScreenLayout::Screen&); +bool encode(Encoder&, WindowServer::ScreenLayout::Screen const&); ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout::Screen&); -bool encode(Encoder&, const WindowServer::ScreenLayout&); +bool encode(Encoder&, WindowServer::ScreenLayout const&); ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout&); } diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index 7317a37c0c..f372aff82c 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -137,7 +137,7 @@ void Window::destroy() set_visible(false); } -void Window::set_title(const String& title) +void Window::set_title(String const& title) { if (m_title == title) return; @@ -146,7 +146,7 @@ void Window::set_title(const String& title) WindowManager::the().notify_title_changed(*this); } -void Window::set_rect(const Gfx::IntRect& rect) +void Window::set_rect(Gfx::IntRect const& rect) { if (m_rect == rect) return; @@ -167,7 +167,7 @@ void Window::set_rect(const Gfx::IntRect& rect) invalidate_last_rendered_screen_rects(); } -void Window::set_rect_without_repaint(const Gfx::IntRect& rect) +void Window::set_rect_without_repaint(Gfx::IntRect const& rect) { VERIFY(!rect.is_empty()); if (m_rect == rect) @@ -246,7 +246,7 @@ void Window::nudge_into_desktop(Screen* target_screen, bool force_titlebar_visib set_rect(new_window_rect); } -void Window::set_minimum_size(const Gfx::IntSize& size) +void Window::set_minimum_size(Gfx::IntSize const& size) { if (size.is_null()) return; @@ -261,7 +261,7 @@ void Window::set_minimum_size(const Gfx::IntSize& size) m_minimum_size = size; } -void Window::handle_mouse_event(const MouseEvent& event) +void Window::handle_mouse_event(MouseEvent const& event) { set_automatic_cursor_tracking_enabled(event.buttons() != 0); @@ -357,7 +357,7 @@ void Window::set_closeable(bool closeable) update_window_menu_items(); } -void Window::set_taskbar_rect(const Gfx::IntRect& rect) +void Window::set_taskbar_rect(Gfx::IntRect const& rect) { m_taskbar_rect = rect; m_have_taskbar_rect = !m_taskbar_rect.is_empty(); @@ -536,7 +536,7 @@ void Window::event(Core::Event& event) } if (static_cast<Event&>(event).is_mouse_event()) - return handle_mouse_event(static_cast<const MouseEvent&>(event)); + return handle_mouse_event(static_cast<MouseEvent const&>(event)); switch (event.type()) { case Event::WindowEntered: @@ -546,14 +546,14 @@ void Window::event(Core::Event& event) m_client->async_window_left(m_window_id); break; case Event::KeyDown: - handle_keydown_event(static_cast<const KeyEvent&>(event)); + handle_keydown_event(static_cast<KeyEvent const&>(event)); break; case Event::KeyUp: m_client->async_key_up(m_window_id, - (u32) static_cast<const KeyEvent&>(event).code_point(), - (u32) static_cast<const KeyEvent&>(event).key(), - static_cast<const KeyEvent&>(event).modifiers(), - (u32) static_cast<const KeyEvent&>(event).scancode()); + (u32) static_cast<KeyEvent const&>(event).code_point(), + (u32) static_cast<KeyEvent const&>(event).key(), + static_cast<KeyEvent const&>(event).modifiers(), + (u32) static_cast<KeyEvent const&>(event).scancode()); break; case Event::WindowActivated: m_client->async_window_activated(m_window_id); @@ -571,14 +571,14 @@ void Window::event(Core::Event& event) m_client->async_window_close_request(m_window_id); break; case Event::WindowResized: - m_client->async_window_resized(m_window_id, static_cast<const ResizeEvent&>(event).rect()); + m_client->async_window_resized(m_window_id, static_cast<ResizeEvent const&>(event).rect()); break; default: break; } } -void Window::handle_keydown_event(const KeyEvent& event) +void Window::handle_keydown_event(KeyEvent const& event) { if (event.modifiers() == Mod_Alt && event.key() == Key_Space && type() == WindowType::Normal && !is_frameless()) { auto position = frame().titlebar_rect().bottom_left().translated(frame().rect().location()); @@ -661,7 +661,7 @@ void Window::invalidate(Gfx::IntRect const& rect, bool invalidate_frame) Compositor::the().invalidate_window(); } -bool Window::invalidate_no_notify(const Gfx::IntRect& rect, bool invalidate_frame) +bool Window::invalidate_no_notify(Gfx::IntRect const& rect, bool invalidate_frame) { if (rect.is_empty()) return false; @@ -764,7 +764,7 @@ void Window::set_default_icon() m_icon = default_window_icon(); } -void Window::request_update(const Gfx::IntRect& rect, bool ignore_occlusion) +void Window::request_update(Gfx::IntRect const& rect, bool ignore_occlusion) { if (rect.is_empty()) return; @@ -865,7 +865,7 @@ void Window::handle_window_menu_action(WindowMenuAction action) } } -void Window::popup_window_menu(const Gfx::IntPoint& position, WindowMenuDefaultAction default_action) +void Window::popup_window_menu(Gfx::IntPoint const& position, WindowMenuDefaultAction default_action) { ensure_window_menu(); if (default_action == WindowMenuDefaultAction::BasedOnWindowState) { diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h index a6a43a7c0f..79ec348edc 100644 --- a/Userland/Services/WindowServer/Window.h +++ b/Userland/Services/WindowServer/Window.h @@ -88,7 +88,7 @@ public: bool is_modified() const { return m_modified; } void set_modified(bool); - void popup_window_menu(const Gfx::IntPoint&, WindowMenuDefaultAction); + void popup_window_menu(Gfx::IntPoint const&, WindowMenuDefaultAction); void handle_window_menu_action(WindowMenuAction); void window_menu_activate_default(); void request_close(); @@ -139,12 +139,12 @@ public: } WindowFrame& frame() { return m_frame; } - const WindowFrame& frame() const { return m_frame; } + WindowFrame const& frame() const { return m_frame; } Window* blocking_modal_window(); ConnectionFromClient* client() { return m_client; } - const ConnectionFromClient* client() const { return m_client; } + ConnectionFromClient const* client() const { return m_client; } WindowType type() const { return m_type; } int window_id() const { return m_window_id; } @@ -153,7 +153,7 @@ public: i32 client_id() const { return m_client_id; } String title() const { return m_title; } - void set_title(const String&); + void set_title(String const&); String computed_title() const; @@ -170,7 +170,7 @@ public: m_alpha_hit_threshold = threshold; } - Optional<HitTestResult> hit_test(const Gfx::IntPoint&, bool include_frame = true); + Optional<HitTestResult> hit_test(Gfx::IntPoint const&, bool include_frame = true); int x() const { return m_rect.x(); } int y() const { return m_rect.y(); } @@ -186,34 +186,34 @@ public: bool is_modal_dont_unparent() const { return m_modal && m_parent_window; } Gfx::IntRect rect() const { return m_rect; } - void set_rect(const Gfx::IntRect&); + void set_rect(Gfx::IntRect const&); void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } - void set_rect_without_repaint(const Gfx::IntRect&); + void set_rect_without_repaint(Gfx::IntRect const&); bool apply_minimum_size(Gfx::IntRect&); void nudge_into_desktop(Screen*, bool force_titlebar_visible = true); Gfx::IntSize minimum_size() const { return m_minimum_size; } - void set_minimum_size(const Gfx::IntSize&); + void set_minimum_size(Gfx::IntSize const&); void set_minimum_size(int width, int height) { set_minimum_size({ width, height }); } - void set_taskbar_rect(const Gfx::IntRect&); - const Gfx::IntRect& taskbar_rect() const { return m_taskbar_rect; } + void set_taskbar_rect(Gfx::IntRect const&); + Gfx::IntRect const& taskbar_rect() const { return m_taskbar_rect; } - void move_to(const Gfx::IntPoint& position) { set_rect({ position, size() }); } + void move_to(Gfx::IntPoint const& position) { set_rect({ position, size() }); } void move_to(int x, int y) { move_to({ x, y }); } - void move_by(const Gfx::IntPoint& delta) { set_position_without_repaint(position().translated(delta)); } + void move_by(Gfx::IntPoint const& delta) { set_position_without_repaint(position().translated(delta)); } Gfx::IntPoint position() const { return m_rect.location(); } - void set_position(const Gfx::IntPoint& position) { set_rect({ position.x(), position.y(), width(), height() }); } - void set_position_without_repaint(const Gfx::IntPoint& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); } + void set_position(Gfx::IntPoint const& position) { set_rect({ position.x(), position.y(), width(), height() }); } + void set_position_without_repaint(Gfx::IntPoint const& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); } Gfx::IntSize size() const { return m_rect.size(); } void invalidate(bool with_frame = true, bool re_render_frame = false); void invalidate(Gfx::IntRect const&, bool invalidate_frame = false); void invalidate_menubar(); - bool invalidate_no_notify(const Gfx::IntRect& rect, bool invalidate_frame = false); + bool invalidate_no_notify(Gfx::IntRect const& rect, bool invalidate_frame = false); void invalidate_last_rendered_screen_rects(); void invalidate_last_rendered_screen_rects_now(); [[nodiscard]] bool should_invalidate_last_rendered_screen_rects() { return exchange(m_invalidate_last_render_rects, false); } @@ -225,10 +225,10 @@ public: Gfx::DisjointRectSet& dirty_rects() { return m_dirty_rects; } // Only used by WindowType::Applet. Perhaps it could be a Window subclass? I don't know. - void set_rect_in_applet_area(const Gfx::IntRect& rect) { m_rect_in_applet_area = rect; } - const Gfx::IntRect& rect_in_applet_area() const { return m_rect_in_applet_area; } + void set_rect_in_applet_area(Gfx::IntRect const& rect) { m_rect_in_applet_area = rect; } + Gfx::IntRect const& rect_in_applet_area() const { return m_rect_in_applet_area; } - const Gfx::Bitmap* backing_store() const { return m_backing_store.ptr(); } + Gfx::Bitmap const* backing_store() const { return m_backing_store.ptr(); } Gfx::Bitmap* backing_store() { return m_backing_store.ptr(); } void set_backing_store(RefPtr<Gfx::Bitmap> backing_store, i32 serial) @@ -257,10 +257,10 @@ public: void set_has_alpha_channel(bool value); Gfx::IntSize size_increment() const { return m_size_increment; } - void set_size_increment(const Gfx::IntSize& increment) { m_size_increment = increment; } + void set_size_increment(Gfx::IntSize const& increment) { m_size_increment = increment; } - const Optional<Gfx::IntSize>& resize_aspect_ratio() const { return m_resize_aspect_ratio; } - void set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio) + Optional<Gfx::IntSize> const& resize_aspect_ratio() const { return m_resize_aspect_ratio; } + void set_resize_aspect_ratio(Optional<Gfx::IntSize> const& ratio) { // "Tiled" means that we take up a chunk of space relative to the screen. // The screen can change, so "tiled" and "fixed aspect ratio" are mutually exclusive. @@ -272,19 +272,19 @@ public: } Gfx::IntSize base_size() const { return m_base_size; } - void set_base_size(const Gfx::IntSize& size) { m_base_size = size; } + void set_base_size(Gfx::IntSize const& size) { m_base_size = size; } - const Gfx::Bitmap& icon() const { return *m_icon; } + Gfx::Bitmap const& icon() const { return *m_icon; } void set_icon(NonnullRefPtr<Gfx::Bitmap>&& icon) { m_icon = move(icon); } void set_default_icon(); - const Cursor* cursor() const { return (m_cursor_override ? m_cursor_override : m_cursor).ptr(); } + Cursor const* cursor() const { return (m_cursor_override ? m_cursor_override : m_cursor).ptr(); } void set_cursor(RefPtr<Cursor> cursor) { m_cursor = move(cursor); } void set_cursor_override(RefPtr<Cursor> cursor) { m_cursor_override = move(cursor); } void remove_cursor_override() { m_cursor_override = nullptr; } - void request_update(const Gfx::IntRect&, bool ignore_occlusion = false); + void request_update(Gfx::IntRect const&, bool ignore_occlusion = false); Gfx::DisjointRectSet take_pending_paint_rects() { return move(m_pending_paint_rects); } bool has_taskbar_rect() const { return m_have_taskbar_rect; }; @@ -299,15 +299,15 @@ public: void detach_client(Badge<ConnectionFromClient>); Window* parent_window() { return m_parent_window; } - const Window* parent_window() const { return m_parent_window; } + Window const* parent_window() const { return m_parent_window; } void set_parent_window(Window&); Vector<WeakPtr<Window>>& child_windows() { return m_child_windows; } - const Vector<WeakPtr<Window>>& child_windows() const { return m_child_windows; } + Vector<WeakPtr<Window>> const& child_windows() const { return m_child_windows; } Vector<WeakPtr<Window>>& accessory_windows() { return m_accessory_windows; } - const Vector<WeakPtr<Window>>& accessory_windows() const { return m_accessory_windows; } + Vector<WeakPtr<Window>> const& accessory_windows() const { return m_accessory_windows; } bool is_descendant_of(Window&) const; @@ -364,7 +364,7 @@ public: bool is_on_any_window_stack(Badge<WindowStack>) const { return m_window_stack != nullptr; } void set_window_stack(Badge<WindowStack>, WindowStack* stack) { m_window_stack = stack; } - const Vector<Screen*, default_screen_count>& screens() const { return m_screens; } + Vector<Screen*, default_screen_count> const& screens() const { return m_screens; } Vector<Screen*, default_screen_count>& screens() { return m_screens; } void set_moving_to_another_stack(bool value) { m_moving_to_another_stack = value; } @@ -385,8 +385,8 @@ private: Window(Core::Object&, WindowType); virtual void event(Core::Event&) override; - void handle_mouse_event(const MouseEvent&); - void handle_keydown_event(const KeyEvent&); + void handle_mouse_event(MouseEvent const&); + void handle_keydown_event(KeyEvent const&); void add_child_window(Window&); void add_accessory_window(Window&); void ensure_window_menu(); diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 7c44578d27..8a66dc84c9 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -52,7 +52,7 @@ static String s_last_menu_shadow_path; static String s_last_taskbar_shadow_path; static String s_last_tooltip_shadow_path; -static Gfx::IntRect frame_rect_for_window(Window& window, const Gfx::IntRect& rect) +static Gfx::IntRect frame_rect_for_window(Window& window, Gfx::IntRect const& rect) { if (window.is_frameless()) return rect; @@ -148,7 +148,7 @@ void WindowFrame::reload_config() reload_icon(s_close_icon, "window-close.png", "/res/icons/16x16/window-close.png"); reload_icon(s_close_modified_icon, "window-close-modified.png", "/res/icons/16x16/window-close-modified.png"); - auto load_shadow = [](const String& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) { + auto load_shadow = [](String const& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) { if (path.is_empty()) { last_path = String::empty(); shadow_bitmap = nullptr; @@ -305,13 +305,13 @@ void WindowFrame::paint_normal_frame(Gfx::Painter& painter) paint_menubar(painter); } -void WindowFrame::paint(Screen& screen, Gfx::Painter& painter, const Gfx::IntRect& rect) +void WindowFrame::paint(Screen& screen, Gfx::Painter& painter, Gfx::IntRect const& rect) { if (auto* cached = render_to_cache(screen)) cached->paint(*this, painter, rect); } -void WindowFrame::PerScaleRenderedCache::paint(WindowFrame& frame, Gfx::Painter& painter, const Gfx::IntRect& rect) +void WindowFrame::PerScaleRenderedCache::paint(WindowFrame& frame, Gfx::Painter& painter, Gfx::IntRect const& rect) { auto frame_rect = frame.unconstrained_render_rect(); auto window_rect = frame.window().rect(); @@ -526,7 +526,7 @@ void WindowFrame::set_opacity(float opacity) WindowManager::the().notify_opacity_changed(m_window); } -Gfx::IntRect WindowFrame::inflated_for_shadow(const Gfx::IntRect& frame_rect) const +Gfx::IntRect WindowFrame::inflated_for_shadow(Gfx::IntRect const& frame_rect) const { if (auto* shadow = shadow_bitmap()) { auto total_shadow_size = shadow->default_bitmap().height(); @@ -540,7 +540,7 @@ Gfx::IntRect WindowFrame::rect() const return frame_rect_for_window(m_window, m_window.rect()); } -Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(const Gfx::IntRect& render_rect) const +Gfx::IntRect WindowFrame::constrained_render_rect_to_screen(Gfx::IntRect const& render_rect) const { if (m_window.is_tiled()) return render_rect.intersected(Screen::closest_to_rect(rect()).rect()); @@ -630,7 +630,7 @@ void WindowFrame::invalidate(Gfx::IntRect relative_rect) m_window.invalidate(relative_rect, true); } -void WindowFrame::window_rect_changed(const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect) +void WindowFrame::window_rect_changed(Gfx::IntRect const& old_rect, Gfx::IntRect const& new_rect) { layout_buttons(); @@ -810,7 +810,7 @@ void WindowFrame::handle_mouse_event(MouseEvent const& event) handle_border_mouse_event(event); } -void WindowFrame::handle_border_mouse_event(const MouseEvent& event) +void WindowFrame::handle_border_mouse_event(MouseEvent const& event) { if (!m_window.is_resizable()) return; @@ -838,7 +838,7 @@ void WindowFrame::handle_border_mouse_event(const MouseEvent& event) wm.start_window_resize(m_window, event.translated(rect().location())); } -void WindowFrame::handle_menubar_mouse_event(const MouseEvent& event) +void WindowFrame::handle_menubar_mouse_event(MouseEvent const& event) { Menu* hovered_menu = nullptr; auto menubar_rect = this->menubar_rect(); @@ -869,7 +869,7 @@ void WindowFrame::open_menubar_menu(Menu& menu) invalidate(menubar_rect); } -void WindowFrame::handle_menu_mouse_event(Menu& menu, const MouseEvent& event) +void WindowFrame::handle_menu_mouse_event(Menu& menu, MouseEvent const& event) { auto menubar_rect = this->menubar_rect(); bool is_hover_with_any_menu_open = event.type() == MouseEvent::MouseMove && &m_window == WindowManager::the().window_with_active_menu(); diff --git a/Userland/Services/WindowServer/WindowFrame.h b/Userland/Services/WindowServer/WindowFrame.h index 9e37b8b34f..30483af6cd 100644 --- a/Userland/Services/WindowServer/WindowFrame.h +++ b/Userland/Services/WindowServer/WindowFrame.h @@ -29,7 +29,7 @@ public: friend class WindowFrame; public: - void paint(WindowFrame&, Gfx::Painter&, const Gfx::IntRect&); + void paint(WindowFrame&, Gfx::Painter&, Gfx::IntRect const&); void render(WindowFrame&, Screen&); Optional<HitTestResult> hit_test(WindowFrame&, Gfx::IntPoint const&, Gfx::IntPoint const&); @@ -51,7 +51,7 @@ public: void window_was_constructed(Badge<Window>); Window& window() { return m_window; } - const Window& window() const { return m_window; } + Window const& window() const { return m_window; } Gfx::IntRect rect() const; Gfx::IntRect render_rect() const; @@ -59,7 +59,7 @@ public: Gfx::DisjointRectSet opaque_render_rects() const; Gfx::DisjointRectSet transparent_render_rects() const; - void paint(Screen&, Gfx::Painter&, const Gfx::IntRect&); + void paint(Screen&, Gfx::Painter&, Gfx::IntRect const&); void render(Screen&, Gfx::Painter&); PerScaleRenderedCache* render_to_cache(Screen&); @@ -68,7 +68,7 @@ public: bool handle_titlebar_icon_mouse_event(MouseEvent const&); void handle_border_mouse_event(MouseEvent const&); - void window_rect_changed(const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect); + void window_rect_changed(Gfx::IntRect const& old_rect, Gfx::IntRect const& new_rect); void invalidate_titlebar(); void invalidate_menubar(); void invalidate(Gfx::IntRect relative_rect); @@ -125,15 +125,15 @@ private: void paint_tool_window_frame(Gfx::Painter&); void paint_menubar(Gfx::Painter&); MultiScaleBitmaps const* shadow_bitmap() const; - Gfx::IntRect inflated_for_shadow(const Gfx::IntRect&) const; + Gfx::IntRect inflated_for_shadow(Gfx::IntRect const&) const; - void handle_menubar_mouse_event(const MouseEvent&); - void handle_menu_mouse_event(Menu&, const MouseEvent&); + void handle_menubar_mouse_event(MouseEvent const&); + void handle_menu_mouse_event(Menu&, MouseEvent const&); Gfx::WindowTheme::WindowState window_state_for_theme() const; String computed_title() const; - Gfx::IntRect constrained_render_rect_to_screen(const Gfx::IntRect&) const; + Gfx::IntRect constrained_render_rect_to_screen(Gfx::IntRect const&) const; Gfx::IntRect leftmost_titlebar_button_rect() const; Window& m_window; diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 31dc9d56d2..bf57e84207 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -774,8 +774,8 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event) dbgln(" [!] The window is still maximized. Not moving yet."); } - const int tiling_deadzone = 10; - const int secondary_deadzone = 2; + int const tiling_deadzone = 10; + int const secondary_deadzone = 2; auto& cursor_screen = Screen::closest_to_location(event.position()); auto desktop = desktop_rect(cursor_screen); auto desktop_relative_to_screen = desktop.translated(-cursor_screen.rect().location()); @@ -869,7 +869,7 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event) return false; if (event.type() == Event::MouseMove) { - const int vertical_maximize_deadzone = 5; + int const vertical_maximize_deadzone = 5; auto& cursor_screen = ScreenInput::the().cursor_location_screen(); if (&cursor_screen == &Screen::closest_to_rect(m_resize_window->rect())) { auto desktop_rect = this->desktop_rect(cursor_screen); @@ -2225,7 +2225,7 @@ void WindowManager::apply_cursor_theme(String const& theme_name) auto cursor_theme_config = cursor_theme_config_or_error.release_value(); auto* current_cursor = Compositor::the().current_cursor(); - auto reload_cursor = [&](RefPtr<Cursor>& cursor, const String& name) { + auto reload_cursor = [&](RefPtr<Cursor>& cursor, String const& name) { bool is_current_cursor = current_cursor && current_cursor == cursor.ptr(); static auto const s_default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"; diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index ece88429df..047d6f3866 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -28,8 +28,8 @@ namespace WindowServer { -const int double_click_speed_max = 900; -const int double_click_speed_min = 100; +int const double_click_speed_max = 900; +int const double_click_speed_min = 100; class Screen; class MouseEvent; diff --git a/Userland/Services/WindowServer/WindowSwitcher.cpp b/Userland/Services/WindowServer/WindowSwitcher.cpp index f359ffb998..0243366838 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.cpp +++ b/Userland/Services/WindowServer/WindowSwitcher.cpp @@ -85,7 +85,7 @@ void WindowSwitcher::event(Core::Event& event) event.accept(); } -void WindowSwitcher::on_key_event(const KeyEvent& event) +void WindowSwitcher::on_key_event(KeyEvent const& event) { if (event.type() == Event::KeyUp) { if (event.key() == (m_mode == Mode::ShowAllWindows ? Key_Super : Key_Alt)) { @@ -212,7 +212,7 @@ void WindowSwitcher::draw() void WindowSwitcher::refresh() { auto& wm = WindowManager::the(); - const Window* selected_window = nullptr; + Window const* selected_window = nullptr; if (m_selected_index > 0 && m_windows[m_selected_index]) selected_window = m_windows[m_selected_index].ptr(); if (!selected_window) diff --git a/Userland/Services/WindowServer/WindowSwitcher.h b/Userland/Services/WindowServer/WindowSwitcher.h index 40ee72af9f..52ae22f825 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.h +++ b/Userland/Services/WindowServer/WindowSwitcher.h @@ -38,7 +38,7 @@ public: } void hide() { set_visible(false); } - void on_key_event(const KeyEvent&); + void on_key_event(KeyEvent const&); void refresh(); void refresh_if_needed(); diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index f2e692533b..224b7a0973 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -49,7 +49,7 @@ ErrorOr<void> AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder, for (auto& redir : value.redirections) { TRY(builder.put_padding(' ', 1)); if (redir.is_path_redirection()) { - auto path_redir = (const Shell::AST::PathRedirection*)&redir; + auto path_redir = (Shell::AST::PathRedirection const*)&redir; TRY(builder.put_i64(path_redir->fd)); switch (path_redir->direction) { case Shell::AST::PathRedirection::Read: @@ -67,12 +67,12 @@ ErrorOr<void> AK::Formatter<Shell::AST::Command>::format(FormatBuilder& builder, } TRY(builder.put_literal(path_redir->path)); } else if (redir.is_fd_redirection()) { - auto* fdredir = (const Shell::AST::FdRedirection*)&redir; + auto* fdredir = (Shell::AST::FdRedirection const*)&redir; TRY(builder.put_i64(fdredir->new_fd)); TRY(builder.put_literal(">")); TRY(builder.put_i64(fdredir->old_fd)); } else if (redir.is_close_redirection()) { - auto close_redir = (const Shell::AST::CloseRedirection*)&redir; + auto close_redir = (Shell::AST::CloseRedirection const*)&redir; TRY(builder.put_i64(close_redir->fd)); TRY(builder.put_literal(">&-")); } else { @@ -111,7 +111,7 @@ static inline void print_indented(StringView str, int indent) dbgln("{}{}", String::repeated(' ', indent * 2), str); } -static inline Optional<Position> merge_positions(const Optional<Position>& left, const Optional<Position>& right) +static inline Optional<Position> merge_positions(Optional<Position> const& left, Optional<Position> const& right) { if (!left.has_value()) return right; @@ -260,7 +260,7 @@ void Node::clear_syntax_error() m_syntax_error_node->clear_syntax_error(); } -void Node::set_is_syntax_error(const SyntaxError& error_node) +void Node::set_is_syntax_error(SyntaxError const& error_node) { if (!m_syntax_error_node) { m_syntax_error_node = error_node; @@ -331,7 +331,7 @@ Node::Node(Position position) { } -Vector<Line::CompletionSuggestion> Node::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> Node::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (matching_node) { @@ -747,7 +747,7 @@ HitTestResult CastToCommand::hit_test_position(size_t offset) const return result; } -Vector<Line::CompletionSuggestion> CastToCommand::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> CastToCommand::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node || !matching_node->is_bareword()) @@ -1107,7 +1107,7 @@ HitTestResult FunctionDeclaration::hit_test_position(size_t offset) const return result; } -Vector<Line::CompletionSuggestion> FunctionDeclaration::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> FunctionDeclaration::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node) @@ -1438,7 +1438,7 @@ void HistoryEvent::dump(int level) const print_indented(String::formatted("{}({})", m_selector.event.index, m_selector.event.text), level + 3); print_indented("Word Selector", level + 1); - auto print_word_selector = [&](const HistorySelector::WordSelector& selector) { + auto print_word_selector = [&](HistorySelector::WordSelector const& selector) { switch (selector.kind) { case HistorySelector::WordSelectorKind::Index: print_indented(String::formatted("Index {}", selector.selector), level + 3); @@ -1798,7 +1798,7 @@ HitTestResult Execute::hit_test_position(size_t offset) const return result; } -Vector<Line::CompletionSuggestion> Execute::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> Execute::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node || !matching_node->is_bareword()) @@ -1851,7 +1851,7 @@ RefPtr<Value> IfCond::run(RefPtr<Shell> shell) // The condition could be a builtin, in which case it has already run and exited. if (cond->is_job()) { - auto cond_job_value = static_cast<const JobValue*>(cond.ptr()); + auto cond_job_value = static_cast<JobValue const*>(cond.ptr()); auto cond_job = cond_job_value->job(); shell->block_on_job(cond_job); @@ -1978,7 +1978,7 @@ void ImmediateExpression::highlight_in_editor(Line::Editor& editor, Shell& shell editor.stylize({ m_closing_brace_position->start_offset, m_closing_brace_position->end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Green) }); } -Vector<Line::CompletionSuggestion> ImmediateExpression::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> ImmediateExpression::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node || matching_node != this) @@ -2455,7 +2455,7 @@ HitTestResult PathRedirectionNode::hit_test_position(size_t offset) const return result; } -Vector<Line::CompletionSuggestion> PathRedirectionNode::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> PathRedirectionNode::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node || !matching_node->is_bareword()) @@ -2796,7 +2796,7 @@ HitTestResult Slice::hit_test_position(size_t offset) const return m_selector->hit_test_position(offset); } -Vector<Line::CompletionSuggestion> Slice::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> Slice::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { // TODO: Maybe intercept this, and suggest values in range? return m_selector->complete_for_editor(shell, offset, hit_test_result); @@ -2855,7 +2855,7 @@ HitTestResult SimpleVariable::hit_test_position(size_t offset) const return { this, this, nullptr }; } -Vector<Line::CompletionSuggestion> SimpleVariable::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> SimpleVariable::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node) @@ -2909,7 +2909,7 @@ void SpecialVariable::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi m_slice->highlight_in_editor(editor, shell, metadata); } -Vector<Line::CompletionSuggestion> SpecialVariable::complete_for_editor(Shell&, size_t, const HitTestResult&) +Vector<Line::CompletionSuggestion> SpecialVariable::complete_for_editor(Shell&, size_t, HitTestResult const&) { return {}; } @@ -3013,7 +3013,7 @@ void Juxtaposition::highlight_in_editor(Line::Editor& editor, Shell& shell, High } } -Vector<Line::CompletionSuggestion> Juxtaposition::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> Juxtaposition::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (m_left->would_execute() || m_right->would_execute()) { @@ -3190,7 +3190,7 @@ SyntaxError::SyntaxError(Position position, String error, bool is_continuable) { } -const SyntaxError& SyntaxError::syntax_error_node() const +SyntaxError const& SyntaxError::syntax_error_node() const { return *this; } @@ -3242,7 +3242,7 @@ HitTestResult Tilde::hit_test_position(size_t offset) const return { this, this, nullptr }; } -Vector<Line::CompletionSuggestion> Tilde::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result) +Vector<Line::CompletionSuggestion> Tilde::complete_for_editor(Shell& shell, size_t offset, HitTestResult const& hit_test_result) { auto matching_node = hit_test_result.matching_node; if (!matching_node) diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h index 85ab950896..c3290c080d 100644 --- a/Userland/Shell/AST.h +++ b/Userland/Shell/AST.h @@ -39,7 +39,7 @@ struct Position { size_t line_number { 0 }; size_t line_column { 0 }; - bool operator==(const Line& other) const + bool operator==(Line const& other) const { return line_number == other.line_number && line_column == other.line_column; } @@ -290,7 +290,7 @@ public: { } - const RefPtr<Job> job() const { return m_job; } + RefPtr<Job> const job() const { return m_job; } private: RefPtr<Job> m_job; @@ -314,7 +314,7 @@ public: { } - const NonnullRefPtrVector<Value>& values() const { return m_contained_values; } + NonnullRefPtrVector<Value> const& values() const { return m_contained_values; } NonnullRefPtrVector<Value>& values() { return m_contained_values; } private: @@ -416,7 +416,7 @@ public: virtual void for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(NonnullRefPtr<Value>)> callback); virtual RefPtr<Value> run(RefPtr<Shell>) = 0; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) = 0; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&); + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&); Vector<Line::CompletionSuggestion> complete_for_editor(Shell& shell, size_t offset); virtual HitTestResult hit_test_position(size_t offset) const { @@ -441,10 +441,10 @@ public: virtual bool would_execute() const { return false; } virtual bool should_override_execution_in_current_process() const { return false; } - const Position& position() const { return m_position; } + Position const& position() const { return m_position; } virtual void clear_syntax_error(); - virtual void set_is_syntax_error(const SyntaxError& error_node); - virtual const SyntaxError& syntax_error_node() const + virtual void set_is_syntax_error(SyntaxError const& error_node); + virtual SyntaxError const& syntax_error_node() const { VERIFY(is_syntax_error()); return *m_syntax_error_node; @@ -520,13 +520,13 @@ public: PathRedirectionNode(Position, int, NonnullRefPtr<Node>); virtual ~PathRedirectionNode(); virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual HitTestResult hit_test_position(size_t offset) const override; virtual bool is_command() const override { return true; } virtual bool is_list() const override { return true; } virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& path() const { return m_path; } + NonnullRefPtr<Node> const& path() const { return m_path; } int fd() const { return m_fd; } protected: @@ -540,9 +540,9 @@ public: virtual ~And() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& left() const { return m_left; } - const NonnullRefPtr<Node>& right() const { return m_right; } - const Position& and_position() const { return m_and_position; } + NonnullRefPtr<Node> const& left() const { return m_left; } + NonnullRefPtr<Node> const& right() const { return m_right; } + Position const& and_position() const { return m_and_position; } private: NODE(And); @@ -561,7 +561,7 @@ public: ListConcatenate(Position, Vector<NonnullRefPtr<Node>>); virtual ~ListConcatenate() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const Vector<NonnullRefPtr<Node>> list() const { return m_list; } + Vector<NonnullRefPtr<Node>> const list() const { return m_list; } private: NODE(ListConcatenate); @@ -582,7 +582,7 @@ public: virtual ~Background() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& command() const { return m_command; } + NonnullRefPtr<Node> const& command() const { return m_command; } private: NODE(Background); @@ -600,7 +600,7 @@ public: virtual ~BarewordLiteral() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& text() const { return m_text; } + String const& text() const { return m_text; } private: NODE(BarewordLiteral); @@ -619,7 +619,7 @@ public: virtual ~BraceExpansion() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtrVector<Node>& entries() const { return m_entries; } + NonnullRefPtrVector<Node> const& entries() const { return m_entries; } private: NODE(BraceExpansion); @@ -637,7 +637,7 @@ public: virtual ~CastToCommand() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& inner() const { return m_inner; } + NonnullRefPtr<Node> const& inner() const { return m_inner; } private: NODE(CastToCommand); @@ -645,7 +645,7 @@ private: virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual HitTestResult hit_test_position(size_t) const override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual bool is_command() const override { return true; } virtual bool is_list() const override { return true; } virtual RefPtr<Node> leftmost_trivial_literal() const override; @@ -659,7 +659,7 @@ public: virtual ~CastToList() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const RefPtr<Node>& inner() const { return m_inner; } + RefPtr<Node> const& inner() const { return m_inner; } private: NODE(CastToList); @@ -698,7 +698,7 @@ public: virtual ~CommandLiteral(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const Command& command() const { return m_command; } + Command const& command() const { return m_command; } private: NODE(CommandLiteral); @@ -717,7 +717,7 @@ public: virtual ~Comment(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& text() const { return m_text; } + String const& text() const { return m_text; } private: NODE(Comment); @@ -760,7 +760,7 @@ public: virtual ~DynamicEvaluate(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& inner() const { return m_inner; } + NonnullRefPtr<Node> const& inner() const { return m_inner; } private: NODE(DynamicEvaluate); @@ -787,7 +787,7 @@ public: virtual ~DoubleQuotedString(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const RefPtr<Node>& inner() const { return m_inner; } + RefPtr<Node> const& inner() const { return m_inner; } private: NODE(DoubleQuotedString); @@ -825,9 +825,9 @@ public: virtual ~FunctionDeclaration(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NameWithPosition& name() const { return m_name; } - const Vector<NameWithPosition> arguments() const { return m_arguments; } - const RefPtr<Node>& block() const { return m_block; } + NameWithPosition const& name() const { return m_name; } + Vector<NameWithPosition> const arguments() const { return m_arguments; } + RefPtr<Node> const& block() const { return m_block; } private: NODE(FunctionDeclaration); @@ -835,7 +835,7 @@ private: virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual HitTestResult hit_test_position(size_t) const override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual bool would_execute() const override { return true; } virtual bool should_override_execution_in_current_process() const override { return true; } @@ -850,12 +850,12 @@ public: virtual ~ForLoop(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const Optional<NameWithPosition>& variable() const { return m_variable; } - const Optional<NameWithPosition>& index_variable() const { return m_index_variable; } - const RefPtr<Node>& iterated_expression() const { return m_iterated_expression; } - const RefPtr<Node>& block() const { return m_block; } - const Optional<Position> index_keyword_position() const { return m_index_kw_position; } - const Optional<Position> in_keyword_position() const { return m_in_kw_position; } + Optional<NameWithPosition> const& variable() const { return m_variable; } + Optional<NameWithPosition> const& index_variable() const { return m_index_variable; } + RefPtr<Node> const& iterated_expression() const { return m_iterated_expression; } + RefPtr<Node> const& block() const { return m_block; } + Optional<Position> const index_keyword_position() const { return m_index_kw_position; } + Optional<Position> const in_keyword_position() const { return m_in_kw_position; } private: NODE(ForLoop); @@ -880,7 +880,7 @@ public: virtual ~Glob(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& text() const { return m_text; } + String const& text() const { return m_text; } private: NODE(Glob); @@ -939,7 +939,7 @@ public: virtual ~HistoryEvent(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const HistorySelector& selector() const { return m_selector; } + HistorySelector const& selector() const { return m_selector; } private: NODE(HistoryEvent); @@ -959,7 +959,7 @@ public: virtual void for_each_entry(RefPtr<Shell> shell, Function<IterationDecision(NonnullRefPtr<Value>)> callback) override; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& command() const { return m_command; } + NonnullRefPtr<Node> const& command() const { return m_command; } bool does_capture_stdout() const { return m_capture_stdout; } private: @@ -968,7 +968,7 @@ private: virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual HitTestResult hit_test_position(size_t) const override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual bool is_execute() const override { return true; } virtual bool would_execute() const override { return true; } @@ -982,10 +982,10 @@ public: virtual ~IfCond(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& condition() const { return m_condition; } - const RefPtr<Node>& true_branch() const { return m_true_branch; } - const RefPtr<Node>& false_branch() const { return m_false_branch; } - const Optional<Position> else_position() const { return m_else_position; } + NonnullRefPtr<Node> const& condition() const { return m_condition; } + RefPtr<Node> const& true_branch() const { return m_true_branch; } + RefPtr<Node> const& false_branch() const { return m_false_branch; } + Optional<Position> const else_position() const { return m_else_position; } private: NODE(IfCond); @@ -1008,10 +1008,10 @@ public: virtual ~ImmediateExpression(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtrVector<Node>& arguments() const { return m_arguments; } - const auto& function() const { return m_function; } - const String& function_name() const { return m_function.name; } - const Position& function_position() const { return m_function.position; } + NonnullRefPtrVector<Node> const& arguments() const { return m_arguments; } + auto const& function() const { return m_function; } + String const& function_name() const { return m_function.name; } + Position const& function_position() const { return m_function.position; } bool has_closing_brace() const { return m_closing_brace_position.has_value(); } private: @@ -1019,7 +1019,7 @@ private: virtual void dump(int level) const override; virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtrVector<AST::Node> m_arguments; @@ -1033,8 +1033,8 @@ public: virtual ~Join(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& left() const { return m_left; } - const NonnullRefPtr<Node>& right() const { return m_right; } + NonnullRefPtr<Node> const& left() const { return m_left; } + NonnullRefPtr<Node> const& right() const { return m_right; } private: NODE(Join); @@ -1064,10 +1064,10 @@ public: virtual ~MatchExpr(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& matched_expr() const { return m_matched_expr; } - const String& expr_name() const { return m_expr_name; } - const Vector<MatchEntry>& entries() const { return m_entries; } - const Optional<Position>& as_position() const { return m_as_position; } + NonnullRefPtr<Node> const& matched_expr() const { return m_matched_expr; } + String const& expr_name() const { return m_expr_name; } + Vector<MatchEntry> const& entries() const { return m_entries; } + Optional<Position> const& as_position() const { return m_as_position; } private: NODE(MatchExpr); @@ -1090,9 +1090,9 @@ public: virtual ~Or(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& left() const { return m_left; } - const NonnullRefPtr<Node>& right() const { return m_right; } - const Position& or_position() const { return m_or_position; } + NonnullRefPtr<Node> const& left() const { return m_left; } + NonnullRefPtr<Node> const& right() const { return m_right; } + Position const& or_position() const { return m_or_position; } private: NODE(Or); @@ -1112,8 +1112,8 @@ public: virtual ~Pipe(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& left() const { return m_left; } - const NonnullRefPtr<Node>& right() const { return m_right; } + NonnullRefPtr<Node> const& left() const { return m_left; } + NonnullRefPtr<Node> const& right() const { return m_right; } private: NODE(Pipe); @@ -1133,8 +1133,8 @@ public: virtual ~Range(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& start() const { return m_start; } - const NonnullRefPtr<Node>& end() const { return m_end; } + NonnullRefPtr<Node> const& start() const { return m_start; } + NonnullRefPtr<Node> const& end() const { return m_end; } private: NODE(Range); @@ -1177,9 +1177,9 @@ public: virtual ~Sequence(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtrVector<Node>& entries() const { return m_entries; } + NonnullRefPtrVector<Node> const& entries() const { return m_entries; } - const Vector<Position>& separator_positions() const { return m_separator_positions; } + Vector<Position> const& separator_positions() const { return m_separator_positions; } private: NODE(Sequence); @@ -1201,7 +1201,7 @@ public: virtual ~Subshell(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const RefPtr<Node>& block() const { return m_block; } + RefPtr<Node> const& block() const { return m_block; } private: NODE(Subshell); @@ -1227,7 +1227,7 @@ public: virtual void dump(int level) const override; virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual HitTestResult hit_test_position(size_t) const override; protected: @@ -1250,7 +1250,7 @@ public: set_is_syntax_error(m_slice->syntax_error_node()); } - const Slice* slice() const { return m_slice.ptr(); } + Slice const* slice() const { return m_slice.ptr(); } protected: RefPtr<Slice> m_slice; @@ -1262,14 +1262,14 @@ public: virtual ~SimpleVariable(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& name() const { return m_name; } + String const& name() const { return m_name; } private: NODE(SimpleVariable); virtual void dump(int level) const override; virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_simple_variable() const override { return true; } @@ -1289,7 +1289,7 @@ private: virtual void dump(int level) const override; virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual HitTestResult hit_test_position(size_t) const override; char m_name { 0 }; @@ -1301,8 +1301,8 @@ public: virtual ~Juxtaposition(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& left() const { return m_left; } - const NonnullRefPtr<Node>& right() const { return m_right; } + NonnullRefPtr<Node> const& left() const { return m_left; } + NonnullRefPtr<Node> const& right() const { return m_right; } private: NODE(Juxtaposition); @@ -1310,7 +1310,7 @@ private: virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual HitTestResult hit_test_position(size_t) const override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; NonnullRefPtr<Node> m_left; NonnullRefPtr<Node> m_right; @@ -1322,10 +1322,10 @@ public: virtual ~Heredoc(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& end() const { return m_end; } + String const& end() const { return m_end; } bool allow_interpolation() const { return m_allows_interpolation; } bool deindent() const { return m_deindent; } - const RefPtr<AST::Node>& contents() const { return m_contents; } + RefPtr<AST::Node> const& contents() const { return m_contents; } void set_contents(RefPtr<AST::Node> contents) { m_contents = move(contents); @@ -1361,7 +1361,7 @@ public: virtual ~StringLiteral(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& text() const { return m_text; } + String const& text() const { return m_text; } EnclosureType enclosure_type() const { return m_enclosure_type; } private: @@ -1381,8 +1381,8 @@ public: virtual ~StringPartCompose(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const NonnullRefPtr<Node>& left() const { return m_left; } - const NonnullRefPtr<Node>& right() const { return m_right; } + NonnullRefPtr<Node> const& left() const { return m_left; } + NonnullRefPtr<Node> const& right() const { return m_right; } private: NODE(StringPartCompose); @@ -1401,14 +1401,14 @@ public: virtual ~SyntaxError(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const String& error_text() const { return m_syntax_error_text; } + String const& error_text() const { return m_syntax_error_text; } bool is_continuable() const { return m_is_continuable; } virtual void clear_syntax_error() override { m_is_cleared = true; } - virtual void set_is_syntax_error(const SyntaxError& error) override + virtual void set_is_syntax_error(SyntaxError const& error) override { m_position = error.position(); m_is_cleared = error.m_is_cleared; @@ -1424,7 +1424,7 @@ private: virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual HitTestResult hit_test_position(size_t) const override { return { nullptr, nullptr, nullptr }; } - virtual const SyntaxError& syntax_error_node() const override; + virtual SyntaxError const& syntax_error_node() const override; String m_syntax_error_text; bool m_is_continuable { false }; @@ -1437,7 +1437,7 @@ public: virtual ~SyntheticNode() = default; virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const Value& value() const { return m_value; } + Value const& value() const { return m_value; } private: NODE(SyntheticValue); @@ -1461,7 +1461,7 @@ private: virtual void dump(int level) const override; virtual RefPtr<Value> run(RefPtr<Shell>) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, const HitTestResult&) override; + virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, HitTestResult const&) override; virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_tilde() const override { return true; } @@ -1478,7 +1478,7 @@ public: virtual ~VariableDeclarations(); virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } - const Vector<Variable>& variables() const { return m_variables; } + Vector<Variable> const& variables() const { return m_variables; } private: NODE(VariableDeclarations); diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 31a9f36bce..738e44926e 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -25,12 +25,12 @@ extern char** environ; namespace Shell { -int Shell::builtin_noop(int, const char**) +int Shell::builtin_noop(int, char const**) { return 0; } -int Shell::builtin_dump(int argc, const char** argv) +int Shell::builtin_dump(int argc, char const** argv) { if (argc != 2) return 1; @@ -39,9 +39,9 @@ int Shell::builtin_dump(int argc, const char** argv) return 0; } -int Shell::builtin_alias(int argc, const char** argv) +int Shell::builtin_alias(int argc, char const** argv) { - Vector<const char*> arguments; + Vector<char const*> arguments; Core::ArgsParser parser; parser.add_positional_argument(arguments, "List of name[=values]'s", "name[=value]", Core::ArgsParser::Required::No); @@ -74,10 +74,10 @@ int Shell::builtin_alias(int argc, const char** argv) return fail ? 1 : 0; } -int Shell::builtin_unalias(int argc, const char** argv) +int Shell::builtin_unalias(int argc, char const** argv) { bool remove_all { false }; - Vector<const char*> arguments; + Vector<char const*> arguments; Core::ArgsParser parser; parser.set_general_help("Remove alias from the list of aliases"); @@ -113,7 +113,7 @@ int Shell::builtin_unalias(int argc, const char** argv) return failed ? 1 : 0; } -int Shell::builtin_bg(int argc, const char** argv) +int Shell::builtin_bg(int argc, char const** argv) { int job_id = -1; bool is_pid = false; @@ -177,9 +177,9 @@ int Shell::builtin_bg(int argc, const char** argv) return 0; } -int Shell::builtin_type(int argc, const char** argv) +int Shell::builtin_type(int argc, char const** argv) { - Vector<const char*> commands; + Vector<char const*> commands; bool dont_show_function_source = false; Core::ArgsParser parser; @@ -246,9 +246,9 @@ int Shell::builtin_type(int argc, const char** argv) return 0; } -int Shell::builtin_cd(int argc, const char** argv) +int Shell::builtin_cd(int argc, char const** argv) { - const char* arg_path = nullptr; + char const* arg_path = nullptr; Core::ArgsParser parser; parser.add_positional_argument(arg_path, "Path to change to", "path", Core::ArgsParser::Required::No); @@ -283,7 +283,7 @@ int Shell::builtin_cd(int argc, const char** argv) auto path_relative_to_current_directory = LexicalPath::relative_path(real_path, cwd); if (path_relative_to_current_directory.is_empty()) path_relative_to_current_directory = real_path; - const char* path = path_relative_to_current_directory.characters(); + char const* path = path_relative_to_current_directory.characters(); int rc = chdir(path); if (rc < 0) { @@ -300,7 +300,7 @@ int Shell::builtin_cd(int argc, const char** argv) return 0; } -int Shell::builtin_cdh(int argc, const char** argv) +int Shell::builtin_cdh(int argc, char const** argv) { int index = -1; @@ -326,12 +326,12 @@ int Shell::builtin_cdh(int argc, const char** argv) return 1; } - const char* path = cd_history.at(cd_history.size() - index).characters(); - const char* cd_args[] = { "cd", path, nullptr }; + char const* path = cd_history.at(cd_history.size() - index).characters(); + char const* cd_args[] = { "cd", path, nullptr }; return Shell::builtin_cd(2, cd_args); } -int Shell::builtin_dirs(int argc, const char** argv) +int Shell::builtin_dirs(int argc, char const** argv) { // The first directory in the stack is ALWAYS the current directory directory_stack.at(0) = cwd.characters(); @@ -341,7 +341,7 @@ int Shell::builtin_dirs(int argc, const char** argv) bool number_when_printing = false; char separator = ' '; - Vector<const char*> paths; + Vector<char const*> paths; Core::ArgsParser parser; parser.add_option(clear, "Clear the directory stack", "clear", 'c'); @@ -384,21 +384,21 @@ int Shell::builtin_dirs(int argc, const char** argv) return 0; } -int Shell::builtin_exec(int argc, const char** argv) +int Shell::builtin_exec(int argc, char const** argv) { if (argc < 2) { warnln("Shell: No command given to exec"); return 1; } - Vector<const char*> argv_vector; + Vector<char const*> argv_vector; argv_vector.append(argv + 1, argc - 1); argv_vector.append(nullptr); execute_process(move(argv_vector)); } -int Shell::builtin_exit(int argc, const char** argv) +int Shell::builtin_exit(int argc, char const** argv) { int exit_code = 0; Core::ArgsParser parser; @@ -423,9 +423,9 @@ int Shell::builtin_exit(int argc, const char** argv) exit(exit_code); } -int Shell::builtin_export(int argc, const char** argv) +int Shell::builtin_export(int argc, char const** argv) { - Vector<const char*> vars; + Vector<char const*> vars; Core::ArgsParser parser; parser.add_positional_argument(vars, "List of variable[=value]'s", "values", Core::ArgsParser::Required::No); @@ -469,9 +469,9 @@ int Shell::builtin_export(int argc, const char** argv) return 0; } -int Shell::builtin_glob(int argc, const char** argv) +int Shell::builtin_glob(int argc, char const** argv) { - Vector<const char*> globs; + Vector<char const*> globs; Core::ArgsParser parser; parser.add_positional_argument(globs, "Globs to resolve", "glob"); @@ -486,7 +486,7 @@ int Shell::builtin_glob(int argc, const char** argv) return 0; } -int Shell::builtin_fg(int argc, const char** argv) +int Shell::builtin_fg(int argc, char const** argv) { int job_id = -1; bool is_pid = false; @@ -557,7 +557,7 @@ int Shell::builtin_fg(int argc, const char** argv) return 0; } -int Shell::builtin_disown(int argc, const char** argv) +int Shell::builtin_disown(int argc, char const** argv) { Vector<int> job_ids; Vector<bool> id_is_pid; @@ -594,7 +594,7 @@ int Shell::builtin_disown(int argc, const char** argv) id_is_pid.append(false); } - Vector<const Job*> jobs_to_disown; + Vector<Job const*> jobs_to_disown; for (size_t i = 0; i < job_ids.size(); ++i) { auto id = job_ids[i]; @@ -625,7 +625,7 @@ int Shell::builtin_disown(int argc, const char** argv) return 0; } -int Shell::builtin_history(int, const char**) +int Shell::builtin_history(int, char const**) { for (size_t i = 0; i < m_editor->history().size(); ++i) { printf("%6zu %s\n", i + 1, m_editor->history()[i].entry.characters()); @@ -633,7 +633,7 @@ int Shell::builtin_history(int, const char**) return 0; } -int Shell::builtin_jobs(int argc, const char** argv) +int Shell::builtin_jobs(int argc, char const** argv) { bool list = false, show_pid = false; @@ -660,7 +660,7 @@ int Shell::builtin_jobs(int argc, const char** argv) return 0; } -int Shell::builtin_popd(int argc, const char** argv) +int Shell::builtin_popd(int argc, char const** argv) { if (directory_stack.size() <= 1) { warnln("Shell: popd: directory stack empty"); @@ -688,7 +688,7 @@ int Shell::builtin_popd(int argc, const char** argv) return 0; } -int Shell::builtin_pushd(int argc, const char** argv) +int Shell::builtin_pushd(int argc, char const** argv) { StringBuilder path_builder; bool should_switch = true; @@ -728,7 +728,7 @@ int Shell::builtin_pushd(int argc, const char** argv) } else if (argc == 3) { directory_stack.append(cwd.characters()); for (int i = 1; i < argc; i++) { - const char* arg = argv[i]; + char const* arg = argv[i]; if (arg[0] != '-') { if (arg[0] == '/') { @@ -769,14 +769,14 @@ int Shell::builtin_pushd(int argc, const char** argv) return 0; } -int Shell::builtin_pwd(int, const char**) +int Shell::builtin_pwd(int, char const**) { print_path(cwd); fputc('\n', stdout); return 0; } -int Shell::builtin_setopt(int argc, const char** argv) +int Shell::builtin_setopt(int argc, char const** argv) { if (argc == 1) { #define __ENUMERATE_SHELL_OPTION(name, default_, description) \ @@ -815,7 +815,7 @@ int Shell::builtin_setopt(int argc, const char** argv) return 0; } -int Shell::builtin_shift(int argc, const char** argv) +int Shell::builtin_shift(int argc, char const** argv) { int count = 1; @@ -849,10 +849,10 @@ int Shell::builtin_shift(int argc, const char** argv) return 0; } -int Shell::builtin_source(int argc, const char** argv) +int Shell::builtin_source(int argc, char const** argv) { - const char* file_to_source = nullptr; - Vector<const char*> args; + char const* file_to_source = nullptr; + Vector<char const*> args; Core::ArgsParser parser; parser.add_positional_argument(file_to_source, "File to read commands from", "path"); @@ -880,9 +880,9 @@ int Shell::builtin_source(int argc, const char** argv) return 0; } -int Shell::builtin_time(int argc, const char** argv) +int Shell::builtin_time(int argc, char const** argv) { - Vector<const char*> args; + Vector<char const*> args; int number_of_iterations = 1; @@ -938,9 +938,9 @@ int Shell::builtin_time(int argc, const char** argv) return exit_code; } -int Shell::builtin_umask(int argc, const char** argv) +int Shell::builtin_umask(int argc, char const** argv) { - const char* mask_text = nullptr; + char const* mask_text = nullptr; Core::ArgsParser parser; parser.add_positional_argument(mask_text, "New mask (omit to get current mask)", "octal-mask", Core::ArgsParser::Required::No); @@ -966,7 +966,7 @@ int Shell::builtin_umask(int argc, const char** argv) return 1; } -int Shell::builtin_wait(int argc, const char** argv) +int Shell::builtin_wait(int argc, char const** argv) { Vector<int> job_ids; Vector<bool> id_is_pid; @@ -1011,7 +1011,7 @@ int Shell::builtin_wait(int argc, const char** argv) } if (job_ids.is_empty()) { - for (const auto& it : jobs) + for (auto const& it : jobs) jobs_to_wait_for.append(it.value); } @@ -1023,9 +1023,9 @@ int Shell::builtin_wait(int argc, const char** argv) return 0; } -int Shell::builtin_unset(int argc, const char** argv) +int Shell::builtin_unset(int argc, char const** argv) { - Vector<const char*> vars; + Vector<char const*> vars; Core::ArgsParser parser; parser.add_positional_argument(vars, "List of variables", "variables", Core::ArgsParser::Required::Yes); @@ -1051,7 +1051,7 @@ int Shell::builtin_unset(int argc, const char** argv) return 0; } -int Shell::builtin_not(int argc, const char** argv) +int Shell::builtin_not(int argc, char const** argv) { // FIXME: Use ArgsParser when it can collect unrelated -arguments too. if (argc == 1) @@ -1075,7 +1075,7 @@ int Shell::builtin_not(int argc, const char** argv) return exit_code == 0 ? 1 : 0; } -int Shell::builtin_kill(int argc, const char** argv) +int Shell::builtin_kill(int argc, char const** argv) { // Simply translate the arguments and pass them to `kill' Vector<String> replaced_values; @@ -1118,7 +1118,7 @@ int Shell::builtin_kill(int argc, const char** argv) return exit_code; } -bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<AST::Rewiring>& rewirings, int& retval) +bool Shell::run_builtin(const AST::Command& command, NonnullRefPtrVector<AST::Rewiring> const& rewirings, int& retval) { if (command.argv.is_empty()) return false; @@ -1126,7 +1126,7 @@ bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<A if (!has_builtin(command.argv.first())) return false; - Vector<const char*> argv; + Vector<char const*> argv; for (auto& arg : command.argv) argv.append(arg.characters()); @@ -1166,7 +1166,7 @@ bool Shell::run_builtin(const AST::Command& command, const NonnullRefPtrVector<A return false; } -int Shell::builtin_argsparser_parse(int argc, const char** argv) +int Shell::builtin_argsparser_parse(int argc, char const** argv) { // argsparser_parse // --add-option variable [--type (bool | string | i32 | u32 | double | size)] --help-string "" --long-name "" --short-name "" [--value-name "" <if not --type bool>] --list diff --git a/Userland/Shell/Execution.h b/Userland/Shell/Execution.h index 0437700a30..02af16738c 100644 --- a/Userland/Shell/Execution.h +++ b/Userland/Shell/Execution.h @@ -29,7 +29,7 @@ private: class SavedFileDescriptors { public: - SavedFileDescriptors(const NonnullRefPtrVector<AST::Rewiring>&); + SavedFileDescriptors(NonnullRefPtrVector<AST::Rewiring> const&); ~SavedFileDescriptors(); private: diff --git a/Userland/Shell/ImmediateFunctions.cpp b/Userland/Shell/ImmediateFunctions.cpp index e67d8d0383..2791d7b185 100644 --- a/Userland/Shell/ImmediateFunctions.cpp +++ b/Userland/Shell/ImmediateFunctions.cpp @@ -10,7 +10,7 @@ namespace Shell { -RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments, bool across) +RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments, bool across) { auto name = across ? "length_across" : "length"; if (arguments.size() < 1 || arguments.size() > 2) { @@ -37,7 +37,7 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin return nullptr; } - const auto& mode_name = static_cast<const AST::BarewordLiteral&>(mode_arg).text(); + auto const& mode_name = static_cast<const AST::BarewordLiteral&>(mode_arg).text(); if (mode_name == "list") { mode = List; } else if (mode_name == "string") { @@ -189,17 +189,17 @@ RefPtr<AST::Node> Shell::immediate_length_impl(AST::ImmediateExpression& invokin } } -RefPtr<AST::Node> Shell::immediate_length(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_length(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { return immediate_length_impl(invoking_node, arguments, false); } -RefPtr<AST::Node> Shell::immediate_length_across(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_length_across(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { return immediate_length_impl(invoking_node, arguments, true); } -RefPtr<AST::Node> Shell::immediate_regex_replace(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_regex_replace(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { if (arguments.size() != 3) { raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 3 arguments to regex_replace", invoking_node.position()); @@ -231,7 +231,7 @@ RefPtr<AST::Node> Shell::immediate_regex_replace(AST::ImmediateExpression& invok return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), move(result), AST::StringLiteral::EnclosureType::None); } -RefPtr<AST::Node> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { if (arguments.size() != 2) { raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to remove_suffix", invoking_node.position()); @@ -262,7 +262,7 @@ RefPtr<AST::Node> Shell::immediate_remove_suffix(AST::ImmediateExpression& invok return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(nodes)); } -RefPtr<AST::Node> Shell::immediate_remove_prefix(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_remove_prefix(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { if (arguments.size() != 2) { raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to remove_prefix", invoking_node.position()); @@ -293,7 +293,7 @@ RefPtr<AST::Node> Shell::immediate_remove_prefix(AST::ImmediateExpression& invok return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(nodes)); } -RefPtr<AST::Node> Shell::immediate_split(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_split(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { if (arguments.size() != 2) { raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to split", invoking_node.position()); @@ -310,7 +310,7 @@ RefPtr<AST::Node> Shell::immediate_split(AST::ImmediateExpression& invoking_node auto delimiter_str = delimiter->resolve_as_list(this)[0]; - auto transform = [&](const auto& values) { + auto transform = [&](auto const& values) { // Translate to a list of applications of `split <delimiter>` Vector<NonnullRefPtr<AST::Node>> resulting_nodes; resulting_nodes.ensure_capacity(values.size()); @@ -360,7 +360,7 @@ RefPtr<AST::Node> Shell::immediate_split(AST::ImmediateExpression& invoking_node return transform(AST::make_ref_counted<AST::ListValue>(list)->values()); } -RefPtr<AST::Node> Shell::immediate_concat_lists(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_concat_lists(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { NonnullRefPtrVector<AST::Node> result; @@ -383,7 +383,7 @@ RefPtr<AST::Node> Shell::immediate_concat_lists(AST::ImmediateExpression& invoki return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(result)); } -RefPtr<AST::Node> Shell::immediate_filter_glob(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_filter_glob(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { // filter_glob string list if (arguments.size() != 2) { @@ -427,7 +427,7 @@ RefPtr<AST::Node> Shell::immediate_filter_glob(AST::ImmediateExpression& invokin return AST::make_ref_counted<AST::ListConcatenate>(invoking_node.position(), move(result)); } -RefPtr<AST::Node> Shell::immediate_join(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::immediate_join(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { if (arguments.size() != 2) { raise_error(ShellError::EvaluatedSyntaxError, "Expected exactly 2 arguments to join", invoking_node.position()); @@ -453,7 +453,7 @@ RefPtr<AST::Node> Shell::immediate_join(AST::ImmediateExpression& invoking_node, return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), builder.to_string(), AST::StringLiteral::EnclosureType::None); } -RefPtr<AST::Node> Shell::run_immediate_function(StringView str, AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>& arguments) +RefPtr<AST::Node> Shell::run_immediate_function(StringView str, AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments) { #define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(name) \ if (str == #name) \ diff --git a/Userland/Shell/Job.h b/Userland/Shell/Job.h index f2a579fbf6..a92c9577dc 100644 --- a/Userland/Shell/Job.h +++ b/Userland/Shell/Job.h @@ -40,7 +40,7 @@ public: pid_t pgid() const { return m_pgid; } pid_t pid() const { return m_pid; } - const String& cmd() const { return m_cmd; } + String const& cmd() const { return m_cmd; } const AST::Command& command() const { return *m_command; } AST::Command* command_ptr() { return m_command; } u64 job_id() const { return m_job_id; } diff --git a/Userland/Shell/Parser.h b/Userland/Shell/Parser.h index 212c52c8a6..ec8ebfc919 100644 --- a/Userland/Shell/Parser.h +++ b/Userland/Shell/Parser.h @@ -152,7 +152,7 @@ private: AST::Position::Line line; }; - void restore_to(const ScopedOffset& offset) { restore_to(offset.offset, offset.line); } + void restore_to(ScopedOffset const& offset) { restore_to(offset.offset, offset.line); } OwnPtr<ScopedOffset> push_start(); Offset current_position(); diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 29a0540cff..33f7983011 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -155,7 +155,7 @@ String Shell::expand_tilde(StringView expression) path.append(expression[i]); if (login_name.is_empty()) { - const char* home = getenv("HOME"); + char const* home = getenv("HOME"); if (!home) { auto passwd = getpwuid(getuid()); VERIFY(passwd && passwd->pw_dir); @@ -385,7 +385,7 @@ RefPtr<AST::Value> Shell::get_argument(size_t index) const return nullptr; } -String Shell::local_variable_or(StringView name, const String& replacement) const +String Shell::local_variable_or(StringView name, String const& replacement) const { auto value = lookup_local_variable(name); if (value) { @@ -396,7 +396,7 @@ String Shell::local_variable_or(StringView name, const String& replacement) cons return replacement; } -void Shell::set_local_variable(const String& name, RefPtr<AST::Value> value, bool only_in_current_frame) +void Shell::set_local_variable(String const& name, RefPtr<AST::Value> value, bool only_in_current_frame) { if (!only_in_current_frame) { if (auto* frame = find_frame_containing_local_variable(name)) { @@ -700,7 +700,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command) return nullptr; } - Vector<const char*> argv; + Vector<char const*> argv; Vector<String> copy_argv = command.argv; argv.ensure_capacity(command.argv.size() + 1); @@ -842,7 +842,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command) return *job; } -void Shell::execute_process(Vector<const char*>&& argv) +void Shell::execute_process(Vector<char const*>&& argv) { #ifdef __serenity__ for (auto& promise : m_active_promises) { @@ -1008,7 +1008,7 @@ NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands) return spawned_jobs; } -bool Shell::run_file(const String& filename, bool explicitly_invoked) +bool Shell::run_file(String const& filename, bool explicitly_invoked) { TemporaryChange script_change { current_script, filename }; TemporaryChange interactive_change { m_is_interactive, false }; @@ -1062,7 +1062,7 @@ void Shell::block_on_pipeline(RefPtr<AST::Pipeline> pipeline) void Shell::block_on_job(RefPtr<Job> job) { - TemporaryChange<const Job*> current_job { m_current_job, job.ptr() }; + TemporaryChange<Job const*> current_job { m_current_job, job.ptr() }; if (!job) return; @@ -1310,7 +1310,7 @@ String Shell::find_in_path(StringView program_name) String path = getenv("PATH"); if (!path.is_empty()) { auto directories = path.split(':'); - for (const auto& directory : directories) { + for (auto const& directory : directories) { Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots); while (programs.has_next()) { auto program = programs.next_path(); @@ -1335,7 +1335,7 @@ void Shell::cache_path() cached_path.clear_with_capacity(); // Add shell builtins to the cache. - for (const auto& builtin_name : builtin_names) + for (auto const& builtin_name : builtin_names) cached_path.append(escape_token(builtin_name)); // Add functions to the cache. @@ -1347,7 +1347,7 @@ void Shell::cache_path() } // Add aliases to the cache. - for (const auto& alias : m_aliases) { + for (auto const& alias : m_aliases) { auto name = escape_token(alias.key); if (cached_path.contains_slow(name)) continue; @@ -1357,7 +1357,7 @@ void Shell::cache_path() String path = getenv("PATH"); if (!path.is_empty()) { auto directories = path.split(':'); - for (const auto& directory : directories) { + for (auto const& directory : directories) { Core::DirIterator programs(directory.characters(), Core::DirIterator::SkipDots); while (programs.has_next()) { auto program = programs.next_path(); @@ -1374,7 +1374,7 @@ void Shell::cache_path() quick_sort(cached_path); } -void Shell::add_entry_to_cache(const String& entry) +void Shell::add_entry_to_cache(String const& entry) { size_t index = 0; auto match = binary_search(cached_path.span(), entry, &index); @@ -2223,7 +2223,7 @@ u64 Shell::find_last_job_id() const return job_id; } -const Job* Shell::find_job(u64 id, bool is_pid) +Job const* Shell::find_job(u64 id, bool is_pid) { for (auto& entry : jobs) { if (is_pid) { @@ -2237,7 +2237,7 @@ const Job* Shell::find_job(u64 id, bool is_pid) return nullptr; } -void Shell::kill_job(const Job* job, int sig) +void Shell::kill_job(Job const* job, int sig) { if (!job) return; @@ -2441,7 +2441,7 @@ void FileDescriptionCollector::add(int fd) m_fds.append(fd); } -SavedFileDescriptors::SavedFileDescriptors(const NonnullRefPtrVector<AST::Rewiring>& intended_rewirings) +SavedFileDescriptors::SavedFileDescriptors(NonnullRefPtrVector<AST::Rewiring> const& intended_rewirings) { for (auto& rewiring : intended_rewirings) { int new_fd = dup(rewiring.new_fd); diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index 79bf8c327d..31d3066c10 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -96,10 +96,10 @@ public: bool is_runnable(StringView); ErrorOr<RefPtr<Job>> run_command(const AST::Command&); NonnullRefPtrVector<Job> run_commands(Vector<AST::Command>&); - bool run_file(const String&, bool explicitly_invoked = true); - bool run_builtin(const AST::Command&, const NonnullRefPtrVector<AST::Rewiring>&, int& retval); + bool run_file(String const&, bool explicitly_invoked = true); + bool run_builtin(const AST::Command&, NonnullRefPtrVector<AST::Rewiring> const&, int& retval); bool has_builtin(StringView) const; - RefPtr<AST::Node> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>&); + RefPtr<AST::Node> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&); static bool has_immediate_function(StringView); void block_on_job(RefPtr<Job>); void block_on_pipeline(RefPtr<AST::Pipeline>); @@ -118,8 +118,8 @@ public: RefPtr<AST::Value> get_argument(size_t) const; RefPtr<AST::Value> lookup_local_variable(StringView) const; - String local_variable_or(StringView, const String&) const; - void set_local_variable(const String&, RefPtr<AST::Value>, bool only_in_current_frame = false); + String local_variable_or(StringView, String const&) const; + void set_local_variable(String const&, RefPtr<AST::Value>, bool only_in_current_frame = false); void unset_local_variable(StringView, bool only_in_current_frame = false); void define_function(String name, Vector<String> argnames, RefPtr<AST::Node> body); @@ -142,7 +142,7 @@ public: }; struct Frame { - Frame(NonnullOwnPtrVector<LocalFrame>& frames, const LocalFrame& frame) + Frame(NonnullOwnPtrVector<LocalFrame>& frames, LocalFrame const& frame) : frames(frames) , frame(frame) { @@ -153,7 +153,7 @@ public: private: NonnullOwnPtrVector<LocalFrame>& frames; - const LocalFrame& frame; + LocalFrame const& frame; bool should_destroy_frame { true }; }; @@ -235,9 +235,9 @@ public: void restore_ios(); u64 find_last_job_id() const; - const Job* find_job(u64 id, bool is_pid = false); - const Job* current_job() const { return m_current_job; } - void kill_job(const Job*, int sig); + Job const* find_job(u64 id, bool is_pid = false); + Job const* current_job() const { return m_current_job; } + void kill_job(Job const*, int sig); String get_history_path(); void print_path(StringView path); @@ -298,7 +298,7 @@ public: } bool has_error(ShellError err) const { return m_error == err; } bool has_any_error() const { return !has_error(ShellError::None); } - const String& error_description() const { return m_error_description; } + String const& error_description() const { return m_error_description; } ShellError take_error() { auto err = m_error; @@ -344,12 +344,12 @@ private: Optional<int> resolve_job_spec(StringView); void cache_path(); - void add_entry_to_cache(const String&); + void add_entry_to_cache(String const&); void remove_entry_from_cache(StringView); void stop_all_jobs(); - const Job* m_current_job { nullptr }; + Job const* m_current_job { nullptr }; LocalFrame* find_frame_containing_local_variable(StringView name); - const LocalFrame* find_frame_containing_local_variable(StringView name) const + LocalFrame const* find_frame_containing_local_variable(StringView name) const { return const_cast<Shell*>(this)->find_frame_containing_local_variable(name); } @@ -357,21 +357,21 @@ private: void run_tail(RefPtr<Job>); void run_tail(const AST::Command&, const AST::NodeWithAction&, int head_exit_code); - [[noreturn]] void execute_process(Vector<const char*>&& argv); + [[noreturn]] void execute_process(Vector<char const*>&& argv); virtual void custom_event(Core::CustomEvent&) override; #define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(name) \ - RefPtr<AST::Node> immediate_##name(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>&); + RefPtr<AST::Node> immediate_##name(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&); ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS(); #undef __ENUMERATE_SHELL_IMMEDIATE_FUNCTION - RefPtr<AST::Node> immediate_length_impl(AST::ImmediateExpression& invoking_node, const NonnullRefPtrVector<AST::Node>&, bool across); + RefPtr<AST::Node> immediate_length_impl(AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const&, bool across); #define __ENUMERATE_SHELL_BUILTIN(builtin) \ - int builtin_##builtin(int argc, const char** argv); + int builtin_##builtin(int argc, char const** argv); ENUMERATE_SHELL_BUILTINS(); diff --git a/Userland/Shell/SyntaxHighlighter.cpp b/Userland/Shell/SyntaxHighlighter.cpp index 619fe2429b..c469be4560 100644 --- a/Userland/Shell/SyntaxHighlighter.cpp +++ b/Userland/Shell/SyntaxHighlighter.cpp @@ -24,7 +24,7 @@ enum class AugmentedTokenKind : u32 { class HighlightVisitor : public AST::NodeVisitor { public: - HighlightVisitor(Vector<GUI::TextDocumentSpan>& spans, const Gfx::Palette& palette, const GUI::TextDocument& document) + HighlightVisitor(Vector<GUI::TextDocumentSpan>& spans, Gfx::Palette const& palette, const GUI::TextDocument& document) : m_spans(spans) , m_palette(palette) , m_document(document) @@ -516,7 +516,7 @@ private: } Vector<GUI::TextDocumentSpan>& m_spans; - const Gfx::Palette& m_palette; + Gfx::Palette const& m_palette; const GUI::TextDocument& m_document; bool m_is_first_in_command { false }; }; @@ -537,7 +537,7 @@ bool SyntaxHighlighter::is_navigatable(u64) const return false; } -void SyntaxHighlighter::rehighlight(const Palette& palette) +void SyntaxHighlighter::rehighlight(Palette const& palette) { auto text = m_client->get_text(); diff --git a/Userland/Shell/SyntaxHighlighter.h b/Userland/Shell/SyntaxHighlighter.h index b2c7e22510..5f142c0b4e 100644 --- a/Userland/Shell/SyntaxHighlighter.h +++ b/Userland/Shell/SyntaxHighlighter.h @@ -19,7 +19,7 @@ public: virtual bool is_navigatable(u64) const override; virtual Syntax::Language language() const override { return Syntax::Language::Shell; } - virtual void rehighlight(const Palette&) override; + virtual void rehighlight(Palette const&) override; protected: virtual Vector<MatchingTokenPair> matching_token_pairs_impl() const override; diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 42d1ad2a5a..ae02376d81 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -157,11 +157,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) }; }; - const char* command_to_run = nullptr; - const char* file_to_read_from = nullptr; - Vector<const char*> script_args; + char const* command_to_run = nullptr; + char const* file_to_read_from = nullptr; + Vector<char const*> script_args; bool skip_rc_files = false; - const char* format = nullptr; + char const* format = nullptr; bool should_format_live = false; bool keep_open = false; diff --git a/Userland/Utilities/aplay.cpp b/Userland/Utilities/aplay.cpp index 3138a64934..97bc1ce7f6 100644 --- a/Userland/Utilities/aplay.cpp +++ b/Userland/Utilities/aplay.cpp @@ -23,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath sendfd unix")); - const char* path = nullptr; + char const* path = nullptr; bool should_loop = false; bool show_sample_progress = false; diff --git a/Userland/Utilities/arp.cpp b/Userland/Utilities/arp.cpp index 6b51cad357..616127ff9e 100644 --- a/Userland/Utilities/arp.cpp +++ b/Userland/Utilities/arp.cpp @@ -31,8 +31,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) static bool flag_set; static bool flag_delete; - const char* value_ipv4_address = nullptr; - const char* value_hw_address = nullptr; + char const* value_ipv4_address = nullptr; + char const* value_hw_address = nullptr; Core::ArgsParser args_parser; args_parser.set_general_help("Display or modify the system ARP cache"); diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp index c612e39cea..8d65d39d70 100644 --- a/Userland/Utilities/base64.cpp +++ b/Userland/Utilities/base64.cpp @@ -20,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath")); bool decode = false; - const char* filepath = nullptr; + char const* filepath = nullptr; Core::ArgsParser args_parser; args_parser.add_option(decode, "Decode data", "decode", 'd'); diff --git a/Userland/Utilities/blockdev.cpp b/Userland/Utilities/blockdev.cpp index 14e87250ed..3c4a9ad737 100644 --- a/Userland/Utilities/blockdev.cpp +++ b/Userland/Utilities/blockdev.cpp @@ -27,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::pledge("stdio rpath")); - const char* device = nullptr; + char const* device = nullptr; bool flag_get_disk_size = false; bool flag_get_block_size = false; diff --git a/Userland/Utilities/cal.cpp b/Userland/Utilities/cal.cpp index 28ce938d5b..cc0a3d6176 100644 --- a/Userland/Utilities/cal.cpp +++ b/Userland/Utilities/cal.cpp @@ -12,9 +12,9 @@ #include <string.h> #include <time.h> -const int line_width = 70; -const int line_count = 8; -const int column_width = 22; +int const line_width = 70; +int const line_count = 8; +int const column_width = 22; char print_buffer[line_width * line_count]; char temp_buffer[line_width * 8]; diff --git a/Userland/Utilities/chgrp.cpp b/Userland/Utilities/chgrp.cpp index 269b3a8592..6ebe9e548f 100644 --- a/Userland/Utilities/chgrp.cpp +++ b/Userland/Utilities/chgrp.cpp @@ -15,8 +15,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath chown", nullptr)); - const char* gid_arg = nullptr; - const char* path = nullptr; + char const* gid_arg = nullptr; + char const* path = nullptr; bool dont_follow_symlinks = false; Core::ArgsParser args_parser; diff --git a/Userland/Utilities/cksum.cpp b/Userland/Utilities/cksum.cpp index 87807a94a7..d94f96c4f2 100644 --- a/Userland/Utilities/cksum.cpp +++ b/Userland/Utilities/cksum.cpp @@ -13,8 +13,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { - Vector<const char*> paths; - const char* opt_algorithm = nullptr; + Vector<char const*> paths; + char const* opt_algorithm = nullptr; Core::ArgsParser args_parser; args_parser.add_option(opt_algorithm, "Checksum algorithm (default 'crc32', use 'list' to list available algorithms)", "algorithm", '\0', nullptr); diff --git a/Userland/Utilities/comm.cpp b/Userland/Utilities/comm.cpp index 346bbd2e6a..6abe5eedd6 100644 --- a/Userland/Utilities/comm.cpp +++ b/Userland/Utilities/comm.cpp @@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 1; } - auto process_file = [](const String& path, auto& file, int file_number) { + auto process_file = [](String const& path, auto& file, int file_number) { if (path == "-") { file = Core::File::standard_input(); } else { @@ -90,14 +90,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!suppress_col3) col3_fmt = String::formatted("{}{}", String::repeated(tab, tab_count++), print_color ? COL3_COLOR : "{}"); - auto cmp = [&](const String& str1, const String& str2) { + auto cmp = [&](String const& str1, String const& str2) { if (case_insensitive) return strcasecmp(str1.characters(), str2.characters()); else return strcmp(str1.characters(), str2.characters()); }; - auto process_remaining = [](const String& fmt, auto& file, int& count, bool print) { + auto process_remaining = [](String const& fmt, auto& file, int& count, bool print) { while (file->can_read_line()) { ++count; auto line = file->read_line(); diff --git a/Userland/Utilities/copy.cpp b/Userland/Utilities/copy.cpp index dcac098a7d..f5f21cb858 100644 --- a/Userland/Utilities/copy.cpp +++ b/Userland/Utilities/copy.cpp @@ -24,8 +24,8 @@ struct Options { static Options parse_options(Main::Arguments arguments) { - const char* type = "text/plain"; - Vector<const char*> text; + char const* type = "text/plain"; + Vector<char const*> text; bool clear = false; Core::ArgsParser args_parser; diff --git a/Userland/Utilities/cpp-lexer.cpp b/Userland/Utilities/cpp-lexer.cpp index 991214bab1..fbc2f49c38 100644 --- a/Userland/Utilities/cpp-lexer.cpp +++ b/Userland/Utilities/cpp-lexer.cpp @@ -12,7 +12,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { Core::ArgsParser args_parser; - const char* path = nullptr; + char const* path = nullptr; args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::Yes); args_parser.parse(arguments); diff --git a/Userland/Utilities/cpp-parser.cpp b/Userland/Utilities/cpp-parser.cpp index 65f52242ed..f1aee959c7 100644 --- a/Userland/Utilities/cpp-parser.cpp +++ b/Userland/Utilities/cpp-parser.cpp @@ -12,7 +12,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { Core::ArgsParser args_parser; - const char* path = nullptr; + char const* path = nullptr; bool tokens_mode = false; args_parser.add_option(tokens_mode, "Print Tokens", "tokens", 'T'); args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::No); diff --git a/Userland/Utilities/cpp-preprocessor.cpp b/Userland/Utilities/cpp-preprocessor.cpp index 834e80db8c..045aa8c3c7 100644 --- a/Userland/Utilities/cpp-preprocessor.cpp +++ b/Userland/Utilities/cpp-preprocessor.cpp @@ -13,7 +13,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { Core::ArgsParser args_parser; - const char* path = nullptr; + char const* path = nullptr; bool print_definitions = false; args_parser.add_positional_argument(path, "File", "file", Core::ArgsParser::Required::Yes); args_parser.add_option(print_definitions, "Print preprocessor definitions", "definitions", 'D'); diff --git a/Userland/Utilities/cut.cpp b/Userland/Utilities/cut.cpp index 792ae3be20..6d19c9b64c 100644 --- a/Userland/Utilities/cut.cpp +++ b/Userland/Utilities/cut.cpp @@ -17,12 +17,12 @@ struct Range { size_t m_from { 1 }; size_t m_to { SIZE_MAX }; - [[nodiscard]] bool intersects(const Range& other) const + [[nodiscard]] bool intersects(Range const& other) const { return !(other.m_from > m_to || other.m_to < m_from); } - void merge(const Range& other) + void merge(Range const& other) { // Can't merge two ranges that are disjoint. VERIFY(intersects(other)); @@ -120,7 +120,7 @@ static bool expand_list(String& list, Vector<Range>& ranges) return true; } -static void process_line_bytes(char* line, size_t length, const Vector<Range>& ranges) +static void process_line_bytes(char* line, size_t length, Vector<Range> const& ranges) { for (auto& i : ranges) { if (i.m_from >= length) @@ -133,7 +133,7 @@ static void process_line_bytes(char* line, size_t length, const Vector<Range>& r outln(); } -static void process_line_fields(char* line, size_t length, const Vector<Range>& ranges, char delimiter) +static void process_line_fields(char* line, size_t length, Vector<Range> const& ranges, char delimiter) { auto string_split = String(line, length).split(delimiter); Vector<String> output_fields; diff --git a/Userland/Utilities/date.cpp b/Userland/Utilities/date.cpp index a7fdcb8a0d..1573fb1c4e 100644 --- a/Userland/Utilities/date.cpp +++ b/Userland/Utilities/date.cpp @@ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool print_iso_8601 = false; bool print_rfc_3339 = false; bool print_rfc_5322 = false; - const char* set_date = nullptr; + char const* set_date = nullptr; StringView format_string; Core::ArgsParser args_parser; diff --git a/Userland/Utilities/dd.cpp b/Userland/Utilities/dd.cpp index 78b1cc4680..8537027468 100644 --- a/Userland/Utilities/dd.cpp +++ b/Userland/Utilities/dd.cpp @@ -15,7 +15,7 @@ #include <sys/types.h> #include <unistd.h> -const char* usage = "usage:\n" +char const* usage = "usage:\n" "\tdd <options>\n" "options:\n" "\tif=<file>\tinput file (default: stdin)\n" diff --git a/Userland/Utilities/ddate.cpp b/Userland/Utilities/ddate.cpp index c98f8d9019..212285526f 100644 --- a/Userland/Utilities/ddate.cpp +++ b/Userland/Utilities/ddate.cpp @@ -26,8 +26,8 @@ public: m_date = date_from_day_of_yold(day); } - const char* day_of_week() { return m_day_of_week.characters(); }; - const char* season() { return m_season.characters(); }; + char const* day_of_week() { return m_day_of_week.characters(); }; + char const* season() { return m_season.characters(); }; uint16_t year() { return yold(); }; uint16_t yold() { return m_yold; }; uint16_t day_of_year() { return day_of_yold(); }; @@ -57,7 +57,7 @@ private: return (day % m_days_in_season == 0 ? m_days_in_season : day % m_days_in_season); } - const char* day_of_week_from_day_of_yold(uint16_t day) + char const* day_of_week_from_day_of_yold(uint16_t day) { if (is_st_tibs_day()) return nullptr; @@ -78,7 +78,7 @@ private: } } - const char* season_from_day_of_yold(uint16_t day) + char const* season_from_day_of_yold(uint16_t day) { if (is_st_tibs_day()) return nullptr; diff --git a/Userland/Utilities/diff.cpp b/Userland/Utilities/diff.cpp index 51b785fa49..2f4ae8610a 100644 --- a/Userland/Utilities/diff.cpp +++ b/Userland/Utilities/diff.cpp @@ -27,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto file2 = TRY(Core::File::open(filename2, Core::OpenMode::ReadOnly)); auto hunks = Diff::from_text(file1->read_all(), file2->read_all()); - for (const auto& hunk : hunks) { + for (auto const& hunk : hunks) { auto original_start = hunk.original_start_line; auto target_start = hunk.target_start_line; auto num_added = hunk.added_lines.size(); @@ -55,7 +55,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool color_output = isatty(STDOUT_FILENO); outln("Hunk: {}", sb.build()); - for (const auto& line : hunk.removed_lines) { + for (auto const& line : hunk.removed_lines) { if (color_output) outln("\033[31;1m< {}\033[0m", line); else @@ -63,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } if (num_added > 0 && num_removed > 0) outln("---"); - for (const auto& line : hunk.added_lines) { + for (auto const& line : hunk.added_lines) { if (color_output) outln("\033[32;1m> {}\033[0m", line); else diff --git a/Userland/Utilities/disk_benchmark.cpp b/Userland/Utilities/disk_benchmark.cpp index d3dd9f9628..b5e1765fb7 100644 --- a/Userland/Utilities/disk_benchmark.cpp +++ b/Userland/Utilities/disk_benchmark.cpp @@ -24,7 +24,7 @@ struct Result { u64 read_bps {}; }; -static Result average_result(const Vector<Result>& results) +static Result average_result(Vector<Result> const& results) { Result average; @@ -39,7 +39,7 @@ static Result average_result(const Vector<Result>& results) return average; } -static ErrorOr<Result> benchmark(const String& filename, int file_size, ByteBuffer& buffer, bool allow_cache); +static ErrorOr<Result> benchmark(String const& filename, int file_size, ByteBuffer& buffer, bool allow_cache); ErrorOr<int> serenity_main(Main::Arguments arguments) { @@ -99,7 +99,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 0; } -ErrorOr<Result> benchmark(const String& filename, int file_size, ByteBuffer& buffer, bool allow_cache) +ErrorOr<Result> benchmark(String const& filename, int file_size, ByteBuffer& buffer, bool allow_cache) { int flags = O_CREAT | O_TRUNC | O_RDWR; if (!allow_cache) diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp index 34771db5a8..00c039b63d 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -35,7 +35,7 @@ struct DuOption { }; static ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOption& du_option, int& max_depth); -static ErrorOr<off_t> print_space_usage(const String& path, const DuOption& du_option, int max_depth, bool inside_dir = false); +static ErrorOr<off_t> print_space_usage(String const& path, DuOption const& du_option, int max_depth, bool inside_dir = false); ErrorOr<int> serenity_main(Main::Arguments arguments) { @@ -45,7 +45,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(parse_args(arguments, files, du_option, max_depth)); - for (const auto& file : files) + for (auto const& file : files) TRY(print_space_usage(file, du_option, max_depth)); return 0; @@ -54,8 +54,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOption& du_option, int& max_depth) { bool summarize = false; - const char* pattern = nullptr; - const char* exclude_from = nullptr; + char const* pattern = nullptr; + char const* exclude_from = nullptr; Vector<StringView> files_to_process; Core::ArgsParser::Option time_option { @@ -100,7 +100,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOpt du_option.excluded_patterns.append(pattern); if (exclude_from) { auto file = TRY(Core::File::open(exclude_from, Core::OpenMode::ReadOnly)); - const auto buff = file->read_all(); + auto const buff = file->read_all(); if (!buff.is_empty()) { String patterns = String::copy(buff, Chomp); du_option.excluded_patterns.extend(patterns.split('\n')); @@ -118,11 +118,11 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOpt return {}; } -ErrorOr<off_t> print_space_usage(const String& path, const DuOption& du_option, int max_depth, bool inside_dir) +ErrorOr<off_t> print_space_usage(String const& path, DuOption const& du_option, int max_depth, bool inside_dir) { struct stat path_stat = TRY(Core::System::lstat(path.characters())); off_t directory_size = 0; - const bool is_directory = S_ISDIR(path_stat.st_mode); + bool const is_directory = S_ISDIR(path_stat.st_mode); if (--max_depth >= 0 && is_directory) { auto di = Core::DirIterator(path, Core::DirIterator::SkipParentAndBaseDir); if (di.has_error()) { @@ -131,13 +131,13 @@ ErrorOr<off_t> print_space_usage(const String& path, const DuOption& du_option, } while (di.has_next()) { - const auto child_path = di.next_full_path(); + auto const child_path = di.next_full_path(); directory_size += TRY(print_space_usage(child_path, du_option, max_depth, true)); } } - const auto basename = LexicalPath::basename(path); - for (const auto& pattern : du_option.excluded_patterns) { + auto const basename = LexicalPath::basename(path); + for (auto const& pattern : du_option.excluded_patterns) { if (basename.matches(pattern, CaseSensitivity::CaseSensitive)) return { 0 }; } @@ -180,7 +180,7 @@ ErrorOr<off_t> print_space_usage(const String& path, const DuOption& du_option, break; } - const auto formatted_time = Core::DateTime::from_timestamp(time).to_string(); + auto const formatted_time = Core::DateTime::from_timestamp(time).to_string(); outln("\t{}\t{}", formatted_time, path); } diff --git a/Userland/Utilities/echo.cpp b/Userland/Utilities/echo.cpp index 6e8850ba40..b5f37189ba 100644 --- a/Userland/Utilities/echo.cpp +++ b/Userland/Utilities/echo.cpp @@ -101,7 +101,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio")); - Vector<const char*> text; + Vector<char const*> text; bool no_trailing_newline = false; bool should_interpret_backslash_escapes = false; diff --git a/Userland/Utilities/env.cpp b/Userland/Utilities/env.cpp index f73ef75809..95a17888e4 100644 --- a/Userland/Utilities/env.cpp +++ b/Userland/Utilities/env.cpp @@ -17,8 +17,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath exec")); bool ignore_env = false; - const char* split_string = nullptr; - Vector<const char*> values; + char const* split_string = nullptr; + Vector<char const*> values; Core::ArgsParser args_parser; args_parser.set_stop_on_first_non_option(true); @@ -42,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } Vector<String> split_string_storage; - Vector<const char*> new_argv; + Vector<char const*> new_argv; if (split_string) { for (auto view : StringView(split_string).split_view(' ')) { split_string_storage.append(view); @@ -65,7 +65,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) new_argv.append(nullptr); - const char* executable = new_argv[0]; + char const* executable = new_argv[0]; char* const* new_argv_ptr = const_cast<char* const*>(&new_argv[0]); execvp(executable, new_argv_ptr); diff --git a/Userland/Utilities/expr.cpp b/Userland/Utilities/expr.cpp index a16d552f49..2ef9e4e2ba 100644 --- a/Userland/Utilities/expr.cpp +++ b/Userland/Utilities/expr.cpp @@ -388,7 +388,7 @@ private: VERIFY_NOT_REACHED(); } - static auto safe_substring(const String& str, int start, int length) + static auto safe_substring(String const& str, int start, int length) { if (start < 1 || (size_t)start > str.length()) fail("Index out of range"); diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp index b529434ab0..09ebb1a742 100644 --- a/Userland/Utilities/file.cpp +++ b/Userland/Utilities/file.cpp @@ -19,13 +19,13 @@ #include <sys/stat.h> #include <unistd.h> -static Optional<String> description_only(String description, [[maybe_unused]] const String& path) +static Optional<String> description_only(String description, [[maybe_unused]] String const& path) { return description; } // FIXME: Ideally Gfx::ImageDecoder could tell us the image type directly. -static Optional<String> image_details(const String& description, const String& path) +static Optional<String> image_details(String const& description, String const& path) { auto file_or_error = Core::MappedFile::map(path); if (file_or_error.is_error()) @@ -39,7 +39,7 @@ static Optional<String> image_details(const String& description, const String& p return String::formatted("{}, {} x {}", description, image_decoder->width(), image_decoder->height()); } -static Optional<String> gzip_details(String description, const String& path) +static Optional<String> gzip_details(String description, String const& path) { auto file_or_error = Core::MappedFile::map(path); if (file_or_error.is_error()) @@ -56,7 +56,7 @@ static Optional<String> gzip_details(String description, const String& path) return String::formatted("{}, {}", description, gzip_details.value()); } -static Optional<String> elf_details(String description, const String& path) +static Optional<String> elf_details(String description, String const& path) { auto file_or_error = Core::MappedFile::map(path); if (file_or_error.is_error()) @@ -127,7 +127,7 @@ static Optional<String> elf_details(String description, const String& path) __ENUMERATE_MIME_TYPE_DESCRIPTION("text/markdown", "Markdown document", description_only) \ __ENUMERATE_MIME_TYPE_DESCRIPTION("text/x-shellscript", "POSIX shell script text executable", description_only) -static Optional<String> get_description_from_mime_type(const String& mime, const String& path) +static Optional<String> get_description_from_mime_type(String const& mime, String const& path) { #define __ENUMERATE_MIME_TYPE_DESCRIPTION(mime_type, description, details) \ if (String(mime_type) == mime) \ @@ -141,7 +141,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); - Vector<const char*> paths; + Vector<char const*> paths; bool flag_mime_only = false; Core::ArgsParser args_parser; diff --git a/Userland/Utilities/find.cpp b/Userland/Utilities/find.cpp index aee5d9544c..5e45359228 100644 --- a/Userland/Utilities/find.cpp +++ b/Userland/Utilities/find.cpp @@ -44,7 +44,7 @@ struct FileData { // The parent directory of the file. int dirfd { -1 }; // The file's basename, relative to the directory. - const char* basename { nullptr }; + char const* basename { nullptr }; // Optionally, cached information as returned by stat/lstat/fstatat. struct stat stat { }; @@ -110,7 +110,7 @@ private: class TypeCommand final : public Command { public: - TypeCommand(const char* arg) + TypeCommand(char const* arg) { StringView type = arg; if (type.length() != 1 || !StringView("bcdlpfs").contains(type[0])) @@ -155,7 +155,7 @@ private: class LinksCommand final : public StatCommand { public: - LinksCommand(const char* arg) + LinksCommand(char const* arg) { auto number = StringView(arg).to_uint(); if (!number.has_value()) @@ -174,7 +174,7 @@ private: class UserCommand final : public StatCommand { public: - UserCommand(const char* arg) + UserCommand(char const* arg) { if (struct passwd* passwd = getpwnam(arg)) { m_uid = passwd->pw_uid; @@ -198,7 +198,7 @@ private: class GroupCommand final : public StatCommand { public: - GroupCommand(const char* arg) + GroupCommand(char const* arg) { if (struct group* gr = getgrnam(arg)) { m_gid = gr->gr_gid; @@ -222,7 +222,7 @@ private: class SizeCommand final : public StatCommand { public: - SizeCommand(const char* arg) + SizeCommand(char const* arg) { StringView view = arg; if (view.ends_with('c')) { @@ -251,7 +251,7 @@ private: class NameCommand : public Command { public: - NameCommand(const char* pattern, CaseSensitivity case_sensitivity) + NameCommand(char const* pattern, CaseSensitivity case_sensitivity) : m_pattern(pattern) , m_case_sensitivity(case_sensitivity) { diff --git a/Userland/Utilities/fortune.cpp b/Userland/Utilities/fortune.cpp index 324ec17874..9f5f413f9a 100644 --- a/Userland/Utilities/fortune.cpp +++ b/Userland/Utilities/fortune.cpp @@ -21,7 +21,7 @@ class Quote { public: - static Optional<Quote> try_parse(const JsonValue& value) + static Optional<Quote> try_parse(JsonValue const& value) { if (!value.is_object()) return {}; @@ -41,11 +41,11 @@ public: return q; } - const String& quote() const { return m_quote; } - const String& author() const { return m_author; } - const u64& utc_time() const { return m_utc_time; } - const String& url() const { return m_url; } - const Optional<String>& context() const { return m_context; } + String const& quote() const { return m_quote; } + String const& author() const { return m_author; } + u64 const& utc_time() const { return m_utc_time; } + String const& url() const { return m_url; } + Optional<String> const& context() const { return m_context; } private: Quote() = default; @@ -57,7 +57,7 @@ private: Optional<String> m_context; }; -static Vector<Quote> parse_all(const JsonArray& array) +static Vector<Quote> parse_all(JsonArray const& array) { Vector<Quote> quotes; for (size_t i = 0; i < array.size(); ++i) { @@ -75,7 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); - const char* path = "/res/fortunes.json"; + char const* path = "/res/fortunes.json"; Core::ArgsParser args_parser; args_parser.set_general_help("Open a fortune cookie, receive a free quote for the day!"); @@ -94,14 +94,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 1; } - const auto quotes = parse_all(json.as_array()); + auto const quotes = parse_all(json.as_array()); if (quotes.is_empty()) { warnln("{} does not contain any valid quotes", path); return 1; } u32 i = get_random_uniform(quotes.size()); - const auto& chosen_quote = quotes[i]; + auto const& chosen_quote = quotes[i]; auto datetime = Core::DateTime::from_timestamp(chosen_quote.utc_time()); outln(); // Tasteful spacing diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp index f082b866ad..6bfc19d081 100644 --- a/Userland/Utilities/functrace.cpp +++ b/Userland/Utilities/functrace.cpp @@ -71,7 +71,7 @@ static void print_syscall(PtraceRegisters& regs, size_t depth) static NonnullOwnPtr<HashMap<FlatPtr, X86::Instruction>> instrument_code() { auto instrumented = make<HashMap<FlatPtr, X86::Instruction>>(); - g_debug_session->for_each_loaded_library([&](const Debug::LoadedLibrary& lib) { + g_debug_session->for_each_loaded_library([&](Debug::LoadedLibrary const& lib) { lib.debug_info->elf().for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) { if (section.name() != ".text") return IterationDecision::Continue; diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp index f278f290a1..d764d823cb 100644 --- a/Userland/Utilities/gml-format.cpp +++ b/Userland/Utilities/gml-format.cpp @@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) #endif bool inplace = false; - Vector<const char*> files; + Vector<char const*> files; Core::ArgsParser args_parser; args_parser.set_general_help("Format GML files."); diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index dc8d971c7b..e0ae1fcb46 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -39,11 +39,11 @@ ErrorOr<int> serenity_main(Main::Arguments args) String program_name = AK::LexicalPath::basename(args.strings[0]); - Vector<const char*> files; + Vector<char const*> files; bool recursive = (program_name == "rgrep"sv); bool use_ere = (program_name == "egrep"sv); - Vector<const char*> patterns; + Vector<char const*> patterns; BinaryFileMode binary_mode { BinaryFileMode::Binary }; bool case_insensitive = false; bool line_numbers = false; diff --git a/Userland/Utilities/groups.cpp b/Userland/Utilities/groups.cpp index b995726793..f67041a694 100644 --- a/Userland/Utilities/groups.cpp +++ b/Userland/Utilities/groups.cpp @@ -12,7 +12,7 @@ #include <grp.h> #include <unistd.h> -static void print_account_gids(const Core::Account& account) +static void print_account_gids(Core::Account const& account) { auto* gr = getgrgid(account.gid()); if (!gr) { @@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::pledge("stdio rpath", nullptr)); - Vector<const char*> usernames; + Vector<char const*> usernames; Core::ArgsParser args_parser; args_parser.set_general_help("Print group memberships for each username or, if no username is specified, for the current process."); diff --git a/Userland/Utilities/gunzip.cpp b/Userland/Utilities/gunzip.cpp index cd8879577a..4026c74bcf 100644 --- a/Userland/Utilities/gunzip.cpp +++ b/Userland/Utilities/gunzip.cpp @@ -18,7 +18,7 @@ static bool decompress_file(Buffered<Core::InputFileStream>& input_stream, Buffe u8 buffer[4096]; while (!gzip_stream.has_any_error() && !gzip_stream.unreliable_eof()) { - const auto nread = gzip_stream.read({ buffer, sizeof(buffer) }); + auto const nread = gzip_stream.read({ buffer, sizeof(buffer) }); output_stream.write_or_error({ buffer, nread }); } diff --git a/Userland/Utilities/head.cpp b/Userland/Utilities/head.cpp index a230652398..35163e202b 100644 --- a/Userland/Utilities/head.cpp +++ b/Userland/Utilities/head.cpp @@ -14,7 +14,7 @@ #include <string.h> #include <unistd.h> -int head(const String& filename, bool print_filename, ssize_t line_count, ssize_t byte_count); +int head(String const& filename, bool print_filename, ssize_t line_count, ssize_t byte_count); ErrorOr<int> serenity_main(Main::Arguments args) { @@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) int byte_count = -1; bool never_print_filenames = false; bool always_print_filenames = false; - Vector<const char*> files; + Vector<char const*> files; Core::ArgsParser args_parser; args_parser.set_general_help("Print the beginning ('head') of a file."); @@ -60,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) return rc; } -int head(const String& filename, bool print_filename, ssize_t line_count, ssize_t byte_count) +int head(String const& filename, bool print_filename, ssize_t line_count, ssize_t byte_count) { bool is_stdin = false; int fd = -1; @@ -114,7 +114,7 @@ int head(const String& filename, bool print_filename, ssize_t line_count, ssize_ // Count line breaks. ntowrite = 0; while (line_count) { - const char* newline = strchr(buffer + ntowrite, '\n'); + char const* newline = strchr(buffer + ntowrite, '\n'); if (newline) { // Found another line break, include this line. ntowrite = newline - buffer + 1; diff --git a/Userland/Utilities/hexdump.cpp b/Userland/Utilities/hexdump.cpp index 8e53001bea..89cf83fc79 100644 --- a/Userland/Utilities/hexdump.cpp +++ b/Userland/Utilities/hexdump.cpp @@ -22,7 +22,7 @@ enum class State { ErrorOr<int> serenity_main(Main::Arguments args) { Core::ArgsParser args_parser; - const char* path = nullptr; + char const* path = nullptr; bool verbose = false; args_parser.add_positional_argument(path, "Input", "input", Core::ArgsParser::Required::No); args_parser.add_option(verbose, "Display all input data", "verbose", 'v'); diff --git a/Userland/Utilities/host.cpp b/Userland/Utilities/host.cpp index 8ff389d103..959dee48dc 100644 --- a/Userland/Utilities/host.cpp +++ b/Userland/Utilities/host.cpp @@ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) { TRY(Core::System::pledge("stdio unix", nullptr)); - const char* name_or_ip = nullptr; + char const* name_or_ip = nullptr; Core::ArgsParser args_parser; args_parser.set_general_help("Convert between domain name and IPv4 address."); args_parser.add_positional_argument(name_or_ip, "Domain name or IPv4 address", "name"); @@ -46,7 +46,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) } char buffer[INET_ADDRSTRLEN]; - const char* ip_str = inet_ntop(AF_INET, hostent->h_addr_list[0], buffer, sizeof(buffer)); + char const* ip_str = inet_ntop(AF_INET, hostent->h_addr_list[0], buffer, sizeof(buffer)); outln("{} is {}", name_or_ip, ip_str); return 0; diff --git a/Userland/Utilities/hostname.cpp b/Userland/Utilities/hostname.cpp index b99713638f..3275604115 100644 --- a/Userland/Utilities/hostname.cpp +++ b/Userland/Utilities/hostname.cpp @@ -14,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments args) { - const char* hostname = nullptr; + char const* hostname = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(hostname, "Hostname to set", "hostname", Core::ArgsParser::Required::No); diff --git a/Userland/Utilities/ifconfig.cpp b/Userland/Utilities/ifconfig.cpp index 64bfaad74e..6fb108460a 100644 --- a/Userland/Utilities/ifconfig.cpp +++ b/Userland/Utilities/ifconfig.cpp @@ -25,10 +25,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { - const char* value_ipv4 = nullptr; - const char* value_adapter = nullptr; - const char* value_gateway = nullptr; - const char* value_mask = nullptr; + char const* value_ipv4 = nullptr; + char const* value_adapter = nullptr; + char const* value_gateway = nullptr; + char const* value_mask = nullptr; Core::ArgsParser args_parser; args_parser.set_general_help("Display or modify the configuration of each network interface."); diff --git a/Userland/Utilities/ini.cpp b/Userland/Utilities/ini.cpp index 6c47f258fe..ae152a83fc 100644 --- a/Userland/Utilities/ini.cpp +++ b/Userland/Utilities/ini.cpp @@ -14,10 +14,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath wpath cpath")); - const char* path = nullptr; - const char* group = nullptr; - const char* key = nullptr; - const char* value_to_write = nullptr; + char const* path = nullptr; + char const* group = nullptr; + char const* key = nullptr; + char const* value_to_write = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(path, "Path to INI file", "path"); diff --git a/Userland/Utilities/jp.cpp b/Userland/Utilities/jp.cpp index 1523e01254..43584e8a03 100644 --- a/Userland/Utilities/jp.cpp +++ b/Userland/Utilities/jp.cpp @@ -15,7 +15,7 @@ #include <LibMain/Main.h> #include <unistd.h> -static void print(const JsonValue& value, int spaces_per_indent, int indent = 0, bool use_color = true); +static void print(JsonValue const& value, int spaces_per_indent, int indent = 0, bool use_color = true); static void print_indent(int indent, int spaces_per_indent) { for (int i = 0; i < indent * spaces_per_indent; ++i) @@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 0; } -void print(const JsonValue& value, int spaces_per_indent, int indent, bool use_color) +void print(JsonValue const& value, int spaces_per_indent, int indent, bool use_color) { if (value.is_object()) { size_t printed_members = 0; diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 25423b4641..961b6e5449 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -229,7 +229,7 @@ static String strip_ansi(StringView format_string) } template<typename... Parameters> -static void js_out(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) +static void js_out(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { if (!s_strip_ansi) return out(move(fmtstr), parameters...); @@ -238,7 +238,7 @@ static void js_out(CheckedFormatString<Parameters...>&& fmtstr, const Parameters } template<typename... Parameters> -static void js_outln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) +static void js_outln(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { if (!s_strip_ansi) return outln(move(fmtstr), parameters...); diff --git a/Userland/Utilities/killall.cpp b/Userland/Utilities/killall.cpp index af9b5209b0..fe1628ce1d 100644 --- a/Userland/Utilities/killall.cpp +++ b/Userland/Utilities/killall.cpp @@ -19,7 +19,7 @@ static void print_usage_and_exit() exit(1); } -static ErrorOr<int> kill_all(const String& process_name, const unsigned signum) +static ErrorOr<int> kill_all(String const& process_name, unsigned const signum) { auto all_processes = Core::ProcessStatisticsReader::get_all(); if (!all_processes.has_value()) diff --git a/Userland/Utilities/less.cpp b/Userland/Utilities/less.cpp index b526116eca..de7fef050b 100644 --- a/Userland/Utilities/less.cpp +++ b/Userland/Utilities/less.cpp @@ -587,7 +587,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) continue; } - const auto& sequence = sequence_value.value(); + auto const& sequence = sequence_value.value(); if (sequence.to_uint().has_value()) { modifier_buffer.append(sequence); diff --git a/Userland/Utilities/ln.cpp b/Userland/Utilities/ln.cpp index 6fa20fdace..b79cf44692 100644 --- a/Userland/Utilities/ln.cpp +++ b/Userland/Utilities/ln.cpp @@ -16,8 +16,8 @@ ErrorOr<int> serenity_main(Main::Arguments argmuments) bool force = false; bool symbolic = false; - const char* target = nullptr; - const char* path = nullptr; + char const* target = nullptr; + char const* path = nullptr; Core::ArgsParser args_parser; args_parser.add_option(force, "Force the creation", "force", 'f'); diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index 99fa387479..793414cb71 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -42,10 +42,10 @@ struct FileMetadata { }; }; -static int do_file_system_object_long(const char* path); -static int do_file_system_object_short(const char* path); +static int do_file_system_object_long(char const* path); +static int do_file_system_object_short(char const* path); -static bool print_names(const char* path, size_t longest_name, const Vector<FileMetadata>& files); +static bool print_names(char const* path, size_t longest_name, Vector<FileMetadata> const& files); static bool filemetadata_comparator(FileMetadata& a, FileMetadata& b); @@ -136,7 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) endgrent(); } - auto do_file_system_object = [&](const char* path) { + auto do_file_system_object = [&](char const* path) { if (flag_long) return do_file_system_object_long(path); return do_file_system_object_short(path); @@ -235,7 +235,7 @@ static String& hostname() return s_hostname; } -static size_t print_name(const struct stat& st, const String& name, const char* path_for_link_resolution, const char* path_for_hyperlink) +static size_t print_name(const struct stat& st, String const& name, char const* path_for_link_resolution, char const* path_for_hyperlink) { if (!flag_disable_hyperlinks) { auto full_path = Core::File::real_path_for(path_for_hyperlink); @@ -250,8 +250,8 @@ static size_t print_name(const struct stat& st, const String& name, const char* if (!flag_colorize || !output_is_terminal) { nprinted = printf("%s", name.characters()); } else { - const char* begin_color = ""; - const char* end_color = "\033[0m"; + char const* begin_color = ""; + char const* end_color = "\033[0m"; if (st.st_mode & S_ISVTX) begin_color = "\033[42;30;1m"; @@ -300,7 +300,7 @@ static size_t print_name(const struct stat& st, const String& name, const char* return nprinted; } -static bool print_filesystem_object(const String& path, const String& name, const struct stat& st) +static bool print_filesystem_object(String const& path, String const& name, const struct stat& st) { if (flag_show_inode) printf("%s ", String::formatted("{}", st.st_ino).characters()); @@ -373,7 +373,7 @@ static bool print_filesystem_object(const String& path, const String& name, cons return true; } -static int do_file_system_object_long(const char* path) +static int do_file_system_object_long(char const* path) { if (flag_list_directories_only) { struct stat stat { @@ -440,7 +440,7 @@ static int do_file_system_object_long(const char* path) return 0; } -static bool print_filesystem_object_short(const char* path, const char* name, size_t* nprinted) +static bool print_filesystem_object_short(char const* path, char const* name, size_t* nprinted) { struct stat st; int rc = lstat(path, &st); @@ -456,7 +456,7 @@ static bool print_filesystem_object_short(const char* path, const char* name, si return true; } -static bool print_names(const char* path, size_t longest_name, const Vector<FileMetadata>& files) +static bool print_names(char const* path, size_t longest_name, Vector<FileMetadata> const& files) { size_t printed_on_row = 0; size_t nprinted = 0; @@ -490,7 +490,7 @@ static bool print_names(const char* path, size_t longest_name, const Vector<File return printed_on_row; } -int do_file_system_object_short(const char* path) +int do_file_system_object_short(char const* path) { if (flag_list_directories_only) { size_t nprinted = 0; diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index 1d093c66f5..396ea9eeea 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -80,7 +80,7 @@ static Vector<OpenFile> get_open_files_by_pid(pid_t pid) auto json = json_or_error.release_value(); Vector<OpenFile> files; - json.as_array().for_each([pid, &files](const JsonValue& object) { + json.as_array().for_each([pid, &files](JsonValue const& object) { OpenFile open_file; open_file.pid = pid; open_file.fd = object.as_object().get("fd").to_int(); @@ -94,7 +94,7 @@ static Vector<OpenFile> get_open_files_by_pid(pid_t pid) return files; } -static void display_entry(const OpenFile& file, const Core::ProcessStatistics& statistics) +static void display_entry(OpenFile const& file, Core::ProcessStatistics const& statistics) { outln("{:28} {:>4} {:>4} {:10} {:>4} {}", statistics.name, file.pid, statistics.pgid, statistics.username, file.fd, file.full_name); } diff --git a/Userland/Utilities/man.cpp b/Userland/Utilities/man.cpp index c56ff45c11..547314f906 100644 --- a/Userland/Utilities/man.cpp +++ b/Userland/Utilities/man.cpp @@ -59,9 +59,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/bin", "x")); TRY(Core::System::unveil(nullptr, nullptr)); - const char* section = nullptr; - const char* name = nullptr; - const char* pager = nullptr; + char const* section = nullptr; + char const* name = nullptr; + char const* pager = nullptr; Core::ArgsParser args_parser; args_parser.set_general_help("Read manual pages. Try 'man man' to get started."); @@ -70,11 +70,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(pager, "Pager to pipe the man page to", "pager", 'P', "pager"); args_parser.parse(arguments); - auto make_path = [name](const char* section) { + auto make_path = [name](char const* section) { return String::formatted("/usr/share/man/man{}/{}.md", section, name); }; if (!section) { - const char* sections[] = { + char const* sections[] = { "1", "2", "3", diff --git a/Userland/Utilities/md.cpp b/Userland/Utilities/md.cpp index b40c6d88f8..87dd3cb887 100644 --- a/Userland/Utilities/md.cpp +++ b/Userland/Utilities/md.cpp @@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath tty")); - const char* filename = nullptr; + char const* filename = nullptr; bool html = false; int view_width = 0; diff --git a/Userland/Utilities/mkdir.cpp b/Userland/Utilities/mkdir.cpp index 156fd1b2ca..5ba85d498c 100644 --- a/Userland/Utilities/mkdir.cpp +++ b/Userland/Utilities/mkdir.cpp @@ -22,7 +22,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool create_parents = false; String mode_string; - Vector<const char*> directories; + Vector<char const*> directories; Core::ArgsParser args_parser; args_parser.add_option(create_parents, "Create parent directories if they don't exist", "parents", 'p'); diff --git a/Userland/Utilities/mktemp.cpp b/Userland/Utilities/mktemp.cpp index 2ff833f8d3..f79d68131b 100644 --- a/Userland/Utilities/mktemp.cpp +++ b/Userland/Utilities/mktemp.cpp @@ -76,7 +76,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) target_directory = getcwd(nullptr, 0); } else { LexicalPath template_path(file_template); - const char* env_directory = getenv("TMPDIR"); + char const* env_directory = getenv("TMPDIR"); target_directory = env_directory && *env_directory ? env_directory : "/tmp"; } } diff --git a/Userland/Utilities/mv.cpp b/Userland/Utilities/mv.cpp index ba103665c8..23e374fa85 100644 --- a/Userland/Utilities/mv.cpp +++ b/Userland/Utilities/mv.cpp @@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool force = false; bool verbose = false; - Vector<const char*> paths; + Vector<char const*> paths; Core::ArgsParser args_parser; args_parser.add_option(force, "Force", "force", 'f'); @@ -57,7 +57,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) for (auto& old_path : paths) { String combined_new_path; - const char* new_path = original_new_path; + char const* new_path = original_new_path; if (S_ISDIR(st.st_mode)) { auto old_basename = LexicalPath::basename(old_path); combined_new_path = String::formatted("{}/{}", original_new_path, old_basename); diff --git a/Userland/Utilities/nc.cpp b/Userland/Utilities/nc.cpp index 09efa7f4cc..8d11fd61e7 100644 --- a/Userland/Utilities/nc.cpp +++ b/Userland/Utilities/nc.cpp @@ -50,7 +50,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool verbose = false; bool should_close = false; bool udp_mode = false; - const char* target = nullptr; + char const* target = nullptr; int port = 0; int maximum_tcp_receive_buffer_size_input = -1; @@ -135,7 +135,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) sockaddr_in dst_addr {}; dst_addr.sin_family = AF_INET; dst_addr.sin_port = htons(port); - dst_addr.sin_addr.s_addr = *(const in_addr_t*)hostent->h_addr_list[0]; + dst_addr.sin_addr.s_addr = *(in_addr_t const*)hostent->h_addr_list[0]; if (verbose) { char addr_str[INET_ADDRSTRLEN]; diff --git a/Userland/Utilities/nl.cpp b/Userland/Utilities/nl.cpp index 28d080fdac..63787c8511 100644 --- a/Userland/Utilities/nl.cpp +++ b/Userland/Utilities/nl.cpp @@ -22,10 +22,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { NumberStyle number_style = NumberNonEmptyLines; int increment = 1; - const char* separator = " "; + char const* separator = " "; int start_number = 1; int number_width = 6; - Vector<const char*> files; + Vector<char const*> files; Core::ArgsParser args_parser; @@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) "body-numbering", 'b', "style", - [&number_style](const char* s) { + [&number_style](char const* s) { if (!strcmp(s, "t")) number_style = NumberNonEmptyLines; else if (!strcmp(s, "a")) diff --git a/Userland/Utilities/notify.cpp b/Userland/Utilities/notify.cpp index 62b7845882..f889c67990 100644 --- a/Userland/Utilities/notify.cpp +++ b/Userland/Utilities/notify.cpp @@ -15,9 +15,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); Core::ArgsParser args_parser; - const char* title = nullptr; - const char* message = nullptr; - const char* icon_path = nullptr; + char const* title = nullptr; + char const* message = nullptr; + char const* icon_path = nullptr; args_parser.add_positional_argument(title, "Title of the notification", "title"); args_parser.add_positional_argument(message, "Message to display in the notification", "message"); args_parser.add_positional_argument(icon_path, "Path of icon to display in the notification", "icon-path", Core::ArgsParser::Required::No); diff --git a/Userland/Utilities/ntpquery.cpp b/Userland/Utilities/ntpquery.cpp index 26dce2a1a2..c02e0187f6 100644 --- a/Userland/Utilities/ntpquery.cpp +++ b/Userland/Utilities/ntpquery.cpp @@ -53,9 +53,9 @@ static_assert(AssertSize<NtpPacket, 48>()); // NTP measures time in seconds since 1900-01-01, POSIX in seconds since 1970-01-01. // 1900 wasn't a leap year, so there are 70/4 leap years between 1900 and 1970. // Overflows a 32-bit signed int, but not a 32-bit unsigned int. -const unsigned SecondsFrom1900To1970 = (70u * 365u + 70u / 4u) * 24u * 60u * 60u; +unsigned const SecondsFrom1900To1970 = (70u * 365u + 70u / 4u) * 24u * 60u * 60u; -static NtpTimestamp ntp_timestamp_from_timeval(const timeval& t) +static NtpTimestamp ntp_timestamp_from_timeval(timeval const& t) { VERIFY(t.tv_usec >= 0 && t.tv_usec < 1'000'000); // Fits in 20 bits when normalized. @@ -68,7 +68,7 @@ static NtpTimestamp ntp_timestamp_from_timeval(const timeval& t) return (static_cast<NtpTimestamp>(seconds) << 32) | fractional_bits; } -static timeval timeval_from_ntp_timestamp(const NtpTimestamp& ntp_timestamp) +static timeval timeval_from_ntp_timestamp(NtpTimestamp const& ntp_timestamp) { timeval t; t.tv_sec = static_cast<time_t>(ntp_timestamp >> 32) - SecondsFrom1900To1970; @@ -113,7 +113,7 @@ int main(int argc, char** argv) // Leap seconds smearing NTP servers: // - time.facebook.com , https://engineering.fb.com/production-engineering/ntp-service/ , sine-smears over 18 hours // - time.google.com , https://developers.google.com/time/smear , linear-smears over 24 hours - const char* host = "time.google.com"; + char const* host = "time.google.com"; Core::ArgsParser args_parser; args_parser.add_option(adjust_time, "Gradually adjust system time (requires root)", "adjust", 'a'); args_parser.add_option(set_time, "Immediately set system time (requires root)", "set", 's'); @@ -171,7 +171,7 @@ int main(int argc, char** argv) memset(&peer_address, 0, sizeof(peer_address)); peer_address.sin_family = AF_INET; peer_address.sin_port = htons(123); - peer_address.sin_addr.s_addr = *(const in_addr_t*)hostent->h_addr_list[0]; + peer_address.sin_addr.s_addr = *(in_addr_t const*)hostent->h_addr_list[0]; NtpPacket packet; memset(&packet, 0, sizeof(packet)); diff --git a/Userland/Utilities/passwd.cpp b/Userland/Utilities/passwd.cpp index f186982069..339d489af1 100644 --- a/Userland/Utilities/passwd.cpp +++ b/Userland/Utilities/passwd.cpp @@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool del = false; bool lock = false; bool unlock = false; - const char* username = nullptr; + char const* username = nullptr; auto args_parser = Core::ArgsParser(); args_parser.set_general_help("Modify an account password."); diff --git a/Userland/Utilities/paste.cpp b/Userland/Utilities/paste.cpp index 28e03453a2..910dc34a52 100644 --- a/Userland/Utilities/paste.cpp +++ b/Userland/Utilities/paste.cpp @@ -18,7 +18,7 @@ #include <sys/wait.h> #include <unistd.h> -static void spawn_command(const Vector<const char*>& command, const ByteBuffer& data, const char* state) +static void spawn_command(Vector<char const*> const& command, ByteBuffer const& data, char const* state) { auto pipefd = MUST(Core::System::pipe2(0)); pid_t pid = MUST(Core::System::fork()); @@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool print_type = false; bool no_newline = false; bool watch = false; - Vector<const char*> watch_command; + Vector<char const*> watch_command; Core::ArgsParser args_parser; args_parser.set_general_help("Paste from the clipboard to stdout."); @@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (watch) { watch_command.append(nullptr); - clipboard.on_change = [&](const String&) { + clipboard.on_change = [&](String const&) { // Technically there's a race here... auto data_and_type = clipboard.fetch_data_and_type(); if (data_and_type.mime_type.is_null()) { diff --git a/Userland/Utilities/pathchk.cpp b/Userland/Utilities/pathchk.cpp index b3d37227ed..aeb1594dc1 100644 --- a/Userland/Utilities/pathchk.cpp +++ b/Userland/Utilities/pathchk.cpp @@ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) static bool flag_most_posix = false; static bool flag_portability = false; static bool flag_empty_name_and_leading_dash = false; - Vector<const char*> paths; + Vector<char const*> paths; Core::ArgsParser args_parser; args_parser.add_option(flag_most_posix, "Check for most POSIX systems", nullptr, 'p'); diff --git a/Userland/Utilities/pidof.cpp b/Userland/Utilities/pidof.cpp index 357eede7ff..b4c83d39e9 100644 --- a/Userland/Utilities/pidof.cpp +++ b/Userland/Utilities/pidof.cpp @@ -14,7 +14,7 @@ #include <string.h> #include <unistd.h> -static ErrorOr<int> pid_of(const String& process_name, bool single_shot, bool omit_pid, pid_t pid) +static ErrorOr<int> pid_of(String const& process_name, bool single_shot, bool omit_pid, pid_t pid) { bool displayed_at_least_one = false; @@ -48,8 +48,8 @@ ErrorOr<int> serenity_main(Main::Arguments args) TRY(Core::System::unveil(nullptr, nullptr)); bool single_shot = false; - const char* omit_pid_value = nullptr; - const char* process_name = nullptr; + char const* omit_pid_value = nullptr; + char const* process_name = nullptr; Core::ArgsParser args_parser; args_parser.add_option(single_shot, "Only return one pid", nullptr, 's'); diff --git a/Userland/Utilities/ping.cpp b/Userland/Utilities/ping.cpp index 9d2ad1ea6b..cb5796d788 100644 --- a/Userland/Utilities/ping.cpp +++ b/Userland/Utilities/ping.cpp @@ -30,7 +30,7 @@ static Optional<size_t> count; static uint32_t total_ms; static int min_ms; static int max_ms; -static const char* host; +static char const* host; static int payload_size = -1; // variable part of header can be 0 to 40 bytes // https://datatracker.ietf.org/doc/html/rfc791#section-3.1 @@ -101,7 +101,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) sockaddr_in peer_address {}; peer_address.sin_family = AF_INET; peer_address.sin_port = 0; - peer_address.sin_addr.s_addr = *(const in_addr_t*)hostent->h_addr_list[0]; + peer_address.sin_addr.s_addr = *(in_addr_t const*)hostent->h_addr_list[0]; uint16_t seq = 1; diff --git a/Userland/Utilities/pmap.cpp b/Userland/Utilities/pmap.cpp index 7d465d0fd9..f2ec9cb47e 100644 --- a/Userland/Utilities/pmap.cpp +++ b/Userland/Utilities/pmap.cpp @@ -18,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/proc", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - const char* pid; + char const* pid; static bool extended = false; Core::ArgsParser args_parser; diff --git a/Userland/Utilities/printf.cpp b/Userland/Utilities/printf.cpp index fe7a9b7f27..ec1bbf9098 100644 --- a/Userland/Utilities/printf.cpp +++ b/Userland/Utilities/printf.cpp @@ -13,7 +13,7 @@ #include <stdio.h> #include <unistd.h> -[[gnu::noreturn]] static void fail(const char* message) +[[gnu::noreturn]] static void fail(char const* message) { fputs("\e[31m", stderr); fputs(message, stderr); @@ -23,15 +23,15 @@ template<typename PutChFunc, typename ArgumentListRefT, template<typename T, typename U = ArgumentListRefT> typename NextArgument, typename CharType> requires(IsSame<CharType, char>) struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument, CharType> { - ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, const int& nwritten) + ALWAYS_INLINE PrintfImpl(PutChFunc& putch, char*& bufptr, int const& nwritten) : PrintfImplementation::PrintfImpl<PutChFunc, ArgumentListRefT, NextArgument>(putch, bufptr, nwritten) { } - ALWAYS_INLINE int format_q(const PrintfImplementation::ModifierState& state, ArgumentListRefT& ap) const + ALWAYS_INLINE int format_q(PrintfImplementation::ModifierState const& state, ArgumentListRefT& ap) const { auto state_copy = state; - auto str = NextArgument<const char*>()(ap); + auto str = NextArgument<char const*>()(ap); if (!str) str = "(null)"; @@ -106,8 +106,8 @@ struct ArgvNextArgument<char*, V> { }; template<typename V> -struct ArgvNextArgument<const char*, V> { - ALWAYS_INLINE const char* operator()(V arg) const +struct ArgvNextArgument<char const*, V> { + ALWAYS_INLINE char const* operator()(V arg) const { if (arg.argc == 0) return ""; @@ -119,8 +119,8 @@ struct ArgvNextArgument<const char*, V> { }; template<typename V> -struct ArgvNextArgument<const wchar_t*, V> { - ALWAYS_INLINE const wchar_t* operator()(V arg) const +struct ArgvNextArgument<wchar_t const*, V> { + ALWAYS_INLINE wchar_t const* operator()(V arg) const { if (arg.argc == 0) return L""; @@ -208,7 +208,7 @@ struct ArgvWithCount { int& argc; }; -static String handle_escapes(const char* string) +static String handle_escapes(char const* string) { StringBuilder builder; for (auto c = *string; c; c = *++string) { diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index 0463ad26f2..d68a8ba950 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -147,10 +147,10 @@ private: ErrorOr<int> serenity_main(Main::Arguments arguments) { - const char* url_str = nullptr; + char const* url_str = nullptr; bool save_at_provided_name = false; bool should_follow_url = false; - const char* data = nullptr; + char const* data = nullptr; String method = "GET"; HashMap<String, String, CaseInsensitiveStringTraits> request_headers; diff --git a/Userland/Utilities/profile.cpp b/Userland/Utilities/profile.cpp index 5756d78cd2..35fafcbcca 100644 --- a/Userland/Utilities/profile.cpp +++ b/Userland/Utilities/profile.cpp @@ -15,8 +15,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { Core::ArgsParser args_parser; - const char* pid_argument = nullptr; - const char* cmd_argument = nullptr; + char const* pid_argument = nullptr; + char const* cmd_argument = nullptr; bool wait = false; bool free = false; bool enable = false; @@ -108,7 +108,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } auto cmd_parts = String(cmd_argument).split(' '); - Vector<const char*> cmd_argv; + Vector<char const*> cmd_argv; for (auto& part : cmd_parts) cmd_argv.append(part.characters()); diff --git a/Userland/Utilities/readelf.cpp b/Userland/Utilities/readelf.cpp index dc459b564e..09e2bab33f 100644 --- a/Userland/Utilities/readelf.cpp +++ b/Userland/Utilities/readelf.cpp @@ -21,7 +21,7 @@ #include <stdio.h> #include <unistd.h> -static const char* object_program_header_type_to_string(ElfW(Word) type) +static char const* object_program_header_type_to_string(ElfW(Word) type) { switch (type) { case PT_NULL: @@ -65,7 +65,7 @@ static const char* object_program_header_type_to_string(ElfW(Word) type) } } -static const char* object_section_header_type_to_string(ElfW(Word) type) +static char const* object_section_header_type_to_string(ElfW(Word) type) { switch (type) { case SHT_NULL: @@ -137,7 +137,7 @@ static const char* object_section_header_type_to_string(ElfW(Word) type) } } -static const char* object_symbol_type_to_string(ElfW(Word) type) +static char const* object_symbol_type_to_string(ElfW(Word) type) { switch (type) { case STT_NOTYPE: @@ -161,7 +161,7 @@ static const char* object_symbol_type_to_string(ElfW(Word) type) } } -static const char* object_symbol_binding_to_string(ElfW(Word) type) +static char const* object_symbol_binding_to_string(ElfW(Word) type) { switch (type) { case STB_LOCAL: @@ -181,7 +181,7 @@ static const char* object_symbol_binding_to_string(ElfW(Word) type) } } -static const char* object_relocation_type_to_string(ElfW(Word) type) +static char const* object_relocation_type_to_string(ElfW(Word) type) { switch (type) { #if ARCH(I386) @@ -230,7 +230,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); - const char* path; + char const* path; static bool display_all = false; static bool display_elf_header = false; static bool display_program_headers = false; diff --git a/Userland/Utilities/realpath.cpp b/Userland/Utilities/realpath.cpp index bd5bbb54d7..69aa968f15 100644 --- a/Userland/Utilities/realpath.cpp +++ b/Userland/Utilities/realpath.cpp @@ -14,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); - const char* path; + char const* path; Core::ArgsParser args_parser; args_parser.set_general_help( diff --git a/Userland/Utilities/rmdir.cpp b/Userland/Utilities/rmdir.cpp index bafad35fd9..fbdd929889 100644 --- a/Userland/Utilities/rmdir.cpp +++ b/Userland/Utilities/rmdir.cpp @@ -15,7 +15,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio cpath")); - Vector<const char*> paths; + Vector<char const*> paths; Core::ArgsParser args_parser; args_parser.add_positional_argument(paths, "Directories to remove", "paths"); diff --git a/Userland/Utilities/run-tests.cpp b/Userland/Utilities/run-tests.cpp index cb05648839..b874f38235 100644 --- a/Userland/Utilities/run-tests.cpp +++ b/Userland/Utilities/run-tests.cpp @@ -54,13 +54,13 @@ public: virtual ~TestRunner() = default; protected: - virtual void do_run_single_test(const String& test_path, size_t current_text_index, size_t num_tests) override; + virtual void do_run_single_test(String const& test_path, size_t current_text_index, size_t num_tests) override; virtual Vector<String> get_test_paths() const override; - virtual const Vector<String>* get_failed_test_names() const override { return &m_failed_test_names; } + virtual Vector<String> const* get_failed_test_names() const override { return &m_failed_test_names; } - virtual FileResult run_test_file(const String& test_path); + virtual FileResult run_test_file(String const& test_path); - bool should_skip_test(const LexicalPath& test_path); + bool should_skip_test(LexicalPath const& test_path); Regex<PosixExtended> m_exclude_regex; NonnullRefPtr<Core::ConfigFile> m_config; @@ -75,7 +75,7 @@ protected: Vector<String> TestRunner::get_test_paths() const { Vector<String> paths; - Test::iterate_directory_recursively(m_test_root, [&](const String& file_path) { + Test::iterate_directory_recursively(m_test_root, [&](String const& file_path) { if (access(file_path.characters(), R_OK | X_OK) != 0) return; auto result = m_exclude_regex.match(file_path, PosixFlags::Global); @@ -86,16 +86,16 @@ Vector<String> TestRunner::get_test_paths() const return paths; } -bool TestRunner::should_skip_test(const LexicalPath& test_path) +bool TestRunner::should_skip_test(LexicalPath const& test_path) { if (m_run_skipped_tests) return false; - for (const String& dir : m_skip_directories) { + for (String const& dir : m_skip_directories) { if (test_path.dirname().contains(dir)) return true; } - for (const String& file : m_skip_files) { + for (String const& file : m_skip_files) { if (test_path.basename().contains(file)) return true; } @@ -106,7 +106,7 @@ bool TestRunner::should_skip_test(const LexicalPath& test_path) return false; } -void TestRunner::do_run_single_test(const String& test_path, size_t current_test_index, size_t num_tests) +void TestRunner::do_run_single_test(String const& test_path, size_t current_test_index, size_t num_tests) { g_currently_running_test = test_path; auto test_relative_path = LexicalPath::relative_path(test_path, m_test_root); @@ -225,7 +225,7 @@ void TestRunner::do_run_single_test(const String& test_path, size_t current_test close(test_result.stdout_err_fd); } -FileResult TestRunner::run_test_file(const String& test_path) +FileResult TestRunner::run_test_file(String const& test_path) { double start_time = get_time_in_ms(); @@ -248,7 +248,7 @@ FileResult TestRunner::run_test_file(const String& test_path) (void)posix_spawn_file_actions_adddup2(&file_actions, child_out_err_file, STDERR_FILENO); (void)posix_spawn_file_actions_addchdir(&file_actions, dirname.characters()); - Vector<const char*, 4> argv; + Vector<char const*, 4> argv; argv.append(basename.characters()); auto extra_args = m_config->read_entry(path_for_test.basename(), "Arguments", "").split(' '); for (auto& arg : extra_args) @@ -315,7 +315,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool print_all_output = false; bool run_benchmarks = false; bool run_skipped_tests = false; - const char* specified_test_root = nullptr; + char const* specified_test_root = nullptr; String test_glob; String exclude_pattern; String config_file; diff --git a/Userland/Utilities/seq.cpp b/Userland/Utilities/seq.cpp index 72367a9d3c..7bf07c2406 100644 --- a/Userland/Utilities/seq.cpp +++ b/Userland/Utilities/seq.cpp @@ -12,7 +12,7 @@ #include <stdlib.h> #include <string.h> -const char* const g_usage = R"(Usage: +char const* const g_usage = R"(Usage: seq [-h|--help] seq LAST seq FIRST LAST @@ -25,7 +25,7 @@ static void print_usage(FILE* stream) return; } -static double get_double(const char* name, const char* d_string, int* number_of_decimals) +static double get_double(char const* name, char const* d_string, int* number_of_decimals) { char* end; double d = strtod(d_string, &end); @@ -34,7 +34,7 @@ static double get_double(const char* name, const char* d_string, int* number_of_ print_usage(stderr); exit(1); } - if (const char* dot = strchr(d_string, '.')) + if (char const* dot = strchr(d_string, '.')) *number_of_decimals = strlen(dot + 1); else *number_of_decimals = 0; diff --git a/Userland/Utilities/sleep.cpp b/Userland/Utilities/sleep.cpp index 16c6c11001..b80dd37c7b 100644 --- a/Userland/Utilities/sleep.cpp +++ b/Userland/Utilities/sleep.cpp @@ -15,7 +15,7 @@ #include <time.h> #include <unistd.h> -static volatile bool g_interrupted; +static bool volatile g_interrupted; static void handle_sigint(int) { g_interrupted = true; diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index 10d13ef6a8..21983d3116 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -225,12 +225,12 @@ static void handle_sigint(int) } } -static ErrorOr<void> copy_from_process(const void* source, Bytes target) +static ErrorOr<void> copy_from_process(void const* source, Bytes target) { return Core::System::ptrace_peekbuf(g_pid, const_cast<void*>(source), target); } -static ErrorOr<ByteBuffer> copy_from_process(const void* source, size_t length) +static ErrorOr<ByteBuffer> copy_from_process(void const* source, size_t length) { auto buffer = TRY(ByteBuffer::create_uninitialized(length)); TRY(copy_from_process(source, buffer.bytes())); @@ -261,7 +261,7 @@ struct BitflagBase { namespace AK { template<typename BitflagDerivative> - requires(IsBaseOf<BitflagBase, BitflagDerivative>) && requires { BitflagDerivative::options; } +requires(IsBaseOf<BitflagBase, BitflagDerivative>) && requires { BitflagDerivative::options; } struct Formatter<BitflagDerivative> : StandardFormatter { Formatter() = default; explicit Formatter(StandardFormatter formatter) @@ -305,7 +305,7 @@ struct Formatter<BitflagDerivative> : StandardFormatter { } struct PointerArgument { - const void* value; + void const* value; }; namespace AK { @@ -809,11 +809,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio wpath cpath proc exec ptrace sigaction")); - Vector<const char*> child_argv; + Vector<char const*> child_argv; - const char* output_filename = nullptr; - const char* exclude_syscalls_option = nullptr; - const char* include_syscalls_option = nullptr; + char const* output_filename = nullptr; + char const* exclude_syscalls_option = nullptr; + char const* include_syscalls_option = nullptr; HashTable<StringView> exclude_syscalls; HashTable<StringView> include_syscalls; auto trace_file = Core::File::standard_error(); @@ -833,7 +833,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (output_filename != nullptr) trace_file = TRY(Core::File::open(output_filename, Core::OpenMode::WriteOnly)); - auto parse_syscalls = [](const char* option, auto& hash_table) { + auto parse_syscalls = [](char const* option, auto& hash_table) { if (option != nullptr) { for (auto syscall : StringView(option).split_view(',')) hash_table.set(syscall); diff --git a/Userland/Utilities/stty.cpp b/Userland/Utilities/stty.cpp index 905916f136..a88a84b8c2 100644 --- a/Userland/Utilities/stty.cpp +++ b/Userland/Utilities/stty.cpp @@ -156,8 +156,8 @@ constexpr ControlCharacter control_characters[] = { Optional<speed_t> numeric_value_to_speed(unsigned long); Optional<unsigned long> speed_to_numeric_value(speed_t); -void print_stty_readable(const termios&); -void print_human_readable(const termios&, const winsize&, bool); +void print_stty_readable(termios const&); +void print_human_readable(termios const&, winsize const&, bool); Result<void, int> apply_stty_readable_modes(StringView, termios&); Result<void, int> apply_modes(size_t, char**, termios&, winsize&); @@ -179,7 +179,7 @@ Optional<unsigned long> speed_to_numeric_value(speed_t speed) return {}; } -void print_stty_readable(const termios& modes) +void print_stty_readable(termios const& modes) { out("{:x}:{:x}:{:x}:{:x}", modes.c_iflag, modes.c_oflag, modes.c_cflag, modes.c_lflag); for (size_t i = 0; i < NCCS; ++i) @@ -187,7 +187,7 @@ void print_stty_readable(const termios& modes) out(":{:x}:{:x}\n", modes.c_ispeed, modes.c_ospeed); } -void print_human_readable(const termios& modes, const winsize& ws, bool verbose_mode) +void print_human_readable(termios const& modes, winsize const& ws, bool verbose_mode) { auto print_speed = [&] { if (verbose_mode && modes.c_ispeed != modes.c_ospeed) { diff --git a/Userland/Utilities/su.cpp b/Userland/Utilities/su.cpp index 382ae1e6b5..ad53516b66 100644 --- a/Userland/Utilities/su.cpp +++ b/Userland/Utilities/su.cpp @@ -20,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (!TRY(Core::System::isatty(STDIN_FILENO))) return Error::from_string_literal("Standard input is not a terminal"); - const char* user = nullptr; + char const* user = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(user, "User to switch to (defaults to user with UID 0)", "user", Core::ArgsParser::Required::No); diff --git a/Userland/Utilities/syscall.cpp b/Userland/Utilities/syscall.cpp index ab6ba4fd7e..7aab8b32a6 100644 --- a/Userland/Utilities/syscall.cpp +++ b/Userland/Utilities/syscall.cpp @@ -23,7 +23,7 @@ FlatPtr arg[SC_NARG]; char outbuf[BUFSIZ]; -using Arguments = Vector<const char*>; +using Arguments = Vector<char const*>; using ArgIter = Arguments::Iterator; static FlatPtr parse_from(ArgIter&); @@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { bool output_buffer = false; bool list_syscalls = false; - Vector<const char*> syscall_arguments; + Vector<char const*> syscall_arguments; Core::ArgsParser args_parser; args_parser.set_general_help( @@ -154,7 +154,7 @@ static FlatPtr parse_parameter_buffer(ArgIter& iter) static FlatPtr parse_from(ArgIter& iter) { - const char* this_arg = *iter; + char const* this_arg = *iter; ++iter; // Is it a forced literal? diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index 5e0d7ae458..5454ec1161 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -19,7 +19,7 @@ static int tail_from_pos(Core::File& file, off_t startline, bool want_follow) return 1; while (true) { - const auto& b = file.read(4096); + auto const& b = file.read(4096); if (b.is_empty()) { if (!want_follow) { break; @@ -56,7 +56,7 @@ static off_t find_seek_pos(Core::File& file, int wanted_lines) // is smart enough to not read char-by-char. Fix it there, or fix it here :) for (; pos >= 0; pos--) { file.seek(pos); - const auto& ch = file.read(1); + auto const& ch = file.read(1); if (ch.is_empty()) { // Presumably the file got truncated? // Keep trying to read backwards... @@ -78,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool follow = false; int line_count = DEFAULT_LINE_COUNT; - const char* file = nullptr; + char const* file = nullptr; Core::ArgsParser args_parser; args_parser.set_general_help("Print the end ('tail') of a file."); diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index e2d02c8933..bb23a3a1a5 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -32,8 +32,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool gzip = false; bool no_auto_compress = false; StringView archive_file; - const char* directory = nullptr; - Vector<const char*> paths; + char const* directory = nullptr; + Vector<char const*> paths; Core::ArgsParser args_parser; args_parser.add_option(create, "Create archive", "create", 'c'); @@ -96,7 +96,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) }; for (; !tar_stream.finished(); tar_stream.advance()) { - const Archive::TarFileHeader& header = tar_stream.header(); + Archive::TarFileHeader const& header = tar_stream.header(); // Handle meta-entries earlier to avoid consuming the file content stream. if (header.content_is_like_extended_header()) { diff --git a/Userland/Utilities/test-fuzz.cpp b/Userland/Utilities/test-fuzz.cpp index 92f1e8f31c..8a4f96e722 100644 --- a/Userland/Utilities/test-fuzz.cpp +++ b/Userland/Utilities/test-fuzz.cpp @@ -32,7 +32,7 @@ T(URL) #undef __ENUMERATE_TARGET -#define __ENUMERATE_TARGET(x) extern "C" int Test##x(const uint8_t*, size_t); +#define __ENUMERATE_TARGET(x) extern "C" int Test##x(uint8_t const*, size_t); ENUMERATE_TARGETS(__ENUMERATE_TARGET) #undef __ENUMERATE_TARGET diff --git a/Userland/Utilities/test.cpp b/Userland/Utilities/test.cpp index 553656fd0e..399d19027b 100644 --- a/Userland/Utilities/test.cpp +++ b/Userland/Utilities/test.cpp @@ -16,7 +16,7 @@ bool g_there_was_an_error = false; -[[noreturn, gnu::format(printf, 1, 2)]] static void fatal_error(const char* format, ...) +[[noreturn, gnu::format(printf, 1, 2)]] static void fatal_error(char const* format, ...) { fputs("\033[31m", stderr); diff --git a/Userland/Utilities/test_env.cpp b/Userland/Utilities/test_env.cpp index 86bdc36f3f..3c9e281434 100644 --- a/Userland/Utilities/test_env.cpp +++ b/Userland/Utilities/test_env.cpp @@ -11,7 +11,7 @@ #include <stdlib.h> #include <string.h> -static void assert_env(const char* name, const char* value) +static void assert_env(char const* name, char const* value) { char* result = getenv(name); if (!result) { diff --git a/Userland/Utilities/top.cpp b/Userland/Utilities/top.cpp index 6c068f743b..d8813c0468 100644 --- a/Userland/Utilities/top.cpp +++ b/Userland/Utilities/top.cpp @@ -68,7 +68,7 @@ struct ThreadData { }; struct PidAndTid { - bool operator==(const PidAndTid& other) const + bool operator==(PidAndTid const& other) const { return pid == other.pid && tid == other.tid; } @@ -79,7 +79,7 @@ struct PidAndTid { namespace AK { template<> struct Traits<PidAndTid> : public GenericTraits<PidAndTid> { - static unsigned hash(const PidAndTid& value) { return pair_int_hash(value.pid, value.tid); } + static unsigned hash(PidAndTid const& value) { return pair_int_hash(value.pid, value.tid); } }; } @@ -143,7 +143,7 @@ static void parse_args(Main::Arguments arguments, TopOption& top_option) "sort-by", 's', nullptr, - [&top_option](const char* s) { + [&top_option](char const* s) { StringView sort_by_option { s }; if (sort_by_option == "pid"sv) top_option.sort_by = TopOption::SortBy::Pid; diff --git a/Userland/Utilities/touch.cpp b/Userland/Utilities/touch.cpp index 6ad681136f..d745eabdcf 100644 --- a/Userland/Utilities/touch.cpp +++ b/Userland/Utilities/touch.cpp @@ -15,7 +15,7 @@ #include <unistd.h> #include <utime.h> -static bool file_exists(const char* path) +static bool file_exists(char const* path) { struct stat st; int rc = stat(path, &st); @@ -34,7 +34,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath cpath fattr")); - Vector<const char*> paths; + Vector<char const*> paths; Core::ArgsParser args_parser; args_parser.set_general_help("Create a file, or update its mtime (time of last modification)."); diff --git a/Userland/Utilities/tr.cpp b/Userland/Utilities/tr.cpp index bcb8e9b7ac..2e932f3d80 100644 --- a/Userland/Utilities/tr.cpp +++ b/Userland/Utilities/tr.cpp @@ -96,8 +96,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool complement_flag = false; bool delete_flag = false; bool squeeze_flag = false; - const char* from_chars = nullptr; - const char* to_chars = nullptr; + char const* from_chars = nullptr; + char const* to_chars = nullptr; Core::ArgsParser args_parser; args_parser.add_option(complement_flag, "Take the complement of the first set", "complement", 'c'); diff --git a/Userland/Utilities/traceroute.cpp b/Userland/Utilities/traceroute.cpp index 9e288b4235..1e04cb521e 100644 --- a/Userland/Utilities/traceroute.cpp +++ b/Userland/Utilities/traceroute.cpp @@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio id inet unix")); - const char* host_name; + char const* host_name; int max_hops = 30; int max_retries = 3; int echo_timeout = 5; @@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) sockaddr_in host_address {}; host_address.sin_family = AF_INET; host_address.sin_port = 44444; - host_address.sin_addr.s_addr = *(const in_addr_t*)hostent->h_addr_list[0]; + host_address.sin_addr.s_addr = *(in_addr_t const*)hostent->h_addr_list[0]; int fd = TRY(Core::System::socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)); diff --git a/Userland/Utilities/tree.cpp b/Userland/Utilities/tree.cpp index 12f4ea8744..f90c10e669 100644 --- a/Userland/Utilities/tree.cpp +++ b/Userland/Utilities/tree.cpp @@ -27,7 +27,7 @@ static int max_depth = INT_MAX; static int g_directories_seen = 0; static int g_files_seen = 0; -static void print_directory_tree(const String& root_path, int depth, const String& indent_string) +static void print_directory_tree(String const& root_path, int depth, String const& indent_string) { if (depth > 0) { String root_indent_string; @@ -106,7 +106,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath tty")); - Vector<const char*> directories; + Vector<char const*> directories; Core::ArgsParser args_parser; args_parser.add_option(flag_show_hidden_files, "Show hidden files", "all", 'a'); @@ -124,7 +124,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) print_directory_tree(".", 0, ""); puts(""); } else { - for (const char* directory : directories) { + for (char const* directory : directories) { print_directory_tree(directory, 0, ""); puts(""); } diff --git a/Userland/Utilities/truncate.cpp b/Userland/Utilities/truncate.cpp index 4f7b1442ad..25ef85974a 100644 --- a/Userland/Utilities/truncate.cpp +++ b/Userland/Utilities/truncate.cpp @@ -22,9 +22,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath wpath cpath")); - const char* resize = nullptr; - const char* reference = nullptr; - const char* file = nullptr; + char const* resize = nullptr; + char const* reference = nullptr; + char const* file = nullptr; Core::ArgsParser args_parser; args_parser.add_option(resize, "Resize the target file to (or by) this size. Prefix with + or - to expand or shrink the file, or a bare number to set the size exactly", "size", 's', "size"); diff --git a/Userland/Utilities/tt.cpp b/Userland/Utilities/tt.cpp index 5c0929d2bd..e645b4da85 100644 --- a/Userland/Utilities/tt.cpp +++ b/Userland/Utilities/tt.cpp @@ -24,7 +24,7 @@ static int kill_test(); ErrorOr<int> serenity_main(Main::Arguments arguments) { - const char* test_name = "n"; + char const* test_name = "n"; Core::ArgsParser args_parser; args_parser.set_general_help( diff --git a/Userland/Utilities/uniq.cpp b/Userland/Utilities/uniq.cpp index 42f75e43cf..54fb89ba0a 100644 --- a/Userland/Utilities/uniq.cpp +++ b/Userland/Utilities/uniq.cpp @@ -18,7 +18,7 @@ struct linebuf { size_t len = 0; }; -static FILE* get_stream(const char* filepath, const char* perms) +static FILE* get_stream(char const* filepath, char const* perms) { FILE* ret; @@ -41,8 +41,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath wpath cpath")); - const char* inpath = nullptr; - const char* outpath = nullptr; + char const* inpath = nullptr; + char const* outpath = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(inpath, "Input file", "input", Core::ArgsParser::Required::No); args_parser.add_positional_argument(outpath, "Output file", "output", Core::ArgsParser::Required::No); diff --git a/Userland/Utilities/unzip.cpp b/Userland/Utilities/unzip.cpp index 3713c1151a..d8b69c7acc 100644 --- a/Userland/Utilities/unzip.cpp +++ b/Userland/Utilities/unzip.cpp @@ -75,7 +75,7 @@ static bool unpack_zip_member(Archive::ZipMember zip_member, bool quiet) ErrorOr<int> serenity_main(Main::Arguments arguments) { - const char* path; + char const* path; int map_size_limit = 32 * MiB; bool quiet { false }; String output_directory_path; diff --git a/Userland/Utilities/useradd.cpp b/Userland/Utilities/useradd.cpp index 3d31d9376e..f5886e2a6d 100644 --- a/Userland/Utilities/useradd.cpp +++ b/Userland/Utilities/useradd.cpp @@ -25,20 +25,20 @@ constexpr uid_t BASE_UID = 1000; constexpr gid_t USERS_GID = 100; -constexpr const char* DEFAULT_SHELL = "/bin/sh"; +constexpr char const* DEFAULT_SHELL = "/bin/sh"; ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio wpath rpath cpath chown")); - const char* home_path = nullptr; + char const* home_path = nullptr; int uid = 0; int gid = USERS_GID; bool create_home_dir = false; - const char* password = ""; - const char* shell = DEFAULT_SHELL; - const char* gecos = ""; - const char* username = nullptr; + char const* password = ""; + char const* shell = DEFAULT_SHELL; + char const* gecos = ""; + char const* username = nullptr; Core::ArgsParser args_parser; args_parser.add_option(home_path, "Home directory for the new user", "home-dir", 'd', "path"); diff --git a/Userland/Utilities/userdel.cpp b/Userland/Utilities/userdel.cpp index 74d939a5f3..42d604bd6c 100644 --- a/Userland/Utilities/userdel.cpp +++ b/Userland/Utilities/userdel.cpp @@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/etc/", "rwc")); TRY(Core::System::unveil("/bin/rm", "x")); - const char* username = nullptr; + char const* username = nullptr; bool remove_home = false; Core::ArgsParser args_parser; @@ -161,7 +161,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } pid_t child; - const char* argv[] = { "rm", "-r", target_account.home_directory().characters(), nullptr }; + char const* argv[] = { "rm", "-r", target_account.home_directory().characters(), nullptr }; if ((errno = posix_spawn(&child, "/bin/rm", nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); return 12; diff --git a/Userland/Utilities/usermod.cpp b/Userland/Utilities/usermod.cpp index eb6122fabd..17cc041c73 100644 --- a/Userland/Utilities/usermod.cpp +++ b/Userland/Utilities/usermod.cpp @@ -30,11 +30,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) int gid = 0; bool lock = false; bool unlock = false; - const char* new_home_directory = nullptr; + char const* new_home_directory = nullptr; bool move_home = false; - const char* shell = nullptr; - const char* gecos = nullptr; - const char* username = nullptr; + char const* shell = nullptr; + char const* gecos = nullptr; + char const* username = nullptr; auto args_parser = Core::ArgsParser(); args_parser.set_general_help("Modify a user account"); diff --git a/Userland/Utilities/utmpupdate.cpp b/Userland/Utilities/utmpupdate.cpp index 3882b4d788..0922f79660 100644 --- a/Userland/Utilities/utmpupdate.cpp +++ b/Userland/Utilities/utmpupdate.cpp @@ -24,8 +24,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) pid_t pid = 0; bool flag_create = false; bool flag_delete = false; - const char* tty_name = nullptr; - const char* from = nullptr; + char const* tty_name = nullptr; + char const* from = nullptr; Core::ArgsParser args_parser; args_parser.add_option(flag_create, "Create entry", "create", 'c'); diff --git a/Userland/Utilities/watch.cpp b/Userland/Utilities/watch.cpp index 7c3788a192..c749ed16c6 100644 --- a/Userland/Utilities/watch.cpp +++ b/Userland/Utilities/watch.cpp @@ -25,7 +25,7 @@ static int opt_interval = 2; static bool flag_noheader = false; static bool flag_beep_on_fail = false; -static volatile int exit_code = 0; +static int volatile exit_code = 0; static volatile pid_t child_pid = -1; static String build_header_string(Vector<char const*> const& command, struct timeval const& interval) diff --git a/Userland/Utilities/wc.cpp b/Userland/Utilities/wc.cpp index c0270d21f9..b37383175f 100644 --- a/Userland/Utilities/wc.cpp +++ b/Userland/Utilities/wc.cpp @@ -27,7 +27,7 @@ bool g_output_line = false; bool g_output_byte = false; bool g_output_word = false; -static void wc_out(const Count& count) +static void wc_out(Count const& count) { if (g_output_line) out("{:7} ", count.lines); @@ -39,7 +39,7 @@ static void wc_out(const Count& count) outln("{:>14}", count.name); } -static Count get_count(const String& file_specifier) +static Count get_count(String const& file_specifier) { Count count; FILE* file_pointer = nullptr; @@ -74,7 +74,7 @@ static Count get_count(const String& file_specifier) return count; } -static Count get_total_count(const Vector<Count>& counts) +static Count get_total_count(Vector<Count> const& counts) { Count total_count { "total" }; for (auto& count : counts) { @@ -90,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); - Vector<const char*> file_specifiers; + Vector<char const*> file_specifiers; Core::ArgsParser args_parser; args_parser.add_option(g_output_line, "Output line count", "lines", 'l'); @@ -103,7 +103,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) g_output_line = g_output_byte = g_output_word = true; Vector<Count> counts; - for (const auto& file_specifier : file_specifiers) + for (auto const& file_specifier : file_specifiers) counts.append(get_count(file_specifier)); TRY(Core::System::pledge("stdio")); @@ -113,7 +113,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) else if (file_specifiers.size() > 1) counts.append(get_total_count(counts)); - for (const auto& count : counts) { + for (auto const& count : counts) { if (count.exists) wc_out(count); } diff --git a/Userland/Utilities/which.cpp b/Userland/Utilities/which.cpp index f0abc156c3..aace9ea20b 100644 --- a/Userland/Utilities/which.cpp +++ b/Userland/Utilities/which.cpp @@ -14,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); - const char* filename = nullptr; + char const* filename = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(filename, "Name of executable", "executable"); diff --git a/Userland/Utilities/xargs.cpp b/Userland/Utilities/xargs.cpp index d59a52a5b5..de9644e310 100644 --- a/Userland/Utilities/xargs.cpp +++ b/Userland/Utilities/xargs.cpp @@ -28,9 +28,9 @@ bool read_items(FILE* fp, char entry_separator, Function<Decision(StringView)>); class ParsedInitialArguments { public: - ParsedInitialArguments(Vector<const char*>&, StringView placeholder); + ParsedInitialArguments(Vector<char const*>&, StringView placeholder); - void for_each_joined_argument(StringView, Function<void(const String&)>) const; + void for_each_joined_argument(StringView, Function<void(String const&)>) const; size_t size() const { return m_all_parts.size(); } @@ -42,12 +42,12 @@ ErrorOr<int> serenity_main(Main::Arguments main_arguments) { TRY(Core::System::pledge("stdio rpath proc exec", nullptr)); - const char* placeholder = nullptr; + char const* placeholder = nullptr; bool split_with_nulls = false; - const char* specified_delimiter = "\n"; - Vector<const char*> arguments; + char const* specified_delimiter = "\n"; + Vector<char const*> arguments; bool verbose = false; - const char* file_to_read = "-"; + char const* file_to_read = "-"; int max_lines_for_one_command = 0; int max_bytes_for_one_command = ARG_MAX; @@ -238,7 +238,7 @@ bool run_command(Vector<char*>&& child_argv, bool verbose, bool is_stdin, int de return true; } -ParsedInitialArguments::ParsedInitialArguments(Vector<const char*>& arguments, StringView placeholder) +ParsedInitialArguments::ParsedInitialArguments(Vector<char const*>& arguments, StringView placeholder) { m_all_parts.ensure_capacity(arguments.size()); bool some_argument_has_placeholder = false; @@ -264,7 +264,7 @@ ParsedInitialArguments::ParsedInitialArguments(Vector<const char*>& arguments, S } } -void ParsedInitialArguments::for_each_joined_argument(StringView separator, Function<void(const String&)> callback) const +void ParsedInitialArguments::for_each_joined_argument(StringView separator, Function<void(String const&)> callback) const { StringBuilder builder; for (auto& parts : m_all_parts) { diff --git a/Userland/Utilities/yes.cpp b/Userland/Utilities/yes.cpp index 8e731f8b4d..97398e78bb 100644 --- a/Userland/Utilities/yes.cpp +++ b/Userland/Utilities/yes.cpp @@ -13,7 +13,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio")); - const char* string = "yes"; + char const* string = "yes"; Core::ArgsParser args_parser; args_parser.add_positional_argument(string, "String to output (defaults to 'yes')", "string", Core::ArgsParser::Required::No); diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp index dca40dcca9..af62a5bf65 100644 --- a/Userland/Utilities/zip.cpp +++ b/Userland/Utilities/zip.cpp @@ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { - const char* zip_path; + char const* zip_path; Vector<StringView> source_paths; bool recurse = false; bool force = false; |