From 3d638f5d8e24736e2e01f13d66b8517b5997abd9 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 9 Jan 2025 11:42:54 -0500 Subject: [PATCH 1/4] liminal, table: change match statement to question-mark Signed-off-by: Bryan Gurney --- src/engine/strat_engine/liminal/liminal.rs | 5 +---- src/engine/structures/table.rs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/engine/strat_engine/liminal/liminal.rs b/src/engine/strat_engine/liminal/liminal.rs index 73e9496ed2..6adf878d8d 100644 --- a/src/engine/strat_engine/liminal/liminal.rs +++ b/src/engine/strat_engine/liminal/liminal.rs @@ -1017,10 +1017,7 @@ impl LiminalDevices { event: &UdevEngineEvent, ) -> Option<(Name, PoolUuid, AnyPool)> { let event_type = event.event_type(); - let device_path = match event.device().devnode() { - Some(d) => d, - None => return None, - }; + let device_path = event.device().devnode()?; let device_info = match event_type { libudev::EventType::Add | libudev::EventType::Change => { if device_path.exists() { diff --git a/src/engine/structures/table.rs b/src/engine/structures/table.rs index 843c101de3..688c33fe2a 100644 --- a/src/engine/structures/table.rs +++ b/src/engine/structures/table.rs @@ -217,10 +217,7 @@ where /// Get mutable item by name. pub fn get_mut_by_name(&mut self, name: &str) -> Option<(U, &mut T)> { - let uuid = match self.name_to_uuid.get(name) { - Some(uuid) => uuid, - None => return None, - }; + let uuid = self.name_to_uuid.get(name)?; self.items .get_mut(uuid) .map(|&mut (_, ref mut item)| (*uuid, item)) From c861a338210e615439ec1d1be972dc4a0b4d2730 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 9 Jan 2025 11:45:35 -0500 Subject: [PATCH 2/4] udev.rs: remove unnecessary map_or Signed-off-by: Bryan Gurney --- src/engine/strat_engine/udev.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/strat_engine/udev.rs b/src/engine/strat_engine/udev.rs index 9c4c34202e..7617ec3f2f 100644 --- a/src/engine/strat_engine/udev.rs +++ b/src/engine/strat_engine/udev.rs @@ -161,6 +161,6 @@ where Ok(enumerator .scan_devices()? .filter(|dev| dev.is_initialized()) - .find(|x| x.devnode().map_or(false, |d| **device_path == *d)) + .find(|x| x.devnode().is_some_and(|d| **device_path == *d)) .map(|ref d| f(&UdevEngineDevice::from(d)))) } From 04ca6c70026d1fa16f0a29d7fea0a5bf63e76f2a Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 9 Jan 2025 12:08:15 -0500 Subject: [PATCH 3/4] Stop using local array for test_grow_physical write_block Signed-off-by: Bryan Gurney --- src/engine/strat_engine/pool/v1.rs | 4 ++-- src/engine/strat_engine/pool/v2.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/strat_engine/pool/v1.rs b/src/engine/strat_engine/pool/v1.rs index 8be06f304c..44fdb79473 100644 --- a/src/engine/strat_engine/pool/v1.rs +++ b/src/engine/strat_engine/pool/v1.rs @@ -1802,7 +1802,7 @@ mod tests { .tempdir() .unwrap(); let new_file = tmp_dir.path().join("stratis_test.txt"); - let write_block = &[0; 512_000]; + let write_block = vec![0; 512_000].into_boxed_slice(); { let (_, fs) = pool.get_filesystem(fs_uuid).unwrap(); @@ -1823,7 +1823,7 @@ mod tests { .open(new_file) .unwrap(); while !pool.out_of_alloc_space() { - f.write_all(write_block).unwrap(); + f.write_all(&write_block).unwrap(); f.sync_all().unwrap(); match pool { AnyPool::V1(p) => p.event_on(pool_uuid, &pool_name).unwrap(), diff --git a/src/engine/strat_engine/pool/v2.rs b/src/engine/strat_engine/pool/v2.rs index 6c49010375..1d8cda4bd7 100644 --- a/src/engine/strat_engine/pool/v2.rs +++ b/src/engine/strat_engine/pool/v2.rs @@ -1744,7 +1744,7 @@ mod tests { .tempdir() .unwrap(); let new_file = tmp_dir.path().join("stratis_test.txt"); - let write_block = &[0; 512_000]; + let write_block = vec![0; 512_000].into_boxed_slice(); { let (_, fs) = pool.get_filesystem(fs_uuid).unwrap(); @@ -1765,7 +1765,7 @@ mod tests { .open(new_file) .unwrap(); while !pool.out_of_alloc_space() { - f.write_all(write_block).unwrap(); + f.write_all(&write_block).unwrap(); f.sync_all().unwrap(); match pool { AnyPool::V1(p) => p.event_on(pool_uuid, &pool_name).unwrap(), From 66d3066e8e476d13b6d55113679a70db773d3430 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 9 Jan 2025 12:10:40 -0500 Subject: [PATCH 4/4] dbus_api tree: remove unnecessary map_or Signed-off-by: Bryan Gurney --- src/dbus_api/tree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus_api/tree.rs b/src/dbus_api/tree.rs index 4b977591d8..4ffab6c470 100644 --- a/src/dbus_api/tree.rs +++ b/src/dbus_api/tree.rs @@ -298,7 +298,7 @@ impl DbusTreeHandler { opath .get_data() .as_ref() - .map_or(false, |op_cxt| op_cxt.parent == item) + .is_some_and(|op_cxt| op_cxt.parent == item) }) { if let StratisUuid::Fs(_) = opath .get_data()