Skip to content

Commit 9bd3bb9

Browse files
committed
refactor: derive Debug for jailer::env::Env
Replaces a manual impl that was already missing some fields because they were added to the struct after the impl was written. Signed-off-by: Patrick Roy <[email protected]>
1 parent 3ca2fab commit 9bd3bb9

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/jailer/src/env.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
use std::ffi::{CString, OsString};
55
use std::fs::{self, canonicalize, read_to_string, File, OpenOptions, Permissions};
6+
use std::io;
67
use std::io::Write;
78
use std::os::unix::fs::PermissionsExt;
89
use std::os::unix::io::AsRawFd;
910
use std::os::unix::process::CommandExt;
1011
use std::path::{Component, Path, PathBuf};
1112
use std::process::{exit, id, Command, Stdio};
12-
use std::{fmt, io};
1313

1414
use utils::arg_parser::UtilsArgParserError::MissingValue;
1515
use utils::time::{get_time_us, ClockType};
@@ -114,6 +114,7 @@ enum UserfaultfdParseError {
114114
NotFound,
115115
}
116116

117+
#[derive(Debug)]
117118
pub struct Env {
118119
id: String,
119120
chroot_dir: PathBuf,
@@ -132,26 +133,6 @@ pub struct Env {
132133
uffd_dev_minor: Option<u32>,
133134
}
134135

135-
impl fmt::Debug for Env {
136-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
137-
f.debug_struct("Env")
138-
.field("id", &self.id)
139-
.field("chroot_dir", &self.chroot_dir)
140-
.field("exec_file_path", &self.exec_file_path)
141-
.field("uid", &self.uid)
142-
.field("gid", &self.gid)
143-
.field("netns", &self.netns)
144-
.field("daemonize", &self.daemonize)
145-
.field("new_pid_ns", &self.new_pid_ns)
146-
.field("start_time_us", &self.start_time_us)
147-
.field("jailer_cpu_time_us", &self.jailer_cpu_time_us)
148-
.field("extra_args", &self.extra_args)
149-
.field("cgroups", &self.cgroup_conf)
150-
.field("resource_limits", &self.resource_limits)
151-
.finish()
152-
}
153-
}
154-
155136
impl Env {
156137
pub fn new(
157138
arguments: &arg_parser::Arguments,

0 commit comments

Comments
 (0)