diff --git a/kernel/src/memory/Heap.cpp b/kernel/src/memory/Heap.cpp index ad16eebe..e7dba4f2 100644 --- a/kernel/src/memory/Heap.cpp +++ b/kernel/src/memory/Heap.cpp @@ -178,7 +178,7 @@ Result kmalloc(usize size) heap.append(block); } - HeapBlock* block = heap.first().value(); + HeapBlock* block = heap.expect_first(); while (block) { // Trying to find a free block... @@ -330,7 +330,7 @@ void dump_heap_usage() } usize alloc_total = 0; usize alloc_used = 0; - HeapBlock* block = heap.first().value(); + HeapBlock* block = heap.expect_first(); while (block) { if (is_block_free(block)) diff --git a/kernel/src/thread/Scheduler.cpp b/kernel/src/thread/Scheduler.cpp index c925d356..9722afac 100644 --- a/kernel/src/thread/Scheduler.cpp +++ b/kernel/src/thread/Scheduler.cpp @@ -98,7 +98,7 @@ namespace Scheduler do { auto maybe_next = g_threads.next(g_current); - if (maybe_next.has_error()) g_current = g_threads.first().value(); + if (maybe_next.has_error()) g_current = g_threads.expect_first(); else g_current = maybe_next.value(); diff --git a/luna/include/luna/LinkedList.h b/luna/include/luna/LinkedList.h index 5e343b3d..698e5a9a 100644 --- a/luna/include/luna/LinkedList.h +++ b/luna/include/luna/LinkedList.h @@ -106,11 +106,21 @@ template class DoublyLinkedList return nonnull_or_error((T*)m_start_node); } + T* expect_first() + { + return first().value(); + } + Result last() { return nonnull_or_error((T*)m_end_node); } + T* expect_last() + { + return last().value(); + } + Result next(T* item) { return nonnull_or_error((T*)extract_node(item)->get_next());