From 2c859ced8adb5a9876d39b34471400a43516b036 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 20 Aug 2022 16:22:55 -0700 Subject: Return result of initialization --- src/kernel.rs | 2 +- src/mem/alloc.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/kernel.rs b/src/kernel.rs index 28d8f87..3d93e37 100644 --- a/src/kernel.rs +++ b/src/kernel.rs @@ -40,7 +40,7 @@ use crate::mem::alloc::alloc; /// the regular main. unsafe fn kernel_init() -> ! { console().init().unwrap(); - alloc().init(); + alloc().init().unwrap(); kernel_main() } diff --git a/src/mem/alloc.rs b/src/mem/alloc.rs index fcd33c2..f4ba935 100644 --- a/src/mem/alloc.rs +++ b/src/mem/alloc.rs @@ -5,7 +5,8 @@ use alloc::alloc::{GlobalAlloc,Layout}; use crate::sync::NullLock; use crate::sync::interface::Mutex; -use core::fmt::{Debug,Formatter,Result}; +use core::fmt; +use core::fmt::{Debug,Formatter}; /// # Initialize Queue /// - Name: Symbol name @@ -58,7 +59,7 @@ impl Debug for QueueItem<'_,T> { /// # Debug formatter for `QueueItem` /// /// Output the encapsulated data - fn fmt(&self, f: &mut Formatter<'_>) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.data) } } @@ -149,7 +150,7 @@ impl Debug for QueueAllocator<'_,T,COUNT> { /// /// Output each data point in the array with /// its debug formatter. - fn fmt(&self, f: &mut Formatter<'_>) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { self.inner.lock(|queue| { write!(f, "{:?}", queue) }) @@ -235,7 +236,7 @@ init_queue!(U2048_GRAND_ALLOC, GRAND_ALLOC_SIZE, {U2048::new()}, U2048); init_queue!(U4096_GRAND_ALLOC, GRAND_ALLOC_SIZE, {U4096::new()}, U4096); impl GrandAllocator { - pub fn init(&self) { + pub fn init(&self) -> Result<(), &'static str> { U8_GRAND_ALLOC.init(); U16_GRAND_ALLOC.init(); U32_GRAND_ALLOC.init(); @@ -246,6 +247,7 @@ impl GrandAllocator { U1024_GRAND_ALLOC.init(); U2048_GRAND_ALLOC.init(); U4096_GRAND_ALLOC.init(); + Ok(()) } } -- cgit v1.2.1