Skip to content

Commit

Permalink
Fix unused imports and gated feature for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Eyob94 committed Sep 8, 2024
1 parent ac81a46 commit 67be39a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ use core::{
any,
fmt::{self, Debug},
};
use errno::errno;
use libc::{madvise, mlock, munlock, sysconf, MADV_DODUMP, MADV_DONTDUMP, _SC_PAGESIZE};
use std::mem::size_of_val;
use std::ops::{Deref, DerefMut};
use std::{ffi::c_void, mem::size_of_val};

#[cfg(unix)]
use errno::errno;

#[cfg(unix)]
use std::ffi::c_void;

#[cfg(unix)]
use libc::{mlock, munlock, sysconf, _SC_PAGESIZE};

#[cfg(target_os = "linux")]
use libc::{madvise, MADV_DODUMP, MADV_DONTDUMP};

pub use zeroize;
use zeroize::{Zeroize, ZeroizeOnDrop};

Expand Down Expand Up @@ -55,6 +66,7 @@ impl<S: Zeroize> Drop for SecretBox<S> {

#[cfg(windows)]
unsafe {
#[cfg(feature = "Win32")]
if windows_sys::Win32::System::Memory::VirtualUnlock(secret_ptr.cast(), len) == 0 {
panic!(
"VirtualUnlock failed: {:?}",
Expand Down Expand Up @@ -103,6 +115,7 @@ impl<S: Zeroize> SecretBox<S> {

#[cfg(windows)]
unsafe {
#[cfg(feature = "Win32")]
if windows_sys::Win32::System::Memory::VirtualLock(secret_ptr.cast(), len) == 0 {
panic!(
"VirtualLock failed: {:?}",
Expand Down

0 comments on commit 67be39a

Please sign in to comment.