[Lldb-commits] [lldb] r319937 - Fix misc -Wcast-qual warnings, NFC

Vedant Kumar via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 6 11:21:11 PST 2017


Author: vedantk
Date: Wed Dec  6 11:21:11 2017
New Revision: 319937

URL: http://llvm.org/viewvc/llvm-project?rev=319937&view=rev
Log:
Fix misc -Wcast-qual warnings, NFC

Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
    lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm
    lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
    lldb/trunk/tools/debugserver/source/RNBRemote.cpp
    lldb/trunk/tools/debugserver/source/RNBServices.cpp
    lldb/trunk/tools/debugserver/source/RNBSocket.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Wed Dec  6 11:21:11 2017
@@ -3147,7 +3147,8 @@ pid_t MachProcess::PosixSpawnChildForPTr
       ::chdir(working_directory);
 
     err.SetError(::posix_spawnp(&pid, path, &file_actions, &attr,
-                                (char *const *)argv, (char *const *)envp),
+                                const_cast<char *const *>(argv),
+                                const_cast<char *const *>(envp)),
                  DNBError::POSIX);
     if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
       err.LogThreaded("::posix_spawnp ( pid => %i, path = '%s', file_actions = "
@@ -3159,8 +3160,9 @@ pid_t MachProcess::PosixSpawnChildForPTr
     if (working_directory)
       ::chdir(working_directory);
 
-    err.SetError(::posix_spawnp(&pid, path, NULL, &attr, (char *const *)argv,
-                                (char *const *)envp),
+    err.SetError(::posix_spawnp(&pid, path, NULL, &attr,
+                                const_cast<char *const *>(argv),
+                                const_cast<char *const *>(envp)),
                  DNBError::POSIX);
     if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
       err.LogThreaded("::posix_spawnp ( pid => %i, path = '%s', file_actions = "
@@ -3257,7 +3259,7 @@ pid_t MachProcess::ForkChildForPTraceDeb
       ::sleep(1);
 
       // Turn this process into
-      ::execv(path, (char *const *)argv);
+      ::execv(path, const_cast<char *const *>(argv));
     }
     // Exit with error code. Child process should have taken
     // over in above exec call and if the exec fails it will

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm Wed Dec  6 11:21:11 2017
@@ -188,7 +188,7 @@ nub_size_t MachTask::WriteMemory(nub_add
                      (uint64_t)addr, (uint64_t)size, buf, (uint64_t)n);
     if (DNBLogCheckLogBit(LOG_MEMORY_DATA_LONG) ||
         (DNBLogCheckLogBit(LOG_MEMORY_DATA_SHORT) && size <= 8)) {
-      DNBDataRef data((uint8_t *)buf, n, false);
+      DNBDataRef data((const uint8_t *)buf, n, false);
       data.Dump(0, static_cast<DNBDataRef::offset_t>(n), addr,
                 DNBDataRef::TypeUInt8, 16);
     }

Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Wed Dec  6 11:21:11 2017
@@ -1886,7 +1886,7 @@ nub_size_t DNBArchImplI386::SetRegisterC
     if (size > buf_len)
       size = buf_len;
 
-    uint8_t *p = (uint8_t *)buf;
+    const uint8_t *p = (const uint8_t *)buf;
     // Copy the GPR registers
     memcpy(&m_state.context.gpr, p, sizeof(GPR));
     p += sizeof(GPR);
@@ -1927,7 +1927,7 @@ nub_size_t DNBArchImplI386::SetRegisterC
     p += sizeof(EXC);
 
     // make sure we end up with exactly what we think we should have
-    size_t bytes_written = p - (uint8_t *)buf;
+    size_t bytes_written = p - (const uint8_t *)buf;
     UNUSED_IF_ASSERT_DISABLED(bytes_written);
     assert(bytes_written == size);
     kern_return_t kret;

Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Wed Dec  6 11:21:11 2017
@@ -2164,7 +2164,7 @@ nub_size_t DNBArchImplX86_64::SetRegiste
     if (size > buf_len)
       size = static_cast<uint32_t>(buf_len);
 
-    uint8_t *p = (uint8_t *)buf;
+    const uint8_t *p = (const uint8_t *)buf;
     // Copy the GPR registers
     memcpy(&m_state.context.gpr, p, sizeof(GPR));
     p += sizeof(GPR);
@@ -2205,7 +2205,7 @@ nub_size_t DNBArchImplX86_64::SetRegiste
     p += sizeof(EXC);
 
     // make sure we end up with exactly what we think we should have
-    size_t bytes_written = p - (uint8_t *)buf;
+    size_t bytes_written = p - (const uint8_t *)buf;
     UNUSED_IF_ASSERT_DISABLED(bytes_written);
     assert(bytes_written == size);
 

Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Wed Dec  6 11:21:11 2017
@@ -712,23 +712,27 @@ std::string RNBRemote::CompressString(co
 #if defined(HAVE_LIBCOMPRESSION)
       if (compression_type == compression_types::lz4) {
         compressed_size = compression_encode_buffer(
-            encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
-            orig.size(), nullptr, COMPRESSION_LZ4_RAW);
+            encoded_data.data(), encoded_data_buf_size,
+            (const uint8_t *)orig.c_str(), orig.size(), nullptr,
+            COMPRESSION_LZ4_RAW);
       }
       if (compression_type == compression_types::zlib_deflate) {
         compressed_size = compression_encode_buffer(
-            encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
-            orig.size(), nullptr, COMPRESSION_ZLIB);
+            encoded_data.data(), encoded_data_buf_size,
+            (const uint8_t *)orig.c_str(), orig.size(), nullptr,
+            COMPRESSION_ZLIB);
       }
       if (compression_type == compression_types::lzma) {
         compressed_size = compression_encode_buffer(
-            encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
-            orig.size(), nullptr, COMPRESSION_LZMA);
+            encoded_data.data(), encoded_data_buf_size,
+            (const uint8_t *)orig.c_str(), orig.size(), nullptr,
+            COMPRESSION_LZMA);
       }
       if (compression_type == compression_types::lzfse) {
         compressed_size = compression_encode_buffer(
-            encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
-            orig.size(), nullptr, COMPRESSION_LZFSE);
+            encoded_data.data(), encoded_data_buf_size,
+            (const uint8_t *)orig.c_str(), orig.size(), nullptr,
+            COMPRESSION_LZFSE);
       }
 #endif
 
@@ -2858,7 +2862,7 @@ rnb_err_t RNBRemote::SendStopReplyPacket
       else {
         // the thread name contains special chars, send as hex bytes
         ostrm << std::hex << "hexname:";
-        uint8_t *u_thread_name = (uint8_t *)thread_name;
+        const uint8_t *u_thread_name = (const uint8_t *)thread_name;
         for (size_t i = 0; i < thread_name_len; i++)
           ostrm << RAWHEX8(u_thread_name[i]);
         ostrm << ';';
@@ -3663,7 +3667,7 @@ rnb_err_t RNBRemote::HandlePacket_v(cons
     return RNBRemote::HandlePacket_s("s");
   } else if (strstr(p, "vCont") == p) {
     DNBThreadResumeActions thread_actions;
-    char *c = (char *)(p += strlen("vCont"));
+    char *c = const_cast<char *>(p += strlen("vCont"));
     char *c_end = c + strlen(c);
     if (*c == '?')
       return SendPacket("vCont;c;C;s;S");

Modified: lldb/trunk/tools/debugserver/source/RNBServices.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBServices.cpp?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBServices.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBServices.cpp Wed Dec  6 11:21:11 2017
@@ -220,7 +220,7 @@ int ListApplications(std::string &plist,
     CFIndex size = ::CFDataGetLength(plistData.get());
     const UInt8 *bytes = ::CFDataGetBytePtr(plistData.get());
     if (bytes != NULL && size > 0) {
-      plist.assign((char *)bytes, size);
+      plist.assign((const char *)bytes, size);
       return 0; // Success
     } else {
       DNBLogError("empty application property list.");

Modified: lldb/trunk/tools/debugserver/source/RNBSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBSocket.cpp?rev=319937&r1=319936&r2=319937&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBSocket.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBSocket.cpp Wed Dec  6 11:21:11 2017
@@ -373,9 +373,10 @@ rnb_err_t RNBSocket::Write(const void *b
 
   DNBLogThreadedIf(
       LOG_RNB_PACKETS, "putpkt: %*s", (int)length,
-      (char *)
+      (const char *)
           buffer); // All data is string based in debugserver, so this is safe
-  DNBLogThreadedIf(LOG_RNB_COMM, "sent: %*s", (int)length, (char *)buffer);
+  DNBLogThreadedIf(LOG_RNB_COMM, "sent: %*s", (int)length,
+                   (const char *)buffer);
 
   return rnb_success;
 }




More information about the lldb-commits mailing list