[llvm-commits] [compiler-rt] r159083 - /compiler-rt/trunk/lib/asan/asan_rtl.cc

Kostya Serebryany kcc at google.com
Sat Jun 23 09:30:49 PDT 2012


Author: kcc
Date: Sat Jun 23 11:30:48 2012
New Revision: 159083

URL: http://llvm.org/viewvc/llvm-project?rev=159083&view=rev
Log:
[asan] fix -Wsign-compare

Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=159083&r1=159082&r2=159083&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Sat Jun 23 11:30:48 2012
@@ -112,8 +112,9 @@
 
 void AppendToErrorMessageBuffer(const char *buffer) {
   if (error_message_buffer) {
-    uptr length = (uptr)internal_strlen(buffer);
-    int remaining = error_message_buffer_size - error_message_buffer_pos;
+    uptr length = internal_strlen(buffer);
+    CHECK_GE(error_message_buffer_size, error_message_buffer_pos);
+    uptr remaining = error_message_buffer_size - error_message_buffer_pos;
     internal_strncpy(error_message_buffer + error_message_buffer_pos,
                      buffer, remaining);
     error_message_buffer[error_message_buffer_size - 1] = '\0';
@@ -135,7 +136,7 @@
 // ---------------------- LowLevelAllocator ------------- {{{1
 void *LowLevelAllocator::Allocate(uptr size) {
   CHECK((size & (size - 1)) == 0 && "size must be a power of two");
-  if (allocated_end_ - allocated_current_ < size) {
+  if (allocated_end_ - allocated_current_ < (sptr)size) {
     uptr size_to_allocate = Max(size, kPageSize);
     allocated_current_ =
         (char*)MmapOrDie(size_to_allocate, __FUNCTION__);
@@ -143,7 +144,7 @@
     PoisonShadow((uptr)allocated_current_, size_to_allocate,
                  kAsanInternalHeapMagic);
   }
-  CHECK(allocated_end_ - allocated_current_ >= size);
+  CHECK(allocated_end_ - allocated_current_ >= (sptr)size);
   void *res = allocated_current_;
   allocated_current_ += size;
   return res;





More information about the llvm-commits mailing list