From bde121b849ad880dd863af1d99bc32e92c253b8f Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 5 Jan 2016 23:07:59 +0000 Subject: [PATCH] tests/mmap.c: use libtests * tests/mmap.c (main): Use get_page_size and perror_msg_and_fail. --- tests/mmap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/mmap.c b/tests/mmap.c index 8639ce67..46542622 100644 --- a/tests/mmap.c +++ b/tests/mmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,7 +35,7 @@ int main(void) { - const intmax_t pagesize = sysconf(_SC_PAGESIZE); + const intmax_t pagesize = get_page_size(); const unsigned long length = pagesize * 3; const int fd = -1; off_t offset; @@ -51,10 +51,12 @@ main(void) p = mmap(addr, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, fd, offset); - if (p == MAP_FAILED || - mprotect(p, length, PROT_NONE) || - munmap(p, length)) - return 77; + if (MAP_FAILED == p) + perror_msg_and_fail("mmap"); + if (mprotect(p, length, PROT_NONE)) + perror_msg_and_fail("mprotect"); + if (munmap(p, length)) + perror_msg_and_fail("munmap"); if (sizeof(offset) == sizeof(int)) printf("mmap2?\\(%p, %lu, PROT_READ\\|PROT_WRITE, " -- 2.40.0