[ASan] minor fixes to silence cmake build warnings

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@160624 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc
index 0e8530c..352cce0 100644
--- a/lib/asan/asan_allocator.cc
+++ b/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 @@
     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 @@
     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/lib/asan/tests/asan_noinst_test.cc b/lib/asan/tests/asan_noinst_test.cc
index 50192a7..e93806e 100644
--- a/lib/asan/tests/asan_noinst_test.cc
+++ b/lib/asan/tests/asan_noinst_test.cc
@@ -597,8 +597,10 @@
 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 @@
           __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 @@
           __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 @@
   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/lib/asan/tests/asan_test.cc b/lib/asan/tests/asan_test.cc
index 68c0b75..2b0def9 100644
--- a/lib/asan/tests/asan_test.cc
+++ b/lib/asan/tests/asan_test.cc
@@ -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