From fb124dd2280af102e60eba2d538ebb0900fadd40 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 31 Jul 2021 23:09:00 +1200 Subject: [PATCH] Fix clippy warnings --- daemon/src/config_aura.rs | 4 ++-- daemon/src/ctrl_gfx/controller.rs | 17 ++++++++--------- daemon/src/ctrl_gfx/system.rs | 4 ++-- daemon/src/ctrl_leds/controller.rs | 4 ++-- daemon/src/ctrl_profiles/zbus.rs | 2 +- rog-aura/src/sequencer.rs | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/daemon/src/config_aura.rs b/daemon/src/config_aura.rs index d60b2809..4cb8924e 100644 --- a/daemon/src/config_aura.rs +++ b/daemon/src/config_aura.rs @@ -90,7 +90,7 @@ impl AuraConfig { let mut buf = String::new(); if let Ok(read_len) = file.read_to_string(&mut buf) { if read_len == 0 { - return AuraConfig::create_default(&mut file, &supported_led_modes); + return AuraConfig::create_default(&mut file, supported_led_modes); } else { if let Ok(data) = serde_json::from_str(&buf) { return data; @@ -109,7 +109,7 @@ impl AuraConfig { panic!("Please remove {} then restart asusd", AURA_CONFIG_PATH); } } - AuraConfig::create_default(&mut file, &supported_led_modes) + AuraConfig::create_default(&mut file, supported_led_modes) } fn create_default(file: &mut File, support_data: &LaptopLedData) -> Self { diff --git a/daemon/src/ctrl_gfx/controller.rs b/daemon/src/ctrl_gfx/controller.rs index d4d92c3c..6a2f23b2 100644 --- a/daemon/src/ctrl_gfx/controller.rs +++ b/daemon/src/ctrl_gfx/controller.rs @@ -8,7 +8,6 @@ use logind_zbus::{ ManagerProxy, SessionProxy, }; use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors}; -use std::iter::FromIterator; use std::{io::Write, ops::Add, path::Path, time::Instant}; use std::{process::Command, thread::sleep, time::Duration}; use std::{str::FromStr, sync::mpsc}; @@ -79,20 +78,20 @@ impl CtrlGraphics { match dev.vendor()? { 0x1002 => { info!("GFX: {}: AMD graphics", dev.id()); - amd.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); + amd.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev))); } 0x10DE => { info!("GFX: {}: NVIDIA graphics", dev.id()); dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?; - nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); + nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev))); } 0x8086 => { info!("GFX: {}: Intel graphics", dev.id()); - intel.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); + intel.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev))); } vendor => { info!("GFX: {}: Other({:X}) graphics", dev.id(), vendor); - other.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); + other.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev))); } } } @@ -265,13 +264,13 @@ impl CtrlGraphics { let unbinds = devices.iter().map(|dev| dev.unbind()); // Remove NVIDIA graphics devices and their functions let removes = devices.iter().map(|dev| dev.remove()); - Result::from_iter(unbinds.chain(removes)) + unbinds.chain(removes).collect::>() .map_err(|err| RogError::Command("device unbind error".into(), err)) } fn unbind_only(devices: &[GraphicsDevice]) -> Result<(), RogError> { let unbinds = devices.iter().map(|dev| dev.unbind()); - Result::from_iter(unbinds) + unbinds.collect::>() .map_err(|err| RogError::Command("device unbind error".into(), err)) } @@ -462,7 +461,7 @@ impl CtrlGraphics { for driver in NVIDIA_DRIVERS.iter() { Self::do_driver_action(driver, "rmmod")?; } - Self::unbind_only(&devices)?; + Self::unbind_only(devices)?; Self::do_driver_action("vfio-pci", "modprobe")?; } else { return Err(GfxError::VfioDisabled.into()); @@ -478,7 +477,7 @@ impl CtrlGraphics { for driver in NVIDIA_DRIVERS.iter() { Self::do_driver_action(driver, "rmmod")?; } - Self::unbind_remove_nvidia(&devices)?; + Self::unbind_remove_nvidia(devices)?; } } Ok(()) diff --git a/daemon/src/ctrl_gfx/system.rs b/daemon/src/ctrl_gfx/system.rs index f730a9ae..ce1ddf67 100644 --- a/daemon/src/ctrl_gfx/system.rs +++ b/daemon/src/ctrl_gfx/system.rs @@ -83,7 +83,7 @@ impl GraphicsDevice { Ok(driver) => { info!("{}: Unbinding {}", driver.id(), func.id()); unsafe { - driver.unbind(&func).map_err(|err| { + driver.unbind(func).map_err(|err| { error!("gfx unbind: {}", err); err })?; @@ -109,7 +109,7 @@ impl GraphicsDevice { Ok(driver) => { info!("{}: Binding {}", driver.id(), func.id()); unsafe { - driver.bind(&func).map_err(|err| { + driver.bind(func).map_err(|err| { error!("gfx bind: {}", err); err })?; diff --git a/daemon/src/ctrl_leds/controller.rs b/daemon/src/ctrl_leds/controller.rs index e37b5fea..d9e0a64f 100644 --- a/daemon/src/ctrl_leds/controller.rs +++ b/daemon/src/ctrl_leds/controller.rs @@ -370,7 +370,7 @@ impl CtrlKbdLed { self.config.read(); if let Some(data) = self.config.builtins.get(&next) { - self.write_mode(&data)?; + self.write_mode(data)?; self.config.current_mode = next; } self.config.write(); @@ -381,7 +381,7 @@ impl CtrlKbdLed { #[inline] fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> { - if !self.supported_modes.standard.contains(&mode.mode()) { + if !self.supported_modes.standard.contains(mode.mode()) { return Err(RogError::NotSupported); } let bytes: [u8; LED_MSG_LEN] = mode.into(); diff --git a/daemon/src/ctrl_profiles/zbus.rs b/daemon/src/ctrl_profiles/zbus.rs index 4ae52096..84c7da2b 100644 --- a/daemon/src/ctrl_profiles/zbus.rs +++ b/daemon/src/ctrl_profiles/zbus.rs @@ -139,7 +139,7 @@ impl FanAndCpuZbus { if let Ok(ctrl) = self.inner.try_lock() { if let Ok(cfg) = ctrl.config.clone().try_lock() { if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) { - self.notify_profile(&profile) + self.notify_profile(profile) .unwrap_or_else(|err| warn!("{}", err)); } } diff --git a/rog-aura/src/sequencer.rs b/rog-aura/src/sequencer.rs index c54f1c61..f3ba5016 100644 --- a/rog-aura/src/sequencer.rs +++ b/rog-aura/src/sequencer.rs @@ -39,7 +39,7 @@ impl Sequences { pub fn iter(&self) -> ActionIterator { ActionIterator { - actions: &self, + actions: self, next_idx: 0, } }