mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: use Option::map and Option::cloned
It's more concise, more idiomatic Rust, and satisfies nightly clippy. Signed-off-by: Gaelan Steele <gbs@canishe.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
b16fdb1b3a
commit
b161a570ec
+7
-12
@@ -560,12 +560,12 @@ impl CpuManager {
|
|||||||
vcpu_states.resize_with(usize::from(config.max_vcpus), VcpuState::default);
|
vcpu_states.resize_with(usize::from(config.max_vcpus), VcpuState::default);
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
let sgx_epc_sections =
|
let sgx_epc_sections = memory_manager
|
||||||
if let Some(sgx_epc_region) = memory_manager.lock().unwrap().sgx_epc_region() {
|
.lock()
|
||||||
Some(sgx_epc_region.epc_sections().clone())
|
.unwrap()
|
||||||
} else {
|
.sgx_epc_region()
|
||||||
None
|
.as_ref()
|
||||||
};
|
.map(|sgx_epc_region| sgx_epc_region.epc_sections().clone());
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
let cpuid = {
|
let cpuid = {
|
||||||
let phys_bits = physical_bits(config.max_phys_bits);
|
let phys_bits = physical_bits(config.max_phys_bits);
|
||||||
@@ -858,12 +858,7 @@ impl CpuManager {
|
|||||||
.map_err(Error::CreateSeccompFilter)?;
|
.map_err(Error::CreateSeccompFilter)?;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
let interrupt_controller_clone =
|
let interrupt_controller_clone = self.interrupt_controller.as_ref().cloned();
|
||||||
if let Some(interrupt_controller) = &self.interrupt_controller {
|
|
||||||
Some(interrupt_controller.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let handle = Some(
|
let handle = Some(
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
|
|||||||
@@ -3136,11 +3136,9 @@ impl DeviceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn interrupt_controller(&self) -> Option<Arc<Mutex<dyn InterruptController>>> {
|
pub fn interrupt_controller(&self) -> Option<Arc<Mutex<dyn InterruptController>>> {
|
||||||
if let Some(interrupt_controller) = &self.interrupt_controller {
|
self.interrupt_controller
|
||||||
Some(interrupt_controller.clone() as Arc<Mutex<dyn InterruptController>>)
|
.as_ref()
|
||||||
} else {
|
.map(|ic| ic.clone() as Arc<Mutex<dyn InterruptController>>)
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn console(&self) -> &Arc<Console> {
|
pub fn console(&self) -> &Arc<Console> {
|
||||||
|
|||||||
Reference in New Issue
Block a user