From 208b237ecc795506cedb9bbc96856e8c30ff8154 Mon Sep 17 00:00:00 2001 From: J Robert Ray Date: Mon, 2 Dec 2024 16:05:39 -0800 Subject: [PATCH] Apply clippy suggestions Changes that weren't automatically applied via --fix. Signed-off-by: J Robert Ray --- crates/spfs-cli/common/src/args.rs | 3 +-- crates/spfs-vfs/src/winfsp/mount.rs | 12 +++--------- crates/spfs-vfs/src/winfsp/router.rs | 6 ++++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/crates/spfs-cli/common/src/args.rs b/crates/spfs-cli/common/src/args.rs index 3dfeb2e5d..b8e1fb0b5 100644 --- a/crates/spfs-cli/common/src/args.rs +++ b/crates/spfs-cli/common/src/args.rs @@ -389,8 +389,7 @@ impl Logging { #[cfg(unix)] let syslog_layer = self.syslog.then(|| { - let identity = std::ffi::CStr::from_bytes_with_nul(b"spfs\0") - .expect("identity value is valid CStr"); + let identity = c"spfs"; let (options, facility) = Default::default(); let layer = fmt_layer().with_writer( syslog_tracing::Syslog::new(identity, options, facility) diff --git a/crates/spfs-vfs/src/winfsp/mount.rs b/crates/spfs-vfs/src/winfsp/mount.rs index 556b77d79..eec4326fb 100644 --- a/crates/spfs-vfs/src/winfsp/mount.rs +++ b/crates/spfs-vfs/src/winfsp/mount.rs @@ -167,9 +167,7 @@ impl Mount { let Ok(relative) = path.strip_prefix(r"\\") else { return None; }; - let Some(str_path) = relative.to_str() else { - return None; - }; + let str_path = relative.to_str()?; const TRIM_END: &[char] = &['/']; let path = str_path.replace('\\', "/"); @@ -183,15 +181,11 @@ impl Mount { return entry; } for step in path.split('/') { - let Some(current) = entry.take() else { - return None; - }; + let current = entry.take()?; let EntryKind::Tree = current.kind else { return None; }; - let Some(child) = current.entries.get(step) else { - return None; - }; + let child = current.entries.get(step)?; entry = self .inodes .get(&child.user_data) diff --git a/crates/spfs-vfs/src/winfsp/router.rs b/crates/spfs-vfs/src/winfsp/router.rs index df9bcb175..afc2de5b4 100644 --- a/crates/spfs-vfs/src/winfsp/router.rs +++ b/crates/spfs-vfs/src/winfsp/router.rs @@ -557,8 +557,10 @@ pub fn get_parent_pids(root: Option) -> std::result::Result, winfs let no_more_files = HRESULT::from(ERROR_NO_MORE_FILES); let snapshot = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, child)? }; let mut parents = HashMap::new(); - let mut process = PROCESSENTRY32::default(); - process.dwSize = std::mem::size_of::() as u32; + let mut process = PROCESSENTRY32 { + dwSize: std::mem::size_of::() as u32, + ..Default::default() + }; loop { match unsafe { Process32Next(snapshot, &mut process as *mut PROCESSENTRY32) } { Ok(()) => {