summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-11-20 21:48:28 +0000
committerGitHub <noreply@github.com>2022-11-20 21:48:28 +0000
commit6e2b0a02e662a83c1748dda9825dc96da5374f6f (patch)
treed9bd34d4f9d9212ccec761e056ed184e250853bf /test
parent2ad2f48693b7ecb262d4f887573d1170f4f79133 (diff)
parentd34696c84b0d3b49456fa6f0f12af91d94b11371 (diff)
downloadnix-6e2b0a02e662a83c1748dda9825dc96da5374f6f.zip
Merge #1870
1870: mmap addr r=asomers a=JonathanWoollett-Light Uses `Some<size_t>` instead of `*mut c_void` for the `addr` passed to [`sys::mman::mmap`](https://docs.rs/nix/latest/nix/sys/mman/fn.mmap.html). In this instance we are not usefully passing a pointer, it will never be dereferenced. We are passing a location which represents where to attach the shared memory to. In this case `size_t` better represents an address and not a pointer, and `Option<size_t>` better represents an optional argument than `NULLPTR`. In C since there is no optional type this is a pointer as this allows it be null which is an alias here for `None`. Co-authored-by: Jonathan <jonathanwoollettlight@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_mman.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/sys/test_mman.rs b/test/sys/test_mman.rs
index 75cbf6ce..a43991c2 100644
--- a/test/sys/test_mman.rs
+++ b/test/sys/test_mman.rs
@@ -4,7 +4,7 @@ use nix::sys::mman::{mmap, MapFlags, ProtFlags};
fn test_mmap_anonymous() {
unsafe {
let ptr = mmap(
- std::ptr::null_mut(),
+ None,
1,
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS,
@@ -27,7 +27,7 @@ fn test_mremap_grow() {
const ONE_K: size_t = 1024;
let slice: &mut [u8] = unsafe {
let mem = mmap(
- std::ptr::null_mut(),
+ None,
ONE_K,
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_ANONYMOUS | MapFlags::MAP_PRIVATE,
@@ -83,7 +83,7 @@ fn test_mremap_shrink() {
const ONE_K: size_t = 1024;
let slice: &mut [u8] = unsafe {
let mem = mmap(
- std::ptr::null_mut(),
+ None,
10 * ONE_K,
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_ANONYMOUS | MapFlags::MAP_PRIVATE,