aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor_bsd.h
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@freebsd.org>2018-12-29 18:52:14 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-12-29 19:17:28 +0100
commite8f58194c1b72fddba1dbcb86cd84b1a5f91f074 (patch)
treee7e7ef2865d3804146947eef3e4df13f53c699ec /executor/executor_bsd.h
parent8d43fb9c5ec9d2afd4605d83b57d4b5fbf313114 (diff)
executor: fix error handling of mmap()
mmap() returns MAP_FAILED, which is (void *)(-1), in case of an error. This is different from NULL.
Diffstat (limited to 'executor/executor_bsd.h')
-rw-r--r--executor/executor_bsd.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h
index b359d4781..3d22f91ed 100644
--- a/executor/executor_bsd.h
+++ b/executor/executor_bsd.h
@@ -86,13 +86,12 @@ static void cover_open(cover_t* cov)
#else
size_t mmap_alloc_size = kCoverSize * (is_kernel_64_bit ? 8 : 4);
#endif
- char* mmap_ptr = (char*)mmap(NULL, mmap_alloc_size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, cov->fd, 0);
- if (mmap_ptr == NULL)
+ void* mmap_ptr = mmap(NULL, mmap_alloc_size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, cov->fd, 0);
+ if (mmap_ptr == MAP_FAILED)
fail("cover mmap failed");
- cov->data = mmap_ptr;
- cov->data_end = mmap_ptr + mmap_alloc_size;
+ cov->data = (char*)mmap_ptr;
+ cov->data_end = cov->data + mmap_alloc_size;
}
static void cover_enable(cover_t* cov, bool collect_comps)