Skip to content

Commit

Permalink
Fix usize errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Eyob94 committed Sep 8, 2024
1 parent b97436c commit e1b42bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["profile-rustflags"]

[package]
name = "shush"
version = "0.1.0"
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ impl<S: Zeroize> Drop for SecretBox<S> {

#[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);
Expand Down Expand Up @@ -94,11 +96,13 @@ impl<S: Zeroize> SecretBox<S> {

#[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);
Expand Down

0 comments on commit e1b42bd

Please sign in to comment.