mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-31 23:36:12 +00:00
agent: Fix clippy manual_inspect
Manually fix `manual_inspect` clippy warning reported by rust 1.85.1. ```console warning: using `map_err` over `inspect_err` --> rustjail/src/mount.rs:881:6 | 881 | .map_err(|e| { | ^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect help: try | 881 ~ .inspect_err(|&e| { 882 ~ log_child!(cfd_log, "mount error: {:?}", e); | ``` Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
parent
7ff34f00c2
commit
f9c76edd23
@ -461,15 +461,14 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
|
||||
}
|
||||
} else {
|
||||
let fd = fcntl::open(ns.path().as_ref().unwrap(), OFlag::O_CLOEXEC, Mode::empty())
|
||||
.map_err(|e| {
|
||||
.inspect_err(|e| {
|
||||
log_child!(
|
||||
cfd_log,
|
||||
"cannot open type: {} path: {}",
|
||||
&ns.typ().to_string(),
|
||||
ns.path().as_ref().unwrap().display()
|
||||
);
|
||||
log_child!(cfd_log, "error is : {:?}", e);
|
||||
e
|
||||
log_child!(cfd_log, "error is : {:?}", e)
|
||||
})?;
|
||||
|
||||
if *s != CloneFlags::CLONE_NEWPID {
|
||||
@ -685,14 +684,12 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
|
||||
.map(|gid| Gid::from_raw(*gid))
|
||||
.collect();
|
||||
|
||||
unistd::setgroups(&gids).map_err(|e| {
|
||||
unistd::setgroups(&gids).inspect_err(|e| {
|
||||
let _ = write_sync(
|
||||
cwfd,
|
||||
SYNC_FAILED,
|
||||
format!("setgroups failed: {:?}", e).as_str(),
|
||||
);
|
||||
|
||||
e
|
||||
})?;
|
||||
}
|
||||
|
||||
@ -1449,16 +1446,14 @@ fn get_pid_namespace(logger: &Logger, linux: &Linux) -> Result<PidNs> {
|
||||
OFlag::O_RDONLY,
|
||||
Mode::empty(),
|
||||
)
|
||||
.map_err(|e| {
|
||||
.inspect_err(|e| {
|
||||
error!(
|
||||
logger,
|
||||
"cannot open type: {} path: {}",
|
||||
&ns.typ().to_string(),
|
||||
ns_path.display()
|
||||
);
|
||||
error!(logger, "error is : {:?}", e);
|
||||
|
||||
e
|
||||
error!(logger, "error is : {:?}", e)
|
||||
})?,
|
||||
};
|
||||
|
||||
@ -1639,10 +1634,8 @@ fn write_mappings(logger: &Logger, path: &str, maps: &[LinuxIdMapping]) -> Resul
|
||||
if !data.is_empty() {
|
||||
let fd = fcntl::open(path, OFlag::O_WRONLY, Mode::empty())?;
|
||||
defer!(unistd::close(fd).unwrap());
|
||||
unistd::write(fd, data.as_bytes()).map_err(|e| {
|
||||
info!(logger, "cannot write mapping");
|
||||
e
|
||||
})?;
|
||||
unistd::write(fd, data.as_bytes())
|
||||
.inspect_err(|_| info!(logger, "cannot write mapping"))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -481,16 +481,14 @@ fn mount_cgroups(
|
||||
|
||||
if key != base {
|
||||
let src = format!("{}/{}", &mount_dest, key);
|
||||
unix::fs::symlink(destination.as_str(), &src[1..]).map_err(|e| {
|
||||
unix::fs::symlink(destination.as_str(), &src[1..]).inspect_err(|e| {
|
||||
log_child!(
|
||||
cfd_log,
|
||||
"symlink: {} {} err: {}",
|
||||
key,
|
||||
destination.as_str(),
|
||||
e.to_string()
|
||||
);
|
||||
|
||||
e
|
||||
)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
@ -793,14 +791,13 @@ fn mount_from(
|
||||
Path::new(&dest).parent().unwrap()
|
||||
};
|
||||
|
||||
fs::create_dir_all(dir).map_err(|e| {
|
||||
fs::create_dir_all(dir).inspect_err(|e| {
|
||||
log_child!(
|
||||
cfd_log,
|
||||
"create dir {}: {}",
|
||||
dir.to_str().unwrap(),
|
||||
e.to_string()
|
||||
);
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
// make sure file exists so we can bind over it
|
||||
@ -830,10 +827,8 @@ fn mount_from(
|
||||
}
|
||||
};
|
||||
|
||||
let _ = stat::stat(dest.as_str()).map_err(|e| {
|
||||
log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e);
|
||||
e
|
||||
})?;
|
||||
let _ = stat::stat(dest.as_str())
|
||||
.inspect_err(|e| log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e))?;
|
||||
|
||||
// Set the SELinux context for the mounts
|
||||
let mut use_xattr = false;
|
||||
@ -878,10 +873,7 @@ fn mount_from(
|
||||
flags,
|
||||
Some(d.as_str()),
|
||||
)
|
||||
.map_err(|e| {
|
||||
log_child!(cfd_log, "mount error: {:?}", e);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| log_child!(cfd_log, "mount error: {:?}", e))?;
|
||||
|
||||
if !label.is_empty() && selinux::is_enabled()? && use_xattr {
|
||||
xattr::set(dest.as_str(), "security.selinux", label.as_bytes())?;
|
||||
@ -904,10 +896,7 @@ fn mount_from(
|
||||
flags | MsFlags::MS_REMOUNT,
|
||||
None::<&str>,
|
||||
)
|
||||
.map_err(|e| {
|
||||
log_child!(cfd_log, "remout {}: {:?}", dest.as_str(), e);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| log_child!(cfd_log, "remout {}: {:?}", dest.as_str(), e))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -321,12 +321,11 @@ pub fn set_ownership(logger: &Logger, storage: &Storage) -> Result<()> {
|
||||
let fs_group = storage.fs_group();
|
||||
let read_only = storage.options.contains(&String::from("ro"));
|
||||
let mount_path = Path::new(&storage.mount_point);
|
||||
let metadata = mount_path.metadata().map_err(|err| {
|
||||
let metadata = mount_path.metadata().inspect_err(|err| {
|
||||
error!(logger, "failed to obtain metadata for mount path";
|
||||
"mount-path" => mount_path.to_str(),
|
||||
"error" => err.to_string(),
|
||||
);
|
||||
err
|
||||
)
|
||||
})?;
|
||||
|
||||
if fs_group.group_change_policy == FSGroupChangePolicy::OnRootMismatch.into()
|
||||
|
Loading…
Reference in New Issue
Block a user