diff --git a/crate/memory/src/memory_set/mod.rs b/crate/memory/src/memory_set/mod.rs index 12cd767f..f6324bb4 100644 --- a/crate/memory/src/memory_set/mod.rs +++ b/crate/memory/src/memory_set/mod.rs @@ -252,7 +252,7 @@ impl MemorySet { // subset let area = self.areas.remove(i); area.unmap(&mut self.page_table); - i -= 1; + i = i.wrapping_sub(1); } else if self.areas[i].start_addr >= start_addr && self.areas[i].start_addr < end_addr { @@ -324,7 +324,7 @@ impl MemorySet { i += 1; } } - i += 1; + i = i.wrapping_add(1); } } diff --git a/kernel/src/sync/condvar.rs b/kernel/src/sync/condvar.rs index 75784669..03f99fc2 100644 --- a/kernel/src/sync/condvar.rs +++ b/kernel/src/sync/condvar.rs @@ -25,7 +25,9 @@ impl Condvar { Condvar::default() } - pub fn wait_queue_len(&self) -> usize { self.wait_queue.lock().len() } + pub fn wait_queue_len(&self) -> usize { + self.wait_queue.lock().len() + } /// Park current thread and wait for this condvar to be notified. #[deprecated(note = "this may leads to lost wakeup problem. please use `wait` instead.")] diff --git a/kernel/src/sync/semaphore.rs b/kernel/src/sync/semaphore.rs index c1c6edca..ab7aae82 100644 --- a/kernel/src/sync/semaphore.rs +++ b/kernel/src/sync/semaphore.rs @@ -7,7 +7,6 @@ use super::SpinNoIrqLock as Mutex; use crate::syscall::SysError; use core::cell::Cell; use core::ops::Deref; -use crate::process::Pid; struct SemaphoreInner { pub count: isize, @@ -95,8 +94,12 @@ impl Semaphore { self.cvar.wait_queue_len() } - pub fn get_pid(&self) -> usize { self.lock.lock().pid } - pub fn set_pid(&self, pid: usize) { self.lock.lock().pid = pid; } + pub fn get_pid(&self) -> usize { + self.lock.lock().pid + } + pub fn set_pid(&self, pid: usize) { + self.lock.lock().pid = pid; + } /// Set the current count pub fn set(&self, value: isize) { diff --git a/kernel/src/syscall/ipc.rs b/kernel/src/syscall/ipc.rs index f1e86987..044fa0f6 100644 --- a/kernel/src/syscall/ipc.rs +++ b/kernel/src/syscall/ipc.rs @@ -74,7 +74,8 @@ impl Syscall<'_> { Ok(0) } IPC_STAT => { - *unsafe { self.vm().check_write_ptr(arg as *mut SemidDs)? } = *sem_array.semid_ds.lock(); + *unsafe { self.vm().check_write_ptr(arg as *mut SemidDs)? } = + *sem_array.semid_ds.lock(); Ok(0) } _ => {