diff --git a/src/context/memory.rs b/src/context/memory.rs index 7c24add14f..ecc8ec5f5e 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -87,11 +87,10 @@ pub struct AddrSpaceWrapper { } impl AddrSpaceWrapper { pub fn new() -> Result> { - Arc::try_new(Self { + Ok(Arc::new(Self { inner: RwLock::new(AddrSpace::new()?), tlb_ack: AtomicU32::new(0), - }) - .map_err(|_| Error::new(ENOMEM)) + })) } pub fn acquire_read(&self) -> RwLockReadGuard<'_, AddrSpace> { let my_percpu = PercpuBlock::current(); diff --git a/src/context/mod.rs b/src/context/mod.rs index 9d3242cde1..2990d50e08 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -4,7 +4,6 @@ use alloc::{collections::BTreeSet, sync::Arc}; use core::num::NonZeroUsize; -use syscall::ENOMEM; use crate::{ context::memory::AddrSpaceWrapper, @@ -15,7 +14,7 @@ use crate::{ ArcRwLockWriteGuard, CleanLockToken, LockToken, RwLock, RwLockReadGuard, RwLockWriteGuard, L0, L1, L2, }, - syscall::error::{Error, Result}, + syscall::error::Result, }; use self::context::Kstack; @@ -159,8 +158,7 @@ pub fn spawn( ) -> Result> { let stack = Kstack::new()?; - let context_lock = Arc::try_new(ContextLock::new(Context::new(owner_proc_id)?)) - .map_err(|_| Error::new(ENOMEM))?; + let context_lock = Arc::new(ContextLock::new(Context::new(owner_proc_id)?)); contexts_mut(token.token()).insert(ContextRef(Arc::clone(&context_lock))); diff --git a/src/main.rs b/src/main.rs index 54c3b066a3..c2e4adcb30 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,6 @@ // Ensure that all must_use results are used #![deny(unused_must_use)] #![warn(static_mut_refs)] // FIXME deny once all occurences are fixed -#![feature(allocator_api)] #![feature(if_let_guard)] #![feature(int_roundings)] #![feature(iter_next_chunk)] diff --git a/src/ptrace.rs b/src/ptrace.rs index 187b2b374f..755448ed27 100644 --- a/src/ptrace.rs +++ b/src/ptrace.rs @@ -87,8 +87,8 @@ impl Session { .as_ref()? .upgrade() } - pub fn try_new(file_id: usize) -> Result> { - Arc::try_new(Session { + pub fn new(file_id: usize) -> Arc { + Arc::new(Session { data: Mutex::new(SessionData { breakpoint: None, events: VecDeque::new(), @@ -97,7 +97,6 @@ impl Session { tracee: WaitCondition::new(), tracer: WaitCondition::new(), }) - .map_err(|_| Error::new(ENOMEM)) } } diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index 21ba16fe09..a9076e53a0 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -729,8 +729,7 @@ impl KernelScheme for ProcScheme { } let filetable = filetable.upgrade().ok_or(Error::new(EOWNERDEAD))?; - let new_filetable = Arc::try_new(spin::RwLock::new(filetable.read().clone())) - .map_err(|_| Error::new(ENOMEM))?; + let new_filetable = Arc::new(spin::RwLock::new(filetable.read().clone())); handle( Handle {