[Lldb-commits] [lldb] r307071 - Fix some warnings in ProcessorTraceTest.cpp

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 4 05:29:30 PDT 2017


Author: labath
Date: Tue Jul  4 05:29:30 2017
New Revision: 307071

URL: http://llvm.org/viewvc/llvm-project?rev=307071&view=rev
Log:
Fix some warnings in ProcessorTraceTest.cpp

Modified:
    lldb/trunk/unittests/Process/Linux/ProcessorTraceTest.cpp

Modified: lldb/trunk/unittests/Process/Linux/ProcessorTraceTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/Linux/ProcessorTraceTest.cpp?rev=307071&r1=307070&r2=307071&view=diff
==============================================================================
--- lldb/trunk/unittests/Process/Linux/ProcessorTraceTest.cpp (original)
+++ lldb/trunk/unittests/Process/Linux/ProcessorTraceTest.cpp Tue Jul  4 05:29:30 2017
@@ -30,42 +30,40 @@ size_t ReadCylicBufferWrapper(void *buf,
 }
 
 TEST(CyclicBuffer, EdgeCases) {
-  size_t bytes_read = 0;
+  size_t bytes_read;
   uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'};
 
   // We will always leave the last bytes untouched
   // so that string comparisions work.
-  char bigger_buffer[10] = {};
-  char equal_size_buffer[7] = {};
   char smaller_buffer[4] = {};
 
   // empty buffer to read into
   bytes_read = ReadCylicBufferWrapper(smaller_buffer, 0, cyclic_buffer,
                                       sizeof(cyclic_buffer), 3, 0);
-  ASSERT_EQ(0, bytes_read);
+  ASSERT_EQ(0u, bytes_read);
 
   // empty cyclic buffer
   bytes_read = ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer),
                                       cyclic_buffer, 0, 3, 0);
-  ASSERT_EQ(0, bytes_read);
+  ASSERT_EQ(0u, bytes_read);
 
   // bigger offset
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 6);
-  ASSERT_EQ(0, bytes_read);
+  ASSERT_EQ(0u, bytes_read);
 
   // wrong offset
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 7);
-  ASSERT_EQ(0, bytes_read);
+  ASSERT_EQ(0u, bytes_read);
 
   // wrong start
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 7);
-  ASSERT_EQ(0, bytes_read);
+  ASSERT_EQ(0u, bytes_read);
 }
 
 TEST(CyclicBuffer, EqualSizeBuffer) {
@@ -73,7 +71,7 @@ TEST(CyclicBuffer, EqualSizeBuffer) {
   uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'};
 
   char cyclic[] = "cyclic";
-  for (int i = 0; i < sizeof(cyclic); i++) {
+  for (size_t i = 0; i < sizeof(cyclic); i++) {
     // We will always leave the last bytes untouched
     // so that string comparisions work.
     char equal_size_buffer[7] = {};
@@ -86,7 +84,7 @@ TEST(CyclicBuffer, EqualSizeBuffer) {
 }
 
 TEST(CyclicBuffer, SmallerSizeBuffer) {
-  size_t bytes_read = 0;
+  size_t bytes_read;
   uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'};
 
   // We will always leave the last bytes untouched
@@ -95,25 +93,25 @@ TEST(CyclicBuffer, SmallerSizeBuffer) {
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 0);
-  ASSERT_EQ(3, bytes_read);
+  ASSERT_EQ(3u, bytes_read);
   ASSERT_STREQ(smaller_buffer, "cyc");
 
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 1);
-  ASSERT_EQ(3, bytes_read);
+  ASSERT_EQ(3u, bytes_read);
   ASSERT_STREQ(smaller_buffer, "ycl");
 
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 2);
-  ASSERT_EQ(3, bytes_read);
+  ASSERT_EQ(3u, bytes_read);
   ASSERT_STREQ(smaller_buffer, "cli");
 
   bytes_read =
       ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1),
                              cyclic_buffer, sizeof(cyclic_buffer), 3, 3);
-  ASSERT_EQ(3, bytes_read);
+  ASSERT_EQ(3u, bytes_read);
   ASSERT_STREQ(smaller_buffer, "lic");
 
   {
@@ -121,7 +119,7 @@ TEST(CyclicBuffer, SmallerSizeBuffer) {
     bytes_read =
         ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1),
                                cyclic_buffer, sizeof(cyclic_buffer), 3, 4);
-    ASSERT_EQ(2, bytes_read);
+    ASSERT_EQ(2u, bytes_read);
     ASSERT_STREQ(smaller_buffer, "ic");
   }
   {
@@ -129,7 +127,7 @@ TEST(CyclicBuffer, SmallerSizeBuffer) {
     bytes_read =
         ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1),
                                cyclic_buffer, sizeof(cyclic_buffer), 3, 5);
-    ASSERT_EQ(1, bytes_read);
+    ASSERT_EQ(1u, bytes_read);
     ASSERT_STREQ(smaller_buffer, "c");
   }
 }
@@ -139,7 +137,7 @@ TEST(CyclicBuffer, BiggerSizeBuffer) {
   uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'};
 
   char cyclic[] = "cyclic";
-  for (int i = 0; i < sizeof(cyclic); i++) {
+  for (size_t i = 0; i < sizeof(cyclic); i++) {
     // We will always leave the last bytes untouched
     // so that string comparisions work.
     char bigger_buffer[10] = {};




More information about the lldb-commits mailing list