From 1fc548e12813f50591e2c6c2c176f00f9824f597 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 5 Aug 2014 13:16:15 -0700 Subject: [PATCH] folly/test: correct an erroneous test for failed mmap Summary: * folly/test/AtomicHashArrayTest.cpp (MmapAllocator): Upon failure, mmap returns MAP_FAILED, not NULL. Test Plan: fbconfig -r folly/test:atomic_hash_array_test && fbmake runtests Reviewed By: mwang@fb.com FB internal diff: D1481080 Tasks: 4846893 --- folly/test/AtomicHashArrayTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/folly/test/AtomicHashArrayTest.cpp b/folly/test/AtomicHashArrayTest.cpp index ad324874..40e11a90 100644 --- a/folly/test/AtomicHashArrayTest.cpp +++ b/folly/test/AtomicHashArrayTest.cpp @@ -81,7 +81,7 @@ class MmapAllocator { T *allocate(size_t n) { void *p = mmap(nullptr, n * sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); - if (!p) throw std::bad_alloc(); + if (p == MAP_FAILED) throw std::bad_alloc(); return (T *)p; } -- 2.34.1