From 11c58870c4733ac00d94d92e8cde535263efba6d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 22 Aug 2023 10:42:59 +0100 Subject: [PATCH] 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 { | ^^^^^^^^^ 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 --- block/src/async_io.rs | 6 +++--- block/src/raw_async.rs | 2 +- block/src/raw_sync.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/src/async_io.rs b/block/src/async_io.rs index 6298dc068..935c259be 100644 --- a/block/src/async_io.rs +++ b/block/src/async_io.rs @@ -51,7 +51,7 @@ enum BlockSize { } impl DiskTopology { - fn is_block_device(f: &mut File) -> std::io::Result { + fn is_block_device(f: &File) -> std::io::Result { let mut stat = std::mem::MaybeUninit::::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 { + fn query_block_size(f: &File, block_size_type: BlockSize) -> std::io::Result { 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 { + pub fn probe(f: &File) -> std::io::Result { if !Self::is_block_device(f)? { return Ok(DiskTopology::default()); } diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index a723fe670..95aafa483 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -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"); diff --git a/block/src/raw_sync.rs b/block/src/raw_sync.rs index a66a36923..66428ba35 100644 --- a/block/src/raw_sync.rs +++ b/block/src/raw_sync.rs @@ -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");