From 5a95a6560458fa0323e9d952bbe0af11c950e314 Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Mon, 26 May 2025 03:36:09 +0000 Subject: [PATCH] agent: Fix clippy `unnecessary_map_or` Fix `unnecessary_map_or` clippy warning as suggested by rust 1.85.1. ```console warning: this `map_or` can be simplified --> rustjail/src/container.rs:1424:20 | 1424 | if namespace | ____________________^ 1425 | | .path() 1426 | | .as_ref() 1427 | | .map_or(true, |p| p.as_os_str().is_empty()) | |_______________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or help: use is_none_or instead | 1424 ~ if namespace 1425 + .path() 1426 + .as_ref().is_none_or(|p| p.as_os_str().is_empty()) | ``` Signed-off-by: Ruoqing He --- src/agent/rustjail/src/container.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/agent/rustjail/src/container.rs b/src/agent/rustjail/src/container.rs index 327232ada5..a35c5b62dd 100644 --- a/src/agent/rustjail/src/container.rs +++ b/src/agent/rustjail/src/container.rs @@ -450,11 +450,7 @@ fn do_init_child(cwfd: RawFd) -> Result<()> { } let s = s.unwrap(); - if ns - .path() - .as_ref() - .map_or(true, |p| p.as_os_str().is_empty()) - { + if ns.path().as_ref().is_none_or(|p| p.as_os_str().is_empty()) { // skip the pidns since it has been done in parent process. if *s != CloneFlags::CLONE_NEWPID { to_new.set(*s, true); @@ -1424,7 +1420,7 @@ pub fn update_namespaces(logger: &Logger, spec: &mut Spec, init_pid: RawFd) -> R if namespace .path() .as_ref() - .map_or(true, |p| p.as_os_str().is_empty()) + .is_none_or(|p| p.as_os_str().is_empty()) { namespace.set_path(Some(PathBuf::from(&ns_path))); }