From 22019ac6b23f45e4423c58ca28fe2e450b57cbf4 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 4 Dec 2022 12:57:43 +0100 Subject: [PATCH] Print the error instead --- kernel/src/memory/Heap.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/src/memory/Heap.cpp b/kernel/src/memory/Heap.cpp index ceb96406..f8fd6210 100644 --- a/kernel/src/memory/Heap.cpp +++ b/kernel/src/memory/Heap.cpp @@ -368,14 +368,16 @@ void dump_heap_usage() void* operator new(usize size) { - return kmalloc(size).expect_release_value("FIXME: Kernel new panics on OOM, since there are no exceptions. If " - "possible, use make for error propagation."); + auto rc = kmalloc(size); + if (rc.has_error()) { expect(false, rc.error_string()); } + return rc.release_value(); } void* operator new[](usize size) { - return kmalloc(size).expect_release_value("FIXME: Kernel new[] panics on OOM, since there are no exceptions. If " - "possible, use make for error propagation."); + auto rc = kmalloc(size); + if (rc.has_error()) { expect(false, rc.error_string()); } + return rc.release_value(); } void operator delete(void* p)