Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Apr 6, 2024
1 parent 280cf07 commit 4a0adb4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/process_data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -179,7 +180,7 @@ impl ProcessData {
}
}

fn get_uid(proc_path: &PathBuf) -> Result<u32> {
fn get_uid(proc_path: &Path) -> Result<u32> {
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")?;
Expand Down Expand Up @@ -221,12 +222,12 @@ impl ProcessData {
}

pub fn try_from_path(proc_path: PathBuf) -> Result<Self> {
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()
Expand Down Expand Up @@ -311,12 +312,12 @@ impl ProcessData {
fn gpu_usage_stats(proc_path: &PathBuf, pid: i32) -> BTreeMap<PciSlot, GpuUsageStats> {
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<BTreeMap<PciSlot, GpuUsageStats>> {
let fdinfo_dir = proc_path.join("fdinfo");
Expand Down

0 comments on commit 4a0adb4

Please sign in to comment.