diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp deleted file mode 100644 index 40389f14de..0000000000 --- a/BAN/BAN/String.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include -#include - -namespace BAN -{ - - String::String() - { - } - - String::String(const String& other) - { - *this = other; - } - - String::String(String&& other) - { - *this = move(other); - } - - String::String(StringView other) - { - *this = other; - } - - String::~String() - { - clear(); - } - - String& String::operator=(const String& other) - { - clear(); - MUST(ensure_capacity(other.size())); - memcpy(data(), other.data(), other.size() + 1); - m_size = other.size(); - return *this; - } - - String& String::operator=(String&& other) - { - clear(); - - if (other.has_sso()) - memcpy(data(), other.data(), other.size() + 1); - else - { - m_storage.general_storage = other.m_storage.general_storage; - m_has_sso = false; - } - m_size = other.m_size; - - other.m_size = 0; - other.m_storage.sso_storage = SSOStorage(); - other.m_has_sso = true; - - return *this; - } - - String& String::operator=(StringView other) - { - clear(); - MUST(ensure_capacity(other.size())); - memcpy(data(), other.data(), other.size()); - m_size = other.size(); - data()[m_size] = '\0'; - return *this; - } - - ErrorOr String::push_back(char c) - { - TRY(ensure_capacity(m_size + 1)); - data()[m_size] = c; - m_size++; - data()[m_size] = '\0'; - return {}; - } - - ErrorOr String::insert(char c, size_type index) - { - ASSERT(index <= m_size); - TRY(ensure_capacity(m_size + 1)); - memmove(data() + index + 1, data() + index, m_size - index); - data()[index] = c; - m_size++; - data()[m_size] = '\0'; - return {}; - } - - ErrorOr String::insert(StringView str, size_type index) - { - ASSERT(index <= m_size); - TRY(ensure_capacity(m_size + str.size())); - memmove(data() + index + str.size(), data() + index, m_size - index); - memcpy(data() + index, str.data(), str.size()); - m_size += str.size(); - data()[m_size] = '\0'; - return {}; - } - - ErrorOr String::append(StringView str) - { - TRY(ensure_capacity(m_size + str.size())); - memcpy(data() + m_size, str.data(), str.size()); - m_size += str.size(); - data()[m_size] = '\0'; - return {}; - } - - void String::pop_back() - { - ASSERT(m_size > 0); - m_size--; - data()[m_size] = '\0'; - } - - void String::remove(size_type index) - { - ASSERT(index < m_size); - memcpy(data() + index, data() + index + 1, m_size - index); - m_size--; - data()[m_size] = '\0'; - } - - void String::clear() - { - if (!has_sso()) - { - deallocator(m_storage.general_storage.data); - m_storage.sso_storage = SSOStorage(); - m_has_sso = true; - } - m_size = 0; - data()[m_size] = '\0'; - } - - bool String::operator==(const String& str) const - { - if (size() != str.size()) - return false; - for (size_type i = 0; i < m_size; i++) - if (data()[i] != str.data()[i]) - return false; - return true; - } - - bool String::operator==(StringView str) const - { - if (size() != str.size()) - return false; - for (size_type i = 0; i < m_size; i++) - if (data()[i] != str.data()[i]) - return false; - return true; - } - - bool String::operator==(const char* cstr) const - { - for (size_type i = 0; i < m_size; i++) - if (data()[i] != cstr[i]) - return false; - if (cstr[size()] != '\0') - return false; - return true; - } - - ErrorOr String::resize(size_type new_size, char init_c) - { - if (m_size == new_size) - return {}; - - // expanding - if (m_size < new_size) - { - TRY(ensure_capacity(new_size)); - memset(data() + m_size, init_c, new_size - m_size); - m_size = new_size; - data()[m_size] = '\0'; - return {}; - } - - m_size = new_size; - data()[m_size] = '\0'; - return {}; - } - - ErrorOr String::reserve(size_type new_size) - { - TRY(ensure_capacity(new_size)); - return {}; - } - - ErrorOr String::shrink_to_fit() - { - if (has_sso()) - return {}; - - if (fits_in_sso()) - { - char* data = m_storage.general_storage.data; - m_storage.sso_storage = SSOStorage(); - m_has_sso = true; - memcpy(this->data(), data, m_size + 1); - deallocator(data); - return {}; - } - - GeneralStorage& storage = m_storage.general_storage; - if (storage.capacity == m_size) - return {}; - - char* new_data = (char*)allocator(m_size + 1); - if (new_data == nullptr) - return Error::from_errno(ENOMEM); - - memcpy(new_data, storage.data, m_size); - deallocator(storage.data); - - storage.capacity = m_size; - storage.data = new_data; - - return {}; - } - - String::size_type String::capacity() const - { - if (has_sso()) - return sso_capacity; - return m_storage.general_storage.capacity; - } - - char* String::data() - { - if (has_sso()) - return m_storage.sso_storage.data; - return m_storage.general_storage.data; - } - - const char* String::data() const - { - if (has_sso()) - return m_storage.sso_storage.data; - return m_storage.general_storage.data; - } - - ErrorOr String::ensure_capacity(size_type new_size) - { - if (m_size >= new_size) - return {}; - if (has_sso() && fits_in_sso(new_size)) - return {}; - - char* new_data = (char*)allocator(new_size + 1); - if (new_data == nullptr) - return Error::from_errno(ENOMEM); - - if (m_size) - memcpy(new_data, data(), m_size + 1); - - if (has_sso()) - { - m_storage.general_storage = GeneralStorage(); - m_has_sso = false; - } - else - deallocator(m_storage.general_storage.data); - - auto& storage = m_storage.general_storage; - storage.capacity = new_size; - storage.data = new_data; - - return {}; - } - - bool String::has_sso() const - { - return m_has_sso; - } - -} diff --git a/BAN/BAN/StringView.cpp b/BAN/BAN/StringView.cpp index 2caa52b85f..5a2eea08a4 100644 --- a/BAN/BAN/StringView.cpp +++ b/BAN/BAN/StringView.cpp @@ -1,196 +1,11 @@ #include #include -#include - -#include namespace BAN { - StringView::StringView() - { } - StringView::StringView(const String& other) : StringView(other.data(), other.size()) { } - StringView::StringView(const char* string, size_type len) - { - if (len == size_type(-1)) - len = strlen(string); - m_data = string; - m_size = len; - } - - char StringView::operator[](size_type index) const - { - ASSERT(index < m_size); - return m_data[index]; - } - - bool StringView::operator==(const String& other) const - { - if (m_size != other.size()) - return false; - return memcmp(m_data, other.data(), m_size) == 0; - } - - bool StringView::operator==(StringView other) const - { - if (m_size != other.m_size) - return false; - return memcmp(m_data, other.m_data, m_size) == 0; - } - - bool StringView::operator==(const char* other) const - { - if (memcmp(m_data, other, m_size)) - return false; - return other[m_size] == '\0'; - } - - StringView StringView::substring(size_type index, size_type len) const - { - ASSERT(index <= m_size); - if (len == size_type(-1)) - len = m_size - index; - ASSERT(len <= m_size - index); // weird order to avoid overflow - StringView result; - result.m_data = m_data + index; - result.m_size = len; - return result; - } - - ErrorOr> StringView::split(char delim, bool allow_empties) const - { - size_type count = 0; - { - size_type start = 0; - for (size_type i = 0; i < m_size; i++) - { - if (m_data[i] == delim) - { - if (allow_empties || start != i) - count++; - start = i + 1; - } - } - if (start != m_size) - count++; - } - - Vector result; - TRY(result.reserve(count)); - - size_type start = 0; - for (size_type i = 0; i < m_size; i++) - { - if (m_data[i] == delim) - { - if (allow_empties || start != i) - TRY(result.push_back(this->substring(start, i - start))); - start = i + 1; - } - } - if (start < m_size || (start == m_size && allow_empties)) - TRY(result.push_back(this->substring(start))); - return result; - } - - ErrorOr> StringView::split(bool(*comp)(char), bool allow_empties) const - { - size_type count = 0; - { - size_type start = 0; - for (size_type i = 0; i < m_size; i++) - { - if (comp(m_data[i])) - { - if (allow_empties || start != i) - count++; - start = i + 1; - } - } - if (start != m_size) - count++; - } - - Vector result; - TRY(result.reserve(count)); - - size_type start = 0; - for (size_type i = 0; i < m_size; i++) - { - if (comp(m_data[i])) - { - if (allow_empties || start != i) - TRY(result.push_back(this->substring(start, i - start))); - start = i + 1; - } - } - if (start < m_size || (start == m_size && allow_empties)) - TRY(result.push_back(this->substring(start))); - return result; - } - - char StringView::back() const - { - ASSERT(m_size > 0); - return m_data[m_size - 1]; - } - - char StringView::front() const - { - ASSERT(m_size > 0); - return m_data[0]; - } - - BAN::Optional StringView::find(char ch) const - { - for (size_type i = 0; i < m_size; i++) - if (m_data[i] == ch) - return i; - return {}; - } - - BAN::Optional StringView::find(bool(*comp)(char)) const - { - for (size_type i = 0; i < m_size; i++) - if (comp(m_data[i])) - return i; - return {}; - } - - bool StringView::contains(char ch) const - { - for (size_type i = 0; i < m_size; i++) - if (m_data[i] == ch) - return true; - return false; - } - - StringView::size_type StringView::count(char ch) const - { - size_type result = 0; - for (size_type i = 0; i < m_size; i++) - if (m_data[i] == ch) - result++; - return result; - } - - bool StringView::empty() const - { - return m_size == 0; - } - - StringView::size_type StringView::size() const - { - return m_size; - } - - const char* StringView::data() const - { - return m_data; - } - } diff --git a/BAN/CMakeLists.txt b/BAN/CMakeLists.txt index ee8dfd8bb9..0f8f05f0f5 100644 --- a/BAN/CMakeLists.txt +++ b/BAN/CMakeLists.txt @@ -5,7 +5,6 @@ project(BAN CXX) set(BAN_SOURCES BAN/Assert.cpp BAN/New.cpp - BAN/String.cpp BAN/StringView.cpp BAN/Time.cpp ) diff --git a/BAN/include/BAN/Errors.h b/BAN/include/BAN/Errors.h index f0ae5fa9d7..d377d259db 100644 --- a/BAN/include/BAN/Errors.h +++ b/BAN/include/BAN/Errors.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include @@ -56,7 +55,7 @@ namespace BAN #endif uint64_t get_error_code() const { return m_error_code; } - BAN::StringView get_message() const + const char* get_message() const { #ifdef __is_kernel if (m_error_code & kernel_error_mask) @@ -64,7 +63,7 @@ namespace BAN #endif if (auto* desc = strerrordesc_np(m_error_code)) return desc; - return "Unknown error"sv; + return "Unknown error"; } private: diff --git a/BAN/include/BAN/String.h b/BAN/include/BAN/String.h index a0c4717112..6c51be488e 100644 --- a/BAN/include/BAN/String.h +++ b/BAN/include/BAN/String.h @@ -2,9 +2,10 @@ #include #include -#include #include #include +#include +#include namespace BAN { @@ -18,28 +19,125 @@ namespace BAN static constexpr size_type sso_capacity = 15; public: - String(); - String(const String&); - String(String&&); - String(StringView); - ~String(); + String() {} + String(const String& other) { *this = other; } + String(String&& other) { *this = move(other); } + String(StringView other) { *this = other; } + ~String() { clear(); } template - static String formatted(const char* format, const Args&... args); + static String formatted(const char* format, const Args&... args) + { + String result; + BAN::Formatter::print([&](char c){ MUST(result.push_back(c)); }, format, args...); + return result; + } - String& operator=(const String&); - String& operator=(String&&); - String& operator=(StringView); + String& operator=(const String& other) + { + clear(); + MUST(ensure_capacity(other.size())); + memcpy(data(), other.data(), other.size() + 1); + m_size = other.size(); + return *this; + } - ErrorOr push_back(char); - ErrorOr insert(char, size_type); - ErrorOr insert(StringView, size_type); - ErrorOr append(StringView); + String& operator=(String&& other) + { + clear(); - void pop_back(); - void remove(size_type); + if (other.has_sso()) + memcpy(data(), other.data(), other.size() + 1); + else + { + m_storage.general_storage = other.m_storage.general_storage; + m_has_sso = false; + } + m_size = other.m_size; - void clear(); + other.m_size = 0; + other.m_storage.sso_storage = SSOStorage(); + other.m_has_sso = true; + + return *this; + } + + String& operator=(StringView other) + { + clear(); + MUST(ensure_capacity(other.size())); + memcpy(data(), other.data(), other.size()); + m_size = other.size(); + data()[m_size] = '\0'; + return *this; + } + + ErrorOr push_back(char c) + { + TRY(ensure_capacity(m_size + 1)); + data()[m_size] = c; + m_size++; + data()[m_size] = '\0'; + return {}; + } + + ErrorOr insert(char c, size_type index) + { + ASSERT(index <= m_size); + TRY(ensure_capacity(m_size + 1)); + memmove(data() + index + 1, data() + index, m_size - index); + data()[index] = c; + m_size++; + data()[m_size] = '\0'; + return {}; + } + + ErrorOr insert(StringView str, size_type index) + { + ASSERT(index <= m_size); + TRY(ensure_capacity(m_size + str.size())); + memmove(data() + index + str.size(), data() + index, m_size - index); + memcpy(data() + index, str.data(), str.size()); + m_size += str.size(); + data()[m_size] = '\0'; + return {}; + } + + ErrorOr append(StringView str) + { + TRY(ensure_capacity(m_size + str.size())); + memcpy(data() + m_size, str.data(), str.size()); + m_size += str.size(); + data()[m_size] = '\0'; + return {}; + } + + void pop_back() + { + ASSERT(m_size > 0); + m_size--; + data()[m_size] = '\0'; + } + + void remove(size_type index) + { + ASSERT(index < m_size); + memcpy(data() + index, data() + index + 1, m_size - index); + m_size--; + data()[m_size] = '\0'; + } + + void clear() + { + if (!has_sso()) + { + deallocator(m_storage.general_storage.data); + m_storage.sso_storage = SSOStorage(); + m_has_sso = true; + } + m_size = 0; + data()[m_size] = '\0'; + } const_iterator begin() const { return const_iterator(data()); } iterator begin() { return iterator(data()); } @@ -55,27 +153,151 @@ namespace BAN char operator[](size_type index) const { ASSERT(index < m_size); return data()[index]; } char& operator[](size_type index) { ASSERT(index < m_size); return data()[index]; } - bool operator==(const String&) const; - bool operator==(StringView) const; - bool operator==(const char*) const; + bool operator==(const String& str) const + { + if (size() != str.size()) + return false; + for (size_type i = 0; i < m_size; i++) + if (data()[i] != str.data()[i]) + return false; + return true; + } - ErrorOr resize(size_type, char = '\0'); - ErrorOr reserve(size_type); - ErrorOr shrink_to_fit(); + bool operator==(StringView str) const + { + if (size() != str.size()) + return false; + for (size_type i = 0; i < m_size; i++) + if (data()[i] != str.data()[i]) + return false; + return true; + } + + bool operator==(const char* cstr) const + { + for (size_type i = 0; i < m_size; i++) + if (data()[i] != cstr[i]) + return false; + if (cstr[size()] != '\0') + return false; + return true; + } + + ErrorOr resize(size_type new_size, char init_c = '\0') + { + if (m_size == new_size) + return {}; + + // expanding + if (m_size < new_size) + { + TRY(ensure_capacity(new_size)); + memset(data() + m_size, init_c, new_size - m_size); + m_size = new_size; + data()[m_size] = '\0'; + return {}; + } + + m_size = new_size; + data()[m_size] = '\0'; + return {}; + } + + ErrorOr reserve(size_type new_size) + { + TRY(ensure_capacity(new_size)); + return {}; + } + + ErrorOr shrink_to_fit() + { + if (has_sso()) + return {}; + + if (fits_in_sso()) + { + char* data = m_storage.general_storage.data; + m_storage.sso_storage = SSOStorage(); + m_has_sso = true; + memcpy(this->data(), data, m_size + 1); + deallocator(data); + return {}; + } + + GeneralStorage& storage = m_storage.general_storage; + if (storage.capacity == m_size) + return {}; + + char* new_data = (char*)allocator(m_size + 1); + if (new_data == nullptr) + return Error::from_errno(ENOMEM); + + memcpy(new_data, storage.data, m_size); + deallocator(storage.data); + + storage.capacity = m_size; + storage.data = new_data; + + return {}; + } StringView sv() const { return StringView(data(), size()); } bool empty() const { return m_size == 0; } size_type size() const { return m_size; } - size_type capacity() const; - char* data(); - const char* data() const; + size_type capacity() const + { + if (has_sso()) + return sso_capacity; + return m_storage.general_storage.capacity; + } + + char* data() + { + if (has_sso()) + return m_storage.sso_storage.data; + return m_storage.general_storage.data; + } + + const char* data() const + { + if (has_sso()) + return m_storage.sso_storage.data; + return m_storage.general_storage.data; + } private: - ErrorOr ensure_capacity(size_type); + ErrorOr ensure_capacity(size_type new_size) + { + if (m_size >= new_size) + return {}; + if (has_sso() && fits_in_sso(new_size)) + return {}; - bool has_sso() const; + char* new_data = (char*)allocator(new_size + 1); + if (new_data == nullptr) + return Error::from_errno(ENOMEM); + + if (m_size) + memcpy(new_data, data(), m_size + 1); + + if (has_sso()) + { + m_storage.general_storage = GeneralStorage(); + m_has_sso = false; + } + else + deallocator(m_storage.general_storage.data); + + auto& storage = m_storage.general_storage; + storage.capacity = new_size; + storage.data = new_data; + + return {}; + } + + bool has_sso() const { return m_has_sso; } bool fits_in_sso() const { return fits_in_sso(m_size); } static bool fits_in_sso(size_type size) { return size < sso_capacity; } @@ -100,14 +322,6 @@ namespace BAN size_type m_has_sso : 1 { true }; }; - template - String String::formatted(const char* format, const Args&... args) - { - String result; - BAN::Formatter::print([&](char c){ MUST(result.push_back(c)); }, format, args...); - return result; - } - template<> struct hash { diff --git a/BAN/include/BAN/StringView.h b/BAN/include/BAN/StringView.h index 6163e42445..6f3d57f687 100644 --- a/BAN/include/BAN/StringView.h +++ b/BAN/include/BAN/StringView.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace BAN { @@ -15,37 +16,171 @@ namespace BAN using const_iterator = ConstIteratorSimple; public: - StringView(); + StringView() {} StringView(const String&); - StringView(const char*, size_type = -1); + StringView(const char* string, size_type len = -1) + { + if (len == size_type(-1)) + len = strlen(string); + m_data = string; + m_size = len; + } const_iterator begin() const { return const_iterator(m_data); } const_iterator end() const { return const_iterator(m_data + m_size); } - char operator[](size_type) const; + char operator[](size_type index) const + { + ASSERT(index < m_size); + return m_data[index]; + } - bool operator==(const String&) const; - bool operator==(StringView) const; - bool operator==(const char*) const; + bool operator==(StringView other) const + { + if (m_size != other.m_size) + return false; + return memcmp(m_data, other.m_data, m_size) == 0; + } - StringView substring(size_type, size_type = -1) const; + bool operator==(const char* other) const + { + if (memcmp(m_data, other, m_size)) + return false; + return other[m_size] == '\0'; + } - ErrorOr> split(char, bool = false) const; - ErrorOr> split(bool(*comp)(char), bool = false) const; + StringView substring(size_type index, size_type len = -1) const + { + ASSERT(index <= m_size); + if (len == size_type(-1)) + len = m_size - index; + ASSERT(len <= m_size - index); // weird order to avoid overflow + StringView result; + result.m_data = m_data + index; + result.m_size = len; + return result; + } - char back() const; - char front() const; + ErrorOr> split(char delim, bool allow_empties = false) const + { + size_type count = 0; + { + size_type start = 0; + for (size_type i = 0; i < m_size; i++) + { + if (m_data[i] == delim) + { + if (allow_empties || start != i) + count++; + start = i + 1; + } + } + if (start != m_size) + count++; + } - BAN::Optional find(char) const; - BAN::Optional find(bool(*comp)(char)) const; + Vector result; + TRY(result.reserve(count)); - bool contains(char) const; - size_type count(char) const; + size_type start = 0; + for (size_type i = 0; i < m_size; i++) + { + if (m_data[i] == delim) + { + if (allow_empties || start != i) + TRY(result.push_back(this->substring(start, i - start))); + start = i + 1; + } + } + if (start < m_size || (start == m_size && allow_empties)) + TRY(result.push_back(this->substring(start))); + return result; + } - bool empty() const; - size_type size() const; + ErrorOr> split(bool(*comp)(char), bool allow_empties = false) const + { + size_type count = 0; + { + size_type start = 0; + for (size_type i = 0; i < m_size; i++) + { + if (comp(m_data[i])) + { + if (allow_empties || start != i) + count++; + start = i + 1; + } + } + if (start != m_size) + count++; + } - const char* data() const; + Vector result; + TRY(result.reserve(count)); + + size_type start = 0; + for (size_type i = 0; i < m_size; i++) + { + if (comp(m_data[i])) + { + if (allow_empties || start != i) + TRY(result.push_back(this->substring(start, i - start))); + start = i + 1; + } + } + if (start < m_size || (start == m_size && allow_empties)) + TRY(result.push_back(this->substring(start))); + return result; + } + + char back() const + { + ASSERT(m_size > 0); + return m_data[m_size - 1]; + } + + char front() const + { + ASSERT(m_size > 0); + return m_data[0]; + } + + BAN::Optional find(char ch) const + { + for (size_type i = 0; i < m_size; i++) + if (m_data[i] == ch) + return i; + return {}; + } + + BAN::Optional find(bool(*comp)(char)) const + { + for (size_type i = 0; i < m_size; i++) + if (comp(m_data[i])) + return i; + return {}; + } + + bool contains(char ch) const + { + for (size_type i = 0; i < m_size; i++) + if (m_data[i] == ch) + return true; + return false; + } + + size_type count(char ch) const + { + size_type result = 0; + for (size_type i = 0; i < m_size; i++) + if (m_data[i] == ch) + result++; + return result; + } + + bool empty() const { return m_size == 0; } + size_type size() const { return m_size; } + const char* data() const { return m_data; } private: const char* m_data = nullptr; diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 9db24017c0..6da790f221 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -137,7 +137,6 @@ endif() set(BAN_SOURCES ../BAN/BAN/Assert.cpp ../BAN/BAN/New.cpp - ../BAN/BAN/String.cpp ../BAN/BAN/StringView.cpp ../BAN/BAN/Time.cpp ) diff --git a/kernel/include/kernel/Errors.h b/kernel/include/kernel/Errors.h index 803e76582b..6429ec4620 100644 --- a/kernel/include/kernel/Errors.h +++ b/kernel/include/kernel/Errors.h @@ -1,11 +1,9 @@ #pragma once -#include - namespace Kernel { - enum class ErrorCode : uint32_t + enum class ErrorCode { None, ACPI_NoRootSDT, @@ -31,6 +29,6 @@ namespace Kernel Count }; - BAN::StringView error_string(ErrorCode); + const char* error_string(ErrorCode); } diff --git a/kernel/kernel/Errors.cpp b/kernel/kernel/Errors.cpp index 6f33ca6db9..a4700ffcb3 100644 --- a/kernel/kernel/Errors.cpp +++ b/kernel/kernel/Errors.cpp @@ -1,34 +1,38 @@ +#include #include +#include +#include + namespace Kernel { - static BAN::StringView s_error_strings[] { - "No Error"sv, - "ACPI could not find root SDT header"sv, - "ACPI no such header"sv, + static const char* s_error_strings[] { + "No Error", + "ACPI could not find root SDT header", + "ACPI no such header", "ACPI root invalid", - "Invalid ext2 filesystem"sv, - "Ext2 filesystem corrupted"sv, - "Ext2 filesystem out of inodes"sv, - "Attempted to access outside of device boundaries"sv, - "Device has invalid GPT header"sv, - "Device does not support LBA addressing"sv, - "Address mark not found"sv, - "Track zero not found"sv, - "Aborted command"sv, - "Media change request"sv, - "ID not found"sv, - "Media changed"sv, - "Uncorrectable data error"sv, - "Bad Block detected"sv, - "Unsupported ata device"sv, - "Font file too small"sv, - "Unsupported font format"sv, + "Invalid ext2 filesystem", + "Ext2 filesystem corrupted", + "Ext2 filesystem out of inodes", + "Attempted to access outside of device boundaries", + "Device has invalid GPT header", + "Device does not support LBA addressing", + "Address mark not found", + "Track zero not found", + "Aborted command", + "Media change request", + "ID not found", + "Media changed", + "Uncorrectable data error", + "Bad Block detected", + "Unsupported ata device", + "Font file too small", + "Unsupported font format", }; static_assert(sizeof(s_error_strings) / sizeof(*s_error_strings) == (size_t)ErrorCode::Count); - BAN::StringView error_string(ErrorCode error) + const char* error_string(ErrorCode error) { ASSERT((uint32_t)error < (uint32_t)ErrorCode::Count); return s_error_strings[(uint32_t)error]; diff --git a/userspace/aoc2023/day17/main.cpp b/userspace/aoc2023/day17/main.cpp index f5f83f4722..a56cb001e9 100644 --- a/userspace/aoc2023/day17/main.cpp +++ b/userspace/aoc2023/day17/main.cpp @@ -1,6 +1,7 @@ -#include -#include #include +#include +#include +#include #include #include diff --git a/userspace/aoc2023/day21/main.cpp b/userspace/aoc2023/day21/main.cpp index 461497dd4c..4bfd374d66 100644 --- a/userspace/aoc2023/day21/main.cpp +++ b/userspace/aoc2023/day21/main.cpp @@ -1,5 +1,6 @@ -#include #include +#include +#include #include #include diff --git a/userspace/aoc2023/day24/main.cpp b/userspace/aoc2023/day24/main.cpp index 5384431712..8024454ee4 100644 --- a/userspace/aoc2023/day24/main.cpp +++ b/userspace/aoc2023/day24/main.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/userspace/aoc2023/day5/main.cpp b/userspace/aoc2023/day5/main.cpp index 690d2e3560..e0a37ea69d 100644 --- a/userspace/aoc2023/day5/main.cpp +++ b/userspace/aoc2023/day5/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/userspace/aoc2023/day6/main.cpp b/userspace/aoc2023/day6/main.cpp index a56d62c34d..3c503952fa 100644 --- a/userspace/aoc2023/day6/main.cpp +++ b/userspace/aoc2023/day6/main.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/userspace/dhcp-client/main.cpp b/userspace/dhcp-client/main.cpp index 3e01cd90d9..3583d8f2ee 100644 --- a/userspace/dhcp-client/main.cpp +++ b/userspace/dhcp-client/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/userspace/image/Image.h b/userspace/image/Image.h index 87ec66c153..02273b1789 100644 --- a/userspace/image/Image.h +++ b/userspace/image/Image.h @@ -1,7 +1,8 @@ #pragma once -#include +#include #include +#include class Image {