Skip to content

Commit 2c34350

Browse files
committed
fix: resolve Linux CI unused-result and cast warnings
- Handle Command::env()/pre_exec() return values in process.rs (these are Linux-only code paths invisible on macOS) - Use i32::try_from for safe pid cast in container stop
1 parent f345301 commit 2c34350

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

crates/containust-runtime/src/container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Container {
8686
use nix::sys::signal::{Signal, kill};
8787
use nix::unistd::Pid;
8888

89-
let nix_pid = Pid::from_raw(pid as i32);
89+
let nix_pid = Pid::from_raw(i32::try_from(pid).unwrap_or(i32::MAX));
9090

9191
if kill(nix_pid, Signal::SIGTERM).is_ok() {
9292
tracing::info!(pid, "sent SIGTERM");

crates/containust-runtime/src/process.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ pub fn spawn_container_process(
4747

4848
let mut child_cmd = std::process::Command::new(&command[0]);
4949
if command.len() > 1 {
50-
child_cmd.args(&command[1..]);
50+
let _ = child_cmd.args(&command[1..]);
5151
}
5252

53-
child_cmd.env_clear();
54-
child_cmd.env("PATH", "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
55-
child_cmd.env("HOME", "/root");
56-
child_cmd.env("TERM", "xterm");
53+
let _ = child_cmd.env_clear();
54+
let _ = child_cmd.env("PATH", "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
55+
let _ = child_cmd.env("HOME", "/root");
56+
let _ = child_cmd.env("TERM", "xterm");
5757
for (key, value) in env {
58-
child_cmd.env(key, value);
58+
let _ = child_cmd.env(key, value);
5959
}
6060

6161
let rootfs_owned = rootfs.to_path_buf();
6262
// SAFETY: pre_exec runs in the child process between fork and exec.
6363
// chroot and chdir are safe here as we've validated rootfs exists.
6464
unsafe {
65-
child_cmd.pre_exec(move || {
65+
let _ = child_cmd.pre_exec(move || {
6666
nix::unistd::chroot(&rootfs_owned).map_err(|e| {
6767
std::io::Error::new(std::io::ErrorKind::PermissionDenied, e.to_string())
6868
})?;

0 commit comments

Comments
 (0)