Skip to content

Commit

Permalink
refactor: make it obvious that we always pass 0 to start-time-cpu-us
Browse files Browse the repository at this point in the history
Instead of setting the variable to 0 unconditionally right before it is
used, just inline this zero into the only use-site.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
  • Loading branch information
roypat committed Feb 10, 2025
1 parent 89202d6 commit d09494c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/jailer/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl Env {
Command::new(chroot_exec_file)
.args(["--id", &self.id])
.args(["--start-time-us", &self.start_time_us.to_string()])
.args(["--start-time-cpu-us", &self.start_time_cpu_us.to_string()])
.args(["--start-time-cpu-us", "0"])

Check warning on line 479 in src/jailer/src/env.rs

View check run for this annotation

Codecov / codecov/patch

src/jailer/src/env.rs#L479

Added line #L479 was not covered by tests
.args(["--parent-cpu-time-us", &self.jailer_cpu_time_us.to_string()])
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
Expand Down Expand Up @@ -698,8 +698,6 @@ impl Env {
// Compute jailer's total CPU time up to the current time.
self.jailer_cpu_time_us += get_time_us(ClockType::ProcessCpu);
self.jailer_cpu_time_us -= self.start_time_cpu_us;

Check warning on line 700 in src/jailer/src/env.rs

View check run for this annotation

Codecov / codecov/patch

src/jailer/src/env.rs#L699-L700

Added lines #L699 - L700 were not covered by tests
// Reset process start time.
self.start_time_cpu_us = 0;

// If specified, exec the provided binary into a new PID namespace.
if self.new_pid_ns {
Expand Down

0 comments on commit d09494c

Please sign in to comment.