From 184baff355518bc282b46c0cfa7915f661dcdfe4 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sun, 3 Jan 2021 10:49:29 +0000 Subject: [PATCH] hypervisor: kvm: aarch64: Use struct initialisation error: field assignment outside of initializer for an instance created with Default::default() Error: --> hypervisor/src/kvm/mod.rs:1239:9 | 1239 | state.mp_state = self.get_mp_state()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::field-reassign-with-default` implied by `-D warnings` note: consider initializing the variable with `kvm::aarch64::VcpuKvmState { mp_state: self.get_mp_state()?, ..Default::default() }` and removing relevant reassignments --> hypervisor/src/kvm/mod.rs:1237:9 | 1237 | let mut state = CpuState::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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index d2334ca8c..c98b10ad2 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1234,12 +1234,13 @@ impl cpu::Vcpu for KvmVcpu { /// #[cfg(target_arch = "aarch64")] fn state(&self) -> cpu::Result { - let mut state = CpuState::default(); - // Get this vCPUs multiprocessing state. - state.mp_state = self.get_mp_state()?; + let mut state = CpuState { + mp_state: self.get_mp_state()?, + mpidr: self.read_mpidr()?, + ..Default::default() + }; self.core_registers(&mut state.core_regs)?; self.system_registers(&mut state.sys_regs)?; - state.mpidr = self.read_mpidr()?; Ok(state) }