misc: clippy: add needless_pass_by_value

This is a follow-up of [0].

# Advantages

- This saves dozens of unneeded clone()s across the whole code base
- Makes it much easier to reason about how parameters are used
  (often we passed owned Arc/Rc versions without actually needing
  ownership)

# Exceptions

For certain code paths, the alternatives would require awkward or overly
complex code, and in some cases the functions are the logical owners of
the values they take. In those cases, I've added
#[allow(clippy::needless_pass_by_value)].

This does not mean that one should not improve this in the future.

[0] 6a86c157af

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-11-26 14:00:44 +01:00
committed by Rob Bradford
parent ed4af3a005
commit c53781bf5f
53 changed files with 273 additions and 231 deletions

View File

@@ -56,7 +56,7 @@ impl From<MshvGicV2MState> for GicState {
impl MshvGicV2M {
/// Create a new GICv2m device
pub fn new(_vm: &dyn Vm, config: VgicConfig) -> Result<MshvGicV2M> {
pub fn new(_vm: &dyn Vm, config: &VgicConfig) -> Result<MshvGicV2M> {
let gic_device = MshvGicV2M {
dist_addr: config.dist_addr,
dist_size: config.dist_size,

View File

@@ -2193,7 +2193,7 @@ impl vm::Vm for MshvVm {
}
#[cfg(target_arch = "aarch64")]
fn create_vgic(&self, config: VgicConfig) -> vm::Result<Arc<Mutex<dyn Vgic>>> {
fn create_vgic(&self, config: &VgicConfig) -> vm::Result<Arc<Mutex<dyn Vgic>>> {
let gic_device = MshvGicV2M::new(self, config)
.map_err(|e| vm::HypervisorVmError::CreateVgic(anyhow!("Vgic error {e:?}")))?;