mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-17 15:38:00 +00:00
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:
parent
4d05ab8022
commit
f5549de9cf
15
src/runtime-rs/Cargo.lock
generated
15
src/runtime-rs/Cargo.lock
generated
@ -1223,6 +1223,7 @@ dependencies = [
|
||||
"seccompiler",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shim-interface",
|
||||
"slog",
|
||||
"slog-scope",
|
||||
"thiserror",
|
||||
@ -1919,6 +1920,7 @@ dependencies = [
|
||||
"safe-path",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shim-interface",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2343,6 +2345,7 @@ dependencies = [
|
||||
"logging",
|
||||
"oci",
|
||||
"persist",
|
||||
"shim-interface",
|
||||
"slog",
|
||||
"slog-scope",
|
||||
"tokio",
|
||||
@ -2474,6 +2477,7 @@ dependencies = [
|
||||
"logging",
|
||||
"persist",
|
||||
"runtimes",
|
||||
"shim-interface",
|
||||
"slog",
|
||||
"slog-scope",
|
||||
"tokio",
|
||||
@ -2539,12 +2543,23 @@ dependencies = [
|
||||
name = "shim-ctl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"common",
|
||||
"logging",
|
||||
"runtimes",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shim-interface"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hyper",
|
||||
"hyperlocal",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.0"
|
||||
|
@ -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)> {
|
||||
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)?;
|
||||
unsafe {
|
||||
req.set_raw_flags(flags as libc::c_short);
|
||||
|
@ -20,7 +20,7 @@ impl NetnsGuard {
|
||||
let current_netns_path = format!("/proc/{}/task/{}/ns/{}", getpid(), gettid(), "net");
|
||||
let old_netns = File::open(¤t_netns_path)
|
||||
.with_context(|| format!("open current netns path {}", ¤t_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))?;
|
||||
setns(new_netns.as_raw_fd(), CloneFlags::CLONE_NEWNET)
|
||||
.with_context(|| "set netns to new netns")?;
|
||||
|
@ -38,7 +38,7 @@ pub(crate) fn share_to_guest(
|
||||
// to remount the read only dir mount point directly.
|
||||
if readonly {
|
||||
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))
|
||||
|
@ -173,11 +173,11 @@ impl ShareFsMount for VirtiofsShareMount {
|
||||
async fn upgrade_to_rw(&self, file_name: &str) -> Result<()> {
|
||||
// Remount readonly directory with readwrite permission
|
||||
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")?;
|
||||
// Remount readwrite directory with readwrite permission
|
||||
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")?;
|
||||
Ok(())
|
||||
}
|
||||
@ -185,18 +185,18 @@ impl ShareFsMount for VirtiofsShareMount {
|
||||
async fn downgrade_to_ro(&self, file_name: &str) -> Result<()> {
|
||||
// Remount readwrite directory with readonly permission
|
||||
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")?;
|
||||
// Remount readonly directory with readonly permission
|
||||
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")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn umount(&self, file_name: &str) -> Result<()> {
|
||||
let host_dest = do_get_host_path(file_name, &self.id, "", true, true);
|
||||
umount_timeout(&host_dest, 0).context("Umount readwrite host dest")?;
|
||||
umount_timeout(host_dest, 0).context("Umount readwrite host dest")?;
|
||||
// Umount event will be propagated to ro directory
|
||||
Ok(())
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ async fn send_event(
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.args(&[
|
||||
.args([
|
||||
"--address",
|
||||
&address,
|
||||
"publish",
|
||||
|
@ -40,7 +40,7 @@ impl ShimExecutor {
|
||||
let trim_path = address.strip_prefix("unix://").context("trim path")?;
|
||||
let file_path = Path::new("/").join(trim_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);
|
||||
fs::remove_file(file_path).ok();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user