Update .clang-format
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2022-12-21 20:22:44 +01:00
parent 96135ff808
commit a3595e71a9
Signed by: apio
GPG Key ID: B8A7D06E42258954
17 changed files with 552 additions and 550 deletions

View File

@ -9,4 +9,6 @@ AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Always AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'true' AllowShortLoopsOnASingleLine: 'true'
PointerAlignment: Left PointerAlignment: Left
Cpp11BracedListStyle: 'false'
SpaceBeforeCpp11BracedList: 'true'

View File

@ -14,8 +14,8 @@ static constexpr u32 WHITE = 0xffffffff;
static constexpr u32 YELLOW = 0xffffff00; static constexpr u32 YELLOW = 0xffffff00;
static constexpr u32 RED = 0xffff0000; static constexpr u32 RED = 0xffff0000;
static char log_level_letters[] = {'D', 'I', 'W', 'E'}; // D for debug, I for info, W for warning, E for error static char log_level_letters[] = { 'D', 'I', 'W', 'E' }; // D for debug, I for info, W for warning, E for error
static const char* ansi_color_codes_per_log_level[] = {"37", "37", "33", "31"}; // 37 is white, 33 yellow, 31 red static const char* ansi_color_codes_per_log_level[] = { "37", "37", "33", "31" }; // 37 is white, 33 yellow, 31 red
static void log_serial(LogLevel level, const char* format, va_list origin) static void log_serial(LogLevel level, const char* format, va_list origin)
{ {

View File

@ -13,7 +13,7 @@ static inline constexpr bool isleap(u32 year)
static constexpr u32 make_yday(u32 year, u32 month) static constexpr u32 make_yday(u32 year, u32 month)
{ {
constexpr u16 upto[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; constexpr u16 upto[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
u32 yd = upto[month - 1]; u32 yd = upto[month - 1];
if (month > 2 && isleap(year)) yd++; if (month > 2 && isleap(year)) yd++;

View File

@ -44,13 +44,13 @@ struct [[gnu::packed]] alignas(4096) GlobalDescriptorTable
TSS task_state_segment; TSS task_state_segment;
static GlobalDescriptorTable gdt = {{0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00}, static GlobalDescriptorTable gdt = { { 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00 },
{0xffff, 0x0000, 0x00, 0x9a, 0xaf, 0x00}, { 0xffff, 0x0000, 0x00, 0x9a, 0xaf, 0x00 },
{0xffff, 0x0000, 0x00, 0x92, 0xcf, 0x00}, { 0xffff, 0x0000, 0x00, 0x92, 0xcf, 0x00 },
{0xffff, 0x0000, 0x00, 0xfa, 0xaf, 0x00}, { 0xffff, 0x0000, 0x00, 0xfa, 0xaf, 0x00 },
{0xffff, 0x0000, 0x00, 0xf2, 0xcf, 0x00}, { 0xffff, 0x0000, 0x00, 0xf2, 0xcf, 0x00 },
{0x0000, 0x0000, 0x00, 0xe9, 0x0f, 0x00}, { 0x0000, 0x0000, 0x00, 0xe9, 0x0f, 0x00 },
{0x00000000, 0x00000000}}; { 0x00000000, 0x00000000 } };
extern "C" void load_gdt(GDTR* gdtr); extern "C" void load_gdt(GDTR* gdtr);
extern "C" void load_tr(int segment); extern "C" void load_tr(int segment);

View File

@ -22,7 +22,7 @@ MemoryMapEntry& MemoryMapEntry::operator=(const MemoryMapEntry& other)
static MemoryMapEntry memory_map_entry_from_mmapent(const MMapEnt* ent) static MemoryMapEntry memory_map_entry_from_mmapent(const MMapEnt* ent)
{ {
return {MMapEnt_Ptr(ent), MMapEnt_Size(ent), MMapEnt_IsFree(ent)}; return { MMapEnt_Ptr(ent), MMapEnt_Size(ent), MMapEnt_IsFree(ent) };
} }
MemoryMapIterator::MemoryMapIterator() : m_mmap_entries((bootboot.size - 128) / 16), m_base_ent(&bootboot.mmap) MemoryMapIterator::MemoryMapIterator() : m_mmap_entries((bootboot.size - 128) / 16), m_base_ent(&bootboot.mmap)

View File

@ -26,7 +26,7 @@ namespace Scheduler
u64 idle_stack_vm = MemoryManager::alloc_for_kernel(1, MMU::NoExecute | MMU::ReadWrite) u64 idle_stack_vm = MemoryManager::alloc_for_kernel(1, MMU::NoExecute | MMU::ReadWrite)
.expect_value("Error while setting up the idle task, cannot continue"); .expect_value("Error while setting up the idle task, cannot continue");
Stack idle_stack{idle_stack_vm, ARCH_PAGE_SIZE}; Stack idle_stack { idle_stack_vm, ARCH_PAGE_SIZE };
g_idle.set_sp(idle_stack.top()); g_idle.set_sp(idle_stack.top());
g_idle.stack = idle_stack; g_idle.stack = idle_stack;
@ -55,7 +55,7 @@ namespace Scheduler
guard.deactivate(); guard.deactivate();
Stack thread_stack{thread_stack_vm, ARCH_PAGE_SIZE * 4}; Stack thread_stack { thread_stack_vm, ARCH_PAGE_SIZE * 4 };
thread->set_sp(thread_stack.top()); thread->set_sp(thread_stack.top());
thread->stack = thread_stack; thread->stack = thread_stack;

View File

@ -16,7 +16,7 @@ class Spinlock
} }
private: private:
Atomic<int> m_lock{0}; Atomic<int> m_lock { 0 };
}; };
template <typename T> class LockedValue template <typename T> class LockedValue
@ -76,12 +76,12 @@ template <typename T> class LockedValue
LockedValueGuard lock() LockedValueGuard lock()
{ {
m_lock.lock(); m_lock.lock();
return {*this}; return { *this };
} }
Option<LockedValueGuard> try_lock() Option<LockedValueGuard> try_lock()
{ {
if (m_lock.try_lock()) { return {*this}; } if (m_lock.try_lock()) { return { *this }; }
return {}; return {};
} }

File diff suppressed because it is too large Load Diff

View File

@ -83,7 +83,7 @@ template <typename T> class Option
ErrorHandle release_error() ErrorHandle release_error()
{ {
expect(!has_value(), "Option::release_error called on a non-empty Option"); expect(!has_value(), "Option::release_error called on a non-empty Option");
return ErrorHandle{}; return ErrorHandle {};
} }
private: private:
@ -127,5 +127,5 @@ template <typename T> class Option
} }
}; };
Storage m_storage; Storage m_storage;
bool m_has_value{false}; bool m_has_value { false };
}; };

View File

@ -27,6 +27,6 @@ class OwnedStringView
const char& operator[](usize) const; const char& operator[](usize) const;
private: private:
char* m_string{nullptr}; char* m_string { nullptr };
usize m_length{0}; usize m_length { 0 };
}; };

View File

@ -60,7 +60,7 @@ template <typename T> class Result
Error release_error() const Error release_error() const
{ {
expect(has_error(), "Result::release_error() called on a Result that holds a value"); expect(has_error(), "Result::release_error() called on a Result that holds a value");
return {m_error}; return { m_error };
} }
const char* error_string() const const char* error_string() const
@ -154,7 +154,7 @@ template <> class Result<void>
Error release_error() const Error release_error() const
{ {
expect(has_error(), "Result::release_error() called on a Result that holds a value"); expect(has_error(), "Result::release_error() called on a Result that holds a value");
return {m_error}; return { m_error };
} }
const char* error_string() const const char* error_string() const

View File

@ -18,11 +18,11 @@ template <typename Callback> class ScopeGuard
} }
private: private:
bool m_activated{true}; bool m_activated { true };
Callback m_callback; Callback m_callback;
}; };
template <typename Callback> [[nodiscard]] ScopeGuard<Callback> make_scope_guard(const Callback& callback) template <typename Callback> [[nodiscard]] ScopeGuard<Callback> make_scope_guard(const Callback& callback)
{ {
return {callback}; return { callback };
} }

View File

@ -487,7 +487,7 @@ Result<usize> cstyle_format(const char* format, callback_t callback, void* arg,
usize precision = parse_precision(&format, flags, ap); usize precision = parse_precision(&format, flags, ap);
parse_length(&format, flags); parse_length(&format, flags);
conv_state vstate = {flags, width, precision}; conv_state vstate = { flags, width, precision };
const char specifier = *format; const char specifier = *format;
format++; format++;
@ -587,7 +587,7 @@ usize pure_cstyle_format(const char* format, pure_callback_t callback, void* arg
usize precision = parse_precision(&format, flags, ap); usize precision = parse_precision(&format, flags, ap);
parse_length(&format, flags); parse_length(&format, flags);
conv_state vstate = {flags, width, precision}; conv_state vstate = { flags, width, precision };
const char specifier = *format; const char specifier = *format;
format++; format++;
@ -664,7 +664,7 @@ struct StringFormatInfo
usize vstring_format(char* buf, usize max, const char* format, va_list ap) usize vstring_format(char* buf, usize max, const char* format, va_list ap)
{ {
StringFormatInfo info = {.buffer = buf, .remaining = max - 1}; StringFormatInfo info = { .buffer = buf, .remaining = max - 1 };
usize result = pure_cstyle_format( usize result = pure_cstyle_format(
format, format,

View File

@ -32,7 +32,7 @@ Result<OwnedStringView> OwnedStringView::clone() const
if (!c_str) return err(ENOMEM); if (!c_str) return err(ENOMEM);
return OwnedStringView{c_str}; return OwnedStringView { c_str };
} }
const char& OwnedStringView::operator[](usize index) const const char& OwnedStringView::operator[](usize index) const
@ -45,5 +45,5 @@ Result<OwnedStringView> OwnedStringView::from_string_literal(const char* str)
{ {
char* dup = strdup(str); char* dup = strdup(str);
if (!dup) return err(ENOMEM); if (!dup) return err(ENOMEM);
return OwnedStringView{dup}; return OwnedStringView { dup };
} }

View File

@ -105,5 +105,5 @@ Result<OwnedStringView> TarStream::read_contents_as_string(const Entry& entry, u
buf[nread] = 0; buf[nread] = 0;
return OwnedStringView{buf}; return OwnedStringView { buf };
} }

View File

@ -24,5 +24,5 @@ Result<OwnedStringView> to_dynamic_unit(usize value)
to_dynamic_unit_cstr(value, buf, 64); to_dynamic_unit_cstr(value, buf, 64);
return OwnedStringView{buf}; return OwnedStringView { buf };
} }

View File

@ -208,11 +208,11 @@ Result<Option<wchar_t>> Utf8StateDecoder::feed(char c)
if (m_state_len == 1) if (m_state_len == 1)
{ {
m_state_len = 0; m_state_len = 0;
return Option<wchar_t>{c & 0x7f}; return Option<wchar_t> { c & 0x7f };
} }
m_state_index = 0; m_state_index = 0;
m_state[m_state_index] = c; m_state[m_state_index] = c;
return {{}}; return { {} };
} }
m_state_index++; m_state_index++;
@ -223,10 +223,10 @@ Result<Option<wchar_t>> Utf8StateDecoder::feed(char c)
usize len = m_state_len; usize len = m_state_len;
wchar_t wc = TRY(encode_utf8_as_wide_char(m_state, len)); wchar_t wc = TRY(encode_utf8_as_wide_char(m_state, len));
m_state_len = 0; m_state_len = 0;
return Option<wchar_t>{wc}; return Option<wchar_t> { wc };
} }
return {{}}; return { {} };
} }
void Utf8StateDecoder::reset() void Utf8StateDecoder::reset()