From f452fe74970ecc01dfddfd20e328668462ddd99f Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sat, 2 Jan 2021 20:08:09 +0000 Subject: [PATCH] hypervisor: kvm: Use struct initialiser where possible error: field assignment outside of initializer for an instance created with Default::default() --> hypervisor/src/kvm/mod.rs:318:9 | 318 | cap.cap = KVM_CAP_SPLIT_IRQCHIP; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::field-reassign-with-default` implied by `-D warnings` note: consider initializing the variable with `kvm_bindings::kvm_enable_cap { cap: KVM_CAP_SPLIT_IRQCHIP, ..Default::default() }` and removing relevant reassignments --> hypervisor/src/kvm/mod.rs:317:9 | 317 | let mut cap: kvm_enable_cap = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default Signed-off-by: Rob Bradford --- hypervisor/src/kvm/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 8958c1a40..d2334ca8c 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -314,8 +314,10 @@ impl vm::Vm for KvmVm { // Create split irqchip // Only the local APIC is emulated in kernel, both PICs and IOAPIC // are not. - let mut cap: kvm_enable_cap = Default::default(); - cap.cap = KVM_CAP_SPLIT_IRQCHIP; + let mut cap = kvm_enable_cap { + cap: KVM_CAP_SPLIT_IRQCHIP, + ..Default::default() + }; cap.args[0] = NUM_IOAPIC_PINS as u64; self.fd .enable_cap(&cap) @@ -604,8 +606,10 @@ impl cpu::Vcpu for KvmVcpu { // emulated as it will influence later which MSRs should be saved. self.hyperv_synic.store(true, Ordering::Release); - let mut cap: kvm_enable_cap = Default::default(); - cap.cap = KVM_CAP_HYPERV_SYNIC; + let cap = kvm_enable_cap { + cap: KVM_CAP_HYPERV_SYNIC, + ..Default::default() + }; self.fd .enable_cap(&cap) .map_err(|e| cpu::HypervisorCpuError::EnableHyperVSynIC(e.into()))