mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
ed4af3a005
commit
c53781bf5f
@@ -39,6 +39,7 @@ pub struct Aia {
|
||||
}
|
||||
|
||||
impl Aia {
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
pub fn new(
|
||||
vcpu_count: u32,
|
||||
interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||
@@ -51,9 +52,8 @@ impl Aia {
|
||||
})
|
||||
.map_err(Error::CreateInterruptSourceGroup)?;
|
||||
|
||||
let vaia = vm
|
||||
.create_vaia(Aia::create_default_config(vcpu_count as u64))
|
||||
.map_err(Error::CreateAia)?;
|
||||
let config = Aia::create_default_config(vcpu_count as u64);
|
||||
let vaia = vm.create_vaia(&config).map_err(Error::CreateAia)?;
|
||||
|
||||
let aia = Aia {
|
||||
interrupt_source_group,
|
||||
|
||||
@@ -38,6 +38,7 @@ pub struct Gic {
|
||||
}
|
||||
|
||||
impl Gic {
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
pub fn new(
|
||||
vcpu_count: u32,
|
||||
interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||
@@ -50,9 +51,8 @@ impl Gic {
|
||||
})
|
||||
.map_err(Error::CreateInterruptSourceGroup)?;
|
||||
|
||||
let vgic = vm
|
||||
.create_vgic(Gic::create_default_config(vcpu_count as u64))
|
||||
.map_err(Error::CreateGic)?;
|
||||
let config = Gic::create_default_config(vcpu_count as u64);
|
||||
let vgic = vm.create_vgic(&config).map_err(Error::CreateGic)?;
|
||||
|
||||
let gic = Gic {
|
||||
interrupt_source_group,
|
||||
|
||||
@@ -192,7 +192,7 @@ impl Ioapic {
|
||||
id: String,
|
||||
apic_address: GuestAddress,
|
||||
interrupt_manager: &dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>,
|
||||
state: Option<IoapicState>,
|
||||
state: Option<&IoapicState>,
|
||||
) -> Result<Ioapic> {
|
||||
let interrupt_source_group = interrupt_manager
|
||||
.create_group(MsiIrqGroupConfig {
|
||||
|
||||
@@ -36,12 +36,14 @@ enum LocStateFields {
|
||||
TpmRegValidSts,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
enum LocStsFields {
|
||||
Granted,
|
||||
BeenSeized,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Copy, Clone)]
|
||||
enum IntfIdFields {
|
||||
InterfaceType,
|
||||
InterfaceVersion,
|
||||
@@ -59,6 +61,7 @@ enum IntfIdFields {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Copy, Clone)]
|
||||
enum IntfId2Fields {
|
||||
Vid,
|
||||
Did,
|
||||
@@ -70,6 +73,7 @@ enum CtrlStsFields {
|
||||
TpmIdle,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
enum CrbRegister {
|
||||
LocState(LocStateFields),
|
||||
LocSts(LocStsFields),
|
||||
@@ -102,6 +106,7 @@ const CRB_LOC_CTRL_REQUEST_ACCESS: u32 = 1 << 0;
|
||||
const CRB_LOC_CTRL_RELINQUISH: u32 = 1 << 1;
|
||||
const CRB_LOC_CTRL_RESET_ESTABLISHMENT_BIT: u32 = 1 << 3;
|
||||
const CRB_LOC_STS: u32 = 0x0C;
|
||||
|
||||
const fn get_crb_loc_sts_field(f: LocStsFields) -> (u32, u32, u32) {
|
||||
let (offset, len) = match f {
|
||||
LocStsFields::Granted => (0, 1),
|
||||
|
||||
Reference in New Issue
Block a user