Fix misc -Wcast-qual warnings, NFC

llvm-svn: 319937
This commit is contained in:
Vedant Kumar
2017-12-06 19:21:11 +00:00
parent 606908aab5
commit 07d956149b
7 changed files with 29 additions and 22 deletions

View File

@@ -3147,7 +3147,8 @@ pid_t MachProcess::PosixSpawnChildForPTraceDebugging(
::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::PosixSpawnChildForPTraceDebugging(
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::ForkChildForPTraceDebugging(const char *path,
::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

View File

@@ -188,7 +188,7 @@ nub_size_t MachTask::WriteMemory(nub_addr_t addr, nub_size_t size,
(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);
}

View File

@@ -1886,7 +1886,7 @@ nub_size_t DNBArchImplI386::SetRegisterContext(const void *buf,
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::SetRegisterContext(const void *buf,
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;

View File

@@ -2164,7 +2164,7 @@ nub_size_t DNBArchImplX86_64::SetRegisterContext(const void *buf,
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::SetRegisterContext(const void *buf,
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);

View File

@@ -712,23 +712,27 @@ std::string RNBRemote::CompressString(const std::string &orig) {
#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::SendStopReplyPacketForThread(nub_thread_t tid) {
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(const char *p) {
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");

View File

@@ -220,7 +220,7 @@ int ListApplications(std::string &plist, bool opt_runningApps,
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.");

View File

@@ -373,9 +373,10 @@ rnb_err_t RNBSocket::Write(const void *buffer, size_t length) {
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;
}