From e1b42bd84868517b89cb96fd8d46984961bef91c Mon Sep 17 00:00:00 2001 From: Eyob Date: Mon, 9 Sep 2024 00:54:02 +0300 Subject: [PATCH] Fix usize errors --- Cargo.toml | 2 ++ src/lib.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e70f7a0..8e4133a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["profile-rustflags"] + [package] name = "shush" version = "0.1.0" diff --git a/src/lib.rs b/src/lib.rs index 69fa8c9..01d6c89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,11 +44,13 @@ impl Drop for SecretBox { #[cfg(unix)] { - let page_size = unsafe { sysconf(_SC_PAGESIZE) } as usize; + let page_size = unsafe { sysconf(_SC_PAGESIZE) }; if page_size == -1 { panic!("Error getting page size: \n{}", errno()) } + + let page_size = page_size as usize; // Align the address and size to the page boundary let start = (secret_ptr as usize) & !(page_size - 1); let end = ((secret_ptr as usize) + len + page_size - 1) & !(page_size - 1); @@ -94,11 +96,13 @@ impl SecretBox { #[cfg(unix)] { - let page_size = unsafe { sysconf(_SC_PAGESIZE) } as usize; + let page_size = unsafe { sysconf(_SC_PAGESIZE) }; if page_size == -1 { panic!("Error getting page size: \n{}", errno()) } + let page_size = page_size as usize; + // Align the address and size to the page boundary let start = (secret_ptr as usize) & !(page_size - 1); let end = ((secret_ptr as usize) + len + page_size - 1) & !(page_size - 1);