From 80136a1e4142d66846cf9024ac83346a9444cdca Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Sun, 24 Sep 2017 13:36:29 -0700 Subject: [PATCH] Silence static analyzer warnings about memory leaks The static analyzer complains that this memory is leaked regardless of how I try to work around it (unless we escape the memory by using a global or something, but...). Basically, as long as there's some sort of operation on the reinterpret_cast'ed pointer, it complains. If we remove the bitwise negations, it doesn't. Doing so would presumably defeat the purpose of this test, though, so add a NOLINT. Bug: 27101951 Test: mma. No more static analyzer warning for this file. Change-Id: If9008946a2145d17b8651535141bfd7ec9224739 --- libmemunreachable/tests/MemUnreachable_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmemunreachable/tests/MemUnreachable_test.cpp b/libmemunreachable/tests/MemUnreachable_test.cpp index ec8938885..87417f132 100644 --- a/libmemunreachable/tests/MemUnreachable_test.cpp +++ b/libmemunreachable/tests/MemUnreachable_test.cpp @@ -27,6 +27,9 @@ namespace android { class HiddenPointer { public: + // Since we're doing such a good job of hiding it, the static analyzer + // thinks that we're leaking this `malloc`. This is probably related to + // https://bugs.llvm.org/show_bug.cgi?id=34198. NOLINTNEXTLINE explicit HiddenPointer(size_t size = 256) { Set(malloc(size)); } ~HiddenPointer() { Free(); } void* Get() { return reinterpret_cast(~ptr_); }