diff --git a/src/kernel/exception.rs b/src/kernel/exception.rs index 45fb0c1..798b5d3 100644 --- a/src/kernel/exception.rs +++ b/src/kernel/exception.rs @@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc}; use crate::{simulator::{machine::{ExceptionType, Machine}, error::{MachineOk, MachineError}}}; use crate::kernel::synch::{Lock, Semaphore}; -use super::{system::{System, self}, thread::Thread}; +use super::{system::{System}, thread::Thread}; /// The halt system call. Stops Burritos. pub const SC_SHUTDOWN: u8 = 0; @@ -239,7 +239,7 @@ fn sc_sem_create(machine: &mut Machine, system: &mut System) -> Result Err(format!("Initial_count < 0"))?, + true => Err("Initial_count < 0".to_string())?, false => { let id = system.get_thread_manager().get_obj_addrs().add_semaphore(Semaphore::new(initial_count)); machine.write_int_register(10, id as i64); @@ -278,12 +278,12 @@ fn sc_new_thread(machine: &mut Machine, system: &mut System) -> Result { - Rc::clone(&th) + Rc::clone(th) }, None => unreachable!() }); } else { match thread_manager.get_g_current_thread() { Some(x) => { - let x = Rc::clone(&x); + let x = Rc::clone(x); self.waiting_queue.push(Rc::clone(&x)); thread_manager.thread_sleep(machine, Rc::clone(&x)); }, @@ -111,7 +111,7 @@ impl Lock { Some(thread) => { self.owner = Some(thread); match &self.owner { - Some(x) => thread_manager.ready_to_run(Rc::clone(&x)), + Some(x) => thread_manager.ready_to_run(Rc::clone(x)), None => () } }, diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index e09606e..2c2d7ac 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -252,7 +252,7 @@ impl ThreadManager { self.debug(format!("Finishing thread {}", thread.borrow().get_name())); // g_objets_addrs->removeObject(self.thread) // a ajouté plus tard for (_, el) in thread.borrow().join_thread.iter().enumerate() { - self.ready_to_run(Rc::clone(&el)); + self.ready_to_run(Rc::clone(el)); } self.thread_sleep(machine, Rc::clone(&thread)); machine.interrupt.set_status(old_status); @@ -512,7 +512,7 @@ mod test { thread_manager.lock_acquire(lock_id, &mut machine).expect("lock acquire return an error at second iteration: "); { let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap(); - assert_eq!(lock.owner,Some(thread_1.clone())); + assert_eq!(lock.owner,Some(thread_1)); assert!(!lock.free); assert_eq!(lock.waiting_queue.iter().count(),1); } @@ -525,7 +525,7 @@ mod test { assert!(lock.waiting_queue.is_empty()); } - thread_manager.set_g_current_thread(Some(thread_2.clone())); + thread_manager.set_g_current_thread(Some(thread_2)); thread_manager.lock_release(lock_id, &mut machine).expect("lock release return an error at second iteration: "); { let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap(); diff --git a/src/simulator/interrupt.rs b/src/simulator/interrupt.rs index c4be710..000302d 100644 --- a/src/simulator/interrupt.rs +++ b/src/simulator/interrupt.rs @@ -1,5 +1,5 @@ -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub struct Interrupt { level: InterruptStatus } @@ -21,7 +21,7 @@ impl Interrupt { old } - fn one_tick(&self, nb_cycle: i32) { + fn one_tick(&self, _nb_cycle: i32) { todo!(); } @@ -35,7 +35,7 @@ impl Interrupt { } -#[derive(PartialEq, Clone, Copy, Debug)] +#[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum InterruptStatus { InterruptOff, InterruptOn diff --git a/src/simulator/loader.rs b/src/simulator/loader.rs index 18f56fe..19146fe 100644 --- a/src/simulator/loader.rs +++ b/src/simulator/loader.rs @@ -619,7 +619,7 @@ mod test { assert_eq!(loader.sections[1].virt_addr, 0x4000); assert_eq!(loader.sections[1].image_offset, 0x1000); assert!(loader.sections[1].does_flag_contains_key(crate::simulator::loader::FlagValue::ShfAlloc)); - assert_eq!(loader.sections[2].virt_addr, 0x400_000); + assert_eq!(loader.sections[2].virt_addr, 0x0040_0000); assert_eq!(loader.sections[2].image_offset, 0x2000); assert!(loader.sections[2].does_flag_contains_key(crate::simulator::loader::FlagValue::ShfAlloc)); } diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index fae3a68..a689a0d 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -228,7 +228,7 @@ impl Machine { s } - pub fn raise_exception(&mut self, exception: ExceptionType, address : u64, system: &mut System) -> Result{ + pub fn raise_exception(&mut self, exception: ExceptionType, _address : u64, system: &mut System) -> Result{ self.set_status(MachineStatus::SystemMode); // Handle the interruption match exception::call(&exception, self, system) { diff --git a/src/simulator/register.rs b/src/simulator/register.rs index bbad262..427dbaa 100644 --- a/src/simulator/register.rs +++ b/src/simulator/register.rs @@ -21,7 +21,7 @@ impl RegisterNum for i64 {} impl RegisterNum for f32 {} /// Machine register array -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub struct Register { /// 32 available registers of type U register: [U; 32] diff --git a/src/simulator/translationtable.rs b/src/simulator/translationtable.rs index f0d7091..1d07d6a 100644 --- a/src/simulator/translationtable.rs +++ b/src/simulator/translationtable.rs @@ -22,7 +22,7 @@ impl TranslationTable { let mut tmp_vec : Vec = Vec::new(); - for i in 0..MaxVirtPages { + for _i in 0..MaxVirtPages { tmp_vec.push(PageTableEntry::create()); } @@ -36,7 +36,7 @@ impl TranslationTable { //Assert a mettre dans chacune des fonctions suivantes pub fn get_max_num_pages(&self) -> u64{ - return self.maxNumPages; + self.maxNumPages } pub fn set_physical_page(&mut self, vpn : u64, physical_page : i32){ diff --git a/src/utility/list.rs b/src/utility/list.rs index 0334261..1080878 100644 --- a/src/utility/list.rs +++ b/src/utility/list.rs @@ -9,7 +9,7 @@ use std::ptr; /// These methods wrap unsafe instructions because it doesn't respect borrow rules per example /// but everything has been tested with miri to assure there's no Undefined Behaviour (use-after-free, double free, etc.) /// or memory leak -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct List { head: Link, tail: Link,