mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
block: async_io: Remove unnecessary mut from reference
warning: this argument is a mutable reference, but not used mutably --> block/src/async_io.rs:68:28 | 68 | fn query_block_size(f: &mut File, block_size_type: BlockSize) -> std::io::Result<u64> { | ^^^^^^^^^ help: consider changing to: `&File` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
parent
b74907fa1b
commit
11c58870c4
@ -51,7 +51,7 @@ enum BlockSize {
|
||||
}
|
||||
|
||||
impl DiskTopology {
|
||||
fn is_block_device(f: &mut File) -> std::io::Result<bool> {
|
||||
fn is_block_device(f: &File) -> std::io::Result<bool> {
|
||||
let mut stat = std::mem::MaybeUninit::<libc::stat>::uninit();
|
||||
// SAFETY: FFI call with a valid fd and buffer
|
||||
let ret = unsafe { libc::fstat(f.as_raw_fd(), stat.as_mut_ptr()) };
|
||||
@ -65,7 +65,7 @@ impl DiskTopology {
|
||||
}
|
||||
|
||||
// libc::ioctl() takes different types on different architectures
|
||||
fn query_block_size(f: &mut File, block_size_type: BlockSize) -> std::io::Result<u64> {
|
||||
fn query_block_size(f: &File, block_size_type: BlockSize) -> std::io::Result<u64> {
|
||||
let mut block_size = 0;
|
||||
// SAFETY: FFI call with correct arguments
|
||||
let ret = unsafe {
|
||||
@ -87,7 +87,7 @@ impl DiskTopology {
|
||||
Ok(block_size)
|
||||
}
|
||||
|
||||
pub fn probe(f: &mut File) -> std::io::Result<Self> {
|
||||
pub fn probe(f: &File) -> std::io::Result<Self> {
|
||||
if !Self::is_block_device(f)? {
|
||||
return Ok(DiskTopology::default());
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ impl DiskFile for RawFileDisk {
|
||||
}
|
||||
|
||||
fn topology(&mut self) -> DiskTopology {
|
||||
if let Ok(topology) = DiskTopology::probe(&mut self.file) {
|
||||
if let Ok(topology) = DiskTopology::probe(&self.file) {
|
||||
topology
|
||||
} else {
|
||||
warn!("Unable to get device topology. Using default topology");
|
||||
|
@ -33,7 +33,7 @@ impl DiskFile for RawFileDiskSync {
|
||||
}
|
||||
|
||||
fn topology(&mut self) -> DiskTopology {
|
||||
if let Ok(topology) = DiskTopology::probe(&mut self.file) {
|
||||
if let Ok(topology) = DiskTopology::probe(&self.file) {
|
||||
topology
|
||||
} else {
|
||||
warn!("Unable to get device topology. Using default topology");
|
||||
|
Loading…
Reference in New Issue
Block a user