Przeglądaj źródła

Replace C-style casts

Daniel Pfeifer 8 lat temu
rodzic
commit
190e3825d4

+ 1 - 0
.clang-tidy

@@ -1,5 +1,6 @@
 ---
 ---
 Checks: "-*,\
 Checks: "-*,\
+google-readability-casting,\
 misc-*,\
 misc-*,\
 -misc-incorrect-roundings,\
 -misc-incorrect-roundings,\
 -misc-macro-parentheses,\
 -misc-macro-parentheses,\

+ 3 - 3
Source/CTest/cmCTestBuildAndTestHandler.cxx

@@ -115,21 +115,21 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
 void CMakeMessageCallback(const char* m, const char* /*unused*/,
 void CMakeMessageCallback(const char* m, const char* /*unused*/,
                           bool& /*unused*/, void* s)
                           bool& /*unused*/, void* s)
 {
 {
-  std::string* out = (std::string*)s;
+  std::string* out = reinterpret_cast<std::string*>(s);
   *out += m;
   *out += m;
   *out += "\n";
   *out += "\n";
 }
 }
 
 
 void CMakeProgressCallback(const char* msg, float /*unused*/, void* s)
 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 += msg;
   *out += "\n";
   *out += "\n";
 }
 }
 
 
 void CMakeOutputCallback(const char* m, size_t len, void* s)
 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);
   out->append(m, len);
 }
 }
 
 

+ 1 - 1
Source/CTest/cmCTestBuildCommand.cxx

@@ -43,7 +43,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
     this->SetError("internal CTest error. Cannot instantiate build handler");
     this->SetError("internal CTest error. Cannot instantiate build handler");
     return nullptr;
     return nullptr;
   }
   }
-  this->Handler = (cmCTestBuildHandler*)handler;
+  this->Handler = static_cast<cmCTestBuildHandler*>(handler);
 
 
   const char* ctestBuildCommand =
   const char* ctestBuildCommand =
     this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
     this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");

+ 5 - 5
Source/CTest/cmCTestCurl.cxx

@@ -42,7 +42,7 @@ namespace {
 size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
 size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
                                void* data)
                                void* data)
 {
 {
-  int realsize = (int)(size * nmemb);
+  int realsize = static_cast<int>(size * nmemb);
 
 
   std::vector<char>* vec = static_cast<std::vector<char>*>(data);
   std::vector<char>* vec = static_cast<std::vector<char>*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   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);
   ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
   std::vector<char> responseData;
   std::vector<char> responseData;
   std::vector<char> debugData;
   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);
   ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
   // Now run off and do what you've been told!
   // Now run off and do what you've been told!
   ::curl_easy_perform(this->Curl);
   ::curl_easy_perform(this->Curl);
@@ -207,8 +207,8 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
   ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
   ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
   std::vector<char> responseData;
   std::vector<char> responseData;
   std::vector<char> debugData;
   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);
   ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
 
 
   // Add headers if any were specified.
   // Add headers if any were specified.

+ 2 - 2
Source/CTest/cmCTestGIT.cxx

@@ -510,8 +510,8 @@ private:
     const char* email_last = *c ? c++ : c;
     const char* email_last = *c ? c++ : c;
     person.EMail.assign(email_first, email_last - email_first);
     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
   bool ProcessLine() CM_OVERRIDE

+ 2 - 2
Source/CTest/cmCTestMemCheckHandler.cxx

@@ -33,7 +33,7 @@ static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
 
 
 static void xmlReportError(int line, const char* msg, void* data)
 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 "
   cmCTestLog(ctest, ERROR_MESSAGE, "Error parsing XML in stream at line "
                << line << ": " << msg << std::endl);
                << line << ": " << msg << std::endl);
 }
 }
@@ -45,7 +45,7 @@ public:
   cmBoundsCheckerParser(cmCTest* c)
   cmBoundsCheckerParser(cmCTest* c)
   {
   {
     this->CTest = c;
     this->CTest = c;
-    this->SetErrorCallback(xmlReportError, (void*)c);
+    this->SetErrorCallback(xmlReportError, c);
   }
   }
   void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
   void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
   {
   {

+ 14 - 13
Source/CTest/cmCTestSubmitHandler.cxx

@@ -100,7 +100,7 @@ private:
 static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
 static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
                                                       size_t nmemb, void* data)
                                                       size_t nmemb, void* data)
 {
 {
-  int realsize = (int)(size * nmemb);
+  int realsize = static_cast<int>(size * nmemb);
 
 
   cmCTestSubmitHandlerVectorOfChar* vec =
   cmCTestSubmitHandlerVectorOfChar* vec =
     static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
     static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
@@ -239,8 +239,8 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
       /* we pass our 'chunk' struct to the callback function */
       /* we pass our 'chunk' struct to the callback function */
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunkDebug;
       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!
       // Now run off and do what you've been told!
       res = ::curl_easy_perform(curl);
       res = ::curl_easy_perform(curl);
@@ -413,7 +413,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
           case ' ':
           case ' ':
           case '=':
           case '=':
           case '%':
           case '%':
-            sprintf(hexCh, "%%%02X", (int)c);
+            sprintf(hexCh, "%%%02X", static_cast<int>(c));
             ofile.append(hexCh);
             ofile.append(hexCh);
             break;
             break;
           default:
           default:
@@ -471,8 +471,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
       /* we pass our 'chunk' struct to the callback function */
       /* we pass our 'chunk' struct to the callback function */
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunkDebug;
       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!
       // Now run off and do what you've been told!
       res = ::curl_easy_perform(curl);
       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 */
       /* we pass our 'chunk' struct to the callback function */
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunkDebug;
       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 rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
       std::string ofile;
       std::string ofile;
@@ -686,7 +686,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
           case ' ':
           case ' ':
           case '=':
           case '=':
           case '%':
           case '%':
-            sprintf(hexCh, "%%%02X", (int)c);
+            sprintf(hexCh, "%%%02X", static_cast<int>(c));
             ofile.append(hexCh);
             ofile.append(hexCh);
             break;
             break;
           default:
           default:
@@ -948,8 +948,9 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
 
 
     char remoteCommand[] = "Submit.put";
     char remoteCommand[] = "Submit.put";
     char* pRealURL = const_cast<char*>(realURL.c_str());
     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;
     delete[] fileBuffer;
 
 
@@ -1082,8 +1083,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
       << "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
       << "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
       << "&"
       << "&"
       << "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
       << "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 << "&"
       << "datafilesmd5[0]=" << md5sum << "&"
       << "type=" << curl.Escape(typeString);
       << "type=" << curl.Escape(typeString);
   std::string fields = str.str();
   std::string fields = str.str();

+ 3 - 3
Source/CTest/cmCTestTestHandler.cxx

@@ -544,7 +544,7 @@ int cmCTestTestHandler::ProcessHandler()
     }
     }
 
 
     char realBuf[1024];
     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,
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
                        "\nTotal Test time (real) = " << realBuf << "\n",
                        "\nTotal Test time (real) = " << realBuf << "\n",
                        this->Quiet);
                        this->Quiet);
@@ -851,7 +851,7 @@ void cmCTestTestHandler::ComputeTestList()
   }
   }
   // expand the test list based on the union flag
   // expand the test list based on the union flag
   if (this->UseUnion) {
   if (this->UseUnion) {
-    this->ExpandTestsToRunInformation((int)tmsize);
+    this->ExpandTestsToRunInformation(static_cast<int>(tmsize));
   } else {
   } else {
     this->ExpandTestsToRunInformation(inREcnt);
     this->ExpandTestsToRunInformation(inREcnt);
   }
   }
@@ -1327,7 +1327,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
 
 
   bool randomSchedule = this->CTest->GetScheduleType() == "Random";
   bool randomSchedule = this->CTest->GetScheduleType() == "Random";
   if (randomSchedule) {
   if (randomSchedule) {
-    srand((unsigned)time(nullptr));
+    srand(static_cast<unsigned>(time(nullptr)));
   }
   }
 
 
   for (ListOfTests::iterator it = this->TestList.begin();
   for (ListOfTests::iterator it = this->TestList.begin();

+ 1 - 1
Source/CursesDialog/cmCursesMainForm.cxx

@@ -529,7 +529,7 @@ void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
   char tmp[1024];
   char tmp[1024];
   const char* cmsg = tmp;
   const char* cmsg = tmp;
   if (prog >= 0) {
   if (prog >= 0) {
-    sprintf(tmp, "%s %i%%", msg, (int)(100 * prog));
+    sprintf(tmp, "%s %i%%", msg, static_cast<int>(100 * prog));
   } else {
   } else {
     cmsg = msg;
     cmsg = msg;
   }
   }

+ 4 - 4
Source/cmCTest.cxx

@@ -157,7 +157,7 @@ std::string cmCTest::GetCostDataFile()
 static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
 static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
                                    void* data)
                                    void* data)
 {
 {
-  int realsize = (int)(size * nmemb);
+  int realsize = static_cast<int>(size * nmemb);
 
 
   std::string* response = static_cast<std::string*>(data);
   std::string* response = static_cast<std::string*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   const char* chPtr = static_cast<char*>(ptr);
@@ -206,7 +206,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
 
 
   // set response options
   // set response options
   ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback);
   ::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);
   ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
 
 
   CURLcode res = ::curl_easy_perform(curl);
   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 == '+' ||
     if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
          ch == '=' || ch == '@') &&
          ch == '=' || ch == '@') &&
         ch != 9) {
         ch != 9) {
-      sprintf(buffer, "%02x;", (unsigned int)ch);
+      sprintf(buffer, "%02x;", static_cast<unsigned int>(ch));
       ost << buffer;
       ost << buffer;
     } else {
     } else {
       ost << ch;
       ost << ch;
@@ -1767,7 +1767,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
 
 
   if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
   if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
     i++;
     i++;
-    double timeout = (double)atof(args[i].c_str());
+    double timeout = atof(args[i].c_str());
     this->GlobalTimeout = timeout;
     this->GlobalTimeout = timeout;
   }
   }
 
 

+ 1 - 1
Source/cmCacheManager.h

@@ -175,7 +175,7 @@ public:
   void RemoveCacheEntryProperty(std::string const& key,
   void RemoveCacheEntryProperty(std::string const& key,
                                 std::string const& propName)
                                 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,
   void AppendCacheEntryProperty(std::string const& key,

+ 1 - 1
Source/cmConnection.cxx

@@ -31,7 +31,7 @@ void cmEventBasedConnection::on_read(uv_stream_t* stream, ssize_t nread,
     if (nread >= 0) {
     if (nread >= 0) {
       conn->ReadData(std::string(buf->base, buf->base + nread));
       conn->ReadData(std::string(buf->base, buf->base + nread));
     } else {
     } else {
-      conn->OnDisconnect((int)nread);
+      conn->OnDisconnect(static_cast<int>(nread));
     }
     }
   }
   }
 
 

+ 1 - 1
Source/cmDependsC.cxx

@@ -107,7 +107,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
 
 
   if (!haveDeps) {
   if (!haveDeps) {
     // Walk the dependency graph starting with the source file.
     // Walk the dependency graph starting with the source file.
-    int srcFiles = (int)sources.size();
+    int srcFiles = static_cast<int>(sources.size());
     this->Encountered.clear();
     this->Encountered.clear();
 
 
     for (std::set<std::string>::const_iterator srcIt = sources.begin();
     for (std::set<std::string>::const_iterator srcIt = sources.begin();

+ 3 - 3
Source/cmDependsJavaParserHelper.cxx

@@ -96,9 +96,9 @@ void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
     for (cc = 0; cc < strlen(str); cc++) {
     for (cc = 0; cc < strlen(str); cc++) {
       unsigned char ch = str[cc];
       unsigned char ch = str[cc];
       if (ch >= 32 && ch <= 126) {
       if (ch >= 32 && ch <= 126) {
-        std::cout << (char)ch;
+        std::cout << static_cast<char>(ch);
       } else {
       } else {
-        std::cout << "<" << (int)ch << ">";
+        std::cout << "<" << static_cast<int>(ch) << ">";
         break;
         break;
       }
       }
     }
     }
@@ -166,7 +166,7 @@ void cmDependsJavaParserHelper::AllocateParserType(
 {
 {
   pt->str = nullptr;
   pt->str = nullptr;
   if (len == 0) {
   if (len == 0) {
-    len = (int)strlen(str);
+    len = static_cast<int>(strlen(str));
   }
   }
   if (len == 0) {
   if (len == 0) {
     return;
     return;

+ 1 - 1
Source/cmExecuteProcessCommand.cxx

@@ -16,7 +16,7 @@ class cmExecutionStatus;
 
 
 static bool cmExecuteProcessCommandIsWhitespace(char c)
 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,
 void cmExecuteProcessCommandFixText(std::vector<char>& output,

+ 1 - 1
Source/cmExportBuildFileGenerator.cxx

@@ -233,7 +233,7 @@ void cmExportBuildFileGenerator::HandleMissingTarget(
       dependee->GetLocalGenerator()->GetGlobalGenerator();
       dependee->GetLocalGenerator()->GetGlobalGenerator();
     std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
     std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
 
 
-    int targetOccurrences = (int)namespaces.size();
+    int targetOccurrences = static_cast<int>(namespaces.size());
     if (targetOccurrences == 1) {
     if (targetOccurrences == 1) {
       std::string missingTarget = namespaces[0];
       std::string missingTarget = namespaces[0];
 
 

+ 1 - 1
Source/cmExportInstallFileGenerator.cxx

@@ -445,7 +445,7 @@ void cmExportInstallFileGenerator::HandleMissingTarget(
   const std::string name = dependee->GetName();
   const std::string name = dependee->GetName();
   cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
   cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
   std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
   std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
-  int targetOccurrences = (int)namespaces.size();
+  int targetOccurrences = static_cast<int>(namespaces.size());
   if (targetOccurrences == 1) {
   if (targetOccurrences == 1) {
     std::string missingTarget = namespaces[0];
     std::string missingTarget = namespaces[0];
 
 

+ 12 - 10
Source/cmFileCommand.cxx

@@ -2454,7 +2454,7 @@ namespace {
 
 
 size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
 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);
   cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   const char* chPtr = static_cast<char*>(ptr);
   fout->write(chPtr, realsize);
   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,
 size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb,
                                void* data)
                                void* data)
 {
 {
-  int realsize = (int)(size * nmemb);
+  int realsize = static_cast<int>(size * nmemb);
   cmFileCommandVectorOfChar* vec =
   cmFileCommandVectorOfChar* vec =
     static_cast<cmFileCommandVectorOfChar*>(data);
     static_cast<cmFileCommandVectorOfChar*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   const char* chPtr = static_cast<char*>(ptr);
@@ -2758,7 +2758,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
       msg += "\"";
       msg += "\"";
       if (!statusVar.empty()) {
       if (!statusVar.empty()) {
         std::ostringstream result;
         std::ostringstream result;
-        result << (int)0 << ";\"" << msg;
+        result << 0 << ";\"" << msg;
         this->Makefile->AddDefinition(statusVar, result.str().c_str());
         this->Makefile->AddDefinition(statusVar, result.str().c_str());
       }
       }
       return true;
       return true;
@@ -2831,10 +2831,10 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
 
 
   cmFileCommandVectorOfChar chunkDebug;
   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: ");
   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: ");
   check_curl_result(res, "DOWNLOAD cannot set debug data: ");
 
 
   res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
   res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
@@ -2898,7 +2898,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
 
 
   if (!statusVar.empty()) {
   if (!statusVar.empty()) {
     std::ostringstream result;
     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());
     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
           << "  for file: [" << file << "]" << std::endl
           << "    expected hash: [" << expectedHash << "]" << std::endl
           << "    expected hash: [" << expectedHash << "]" << std::endl
           << "      actual hash: [" << actualHash << "]" << std::endl
           << "      actual hash: [" << actualHash << "]" << std::endl
-          << "           status: [" << (int)res << ";\""
+          << "           status: [" << static_cast<int>(res) << ";\""
           << ::curl_easy_strerror(res) << "\"]" << std::endl;
           << ::curl_easy_strerror(res) << "\"]" << std::endl;
 
 
       if (!statusVar.empty() && res == 0) {
       if (!statusVar.empty() && res == 0) {
@@ -3080,10 +3081,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   cmFileCommandVectorOfChar chunkResponse;
   cmFileCommandVectorOfChar chunkResponse;
   cmFileCommandVectorOfChar chunkDebug;
   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: ");
   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: ");
   check_curl_result(res, "UPLOAD cannot set debug data: ");
 
 
   res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
   res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
@@ -3156,7 +3157,8 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
 
 
   if (!statusVar.empty()) {
   if (!statusVar.empty()) {
     std::ostringstream result;
     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());
     this->Makefile->AddDefinition(statusVar, result.str().c_str());
   }
   }
 
 

+ 1 - 1
Source/cmFortranParserImpl.cxx

@@ -121,7 +121,7 @@ int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
       n = 1;
       n = 1;
       ff.LastCharWasNewline = true;
       ff.LastCharWasNewline = true;
     }
     }
-    return (int)n;
+    return static_cast<int>(n);
   }
   }
   return 0;
   return 0;
 }
 }

+ 1 - 1
Source/cmGeneratorExpressionEvaluator.cxx

@@ -153,7 +153,7 @@ std::string GeneratorExpressionContent::EvaluateParameters(
   }
   }
 
 
   if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
   if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
-       (unsigned int)numExpected != parameters.size())) {
+       static_cast<unsigned int>(numExpected) != parameters.size())) {
     if (numExpected == 0) {
     if (numExpected == 0) {
       reportError(context, this->GetOriginalExpression(),
       reportError(context, this->GetOriginalExpression(),
                   "$<" + identifier + "> expression requires no parameters.");
                   "$<" + identifier + "> expression requires no parameters.");

+ 1 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -741,7 +741,7 @@ void cmGlobalNinjaGenerator::AddRule(
                                     description, comment, depfile, deptype,
                                     description, comment, depfile, deptype,
                                     rspfile, rspcontent, restat, generator);
                                     rspfile, rspcontent, restat, generator);
 
 
-  this->RuleCmdLength[name] = (int)command.size();
+  this->RuleCmdLength[name] = static_cast<int>(command.size());
 }
 }
 
 
 bool cmGlobalNinjaGenerator::HasRule(const std::string& name)
 bool cmGlobalNinjaGenerator::HasRule(const std::string& name)

+ 6 - 6
Source/cmListCommand.cxx

@@ -182,9 +182,9 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
     value += sep;
     value += sep;
     sep = ";";
     sep = ";";
     if (item < 0) {
     if (item < 0) {
-      item = (int)nitem + item;
+      item = static_cast<int>(nitem) + item;
     }
     }
-    if (item < 0 || nitem <= (size_t)item) {
+    if (item < 0 || nitem <= static_cast<size_t>(item)) {
       std::ostringstream str;
       std::ostringstream str;
       str << "index: " << item << " out of range (-" << nitem << ", "
       str << "index: " << item << " out of range (-" << nitem << ", "
           << nitem - 1 << ")";
           << nitem - 1 << ")";
@@ -273,9 +273,9 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
   if (!varArgsExpanded.empty()) {
   if (!varArgsExpanded.empty()) {
     size_t nitem = varArgsExpanded.size();
     size_t nitem = varArgsExpanded.size();
     if (item < 0) {
     if (item < 0) {
-      item = (int)nitem + item;
+      item = static_cast<int>(nitem) + item;
     }
     }
-    if (item < 0 || nitem <= (size_t)item) {
+    if (item < 0 || nitem <= static_cast<size_t>(item)) {
       std::ostringstream str;
       std::ostringstream str;
       str << "index: " << item << " out of range (-" << varArgsExpanded.size()
       str << "index: " << item << " out of range (-" << varArgsExpanded.size()
           << ", "
           << ", "
@@ -423,9 +423,9 @@ bool cmListCommand::HandleRemoveAtCommand(std::vector<std::string> const& args)
   for (cc = 2; cc < args.size(); ++cc) {
   for (cc = 2; cc < args.size(); ++cc) {
     int item = atoi(args[cc].c_str());
     int item = atoi(args[cc].c_str());
     if (item < 0) {
     if (item < 0) {
-      item = (int)nitem + item;
+      item = static_cast<int>(nitem) + item;
     }
     }
-    if (item < 0 || nitem <= (size_t)item) {
+    if (item < 0 || nitem <= static_cast<size_t>(item)) {
       std::ostringstream str;
       std::ostringstream str;
       str << "index: " << item << " out of range (-" << nitem << ", "
       str << "index: " << item << " out of range (-" << nitem << ", "
           << nitem - 1 << ")";
           << nitem - 1 << ")";

+ 7 - 9
Source/cmLoadCommandCommand.cxx

@@ -120,15 +120,14 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args,
   int argc = static_cast<int>(args.size());
   int argc = static_cast<int>(args.size());
   char** argv = nullptr;
   char** argv = nullptr;
   if (argc) {
   if (argc) {
-    argv = (char**)malloc(argc * sizeof(char*));
+    argv = reinterpret_cast<char**>(malloc(argc * sizeof(char*)));
   }
   }
   int i;
   int i;
   for (i = 0; i < argc; ++i) {
   for (i = 0; i < argc; ++i) {
     argv[i] = strdup(args[i].c_str());
     argv[i] = strdup(args[i].c_str());
   }
   }
   cmLoadedCommand::InstallSignalHandlers(info.Name);
   cmLoadedCommand::InstallSignalHandlers(info.Name);
-  int result =
-    info.InitialPass((void*)&info, (void*)this->Makefile, argc, argv);
+  int result = info.InitialPass(&info, this->Makefile, argc, argv);
   cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
   cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
   cmFreeArguments(argc, argv);
   cmFreeArguments(argc, argv);
 
 
@@ -147,7 +146,7 @@ void cmLoadedCommand::FinalPass()
 {
 {
   if (this->info.FinalPass) {
   if (this->info.FinalPass) {
     cmLoadedCommand::InstallSignalHandlers(info.Name);
     cmLoadedCommand::InstallSignalHandlers(info.Name);
-    this->info.FinalPass((void*)&this->info, (void*)this->Makefile);
+    this->info.FinalPass(&this->info, this->Makefile);
     cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
     cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
   }
   }
 }
 }
@@ -156,7 +155,7 @@ cmLoadedCommand::~cmLoadedCommand()
 {
 {
   if (this->info.Destructor) {
   if (this->info.Destructor) {
     cmLoadedCommand::InstallSignalHandlers(info.Name);
     cmLoadedCommand::InstallSignalHandlers(info.Name);
-    this->info.Destructor((void*)&this->info);
+    this->info.Destructor(&this->info);
     cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
     cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
   }
   }
   if (this->info.Error) {
   if (this->info.Error) {
@@ -225,14 +224,13 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
 
 
   // find the init function
   // find the init function
   std::string initFuncName = args[0] + "Init";
   std::string initFuncName = args[0] + "Init";
-  CM_INIT_FUNCTION initFunction =
-    (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(lib,
-                                                             initFuncName);
+  CM_INIT_FUNCTION initFunction = reinterpret_cast<CM_INIT_FUNCTION>(
+    cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
   if (!initFunction) {
   if (!initFunction) {
     initFuncName = "_";
     initFuncName = "_";
     initFuncName += args[0];
     initFuncName += args[0];
     initFuncName += "Init";
     initFuncName += "Init";
-    initFunction = (CM_INIT_FUNCTION)(
+    initFunction = reinterpret_cast<CM_INIT_FUNCTION>(
       cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
       cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
   }
   }
   // if the symbol is found call it to set the name on the
   // if the symbol is found call it to set the name on the

+ 1 - 1
Source/cmOutputConverter.cxx

@@ -389,7 +389,7 @@ int cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags)
 
 
 int cmOutputConverter::Shell__CharIsMakeVariableName(char c)
 int cmOutputConverter::Shell__CharIsMakeVariableName(char c)
 {
 {
-  return c && (c == '_' || isalpha(((int)c)));
+  return c && (c == '_' || isalpha((static_cast<int>(c))));
 }
 }
 
 
 const char* cmOutputConverter::Shell__SkipMakeVariables(const char* c)
 const char* cmOutputConverter::Shell__SkipMakeVariables(const char* c)

+ 4 - 2
Source/cmServer.cxx

@@ -469,11 +469,13 @@ void cmServerBase::OnServeStart()
 
 
 void cmServerBase::StartShutDown()
 void cmServerBase::StartShutDown()
 {
 {
-  if (!uv_is_closing((const uv_handle_t*)&this->SIGINTHandler)) {
+  if (!uv_is_closing(
+        reinterpret_cast<const uv_handle_t*>(&this->SIGINTHandler))) {
     uv_signal_stop(&this->SIGINTHandler);
     uv_signal_stop(&this->SIGINTHandler);
   }
   }
 
 
-  if (!uv_is_closing((const uv_handle_t*)&this->SIGHUPHandler)) {
+  if (!uv_is_closing(
+        reinterpret_cast<const uv_handle_t*>(&this->SIGHUPHandler))) {
     uv_signal_stop(&this->SIGHUPHandler);
     uv_signal_stop(&this->SIGHUPHandler);
   }
   }
 
 

+ 1 - 1
Source/cmServerProtocol.cxx

@@ -742,7 +742,7 @@ static Json::Value DumpBacktrace(const cmListFileBacktrace& backtrace)
     Json::Value entry = Json::objectValue;
     Json::Value entry = Json::objectValue;
     entry[kPATH_KEY] = backtraceCopy.Top().FilePath;
     entry[kPATH_KEY] = backtraceCopy.Top().FilePath;
     if (backtraceCopy.Top().Line) {
     if (backtraceCopy.Top().Line) {
-      entry[kLINE_NUMBER_KEY] = (int)backtraceCopy.Top().Line;
+      entry[kLINE_NUMBER_KEY] = static_cast<int>(backtraceCopy.Top().Line);
     }
     }
     if (!backtraceCopy.Top().Name.empty()) {
     if (!backtraceCopy.Top().Name.empty()) {
       entry[kNAME_KEY] = backtraceCopy.Top().Name;
       entry[kNAME_KEY] = backtraceCopy.Top().Name;

+ 1 - 1
Source/cmState.cxx

@@ -224,7 +224,7 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
                                        std::string const& propertyName)
                                        std::string const& propertyName)
 {
 {
   this->CacheManager->GetCacheIterator(key.c_str())
   this->CacheManager->GetCacheIterator(key.c_str())
-    .SetProperty(propertyName, (void*)nullptr);
+    .SetProperty(propertyName, nullptr);
 }
 }
 
 
 cmStateSnapshot cmState::Reset()
 cmStateSnapshot cmState::Reset()

+ 1 - 1
Source/cmStringCommand.cxx

@@ -818,7 +818,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
   const char* alphaPtr = alphabet.c_str();
   const char* alphaPtr = alphabet.c_str();
   int cc;
   int cc;
   for (cc = 0; cc < length; cc++) {
   for (cc = 0; cc < length; cc++) {
-    int idx = (int)(sizeofAlphabet * rand() / (RAND_MAX + 1.0));
+    int idx = static_cast<int>(sizeofAlphabet * rand() / (RAND_MAX + 1.0));
     result.push_back(*(alphaPtr + idx));
     result.push_back(*(alphaPtr + idx));
   }
   }
   result.push_back(0);
   result.push_back(0);

+ 8 - 7
Source/cmSystemTools.cxx

@@ -1519,21 +1519,21 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
   /* Use uname if it's present, else uid. */
   /* Use uname if it's present, else uid. */
   p = archive_entry_uname(entry);
   p = archive_entry_uname(entry);
   if ((p == nullptr) || (*p == '\0')) {
   if ((p == nullptr) || (*p == '\0')) {
-    sprintf(tmp, "%lu ", (unsigned long)archive_entry_uid(entry));
+    sprintf(tmp, "%lu ", static_cast<unsigned long>(archive_entry_uid(entry)));
     p = tmp;
     p = tmp;
   }
   }
   w = strlen(p);
   w = strlen(p);
   if (w > u_width) {
   if (w > u_width) {
     u_width = w;
     u_width = w;
   }
   }
-  fprintf(out, "%-*s ", (int)u_width, p);
+  fprintf(out, "%-*s ", static_cast<int>(u_width), p);
   /* Use gname if it's present, else gid. */
   /* Use gname if it's present, else gid. */
   p = archive_entry_gname(entry);
   p = archive_entry_gname(entry);
   if (p != nullptr && p[0] != '\0') {
   if (p != nullptr && p[0] != '\0') {
     fprintf(out, "%s", p);
     fprintf(out, "%s", p);
     w = strlen(p);
     w = strlen(p);
   } else {
   } else {
-    sprintf(tmp, "%lu", (unsigned long)archive_entry_gid(entry));
+    sprintf(tmp, "%lu", static_cast<unsigned long>(archive_entry_gid(entry)));
     w = strlen(tmp);
     w = strlen(tmp);
     fprintf(out, "%s", tmp);
     fprintf(out, "%s", tmp);
   }
   }
@@ -1545,8 +1545,9 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
    */
    */
   if (archive_entry_filetype(entry) == AE_IFCHR ||
   if (archive_entry_filetype(entry) == AE_IFCHR ||
       archive_entry_filetype(entry) == AE_IFBLK) {
       archive_entry_filetype(entry) == AE_IFBLK) {
-    sprintf(tmp, "%lu,%lu", (unsigned long)archive_entry_rdevmajor(entry),
-            (unsigned long)archive_entry_rdevminor(entry));
+    unsigned long rdevmajor = archive_entry_rdevmajor(entry);
+    unsigned long rdevminor = archive_entry_rdevminor(entry);
+    sprintf(tmp, "%lu,%lu", rdevmajor, rdevminor);
   } else {
   } else {
     /*
     /*
      * Note the use of platform-dependent macros to format
      * Note the use of platform-dependent macros to format
@@ -1554,12 +1555,12 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
      * corresponding type for the cast.
      * corresponding type for the cast.
      */
      */
     sprintf(tmp, BSDTAR_FILESIZE_PRINTF,
     sprintf(tmp, BSDTAR_FILESIZE_PRINTF,
-            (BSDTAR_FILESIZE_TYPE)archive_entry_size(entry));
+            static_cast<BSDTAR_FILESIZE_TYPE>(archive_entry_size(entry)));
   }
   }
   if (w + strlen(tmp) >= gs_width) {
   if (w + strlen(tmp) >= gs_width) {
     gs_width = w + strlen(tmp) + 1;
     gs_width = w + strlen(tmp) + 1;
   }
   }
-  fprintf(out, "%*s", (int)(gs_width - w), tmp);
+  fprintf(out, "%*s", static_cast<int>(gs_width - w), tmp);
 
 
   /* Format the time using 'ls -l' conventions. */
   /* Format the time using 'ls -l' conventions. */
   tim = archive_entry_mtime(entry);
   tim = archive_entry_mtime(entry);

+ 1 - 1
Source/cmTimestamp.cxx

@@ -56,7 +56,7 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT,
   struct tm timeStruct;
   struct tm timeStruct;
   memset(&timeStruct, 0, sizeof(timeStruct));
   memset(&timeStruct, 0, sizeof(timeStruct));
 
 
-  struct tm* ptr = (struct tm*)nullptr;
+  struct tm* ptr = nullptr;
   if (utcFlag) {
   if (utcFlag) {
     ptr = gmtime(&timeT);
     ptr = gmtime(&timeT);
   } else {
   } else {

+ 1 - 1
Source/cmXMLParser.cxx

@@ -26,7 +26,7 @@ cmXMLParser::~cmXMLParser()
 
 
 int cmXMLParser::Parse(const char* string)
 int cmXMLParser::Parse(const char* string)
 {
 {
-  return (int)this->InitializeParser() &&
+  return this->InitializeParser() &&
     this->ParseChunk(string, strlen(string)) && this->CleanupParser();
     this->ParseChunk(string, strlen(string)) && this->CleanupParser();
 }
 }
 
 

+ 5 - 5
Source/cmakemain.cxx

@@ -103,7 +103,7 @@ static int do_build(int ac, char const* const* av);
 
 
 static cmMakefile* cmakemainGetMakefile(void* clientdata)
 static cmMakefile* cmakemainGetMakefile(void* clientdata)
 {
 {
-  cmake* cm = (cmake*)clientdata;
+  cmake* cm = reinterpret_cast<cmake*>(clientdata);
   if (cm && cm->GetDebugOutput()) {
   if (cm && cm->GetDebugOutput()) {
     cmGlobalGenerator* gg = cm->GetGlobalGenerator();
     cmGlobalGenerator* gg = cm->GetGlobalGenerator();
     if (gg) {
     if (gg) {
@@ -304,8 +304,8 @@ int do_cmake(int ac, char const* const* av)
   cmake cm(role);
   cmake cm(role);
   cm.SetHomeDirectory("");
   cm.SetHomeDirectory("");
   cm.SetHomeOutputDirectory("");
   cm.SetHomeOutputDirectory("");
-  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
-  cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
+  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm);
+  cm.SetProgressCallback(cmakemainProgressCallback, &cm);
   cm.SetWorkingMode(workingMode);
   cm.SetWorkingMode(workingMode);
 
 
   int res = cm.Run(args, view_only);
   int res = cm.Run(args, view_only);
@@ -420,8 +420,8 @@ static int do_build(int ac, char const* const* av)
   }
   }
 
 
   cmake cm(cmake::RoleInternal);
   cmake cm(cmake::RoleInternal);
-  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
-  cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
+  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm);
+  cm.SetProgressCallback(cmakemainProgressCallback, &cm);
   return cm.Build(dir, target, config, nativeOptions, clean);
   return cm.Build(dir, target, config, nativeOptions, clean);
 #endif
 #endif
 }
 }

+ 3 - 2
Tests/CMakeLib/testUTF8.cxx

@@ -8,8 +8,9 @@ typedef char test_utf8_char[5];
 static void test_utf8_char_print(test_utf8_char const c)
 static void test_utf8_char_print(test_utf8_char const c)
 {
 {
   unsigned char const* d = reinterpret_cast<unsigned char const*>(c);
   unsigned char const* d = reinterpret_cast<unsigned char const*>(c);
-  printf("[0x%02X,0x%02X,0x%02X,0x%02X]", (int)d[0], (int)d[1], (int)d[2],
-         (int)d[3]);
+  printf("[0x%02X,0x%02X,0x%02X,0x%02X]", static_cast<int>(d[0]),
+         static_cast<int>(d[1]), static_cast<int>(d[2]),
+         static_cast<int>(d[3]));
 }
 }
 
 
 struct test_utf8_entry
 struct test_utf8_entry