diff options
author | Alan Somers <asomers@gmail.com> | 2022-12-05 11:32:35 -0700 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2022-12-05 11:43:17 -0700 |
commit | 16a8c0298305d76feb87c2430f36ea583bc4bc5f (patch) | |
tree | 95edc2f5dd464df0c669ec79c7d8fa807878de10 /test/sys/test_mman.rs | |
parent | e2257dbb971fa974cf56f00a31d739a7e583e5b8 (diff) | |
download | nix-16a8c0298305d76feb87c2430f36ea583bc4bc5f.zip |
Use I/O safety in sys::mman
Diffstat (limited to 'test/sys/test_mman.rs')
-rw-r--r-- | test/sys/test_mman.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/sys/test_mman.rs b/test/sys/test_mman.rs index e748427b..b4674e53 100644 --- a/test/sys/test_mman.rs +++ b/test/sys/test_mman.rs @@ -1,15 +1,15 @@ use nix::sys::mman::{mmap, MapFlags, ProtFlags}; -use std::num::NonZeroUsize; +use std::{num::NonZeroUsize, os::unix::io::BorrowedFd}; #[test] fn test_mmap_anonymous() { unsafe { - let ptr = mmap( + let ptr = mmap::<BorrowedFd>( None, NonZeroUsize::new(1).unwrap(), ProtFlags::PROT_READ | ProtFlags::PROT_WRITE, MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS, - -1, + None, 0, ) .unwrap() as *mut u8; @@ -29,12 +29,12 @@ fn test_mremap_grow() { let one_k_non_zero = NonZeroUsize::new(ONE_K).unwrap(); let slice: &mut [u8] = unsafe { - let mem = mmap( + let mem = mmap::<BorrowedFd>( None, one_k_non_zero, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE, MapFlags::MAP_ANONYMOUS | MapFlags::MAP_PRIVATE, - -1, + None, 0, ) .unwrap(); @@ -87,12 +87,12 @@ fn test_mremap_shrink() { const ONE_K: size_t = 1024; let ten_one_k = NonZeroUsize::new(10 * ONE_K).unwrap(); let slice: &mut [u8] = unsafe { - let mem = mmap( + let mem = mmap::<BorrowedFd>( None, ten_one_k, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE, MapFlags::MAP_ANONYMOUS | MapFlags::MAP_PRIVATE, - -1, + None, 0, ) .unwrap(); |