mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
e295719967
commit
7536a95424
@@ -124,7 +124,7 @@ where
|
||||
while let Some(mut desc_chain) = self.queues[0].pop_descriptor_chain(self.mem.memory()) {
|
||||
let used_len = match VsockPacket::from_rx_virtq_head(
|
||||
&mut desc_chain,
|
||||
self.access_platform.as_ref(),
|
||||
self.access_platform.as_deref(),
|
||||
) {
|
||||
Ok(mut pkt) => {
|
||||
if self.backend.write().unwrap().recv_pkt(&mut pkt).is_ok() {
|
||||
@@ -166,7 +166,7 @@ where
|
||||
while let Some(mut desc_chain) = self.queues[1].pop_descriptor_chain(self.mem.memory()) {
|
||||
let pkt = match VsockPacket::from_tx_virtq_head(
|
||||
&mut desc_chain,
|
||||
self.access_platform.as_ref(),
|
||||
self.access_platform.as_deref(),
|
||||
) {
|
||||
Ok(pkt) => pkt,
|
||||
Err(e) => {
|
||||
@@ -430,7 +430,7 @@ where
|
||||
interrupt_cb: Arc<dyn VirtioInterrupt>,
|
||||
queues: Vec<(usize, Queue, EventFd)>,
|
||||
) -> ActivateResult {
|
||||
self.common.activate(&queues, &interrupt_cb)?;
|
||||
self.common.activate(&queues, interrupt_cb.clone())?;
|
||||
let (kill_evt, pause_evt) = self.common.dup_eventfds();
|
||||
|
||||
let mut virtqueues = Vec::new();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
//! to temporary buffers, before passing it on to the vsock backend.
|
||||
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use virtio_queue::DescriptorChain;
|
||||
@@ -111,7 +110,7 @@ impl VsockPacket {
|
||||
///
|
||||
pub fn from_tx_virtq_head<M>(
|
||||
desc_chain: &mut DescriptorChain<M>,
|
||||
access_platform: Option<&Arc<dyn AccessPlatform>>,
|
||||
access_platform: Option<&dyn AccessPlatform>,
|
||||
) -> Result<Self>
|
||||
where
|
||||
M: Clone + Deref,
|
||||
@@ -203,7 +202,7 @@ impl VsockPacket {
|
||||
///
|
||||
pub fn from_rx_virtq_head<M>(
|
||||
desc_chain: &mut DescriptorChain<M>,
|
||||
access_platform: Option<&Arc<dyn AccessPlatform>>,
|
||||
access_platform: Option<&dyn AccessPlatform>,
|
||||
) -> Result<Self>
|
||||
where
|
||||
M: Clone + Deref,
|
||||
|
||||
Reference in New Issue
Block a user