[lldb-vscode] Fix warning
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 8 Mar 2019 17:36:54 +0000 (17:36 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 8 Mar 2019 17:36:54 +0000 (17:36 +0000)
I changed the variable to an unsigned to get rid of a signed and
unsigned compare without realizing the value could be negative. This
fixes the assert instead.

llvm-svn: 355708

lldb/tools/lldb-vscode/IOStream.cpp

index 63485a9..e07ae07 100644 (file)
@@ -95,7 +95,7 @@ bool InputStream::read_full(std::ofstream *log, size_t length,
 
   char *ptr = &data[0];
   while (length != 0) {
-    size_t bytes_read = 0;
+    int bytes_read = 0;
     if (descriptor.m_is_socket)
       bytes_read = ::recv(descriptor.m_socket, ptr, length, 0);
     else
@@ -119,7 +119,7 @@ bool InputStream::read_full(std::ofstream *log, size_t length,
       return false;
     }
 
-    assert(bytes_read <= length);
+    assert(bytes_read >= 0 && (size_t)bytes_read <= length);
     ptr += bytes_read;
     length -= bytes_read;
   }