Skip to content

Commit

Permalink
use unwrap_or_default to avoid panic
Browse files Browse the repository at this point in the history
Signed-off-by: Youtirsin <Youtirsin@qq.com>
  • Loading branch information
Youtirsin committed Dec 7, 2023
1 parent 2c3e948 commit bef236e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/shim/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ fn set_cpu_usage(cpu_usage: &mut CPUUsage, stat: &String) {

match parts[0] {
"usage_usec" => {
cpu_usage.set_total(parts[1].parse().unwrap());
cpu_usage.set_total(parts[1].parse().unwrap_or_default());
}
"user_usec" => {
cpu_usage.set_user(parts[1].parse().unwrap());
cpu_usage.set_user(parts[1].parse().unwrap_or_default());
}
"system_usec" => {
cpu_usage.set_kernel(parts[1].parse().unwrap());
cpu_usage.set_kernel(parts[1].parse().unwrap_or_default());
}
_ => {}
}
Expand Down

0 comments on commit bef236e

Please sign in to comment.