Skip to content

Commit

Permalink
Check MAP_FAILED rather than p>0
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed Feb 4, 2020
1 parent e864644 commit 2a9d769
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/test/mmap_shared_dev_zero.c
Expand Up @@ -9,9 +9,9 @@
int main(void) {
int fd = open("/dev/zero", O_RDWR);
void* p1 = mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
assert((intptr_t)p1 > 0);
assert(p1 != MAP_FAILED);
void* p2 = mmap(0, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
assert((intptr_t)p2 > 0);
assert(p2 != MAP_FAILED);
assert(p1 != p2);

memset(p1, 0xdd, PAGE_SIZE);
Expand Down

0 comments on commit 2a9d769

Please sign in to comment.