Commit 190e3825 authored by Daniel Pfeifer's avatar Daniel Pfeifer
Browse files

Replace C-style casts

parent 2ade9a02
---
Checks: "-*,\
google-readability-casting,\
misc-*,\
-misc-incorrect-roundings,\
-misc-macro-parentheses,\
......
......@@ -115,21 +115,21 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
void CMakeMessageCallback(const char* m, const char* /*unused*/,
bool& /*unused*/, void* s)
{
std::string* out = (std::string*)s;
std::string* out = reinterpret_cast<std::string*>(s);
*out += m;
*out += "\n";
}
void CMakeProgressCallback(const char* msg, float /*unused*/, void* s)
{
std::string* out = (std::string*)s;
std::string* out = reinterpret_cast<std::string*>(s);
*out += msg;
*out += "\n";
}
void CMakeOutputCallback(const char* m, size_t len, void* s)
{
std::string* out = (std::string*)s;
std::string* out = reinterpret_cast<std::string*>(s);
out->append(m, len);
}
......
......@@ -43,7 +43,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
this->SetError("internal CTest error. Cannot instantiate build handler");
return nullptr;
}
this->Handler = (cmCTestBuildHandler*)handler;
this->Handler = static_cast<cmCTestBuildHandler*>(handler);
const char* ctestBuildCommand =
this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
......
......@@ -42,7 +42,7 @@ namespace {
size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
void* data)
{
int realsize = (int)(size * nmemb);
int realsize = static_cast<int>(size * nmemb);
std::vector<char>* vec = static_cast<std::vector<char>*>(data);
const char* chPtr = static_cast<char*>(ptr);
......@@ -157,8 +157,8 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData;
std::vector<char> debugData;
::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FILE, &responseData);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, &debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
// Now run off and do what you've been told!
::curl_easy_perform(this->Curl);
......@@ -207,8 +207,8 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
std::vector<char> responseData;
std::vector<char> debugData;
::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FILE, &responseData);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, &debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
// Add headers if any were specified.
......
......@@ -510,8 +510,8 @@ private:
const char* email_last = *c ? c++ : c;
person.EMail.assign(email_first, email_last - email_first);
person.Time = strtoul(c, (char**)&c, 10);
person.TimeZone = strtol(c, (char**)&c, 10);
person.Time = strtoul(c, const_cast<char**>(&c), 10);
person.TimeZone = strtol(c, const_cast<char**>(&c), 10);
}
bool ProcessLine() CM_OVERRIDE
......
......@@ -33,7 +33,7 @@ static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
static void xmlReportError(int line, const char* msg, void* data)
{
cmCTest* ctest = (cmCTest*)data;
cmCTest* ctest = reinterpret_cast<cmCTest*>(data);
cmCTestLog(ctest, ERROR_MESSAGE, "Error parsing XML in stream at line "
<< line << ": " << msg << std::endl);
}
......@@ -45,7 +45,7 @@ public:
cmBoundsCheckerParser(cmCTest* c)
{
this->CTest = c;
this->SetErrorCallback(xmlReportError, (void*)c);
this->SetErrorCallback(xmlReportError, c);
}
void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
{
......
......@@ -100,7 +100,7 @@ private:
static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
size_t nmemb, void* data)
{
int realsize = (int)(size * nmemb);
int realsize = static_cast<int>(size * nmemb);
cmCTestSubmitHandlerVectorOfChar* vec =
static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
......@@ -239,8 +239,8 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
::curl_easy_setopt(curl, CURLOPT_FILE, &chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
// Now run off and do what you've been told!
res = ::curl_easy_perform(curl);
......@@ -413,7 +413,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
case ' ':
case '=':
case '%':
sprintf(hexCh, "%%%02X", (int)c);
sprintf(hexCh, "%%%02X", static_cast<int>(c));
ofile.append(hexCh);
break;
default:
......@@ -471,8 +471,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
::curl_easy_setopt(curl, CURLOPT_FILE, &chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
// Now run off and do what you've been told!
res = ::curl_easy_perform(curl);
......@@ -667,8 +667,8 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
::curl_easy_setopt(curl, CURLOPT_FILE, &chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
std::string ofile;
......@@ -686,7 +686,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
case ' ':
case '=':
case '%':
sprintf(hexCh, "%%%02X", (int)c);
sprintf(hexCh, "%%%02X", static_cast<int>(c));
ofile.append(hexCh);
break;
default:
......@@ -948,8 +948,9 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
char remoteCommand[] = "Submit.put";
char* pRealURL = const_cast<char*>(realURL.c_str());
result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)",
fileBuffer, (xmlrpc_int32)fileSize);
result =
xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)", fileBuffer,
static_cast<xmlrpc_int32>(fileSize));
delete[] fileBuffer;
......@@ -1082,8 +1083,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
<< "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
<< "&"
<< "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
<< "starttime=" << (int)cmSystemTools::GetTime() << "&"
<< "endtime=" << (int)cmSystemTools::GetTime() << "&"
<< "starttime=" << static_cast<int>(cmSystemTools::GetTime()) << "&"
<< "endtime=" << static_cast<int>(cmSystemTools::GetTime()) << "&"
<< "datafilesmd5[0]=" << md5sum << "&"
<< "type=" << curl.Escape(typeString);
std::string fields = str.str();
......
......@@ -544,7 +544,7 @@ int cmCTestTestHandler::ProcessHandler()
}
char realBuf[1024];
sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
sprintf(realBuf, "%6.2f sec", clock_finish - clock_start);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"\nTotal Test time (real) = " << realBuf << "\n",
this->Quiet);
......@@ -851,7 +851,7 @@ void cmCTestTestHandler::ComputeTestList()
}
// expand the test list based on the union flag
if (this->UseUnion) {
this->ExpandTestsToRunInformation((int)tmsize);
this->ExpandTestsToRunInformation(static_cast<int>(tmsize));
} else {
this->ExpandTestsToRunInformation(inREcnt);
}
......@@ -1327,7 +1327,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
bool randomSchedule = this->CTest->GetScheduleType() == "Random";
if (randomSchedule) {
srand((unsigned)time(nullptr));
srand(static_cast<unsigned>(time(nullptr)));
}
for (ListOfTests::iterator it = this->TestList.begin();
......
......@@ -529,7 +529,7 @@ void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
char tmp[1024];
const char* cmsg = tmp;
if (prog >= 0) {
sprintf(tmp, "%s %i%%", msg, (int)(100 * prog));
sprintf(tmp, "%s %i%%", msg, static_cast<int>(100 * prog));
} else {
cmsg = msg;
}
......
......@@ -157,7 +157,7 @@ std::string cmCTest::GetCostDataFile()
static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
void* data)
{
int realsize = (int)(size * nmemb);
int realsize = static_cast<int>(size * nmemb);
std::string* response = static_cast<std::string*>(data);
const char* chPtr = static_cast<char*>(ptr);
......@@ -206,7 +206,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
// set response options
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback);
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&response);
::curl_easy_setopt(curl, CURLOPT_FILE, &response);
::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
CURLcode res = ::curl_easy_perform(curl);
......@@ -227,7 +227,7 @@ std::string cmCTest::MakeURLSafe(const std::string& str)
if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
ch == '=' || ch == '@') &&
ch != 9) {
sprintf(buffer, "%02x;", (unsigned int)ch);
sprintf(buffer, "%02x;", static_cast<unsigned int>(ch));
ost << buffer;
} else {
ost << ch;
......@@ -1767,7 +1767,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
i++;
double timeout = (double)atof(args[i].c_str());
double timeout = atof(args[i].c_str());
this->GlobalTimeout = timeout;
}
......
......@@ -175,7 +175,7 @@ public:
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propName)
{
this->GetCacheIterator(key.c_str()).SetProperty(propName, (void*)nullptr);
this->GetCacheIterator(key.c_str()).SetProperty(propName, nullptr);
}
void AppendCacheEntryProperty(std::string const& key,
......
......@@ -31,7 +31,7 @@ void cmEventBasedConnection::on_read(uv_stream_t* stream, ssize_t nread,
if (nread >= 0) {
conn->ReadData(std::string(buf->base, buf->base + nread));
} else {
conn->OnDisconnect((int)nread);
conn->OnDisconnect(static_cast<int>(nread));
}
}
......
......@@ -107,7 +107,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
if (!haveDeps) {
// Walk the dependency graph starting with the source file.
int srcFiles = (int)sources.size();
int srcFiles = static_cast<int>(sources.size());
this->Encountered.clear();
for (std::set<std::string>::const_iterator srcIt = sources.begin();
......
......@@ -96,9 +96,9 @@ void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
for (cc = 0; cc < strlen(str); cc++) {
unsigned char ch = str[cc];
if (ch >= 32 && ch <= 126) {
std::cout << (char)ch;
std::cout << static_cast<char>(ch);
} else {
std::cout << "<" << (int)ch << ">";
std::cout << "<" << static_cast<int>(ch) << ">";
break;
}
}
......@@ -166,7 +166,7 @@ void cmDependsJavaParserHelper::AllocateParserType(
{
pt->str = nullptr;
if (len == 0) {
len = (int)strlen(str);
len = static_cast<int>(strlen(str));
}
if (len == 0) {
return;
......
......@@ -16,7 +16,7 @@ class cmExecutionStatus;
static bool cmExecuteProcessCommandIsWhitespace(char c)
{
return (isspace((int)c) || c == '\n' || c == '\r');
return (isspace(static_cast<int>(c)) || c == '\n' || c == '\r');
}
void cmExecuteProcessCommandFixText(std::vector<char>& output,
......
......@@ -233,7 +233,7 @@ void cmExportBuildFileGenerator::HandleMissingTarget(
dependee->GetLocalGenerator()->GetGlobalGenerator();
std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
int targetOccurrences = (int)namespaces.size();
int targetOccurrences = static_cast<int>(namespaces.size());
if (targetOccurrences == 1) {
std::string missingTarget = namespaces[0];
......
......@@ -445,7 +445,7 @@ void cmExportInstallFileGenerator::HandleMissingTarget(
const std::string name = dependee->GetName();
cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
int targetOccurrences = (int)namespaces.size();
int targetOccurrences = static_cast<int>(namespaces.size());
if (targetOccurrences == 1) {
std::string missingTarget = namespaces[0];
......
......@@ -2454,7 +2454,7 @@ namespace {
size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
{
int realsize = (int)(size * nmemb);
int realsize = static_cast<int>(size * nmemb);
cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data);
const char* chPtr = static_cast<char*>(ptr);
fout->write(chPtr, realsize);
......@@ -2464,7 +2464,7 @@ size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb,
void* data)
{
int realsize = (int)(size * nmemb);
int realsize = static_cast<int>(size * nmemb);
cmFileCommandVectorOfChar* vec =
static_cast<cmFileCommandVectorOfChar*>(data);
const char* chPtr = static_cast<char*>(ptr);
......@@ -2758,7 +2758,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
msg += "\"";
if (!statusVar.empty()) {
std::ostringstream result;
result << (int)0 << ";\"" << msg;
result << 0 << ";\"" << msg;
this->Makefile->AddDefinition(statusVar, result.str().c_str());
}
return true;
......@@ -2831,10 +2831,10 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
cmFileCommandVectorOfChar chunkDebug;
res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&fout);
res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fout);
check_curl_result(res, "DOWNLOAD cannot set write data: ");
res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
check_curl_result(res, "DOWNLOAD cannot set debug data: ");
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
......@@ -2898,7 +2898,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (!statusVar.empty()) {
std::ostringstream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
<< "\"";
this->Makefile->AddDefinition(statusVar, result.str().c_str());
}
......@@ -2924,7 +2925,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
<< " for file: [" << file << "]" << std::endl
<< " expected hash: [" << expectedHash << "]" << std::endl
<< " actual hash: [" << actualHash << "]" << std::endl
<< " status: [" << (int)res << ";\""
<< " status: [" << static_cast<int>(res) << ";\""
<< ::curl_easy_strerror(res) << "\"]" << std::endl;
if (!statusVar.empty() && res == 0) {
......@@ -3080,10 +3081,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
cmFileCommandVectorOfChar chunkResponse;
cmFileCommandVectorOfChar chunkDebug;
res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&chunkResponse);
res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunkResponse);
check_curl_result(res, "UPLOAD cannot set write data: ");
res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
check_curl_result(res, "UPLOAD cannot set debug data: ");
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
......@@ -3156,7 +3157,8 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (!statusVar.empty()) {
std::ostringstream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
<< "\"";
this->Makefile->AddDefinition(statusVar, result.str().c_str());
}
......
......@@ -121,7 +121,7 @@ int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
n = 1;
ff.LastCharWasNewline = true;
}
return (int)n;
return static_cast<int>(n);
}
return 0;
}
......
......@@ -153,7 +153,7 @@ std::string GeneratorExpressionContent::EvaluateParameters(
}
if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
(unsigned int)numExpected != parameters.size())) {
static_cast<unsigned int>(numExpected) != parameters.size())) {
if (numExpected == 0) {
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires no parameters.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment