mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: raw: Use map_or instead of map().unwrap_or()
Do the necessary replacements to satisfy clippy::map_unwrap_or. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
5925a013af
commit
b7b38df99c
@@ -42,9 +42,8 @@ impl DiskFile for RawFileDisk {
|
||||
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
||||
let mut raw = RawFileAsync::new(self.file.as_raw_fd(), ring_depth)
|
||||
.map_err(DiskFileError::NewAsyncIo)?;
|
||||
raw.alignment = DiskTopology::probe(&self.file)
|
||||
.map(|t| t.logical_block_size)
|
||||
.unwrap_or(SECTOR_SIZE);
|
||||
raw.alignment =
|
||||
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
|
||||
Ok(Box::new(raw) as Box<dyn AsyncIo>)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,8 @@ impl DiskFile for RawFileDiskAio {
|
||||
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
||||
let mut raw = RawFileAsyncAio::new(self.file.as_raw_fd(), ring_depth)
|
||||
.map_err(DiskFileError::NewAsyncIo)?;
|
||||
raw.alignment = DiskTopology::probe(&self.file)
|
||||
.map(|t| t.logical_block_size)
|
||||
.unwrap_or(SECTOR_SIZE);
|
||||
raw.alignment =
|
||||
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
|
||||
Ok(Box::new(raw) as Box<dyn AsyncIo>)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,8 @@ impl DiskFile for RawFileDiskSync {
|
||||
|
||||
fn new_async_io(&self, _ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
||||
let mut raw = RawFileSync::new(self.file.as_raw_fd());
|
||||
raw.alignment = DiskTopology::probe(&self.file)
|
||||
.map(|t| t.logical_block_size)
|
||||
.unwrap_or(SECTOR_SIZE);
|
||||
raw.alignment =
|
||||
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
|
||||
Ok(Box::new(raw) as Box<dyn AsyncIo>)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user