[compiler-rt] bec6b02 - [compiler-rt][scudo] Fix sign-compare warnings

Jinsong Ji via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 14:41:56 PDT 2021


Author: Jinsong Ji
Date: 2021-05-24T21:33:02Z
New Revision: bec6b0225211ac2686e329744882cb87f01d73a5

URL: https://github.com/llvm/llvm-project/commit/bec6b0225211ac2686e329744882cb87f01d73a5
DIFF: https://github.com/llvm/llvm-project/commit/bec6b0225211ac2686e329744882cb87f01d73a5.diff

LOG: [compiler-rt][scudo] Fix sign-compare warnings

Fix buildbot failure
https://lab.llvm.org/buildbot/#/builders/57/builds/6542/steps/6/logs/stdio

/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1629:28:
error: comparison of integers of different signs: 'const unsigned long'
and 'const int' [-Werror,-Wsign-compare]
GTEST_IMPL_CMP_HELPER_(GT, >);
~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1609:12:
note: expanded from macro 'GTEST_IMPL_CMP_HELPER_'
  if (val1 op val2) {\
      ~~~~ ^  ~~~~
/llvm-project/compiler-rt/lib/scudo/standalone/tests/common_test.cpp:30:3:
note: in instantiation of function template specialization
'testing::internal::CmpHelperGT<unsigned long, int>' requested here
  EXPECT_GT(OnStart, 0);
  ^

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D103029

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/tests/common_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/tests/common_test.cpp b/compiler-rt/lib/scudo/standalone/tests/common_test.cpp
index b67acd386189..f8c64b29a183 100644
--- a/compiler-rt/lib/scudo/standalone/tests/common_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/common_test.cpp
@@ -29,7 +29,7 @@ static uptr getResidentMemorySize() {
 // Fuchsia needs getResidentMemorySize implementation.
 TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) {
   uptr OnStart = getResidentMemorySize();
-  EXPECT_GT(OnStart, 0);
+  EXPECT_GT(OnStart, 0UL);
 
   const uptr Size = 1ull << 30;
   const uptr Threshold = Size >> 3;
@@ -37,9 +37,9 @@ TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) {
   MapPlatformData Data = {};
   uptr *P = reinterpret_cast<uptr *>(
       map(nullptr, Size, "ResidentMemorySize", 0, &Data));
-  const uptr N = Size / sizeof(*P);
+  const size_t N = Size / sizeof(*P);
   ASSERT_NE(nullptr, P);
-  EXPECT_EQ(std::count(P, P + N, 0), N);
+  EXPECT_EQ((size_t)std::count(P, P + N, 0), N);
   EXPECT_LT(getResidentMemorySize() - OnStart, Threshold);
 
   memset(P, 1, Size);
@@ -47,7 +47,7 @@ TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) {
   EXPECT_LT(getResidentMemorySize() - Size, Threshold);
 
   releasePagesToOS((uptr)P, 0, Size, &Data);
-  EXPECT_EQ(std::count(P, P + N, 0), N);
+  EXPECT_EQ((size_t)std::count(P, P + N, 0), N);
   // FIXME: does not work with QEMU-user.
   // EXPECT_LT(getResidentMemorySize() - OnStart, Threshold);
 


        


More information about the llvm-commits mailing list