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
+5 -5
View File
@@ -216,7 +216,7 @@ impl Vdpa {
fn activate_vdpa(
&mut self,
mem: &GuestMemoryMmap,
virtio_interrupt: &Arc<dyn VirtioInterrupt>,
virtio_interrupt: &dyn VirtioInterrupt,
queues: Vec<(usize, Queue, EventFd)>,
) -> Result<()> {
assert!(self.vhost.is_some());
@@ -245,15 +245,15 @@ impl Vdpa {
queue_size,
flags: 0u32,
desc_table_addr: queue.desc_table().translate_gpa(
self.common.access_platform.as_ref(),
self.common.access_platform.as_deref(),
queue_size as usize * std::mem::size_of::<RawDescriptor>(),
),
used_ring_addr: queue.used_ring().translate_gpa(
self.common.access_platform.as_ref(),
self.common.access_platform.as_deref(),
4 + queue_size as usize * 8,
),
avail_ring_addr: queue.avail_ring().translate_gpa(
self.common.access_platform.as_ref(),
self.common.access_platform.as_deref(),
4 + queue_size as usize * 2,
),
log_addr: None,
@@ -421,7 +421,7 @@ impl VirtioDevice for Vdpa {
virtio_interrupt: Arc<dyn VirtioInterrupt>,
queues: Vec<(usize, Queue, EventFd)>,
) -> ActivateResult {
self.activate_vdpa(&mem.memory(), &virtio_interrupt, queues)
self.activate_vdpa(&mem.memory(), virtio_interrupt.as_ref(), queues)
.map_err(ActivateError::ActivateVdpa)?;
// Store the virtio interrupt handler as we need to return it on reset