misc: cleanup &Arc<dyn T> -> &dyn T

Consuming `&Arc<T>` as argument is almost always an antipattern as it
hides whether the callee is going to take over (shared) ownership
(by .clone()) or not. Instead, it is better to consume `&dyn T` or
`Arc<dyn T>` to be more explicit. This commit cleans up the code.

The change is very mechanic and was very easy to implement across the
code base.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-10-28 10:49:34 +01:00
committed by Rob Bradford
parent e295719967
commit 7536a95424
37 changed files with 121 additions and 117 deletions

View File

@@ -192,12 +192,13 @@ impl Bus {
}
/// Removes all entries referencing the given device.
pub fn remove_by_device(&self, device: &Arc<dyn BusDeviceSync>) -> Result<()> {
pub fn remove_by_device(&self, device: &dyn BusDeviceSync) -> Result<()> {
let mut device_list = self.devices.write().unwrap();
let mut remove_key_list = Vec::new();
for (key, value) in device_list.iter() {
if Arc::ptr_eq(&value.upgrade().unwrap(), device) {
let value = value.upgrade().unwrap();
if core::ptr::eq(Arc::as_ptr(&value), device) {
remove_key_list.push(*key);
}
}