forked from OSchip/llvm-project
[ASan] minor fixes to silence cmake build warnings
llvm-svn: 160624
This commit is contained in:
parent
7f829e4d32
commit
37d5134f38
|
@ -42,7 +42,7 @@
|
|||
|
||||
namespace __asan {
|
||||
|
||||
#define REDZONE (flags()->redzone)
|
||||
#define REDZONE ((uptr)(flags()->redzone))
|
||||
static const uptr kMinAllocSize = REDZONE * 2;
|
||||
static const u64 kMaxAvailableRam = 128ULL << 30; // 128G
|
||||
static const uptr kMaxThreadLocalQuarantine = 1 << 20; // 1M
|
||||
|
@ -344,7 +344,7 @@ class MallocInfo {
|
|||
AsanChunkFifoList *q = &x->quarantine_;
|
||||
if (q->size() > 0) {
|
||||
quarantine_.PushList(q);
|
||||
while (quarantine_.size() > flags()->quarantine_size) {
|
||||
while (quarantine_.size() > (uptr)flags()->quarantine_size) {
|
||||
QuarantinePop();
|
||||
}
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
|
|||
PoisonHeapPartialRightRedzone(addr + rounded_size - REDZONE,
|
||||
size & (REDZONE - 1));
|
||||
}
|
||||
if (size <= flags()->max_malloc_fill_size) {
|
||||
if (size <= (uptr)(flags()->max_malloc_fill_size)) {
|
||||
REAL(memset)((void*)addr, 0, rounded_size);
|
||||
}
|
||||
return (u8*)addr;
|
||||
|
|
|
@ -597,8 +597,10 @@ TEST(AddressSanitizerInterface, PushAndPopWithPoisoningTest) {
|
|||
static void MakeShadowValid(bool *shadow, int length, int granularity) {
|
||||
bool can_be_poisoned = true;
|
||||
for (int i = length - 1; i >= 0; i--) {
|
||||
can_be_poisoned &= shadow[i];
|
||||
shadow[i] &= can_be_poisoned;
|
||||
if (!shadow[i])
|
||||
can_be_poisoned = false;
|
||||
if (!can_be_poisoned)
|
||||
shadow[i] = false;
|
||||
if (i % (1 << granularity) == 0) {
|
||||
can_be_poisoned = true;
|
||||
}
|
||||
|
@ -619,9 +621,9 @@ TEST(AddressSanitizerInterface, PoisoningStressTest) {
|
|||
__asan_poison_memory_region(arr + l2, s2);
|
||||
memset(expected, false, kSize);
|
||||
memset(expected + l1, true, s1);
|
||||
MakeShadowValid(expected, 24, /*granularity*/ 3);
|
||||
MakeShadowValid(expected, kSize, /*granularity*/ 3);
|
||||
memset(expected + l2, true, s2);
|
||||
MakeShadowValid(expected, 24, /*granularity*/ 3);
|
||||
MakeShadowValid(expected, kSize, /*granularity*/ 3);
|
||||
for (size_t i = 0; i < kSize; i++) {
|
||||
ASSERT_EQ(expected[i], __asan_address_is_poisoned(arr + i));
|
||||
}
|
||||
|
@ -631,9 +633,9 @@ TEST(AddressSanitizerInterface, PoisoningStressTest) {
|
|||
__asan_unpoison_memory_region(arr + l2, s2);
|
||||
memset(expected, true, kSize);
|
||||
memset(expected + l1, false, s1);
|
||||
MakeShadowValid(expected, 24, /*granularity*/ 3);
|
||||
MakeShadowValid(expected, kSize, /*granularity*/ 3);
|
||||
memset(expected + l2, false, s2);
|
||||
MakeShadowValid(expected, 24, /*granularity*/ 3);
|
||||
MakeShadowValid(expected, kSize, /*granularity*/ 3);
|
||||
for (size_t i = 0; i < kSize; i++) {
|
||||
ASSERT_EQ(expected[i], __asan_address_is_poisoned(arr + i));
|
||||
}
|
||||
|
@ -670,7 +672,8 @@ static void ErrorReportCallbackOneToZ(const char *report) {
|
|||
for (int i = 0; i < len; i++) {
|
||||
if (dup[i] == '1') dup[i] = 'Z';
|
||||
}
|
||||
write(2, dup, len);
|
||||
int written = write(2, dup, len);
|
||||
ASSERT_EQ(len, written);
|
||||
free(dup);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
#include <CoreFoundation/CFString.h>
|
||||
#endif // __APPLE__
|
||||
|
||||
#ifdef __APPLE__
|
||||
static bool APPLE = true;
|
||||
#else
|
||||
static bool APPLE = false;
|
||||
#endif
|
||||
|
||||
#if ASAN_HAS_EXCEPTIONS
|
||||
# define ASAN_THROW(x) throw (x)
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue