Small clippy cleanups

This commit is contained in:
Luke D. Jones
2025-01-04 20:04:07 +13:00
parent 2b7a2a5be3
commit 2123f369ad
6 changed files with 25 additions and 26 deletions

View File

@@ -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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
if count == 3 {
mode.colour4 = *c;
}
count += 1;
}
do_update = true;
}
@@ -1126,7 +1124,7 @@ fn print_firmware_attr(attr: &AsusArmouryProxyBlocking) -> Result<(), Box<dyn st
} else {
println!();
}
return Ok(());
Ok(())
}
fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error::Error>> {

View File

@@ -125,10 +125,8 @@ impl AsusArmouryAttribute {
#[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> {
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(),

View File

@@ -213,7 +213,7 @@ impl DeviceManager {
) -> Option<AsusDevice> {
// "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::<ScsiZbus, _>(&path)
.await?;
}
_ => {}
if let DeviceHandle::Scsi(_) = dev.device {
conn_copy
.object_server()
.remove::<ScsiZbus, _>(&path)
.await?;
}
}
} else if action == "add" {

View File

@@ -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 =

View File

@@ -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)

View File

@@ -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;