From: Jim Meyering Date: Tue, 5 Aug 2014 20:16:15 +0000 (-0700) Subject: folly/test: correct an erroneous test for failed mmap X-Git-Tag: v0.22.0~417 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=1fc548e12813f50591e2c6c2c176f00f9824f597;p=folly.git 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 --- 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; }