From 02ba2965d5faae8e2fecca49167587d7229c57d0 Mon Sep 17 00:00:00 2001 From: Albert Armea Date: Sat, 7 Feb 2026 16:51:17 -0500 Subject: [PATCH] lint --- crates/shepherd-host-linux/src/adapter.rs | 19 +++++++------------ crates/shepherd-host-linux/src/process.rs | 9 +++++---- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/crates/shepherd-host-linux/src/adapter.rs b/crates/shepherd-host-linux/src/adapter.rs index 62b9ad2..df5010f 100644 --- a/crates/shepherd-host-linux/src/adapter.rs +++ b/crates/shepherd-host-linux/src/adapter.rs @@ -154,10 +154,9 @@ impl LinuxHost { for session in &steam_snapshot { let has_game = !find_steam_game_pids(session.app_id).is_empty(); if has_game { - if let Some(mut map) = steam_sessions.lock().ok() { - if let Some(entry) = map.get_mut(&session.pid) { - entry.seen_game = true; - } + if let Ok(mut map) = steam_sessions.lock() { + map.entry(session.pid) + .and_modify(|entry| entry.seen_game = true); } } else if session.seen_game { ended.push((session.pid, session.pgid)); @@ -356,10 +355,8 @@ impl HostAdapter for LinuxHost { info!(snap = %snap, "Sent SIGTERM via snap cgroup"); } else if let Some(app_id) = info.steam_app_id { let _ = kill_steam_game_processes(app_id, nix::sys::signal::Signal::SIGTERM); - if let Some(mut map) = self.steam_sessions.lock().ok() { - if let Some(entry) = map.get_mut(&pid) { - entry.seen_game = true; - } + if let Ok(mut map) = self.steam_sessions.lock() { + map.entry(pid).and_modify(|entry| entry.seen_game = true); } info!(steam_app_id = app_id, "Sent SIGTERM to Steam game processes"); } else if let Some(ref app_id) = info.flatpak_app_id { @@ -437,10 +434,8 @@ impl HostAdapter for LinuxHost { info!(snap = %snap, "Sent SIGKILL via snap cgroup"); } else if let Some(app_id) = info.steam_app_id { let _ = kill_steam_game_processes(app_id, nix::sys::signal::Signal::SIGKILL); - if let Some(mut map) = self.steam_sessions.lock().ok() { - if let Some(entry) = map.get_mut(&pid) { - entry.seen_game = true; - } + if let Ok(mut map) = self.steam_sessions.lock() { + map.entry(pid).and_modify(|entry| entry.seen_game = true); } info!(steam_app_id = app_id, "Sent SIGKILL to Steam game processes"); } else if let Some(ref app_id) = info.flatpak_app_id { diff --git a/crates/shepherd-host-linux/src/process.rs b/crates/shepherd-host-linux/src/process.rs index b9cdd19..9889d41 100644 --- a/crates/shepherd-host-linux/src/process.rs +++ b/crates/shepherd-host-linux/src/process.rs @@ -180,10 +180,11 @@ pub fn find_steam_game_pids(app_id: u32) -> Vec { }; for key in &keys { let prefix = format!("{}=", key); - if let Some(val) = var_str.strip_prefix(&prefix) { - if val == target { - pids.push(pid); - } + if var_str + .strip_prefix(&prefix) + .is_some_and(|val| val == target) + { + pids.push(pid); } } }