[compiler-rt] 812a906 - [sanitizers][NFC] Change typesto avoid warnings
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 14:33:12 PST 2021
Author: Vitaly Buka
Date: 2021-02-26T14:32:54-08:00
New Revision: 812a9061338dad80a3e9725db95f67590bc54dcd
URL: https://github.com/llvm/llvm-project/commit/812a9061338dad80a3e9725db95f67590bc54dcd
DIFF: https://github.com/llvm/llvm-project/commit/812a9061338dad80a3e9725db95f67590bc54dcd.diff
LOG: [sanitizers][NFC] Change typesto avoid warnings
Warning was enabled by D94640
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index 26e70df77218..26753b6c8aeb 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -371,8 +371,7 @@ class SizeClassAllocator64 {
}
~PackedCounterArray() {
if (buffer) {
- memory_mapper->UnmapPackedCounterArrayBuffer(
- reinterpret_cast<uptr>(buffer), buffer_size);
+ memory_mapper->UnmapPackedCounterArrayBuffer(buffer, buffer_size);
}
}
@@ -803,17 +802,16 @@ class SizeClassAllocator64 {
return released_bytes;
}
- uptr MapPackedCounterArrayBuffer(uptr buffer_size) {
+ void *MapPackedCounterArrayBuffer(uptr buffer_size) {
// TODO(alekseyshl): The idea to explore is to check if we have enough
// space between num_freed_chunks*sizeof(CompactPtrT) and
// mapped_free_array to fit buffer_size bytes and use that space instead
// of mapping a temporary one.
- return reinterpret_cast<uptr>(
- MmapOrDieOnFatalError(buffer_size, "ReleaseToOSPageCounters"));
+ return MmapOrDieOnFatalError(buffer_size, "ReleaseToOSPageCounters");
}
- void UnmapPackedCounterArrayBuffer(uptr buffer, uptr buffer_size) {
- UnmapOrDie(reinterpret_cast<void *>(buffer), buffer_size);
+ void UnmapPackedCounterArrayBuffer(void *buffer, uptr buffer_size) {
+ UnmapOrDie(buffer, buffer_size);
}
// Releases [from, to) range of pages back to OS.
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp
index 26593c0c2f49..590e477678ea 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp
@@ -1081,11 +1081,11 @@ class NoMemoryMapper {
NoMemoryMapper() : last_request_buffer_size(0) {}
- uptr MapPackedCounterArrayBuffer(uptr buffer_size) {
+ void *MapPackedCounterArrayBuffer(uptr buffer_size) {
last_request_buffer_size = buffer_size;
- return 0;
+ return nullptr;
}
- void UnmapPackedCounterArrayBuffer(uptr buffer, uptr buffer_size) {}
+ void UnmapPackedCounterArrayBuffer(void *buffer, uptr buffer_size) {}
};
class RedZoneMemoryMapper {
@@ -1100,14 +1100,15 @@ class RedZoneMemoryMapper {
UnmapOrDie(buffer, 3 * GetPageSize());
}
- uptr MapPackedCounterArrayBuffer(uptr buffer_size) {
+ void *MapPackedCounterArrayBuffer(uptr buffer_size) {
const auto page_size = GetPageSize();
CHECK_EQ(buffer_size, page_size);
- memset(reinterpret_cast<void*>(reinterpret_cast<uptr>(buffer) + page_size),
- 0, page_size);
- return reinterpret_cast<uptr>(buffer) + page_size;
+ void *p =
+ reinterpret_cast<void *>(reinterpret_cast<uptr>(buffer) + page_size);
+ memset(p, 0, page_size);
+ return p;
}
- void UnmapPackedCounterArrayBuffer(uptr buffer, uptr buffer_size) {}
+ void UnmapPackedCounterArrayBuffer(void *buffer, uptr buffer_size) {}
private:
void *buffer;
@@ -1227,12 +1228,12 @@ class ReleasedPagesTrackingMemoryMapper {
public:
std::set<u32> reported_pages;
- uptr MapPackedCounterArrayBuffer(uptr buffer_size) {
+ void *MapPackedCounterArrayBuffer(uptr buffer_size) {
reported_pages.clear();
- return reinterpret_cast<uptr>(calloc(1, buffer_size));
+ return calloc(1, buffer_size);
}
- void UnmapPackedCounterArrayBuffer(uptr buffer, uptr buffer_size) {
- free(reinterpret_cast<void*>(buffer));
+ void UnmapPackedCounterArrayBuffer(void *buffer, uptr buffer_size) {
+ free(buffer);
}
void ReleasePageRangeToOS(u32 from, u32 to) {
More information about the llvm-commits
mailing list