From 939b63f898d8d868267f75dc4436c3bbb69c54d3 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Tue, 27 Jul 2021 22:11:09 +0800 Subject: [PATCH] fix bugs in shown in 'cargo clippy --all-features' --- linux-object/src/fs/mod.rs | 2 +- rboot | 2 +- zircon-object/Cargo.toml | 4 ++-- zircon-object/src/dev/pci/bus.rs | 2 +- zircon-object/src/dev/pci/nodes.rs | 8 ++++---- zircon-object/src/signal/futex.rs | 4 ++-- zircon-object/src/util/elf_loader.rs | 4 ++-- zircon-object/src/vm/vmar.rs | 4 ++-- zircon-syscall/src/channel.rs | 4 ++-- zircon-syscall/src/task.rs | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/linux-object/src/fs/mod.rs b/linux-object/src/fs/mod.rs index 466f2d34..3a653b9a 100644 --- a/linux-object/src/fs/mod.rs +++ b/linux-object/src/fs/mod.rs @@ -189,7 +189,7 @@ impl LinuxProcess { FileType::SymLink, ))); } - let (fd_dir_path, fd_name) = split_path(&path); + let (fd_dir_path, fd_name) = split_path(path); if fd_dir_path == "/proc/self/fd" { let fd = FileDesc::try_from(fd_name)?; let fd_path = &self.get_file(fd)?.path; diff --git a/rboot b/rboot index 00416ef5..cea94e5c 160000 --- a/rboot +++ b/rboot @@ -1 +1 @@ -Subproject commit 00416ef505784e88e56cf08d6e9f7c7a2a00be16 +Subproject commit cea94e5c8f600ac86366539bd683bb17df993cfe diff --git a/zircon-object/Cargo.toml b/zircon-object/Cargo.toml index 7c7bf893..9f595da9 100644 --- a/zircon-object/Cargo.toml +++ b/zircon-object/Cargo.toml @@ -10,7 +10,7 @@ description = "Zircon kernel objects" [features] aspace-separate = [] elf = ["xmas-elf"] -hypervisor = ["rvm"] +#hypervisor = ["rvm"] [dependencies] bitflags = "1.2" @@ -25,7 +25,7 @@ xmas-elf = { version = "0.7", optional = true } region-alloc = { git = "https://github.com/rzswh/region-allocator", rev = "122c7a71" } lazy_static = { version = "1.4", features = ["spin_no_std" ] } acpi = "1.1" -rvm = { git = "https://github.com/rcore-os/RVM", rev = "382fc60", optional = true } +#rvm = { git = "https://github.com/rcore-os/RVM", rev = "382fc60", optional = true } [dev-dependencies] kernel-hal-unix = { path = "../kernel-hal-unix" } diff --git a/zircon-object/src/dev/pci/bus.rs b/zircon-object/src/dev/pci/bus.rs index 71020d6b..2798b0b3 100644 --- a/zircon-object/src/dev/pci/bus.rs +++ b/zircon-object/src/dev/pci/bus.rs @@ -177,7 +177,7 @@ impl PCIeBusDriver { )?; self.foreach_root( |root, _c| { - root.base_upstream.scan_downstream(&self); + root.base_upstream.scan_downstream(self); true }, (), diff --git a/zircon-object/src/dev/pci/nodes.rs b/zircon-object/src/dev/pci/nodes.rs index f929f31b..3ae4d398 100644 --- a/zircon-object/src/dev/pci/nodes.rs +++ b/zircon-object/src/dev/pci/nodes.rs @@ -404,7 +404,7 @@ impl PcieDeviceInner { for c in self.caps.iter() { if let PciCapability::Msi(std, msi) = c { if std.is_valid() { - return Some((&std, &msi)); + return Some((std, msi)); } } } @@ -414,7 +414,7 @@ impl PcieDeviceInner { for c in self.caps.iter() { if let PciCapability::Pcie(std, pcie) = c { if std.is_valid() { - return Some((&std, &pcie)); + return Some((std, pcie)); } } } @@ -647,7 +647,7 @@ impl PcieDevice { pub fn allocate_bars(&self) -> ZxResult { let mut inner = self.inner.lock(); - assert_eq!(inner.plugged_in, true); + assert!(inner.plugged_in); for i in 0..self.bar_count { let bar_info = &inner.bars[i]; if bar_info.size == 0 || bar_info.allocation.is_some() { @@ -1387,7 +1387,7 @@ impl PciBridge { .set_super(Arc::downgrade(&(node.clone() as _))); node.base_upstream .set_super(Arc::downgrade(&(node.clone() as _))); - node.init(&driver); + node.init(driver); node }) } diff --git a/zircon-object/src/signal/futex.rs b/zircon-object/src/signal/futex.rs index 4a136e26..f1241123 100644 --- a/zircon-object/src/signal/futex.rs +++ b/zircon-object/src/signal/futex.rs @@ -162,7 +162,7 @@ impl Futex { if !inner.woken { let futex = inner.futex.clone(); let queue = &mut futex.inner.lock().waiter_queue; - if let Some(pos) = queue.iter().position(|x| Arc::ptr_eq(&x, &self.waiter)) { + if let Some(pos) = queue.iter().position(|x| Arc::ptr_eq(x, &self.waiter)) { // Nobody cares about the order of queue, so just remove faster queue.swap_remove_back(pos); } @@ -258,7 +258,7 @@ impl FutexInner { .waiter_queue .iter() .filter_map(|waiter| waiter.thread.as_ref()) - .any(|thread| Arc::ptr_eq(&thread, new_owner)) + .any(|thread| Arc::ptr_eq(thread, new_owner)) { return false; } diff --git a/zircon-object/src/util/elf_loader.rs b/zircon-object/src/util/elf_loader.rs index 8c882db7..4c9efe10 100644 --- a/zircon-object/src/util/elf_loader.rs +++ b/zircon-object/src/util/elf_loader.rs @@ -24,7 +24,7 @@ impl VmarExt for VmAddressRegion { if ph.get_type().unwrap() != Type::Load { continue; } - let vmo = make_vmo(&elf, ph)?; + let vmo = make_vmo(elf, ph)?; let offset = ph.virtual_addr() as usize / PAGE_SIZE * PAGE_SIZE; let flags = ph.flags().to_mmu_flags(); self.map_at(offset, vmo.clone(), 0, vmo.len(), flags)?; @@ -72,7 +72,7 @@ fn make_vmo(elf: &ElfFile, ph: ProgramHeader) -> ZxResult> { let page_offset = ph.virtual_addr() as usize % PAGE_SIZE; let pages = pages(ph.mem_size() as usize + page_offset); let vmo = VmObject::new_paged(pages); - let data = match ph.get_data(&elf).unwrap() { + let data = match ph.get_data(elf).unwrap() { SegmentData::Undefined(data) => data, _ => return Err(ZxError::INVALID_ARGS), }; diff --git a/zircon-object/src/vm/vmar.rs b/zircon-object/src/vm/vmar.rs index 16982f93..08be43ba 100644 --- a/zircon-object/src/vm/vmar.rs +++ b/zircon-object/src/vm/vmar.rs @@ -407,7 +407,7 @@ impl VmAddressRegion { if !check_aligned(len, align) { Err(ZxError::INVALID_ARGS) } else if let Some(offset) = offset { - if check_aligned(offset, align) && self.test_map(&inner, offset, len, align) { + if check_aligned(offset, align) && self.test_map(inner, offset, len, align) { Ok(offset) } else { Err(ZxError::INVALID_ARGS) @@ -415,7 +415,7 @@ impl VmAddressRegion { } else if len > self.size { Err(ZxError::INVALID_ARGS) } else { - match self.find_free_area(&inner, 0, len, align) { + match self.find_free_area(inner, 0, len, align) { Some(offset) => Ok(offset), None => Err(ZxError::NO_MEMORY), } diff --git a/zircon-syscall/src/channel.rs b/zircon-syscall/src/channel.rs index eec8ee08..0aa6952b 100644 --- a/zircon-syscall/src/channel.rs +++ b/zircon-syscall/src/channel.rs @@ -280,7 +280,7 @@ fn handle_check( Err(ZxError::ACCESS_DENIED) } else if disposition.handle == handle_value { Err(ZxError::NOT_SUPPORTED) - } else if disposition.type_ != 0 && disposition.type_ != obj_type(&object) { + } else if disposition.type_ != 0 && disposition.type_ != obj_type(object) { Err(ZxError::WRONG_TYPE) } else if disposition.op != ZX_HANDLE_OP_MOVE && disposition.op != ZX_HANDLE_OP_DUP || disposition.rights != Rights::SAME_RIGHTS.bits() @@ -326,7 +326,7 @@ static TESTS_ARGS: spin::Mutex = spin::Mutex::new(String::new()); #[allow(clippy::naive_bytecount)] fn hack_core_tests(handle: HandleValue, thread_name: &str, data: &mut Vec) { if handle == 3 && thread_name == "userboot" { - let cmdline = core::str::from_utf8(&data).unwrap(); + let cmdline = core::str::from_utf8(data).unwrap(); for kv in cmdline.split('\0') { if let Some(v) = kv.strip_prefix("core-tests=") { *TESTS_ARGS.lock() = format!("test\0-f\0{}\0", v.replace(',', ":")); diff --git a/zircon-syscall/src/task.rs b/zircon-syscall/src/task.rs index 556c0171..418a7693 100644 --- a/zircon-syscall/src/task.rs +++ b/zircon-syscall/src/task.rs @@ -91,7 +91,7 @@ impl Syscall<'_> { let proc = self.thread.proc(); let process = proc.get_object_with_rights::(proc_handle, Rights::WRITE)?; let thread = proc.get_object_with_rights::(thread_handle, Rights::WRITE)?; - if !Arc::ptr_eq(&thread.proc(), &process) { + if !Arc::ptr_eq(thread.proc(), &process) { return Err(ZxError::ACCESS_DENIED); } let arg1 = if arg1_handle != INVALID_HANDLE { @@ -222,7 +222,7 @@ impl Syscall<'_> { info!("task.suspend_token: handle={:?}, token={:?}", handle, token); let proc = self.thread.proc(); if let Ok(thread) = proc.get_object_with_rights::(handle, Rights::WRITE) { - if Arc::ptr_eq(&thread, &self.thread) { + if Arc::ptr_eq(&thread, self.thread) { return Err(ZxError::NOT_SUPPORTED); } if thread.state() == ThreadState::Dying || thread.state() == ThreadState::Dead {