mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-12 01:44:30 +00:00
libs: resolve manual_checked_ops warning in mem-agent for Rust 1.95
Replace manual `if us != 0` guard before integer division with `checked_div` as flagged by the new `clippy::manual_checked_ops` lint in Rust 1.95. Generated-by: IBM Bob Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
@@ -144,8 +144,8 @@ impl Period {
|
||||
if self.last_psi != 0 && self.last_psi < psi && self.last_update_time < now {
|
||||
let us = (now - self.last_update_time).num_milliseconds() as u64 * 1000;
|
||||
|
||||
if us != 0 {
|
||||
percent = (psi - self.last_psi) * 100 / us;
|
||||
if let Some(result) = ((psi - self.last_psi) * 100).checked_div(us) {
|
||||
percent = result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user