diff --git a/src/map.rs b/src/map.rs index 1d1686f..4e96b58 100644 --- a/src/map.rs +++ b/src/map.rs @@ -99,13 +99,11 @@ impl Map { /// # } /// ``` pub fn into_map_mut(self) -> ConvertResult { - unsafe { - let (ptr, len) = Size::page().bounds(self.0.ptr, self.0.len); - match protect(ptr, len, Protect::ReadWrite) { + let (ptr, len) = unsafe { Size::page().bounds(self.0.ptr, self.0.len) }; + match unsafe { protect(ptr, len, Protect::ReadWrite) }{ Ok(()) => Ok(self.0), Err(err) => Err((err, self)), } - } } /// Updates the advise for the entire mapped region.. @@ -292,13 +290,11 @@ impl MapMut { /// # } /// ``` pub fn into_map(self) -> ConvertResult { - unsafe { - let (ptr, len) = Size::page().bounds(self.ptr, self.len); - match protect(ptr, len, Protect::ReadWrite) { + let (ptr, len) = unsafe { Size::page().bounds(self.ptr, self.len) }; + match unsafe { protect(ptr, len, Protect::ReadWrite) }{ Ok(()) => Ok(Map(self)), Err(err) => Err((err, self)), } - } } /// Writes modifications back to the filesystem. diff --git a/src/os/windows.rs b/src/os/windows.rs index a601dba..60b701d 100644 --- a/src/os/windows.rs +++ b/src/os/windows.rs @@ -89,8 +89,8 @@ impl Drop for MapHandle { /// Requests the page size and allocation granularity from the system. pub fn system_info() -> (u32, u32) { + let mut info = mem::MaybeUninit::::uninit(); let info = unsafe { - let mut info = mem::MaybeUninit::::uninit(); GetSystemInfo(info.as_mut_ptr() as LPSYSTEM_INFO); info.assume_init() };