Skip to content

Commit

Permalink
clippy integer_arithmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Mar 10, 2023
1 parent ce86db9 commit 2f78ea0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,14 @@ fn check_loader_id(id: &Pubkey) -> bool {

fn calculate_heap_cost(heap_size: u64, heap_cost: u64, enable_rounding_fix: bool) -> u64 {
const KILOBYTE: u64 = 1024;
const PAGE_SIZE_KB: u64 = 32;
let mut rounded_heap_size = heap_size;
if enable_rounding_fix {
rounded_heap_size = rounded_heap_size.saturating_add((32_u64 - 1).saturating_mul(KILOBYTE));
rounded_heap_size = rounded_heap_size
.saturating_add(PAGE_SIZE_KB.saturating_sub(1).saturating_mul(KILOBYTE));
}
rounded_heap_size
.saturating_div(32_u64.saturating_mul(KILOBYTE))
.saturating_div(PAGE_SIZE_KB.saturating_mul(KILOBYTE))
.saturating_sub(1)
.saturating_mul(heap_cost)
}
Expand Down

0 comments on commit 2f78ea0

Please sign in to comment.