From 2123f369adf5c97239119b3205ea134a8b7965ae Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 4 Jan 2025 20:04:07 +1300 Subject: [PATCH] Small clippy cleanups --- asusctl/src/main.rs | 8 +++----- asusd/src/asus_armoury.rs | 6 ++---- asusd/src/aura_manager.rs | 15 ++++++--------- rog-aura/src/aura_detection.rs | 4 +--- rog-control-center/src/zbus_proxies.rs | 4 ++-- rog-slash/src/usb.rs | 14 +++++++++++--- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index b7f185e2..65f96ed6 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -151,7 +151,7 @@ where } if !paths.is_empty() { let mut ctrl = Vec::new(); - paths.sort_by(|a, b| a.cmp(&b)); + paths.sort_by(|a, b| a.cmp(b)); for path in paths { ctrl.push( T::builder(&conn) @@ -616,8 +616,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box> { let mut mode = scsi.led_mode_data()?; let mut do_update = false; if !cmd.colours.is_empty() { - let mut count = 0; - for c in &cmd.colours { + for (count, c) in cmd.colours.iter().enumerate() { if count == 0 { mode.colour1 = *c; } @@ -630,7 +629,6 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box> { if count == 3 { mode.colour4 = *c; } - count += 1; } do_update = true; } @@ -1126,7 +1124,7 @@ fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box Result<(), Box> { diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index f1a3ee8f..fc00879b 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -125,10 +125,8 @@ impl AsusArmouryAttribute { #[zbus(property)] async fn current_value(&self) -> fdo::Result { - if let Ok(v) = self.0.current_value() { - if let AttrValue::Integer(i) = v { - return Ok(i); - } + if let Ok(AttrValue::Integer(i)) = self.0.current_value() { + return Ok(i); } Err(fdo::Error::Failed( "Could not read current value".to_string(), diff --git a/asusd/src/aura_manager.rs b/asusd/src/aura_manager.rs index 5da1e08a..ca4f8212 100644 --- a/asusd/src/aura_manager.rs +++ b/asusd/src/aura_manager.rs @@ -213,7 +213,7 @@ impl DeviceManager { ) -> Option { // "ID_MODEL_ID" "1932" // "ID_VENDOR_ID" "0b05" - if dev_prop_matches(&device, "ID_VENDOR_ID", "0b05") { + if dev_prop_matches(device, "ID_VENDOR_ID", "0b05") { if let Some(dev_node) = device.devnode() { let prod_id = device .property_value("ID_MODEL_ID") @@ -426,14 +426,11 @@ impl DeviceManager { info!("removing: {path:?}"); let dev = devices.lock().await.remove(index); let path = path.clone(); - match dev.device { - DeviceHandle::Scsi(_) => { - conn_copy - .object_server() - .remove::(&path) - .await?; - } - _ => {} + if let DeviceHandle::Scsi(_) = dev.device { + conn_copy + .object_server() + .remove::(&path) + .await?; } } } else if action == "add" { diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index 06876b7a..f0e6733f 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -214,9 +214,7 @@ mod tests { tmp_sort.0.sort_by(|a, b| a.product_id.cmp(&b.product_id)); tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name)); for model in tmp_sort.0.iter_mut() { - model - .basic_modes - .sort_by(|a, b| (*a as u8).cmp(&(*b as u8))); + model.basic_modes.sort_by_key(|a| *a as u8); } if tmp != tmp_sort { let sorted = diff --git a/rog-control-center/src/zbus_proxies.rs b/rog-control-center/src/zbus_proxies.rs index 450f4676..a8adcc66 100644 --- a/rog-control-center/src/zbus_proxies.rs +++ b/rog-control-center/src/zbus_proxies.rs @@ -92,7 +92,7 @@ where } if !paths.is_empty() { let mut ctrl = Vec::new(); - paths.sort_by(|a, b| a.cmp(&b)); + paths.sort_by(|a, b| a.cmp(b)); for path in paths { ctrl.push( T::builder(&conn) @@ -132,7 +132,7 @@ where } if !paths.is_empty() { let mut ctrl = Vec::new(); - paths.sort_by(|a, b| a.cmp(&b)); + paths.sort_by(|a, b| a.cmp(b)); for path in paths { ctrl.push( T::builder(&conn) diff --git a/rog-slash/src/usb.rs b/rog-slash/src/usb.rs index 61109e05..5d15bed5 100644 --- a/rog-slash/src/usb.rs +++ b/rog-slash/src/usb.rs @@ -129,6 +129,14 @@ pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPa [pkt1, pkt2] } +/// DEVICE SETTINGS +/// Interval: +/// - 1 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0x19, 0xff, 0x1 +/// - 5 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0x19, 0xff, 0x5 +/// Brightness: 100 +/// - 100 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0xff, 0xff +/// - 000 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0x00, 0xff +/// - off = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x0, 0x6, 0xff, 0xff #[inline] pub const fn pkt_set_options( slash_type: SlashType, @@ -144,10 +152,10 @@ pub const fn pkt_set_options( pkt[2] = 0x03; pkt[3] = 0x01; pkt[4] = 0x08; - pkt[5] = 0xab; - pkt[6] = 0xff; + pkt[5] = 0xab; // Setting byte 1 + pkt[6] = 0xff; // Setting byte 2 pkt[7] = 0x01; - pkt[8] = status_byte; + pkt[8] = status_byte; // Setting enable/disable pkt[9] = 0x06; pkt[10] = brightness; pkt[11] = 0xff;