Skip to content

Commit

Permalink
Style: Fixup use of legacy numeric constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Jun 23, 2024
1 parent 507b6de commit be4b7f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src-rust/src/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::utilities::disable_write_xor_execute::{
use crate::utilities::icache_clear::clear_instruction_cache;
use crate::utilities::mathematics::round_up;
use core::ptr::{copy_nonoverlapping, NonNull};
use core::u8;

pub struct Buffers {}

Expand Down Expand Up @@ -242,7 +241,7 @@ mod tests {
fn allocate_private_memory_in_2gib() {
let mut settings = BufferAllocatorSettings::new();
settings.min_address = 0;
settings.max_address = std::i32::MAX as usize;
settings.max_address = i32::MAX as usize;

let result = Buffers::allocate_private_memory(&mut settings);
assert!(result.is_ok());
Expand Down Expand Up @@ -412,7 +411,7 @@ mod tests {
#[test]
fn get_buffer_with_proximity() {
const SIZE: usize = 4096;
let base_address = get_sys_info().max_address - (std::i32::MAX as usize);
let base_address = get_sys_info().max_address - (i32::MAX as usize);

unsafe {
LocatorHeaderFinder::reset();
Expand Down
8 changes: 3 additions & 5 deletions src-rust/src/c/buffers_c_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,13 @@ mod tests {
utilities::cached::get_sys_info,
};
use rstest::rstest;
use std;

#[cfg(not(target_os = "macos"))]
#[test]
fn allocate_private_memory_in_2gib() {
let mut settings = BufferAllocatorSettings::new();
settings.min_address = 0;
settings.max_address = std::i32::MAX as usize;
settings.max_address = i32::MAX as usize;

let result = buffers_allocate_private_memory(&mut settings);
assert!(result.is_ok);
Expand Down Expand Up @@ -430,14 +429,13 @@ mod tests {
#[test]
fn get_buffer_with_proximity() {
const SIZE: usize = 4096;
let base_address = get_sys_info().max_address - (std::i32::MAX as usize);
let base_address = get_sys_info().max_address - (i32::MAX as usize);

unsafe {
LocatorHeaderFinder::reset();
}

let settings =
buffersearchsettings_from_proximity(std::i32::MAX as usize, base_address, SIZE);
let settings = buffersearchsettings_from_proximity(i32::MAX as usize, base_address, SIZE);

let result = buffers_get_buffer(&settings);

Expand Down
1 change: 1 addition & 0 deletions src-rust/src/utilities/linux_map_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub fn get_free_regions_from_process_id(process_id: i32) -> Vec<MemoryMapEntry>
get_free_regions(&regions)
}

#[allow(clippy::comparison_chain)]
unsafe fn read_to_string(path: &str) -> String {
const BUFFER_SIZE: usize = 131_072; // 128 KB
let c_path = CString::new(path).unwrap();
Expand Down

0 comments on commit be4b7f2

Please sign in to comment.