mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: clippy: add map_unwrap_or
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
dda89d7027
commit
d2b19bb969
@@ -1562,8 +1562,7 @@ impl BalloonConfig {
|
||||
let size = parser
|
||||
.convert::<ByteSized>("size")
|
||||
.map_err(Error::ParseBalloon)?
|
||||
.map(|v| v.0)
|
||||
.unwrap_or(0);
|
||||
.map_or(0, |v| v.0);
|
||||
|
||||
let deflate_on_oom = parser
|
||||
.convert::<Toggle>("deflate_on_oom")
|
||||
@@ -2482,7 +2481,7 @@ impl VmConfig {
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
{
|
||||
let tdx_enabled = self.platform.as_ref().map(|p| p.tdx).unwrap_or(false);
|
||||
let tdx_enabled = self.platform.as_ref().is_some_and(|p| p.tdx);
|
||||
// At this point we know payload isn't None.
|
||||
if tdx_enabled && self.payload.as_ref().unwrap().firmware.is_none() {
|
||||
return Err(ValidationError::TdxFirmwareMissing);
|
||||
@@ -3110,12 +3109,12 @@ impl VmConfig {
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
pub fn is_tdx_enabled(&self) -> bool {
|
||||
self.platform.as_ref().map(|p| p.tdx).unwrap_or(false)
|
||||
self.platform.as_ref().is_some_and(|p| p.tdx)
|
||||
}
|
||||
|
||||
#[cfg(feature = "sev_snp")]
|
||||
pub fn is_sev_snp_enabled(&self) -> bool {
|
||||
self.platform.as_ref().map(|p| p.sev_snp).unwrap_or(false)
|
||||
self.platform.as_ref().is_some_and(|p| p.sev_snp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2113,8 +2113,7 @@ impl DeviceManager {
|
||||
.debug_console
|
||||
.clone()
|
||||
.iobase
|
||||
.map(|port| port as u64)
|
||||
.unwrap_or(debug_console::DEFAULT_PORT);
|
||||
.map_or(debug_console::DEFAULT_PORT, |port| port as u64);
|
||||
|
||||
self.bus_devices
|
||||
.push(Arc::clone(&debug_console) as Arc<dyn BusDeviceSync>);
|
||||
|
||||
@@ -104,7 +104,7 @@ unsafe fn close_unused_fds(keep_fds: &mut [RawFd]) {
|
||||
// The next fd is the one at i, because the indexes in the
|
||||
// iterator are offset by one due to the initial 0.
|
||||
let next_keep_fd = keep_fds.get(i);
|
||||
let last = next_keep_fd.map(|fd| fd - 1).unwrap_or(RawFd::MAX);
|
||||
let last = next_keep_fd.map_or(RawFd::MAX, |fd| fd - 1);
|
||||
|
||||
if first > last {
|
||||
continue;
|
||||
|
||||
@@ -763,8 +763,7 @@ impl Vm {
|
||||
.unwrap()
|
||||
.payload
|
||||
.as_ref()
|
||||
.map(|p| p.fw_cfg_config.is_some())
|
||||
.unwrap_or(false);
|
||||
.is_some_and(|p| p.fw_cfg_config.is_some());
|
||||
if fw_cfg_config {
|
||||
device_manager
|
||||
.lock()
|
||||
@@ -2338,8 +2337,7 @@ impl Vm {
|
||||
.unwrap()
|
||||
.payload
|
||||
.as_ref()
|
||||
.map(|p| p.fw_cfg_config.is_some())
|
||||
.unwrap_or(false);
|
||||
.is_some_and(|p| p.fw_cfg_config.is_some());
|
||||
if fw_cfg_enabled {
|
||||
let fw_cfg_config = self
|
||||
.config
|
||||
|
||||
Reference in New Issue
Block a user