From 286d918e00aad5c022432289f495dc70c42ff932 Mon Sep 17 00:00:00 2001 From: Stiopa Koltsov Date: Sun, 15 Sep 2024 22:37:11 -0700 Subject: [PATCH] Fix integer overflow in test_host_cpu_load_info Reviewed By: JakobDegen Differential Revision: D62703434 fbshipit-source-id: 27e9d747c25cdc928965b2e6c3406c5dc97c6190 --- app/buck2_util/src/os/macos/host_cpu_load_info.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/buck2_util/src/os/macos/host_cpu_load_info.rs b/app/buck2_util/src/os/macos/host_cpu_load_info.rs index 128f3b82392f..c4ada397a5c5 100644 --- a/app/buck2_util/src/os/macos/host_cpu_load_info.rs +++ b/app/buck2_util/src/os/macos/host_cpu_load_info.rs @@ -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);