Skip to content

Commit

Permalink
Fix integer overflow in test_host_cpu_load_info
Browse files Browse the repository at this point in the history
Reviewed By: JakobDegen

Differential Revision: D62703434

fbshipit-source-id: 27e9d747c25cdc928965b2e6c3406c5dc97c6190
  • Loading branch information
stepancheg authored and facebook-github-bot committed Sep 16, 2024
1 parent db2eca3 commit 286d918
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/buck2_util/src/os/macos/host_cpu_load_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ mod tests {
assert!(x.system <= y.system);
assert!(x.idle <= y.idle);
assert!(x.nice <= y.nice);
let sum_x = x.user + x.system + x.idle + x.nice;
let sum_y = y.user + y.system + y.idle + y.nice;
let sum_x = x.user as u64 + x.system as u64 + x.idle as u64 + x.nice as u64;
let sum_y = y.user as u64 + y.system as u64 + y.idle as u64 + y.nice as u64;

let delta = sum_y.wrapping_sub(sum_x) as i32;
let delta = sum_y.wrapping_sub(sum_x) as i64;

// 10 CPUs for 100 seconds at 100 ticks per second.
assert!(delta < 100_000, "{:?} <=> {:?}", x, y);
Expand Down

0 comments on commit 286d918

Please sign in to comment.