From 80e48b545d7ee3cea3e07631dfacdbe16342f2fd Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 25 Mar 2021 17:01:21 +0000 Subject: [PATCH] block_util: Address Rust 1.51.0 clippy issue (ptr-arg) error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. --> block_util/src/lib.rs:68:31 | 68 | fn build_device_id(disk_path: &PathBuf) -> result::Result { | ^^^^^^^^ help: change this to: `&Path` | = note: `-D clippy::ptr-arg` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. --> block_util/src/lib.rs:83:39 | 83 | pub fn build_disk_image_id(disk_path: &PathBuf) -> Vec { | ^^^^^^^^ help: change this to: `&Path` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. --> block_util/src/lib.rs:68:31 | 68 | fn build_device_id(disk_path: &PathBuf) -> result::Result { | ^^^^^^^^ help: change this to: `&Path` | = note: `-D clippy::ptr-arg` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do. --> block_util/src/lib.rs:83:39 | 83 | pub fn build_disk_image_id(disk_path: &PathBuf) -> Vec { | ^^^^^^^^ help: change this to: `&Path` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg Signed-off-by: Rob Bradford --- block_util/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block_util/src/lib.rs b/block_util/src/lib.rs index 04e63f008..1130c5da9 100644 --- a/block_util/src/lib.rs +++ b/block_util/src/lib.rs @@ -32,7 +32,7 @@ use std::io::{self, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write}; use std::os::linux::fs::MetadataExt; #[cfg(feature = "io_uring")] use std::os::unix::io::AsRawFd; -use std::path::PathBuf; +use std::path::Path; use std::result; use std::sync::{Arc, Mutex}; use virtio_bindings::bindings::virtio_blk::*; @@ -65,7 +65,7 @@ pub enum Error { TooManyDescriptors, } -fn build_device_id(disk_path: &PathBuf) -> result::Result { +fn build_device_id(disk_path: &Path) -> result::Result { let blk_metadata = match disk_path.metadata() { Err(_) => return Err(Error::GetFileMetadata), Ok(m) => m, @@ -80,7 +80,7 @@ fn build_device_id(disk_path: &PathBuf) -> result::Result { Ok(device_id) } -pub fn build_disk_image_id(disk_path: &PathBuf) -> Vec { +pub fn build_disk_image_id(disk_path: &Path) -> Vec { let mut default_disk_image_id = vec![0; VIRTIO_BLK_ID_BYTES as usize]; match build_device_id(disk_path) { Err(_) => {