From 37d5134f38cd75e1640d8de8eec729ef63f8d374 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 23 Jul 2012 09:11:58 +0000 Subject: [PATCH] [ASan] minor fixes to silence cmake build warnings llvm-svn: 160624 --- compiler-rt/lib/asan/asan_allocator.cc | 6 +++--- compiler-rt/lib/asan/tests/asan_noinst_test.cc | 17 ++++++++++------- compiler-rt/lib/asan/tests/asan_test.cc | 6 ------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc index 0e8530c0516b..352cce00fbee 100644 --- a/compiler-rt/lib/asan/asan_allocator.cc +++ b/compiler-rt/lib/asan/asan_allocator.cc @@ -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; diff --git a/compiler-rt/lib/asan/tests/asan_noinst_test.cc b/compiler-rt/lib/asan/tests/asan_noinst_test.cc index 50192a7d6f4f..e93806e9f11a 100644 --- a/compiler-rt/lib/asan/tests/asan_noinst_test.cc +++ b/compiler-rt/lib/asan/tests/asan_noinst_test.cc @@ -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); } diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc index 68c0b75af178..2b0def9f1c12 100644 --- a/compiler-rt/lib/asan/tests/asan_test.cc +++ b/compiler-rt/lib/asan/tests/asan_test.cc @@ -34,12 +34,6 @@ #include #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