runtime-rs: Fix needless_borrow warnings

As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to needless_borrow.

Let's fix them all here.

For more info about the warnings, please, take a look at:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-01-02 16:22:07 +01:00
parent 4fb163d570
commit 025e78341e
6 changed files with 9 additions and 9 deletions

View File

@ -119,7 +119,7 @@ pub fn create_link(name: &str, link_type: LinkType, queues: usize) -> Result<()>
fn create_queue(name: &str, flags: libc::c_int) -> Result<(File, String)> { fn create_queue(name: &str, flags: libc::c_int) -> Result<(File, String)> {
let path = Path::new(DEVICE_PATH); let path = Path::new(DEVICE_PATH);
let file = OpenOptions::new().read(true).write(true).open(&path)?; let file = OpenOptions::new().read(true).write(true).open(path)?;
let mut req = CreateLinkReq::from_name(name)?; let mut req = CreateLinkReq::from_name(name)?;
unsafe { unsafe {
req.set_raw_flags(flags as libc::c_short); req.set_raw_flags(flags as libc::c_short);

View File

@ -20,7 +20,7 @@ impl NetnsGuard {
let current_netns_path = format!("/proc/{}/task/{}/ns/{}", getpid(), gettid(), "net"); let current_netns_path = format!("/proc/{}/task/{}/ns/{}", getpid(), gettid(), "net");
let old_netns = File::open(&current_netns_path) let old_netns = File::open(&current_netns_path)
.with_context(|| format!("open current netns path {}", &current_netns_path))?; .with_context(|| format!("open current netns path {}", &current_netns_path))?;
let new_netns = File::open(&new_netns_path) let new_netns = File::open(new_netns_path)
.with_context(|| format!("open new netns path {}", &new_netns_path))?; .with_context(|| format!("open new netns path {}", &new_netns_path))?;
setns(new_netns.as_raw_fd(), CloneFlags::CLONE_NEWNET) setns(new_netns.as_raw_fd(), CloneFlags::CLONE_NEWNET)
.with_context(|| "set netns to new netns")?; .with_context(|| "set netns to new netns")?;

View File

@ -38,7 +38,7 @@ pub(crate) fn share_to_guest(
// to remount the read only dir mount point directly. // to remount the read only dir mount point directly.
if readonly { if readonly {
let dst = do_get_host_path(target, sid, cid, is_volume, true); let dst = do_get_host_path(target, sid, cid, is_volume, true);
mount::bind_remount(&dst, readonly).context("bind remount readonly")?; mount::bind_remount(dst, readonly).context("bind remount readonly")?;
} }
Ok(do_get_guest_path(target, cid, is_volume, is_rafs)) Ok(do_get_guest_path(target, cid, is_volume, is_rafs))

View File

@ -173,11 +173,11 @@ impl ShareFsMount for VirtiofsShareMount {
async fn upgrade_to_rw(&self, file_name: &str) -> Result<()> { async fn upgrade_to_rw(&self, file_name: &str) -> Result<()> {
// Remount readonly directory with readwrite permission // Remount readonly directory with readwrite permission
let host_dest = do_get_host_path(file_name, &self.id, "", true, true); let host_dest = do_get_host_path(file_name, &self.id, "", true, true);
bind_remount(&host_dest, false) bind_remount(host_dest, false)
.context("remount readonly directory with readwrite permission")?; .context("remount readonly directory with readwrite permission")?;
// Remount readwrite directory with readwrite permission // Remount readwrite directory with readwrite permission
let host_dest = do_get_host_path(file_name, &self.id, "", true, false); let host_dest = do_get_host_path(file_name, &self.id, "", true, false);
bind_remount(&host_dest, false) bind_remount(host_dest, false)
.context("remount readwrite directory with readwrite permission")?; .context("remount readwrite directory with readwrite permission")?;
Ok(()) Ok(())
} }
@ -185,11 +185,11 @@ impl ShareFsMount for VirtiofsShareMount {
async fn downgrade_to_ro(&self, file_name: &str) -> Result<()> { async fn downgrade_to_ro(&self, file_name: &str) -> Result<()> {
// Remount readwrite directory with readonly permission // Remount readwrite directory with readonly permission
let host_dest = do_get_host_path(file_name, &self.id, "", true, false); let host_dest = do_get_host_path(file_name, &self.id, "", true, false);
bind_remount(&host_dest, true) bind_remount(host_dest, true)
.context("remount readwrite directory with readonly permission")?; .context("remount readwrite directory with readonly permission")?;
// Remount readonly directory with readonly permission // Remount readonly directory with readonly permission
let host_dest = do_get_host_path(file_name, &self.id, "", true, true); let host_dest = do_get_host_path(file_name, &self.id, "", true, true);
bind_remount(&host_dest, true) bind_remount(host_dest, true)
.context("remount readonly directory with readonly permission")?; .context("remount readonly directory with readonly permission")?;
Ok(()) Ok(())
} }

View File

@ -55,7 +55,7 @@ async fn send_event(
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.args(&[ .args([
"--address", "--address",
&address, &address,
"publish", "publish",

View File

@ -40,7 +40,7 @@ impl ShimExecutor {
let trim_path = address.strip_prefix("unix://").context("trim path")?; let trim_path = address.strip_prefix("unix://").context("trim path")?;
let file_path = Path::new("/").join(trim_path); let file_path = Path::new("/").join(trim_path);
let file_path = file_path.as_path(); let file_path = file_path.as_path();
if std::fs::metadata(&file_path).is_ok() { if std::fs::metadata(file_path).is_ok() {
info!(sl!(), "remote socket path: {:?}", &file_path); info!(sl!(), "remote socket path: {:?}", &file_path);
fs::remove_file(file_path).ok(); fs::remove_file(file_path).ok();
} }