From bbb62dfa85486a1e710edf2cfafb8295e6bd1594 Mon Sep 17 00:00:00 2001 From: Gwen Lg Date: Tue, 27 Jan 2026 22:06:26 +0100 Subject: [PATCH] refactor: use `u64::midpoint` instead of manual implementation warning: manual implementation of `midpoint` which can overflow help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#manual_midpoint --- Cargo.toml | 1 + src/rpc/layout/version.rs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6bd3d32a..53e14412 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -183,5 +183,6 @@ strip = "debuginfo" [workspace.lints.clippy] # pedantic lints configuration doc_markdown = "warn" +manual_midpoint = "warn" semicolon_if_nothing_returned = "warn" unnecessary_semicolon = "warn" diff --git a/src/rpc/layout/version.rs b/src/rpc/layout/version.rs index be2f98f3..dda48ea3 100644 --- a/src/rpc/layout/version.rs +++ b/src/rpc/layout/version.rs @@ -527,16 +527,16 @@ impl LayoutVersion { let mut s_up = self.get_total_capacity(); while s_down + 1 < s_up { g = self.generate_flow_graph( - (s_down + s_up) / 2, + u64::midpoint(s_down, s_up), zone_to_id, &empty_set, zone_redundancy, )?; g.compute_maximal_flow()?; if g.get_flow_value()? < (NB_PARTITIONS * self.replication_factor) as i64 { - s_up = (s_down + s_up) / 2; + s_up = u64::midpoint(s_down, s_up); } else { - s_down = (s_down + s_up) / 2; + s_down = u64::midpoint(s_down, s_up); } }