From e50fa2df7ef67379985618ccb87f19a7a98ea8d3 Mon Sep 17 00:00:00 2001 From: nokyan Date: Sat, 6 Apr 2024 22:36:36 +0200 Subject: [PATCH] Make clippy happy --- lib/process_data/src/lib.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/process_data/src/lib.rs b/lib/process_data/src/lib.rs index 57319cc5..8a88d360 100644 --- a/lib/process_data/src/lib.rs +++ b/lib/process_data/src/lib.rs @@ -14,6 +14,7 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::fs::File; use std::io::{Read, Write}; use std::os::linux::fs::MetadataExt; +use std::path::Path; use std::str::FromStr; use std::sync::RwLock; use std::{path::PathBuf, time::SystemTime}; @@ -179,7 +180,7 @@ impl ProcessData { } } - fn get_uid(proc_path: &PathBuf) -> Result { + fn get_uid(proc_path: &Path) -> Result { let status = std::fs::read_to_string(proc_path.join("status"))?; if let Some(captures) = RE_UID.captures(&status) { let first_num_str = captures.get(1).context("no uid found")?; @@ -221,12 +222,12 @@ impl ProcessData { } pub fn try_from_path(proc_path: PathBuf) -> Result { - let stat = std::fs::read_to_string(&proc_path.join("stat"))?; - let statm = std::fs::read_to_string(&proc_path.join("statm"))?; - let comm = std::fs::read_to_string(&proc_path.join("comm"))?; - let commandline = std::fs::read_to_string(&proc_path.join("cmdline"))?; - let cgroup = std::fs::read_to_string(&proc_path.join("cgroup"))?; - let io = std::fs::read_to_string(&proc_path.join("io")).ok(); + let stat = std::fs::read_to_string(proc_path.join("stat"))?; + let statm = std::fs::read_to_string(proc_path.join("statm"))?; + let comm = std::fs::read_to_string(proc_path.join("comm"))?; + let commandline = std::fs::read_to_string(proc_path.join("cmdline"))?; + let cgroup = std::fs::read_to_string(proc_path.join("cgroup"))?; + let io = std::fs::read_to_string(proc_path.join("io")).ok(); let pid = proc_path .file_name() @@ -311,12 +312,12 @@ impl ProcessData { fn gpu_usage_stats(proc_path: &PathBuf, pid: i32) -> BTreeMap { let nvidia_stats = Self::nvidia_gpu_stats_all(pid).unwrap_or_default(); let mut other_stats = Self::other_gpu_usage_stats(proc_path, pid).unwrap_or_default(); - other_stats.extend(nvidia_stats.into_iter()); + other_stats.extend(nvidia_stats); other_stats } fn other_gpu_usage_stats( - proc_path: &PathBuf, + proc_path: &Path, pid: i32, ) -> Result> { let fdinfo_dir = proc_path.join("fdinfo");