Просмотр исходного кода

Fix warnings in CMake source code. Suppress rampant warnings emanating from Qt files.

David Cole 16 лет назад
Родитель
Сommit
44bcba7461

+ 1 - 0
CTestCustom.cmake.in

@@ -25,6 +25,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
   "remark\\(1209"
   "stl_deque.h:1051"
   "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"
+  "[Qq]t([Cc]ore|[Gg]ui).*warning.*conversion.*may alter its value"
   "Parser.cxx.*warning.*2111-D.*statement is unreachable"
   "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element"
   )

+ 2 - 2
Source/CPack/cmCPackTGZGenerator.cxx

@@ -176,12 +176,12 @@ int cmCPackTGZ_Data_Close(void *client_data)
     int n;
     uLong x = mydata->CRC;
     for (n = 0; n < 4; n++) {
-      buffer[n] = (int)(x & 0xff);
+      buffer[n] = static_cast<char>(x & 0xff);
       x >>= 8;
     }
     x = mydata->ZLibStream.total_in;
     for (n = 0; n < 4; n++) {
-      buffer[n+4] = (int)(x & 0xff);
+      buffer[n+4] = static_cast<char>(x & 0xff);
       x >>= 8;
     }
 

+ 2 - 2
Source/CTest/cmCTestBuildHandler.cxx

@@ -596,8 +596,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
   std::vector<cmCTestBuildErrorWarning>::iterator it;
 
   // only report the first 50 warnings and first 50 errors
-  unsigned short numErrorsAllowed = this->MaxErrors;
-  unsigned short numWarningsAllowed = this->MaxWarnings;
+  int numErrorsAllowed = this->MaxErrors;
+  int numWarningsAllowed = this->MaxWarnings;
   std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
   // make sure the source dir is in the correct case on windows
   // via a call to collapse full path.

+ 2 - 2
Source/CTest/cmCTestCoverageHandler.cxx

@@ -1590,13 +1590,13 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
       std::string shortFileName =
         this->CTest->GetShortPathToFile(file.c_str());
 
-      float cper = percentBranch + percentFunction;
+      float cper = static_cast<float>(percentBranch + percentFunction);
       if(totalBranches > 0)
         {
         cper /= 2.0f;
         }
       percent_coverage += cper;
-      float cmet = percentFunction + percentBranch;
+      float cmet = static_cast<float>(percentFunction + percentBranch);
       if(totalBranches > 0)
         {
         cmet /= 2.0f;

+ 1 - 1
Source/CursesDialog/cmCursesMainForm.cxx

@@ -920,7 +920,7 @@ void cmCursesMainForm::HandleInput()
         {
         if ( this->SearchString.size() < static_cast<std::string::size_type>(x-10) )
           {
-          this->SearchString += key;
+          this->SearchString += static_cast<char>(key);
           }
         }
       else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC )

+ 2 - 1
Source/cmHexFileConverter.cxx

@@ -172,7 +172,8 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType(
     return Binary;
     }
 
-  fgets(buf, 1024, inFile);
+  buf[0] = 0;
+  (void) fgets(buf, 1024, inFile);
   fclose(inFile);
   FileType type = Binary;
   unsigned int minLineLength = 0;

+ 2 - 2
Source/cmScriptGenerator.cxx

@@ -53,7 +53,7 @@ static void cmScriptGeneratorEncodeConfig(const char* config,
     if(*c >= 'a' && *c <= 'z')
       {
       result += "[";
-      result += *c + ('A' - 'a');
+      result += static_cast<char>(*c + 'A' - 'a');
       result += *c;
       result += "]";
       }
@@ -61,7 +61,7 @@ static void cmScriptGeneratorEncodeConfig(const char* config,
       {
       result += "[";
       result += *c;
-      result += *c + ('a' - 'A');
+      result += static_cast<char>(*c + 'a' - 'A');
       result += "]";
       }
     else

+ 5 - 4
Source/cmSystemTools.cxx

@@ -338,7 +338,7 @@ bool cmSystemTools::IsOn(const char* val)
   for(std::basic_string<char>::iterator c = v.begin();
       c != v.end(); c++)
     {
-    *c = toupper(*c);
+    *c = static_cast<char>(toupper(*c));
     }
   return (v == "ON" || v == "1" || v == "YES" || v == "TRUE" || v == "Y");
 }
@@ -371,7 +371,7 @@ bool cmSystemTools::IsOff(const char* val)
   for(std::basic_string<char>::iterator c = v.begin();
       c != v.end(); c++)
     {
-    *c = toupper(*c);
+    *c = static_cast<char>(toupper(*c));
     }
   return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" || 
           v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
@@ -915,7 +915,8 @@ bool RunCommandViaPopen(const char* command,
 #endif
     return false;
     }
-  fgets(buffer, BUFFER_SIZE, cpipe);
+  buffer[0] = 0;
+  (void) fgets(buffer, BUFFER_SIZE, cpipe);
   while(!feof(cpipe))
     {
     if(verbose)
@@ -924,7 +925,7 @@ bool RunCommandViaPopen(const char* command,
       }
     output += buffer;
     buffer[0] = 0;
-    fgets(buffer, BUFFER_SIZE, cpipe);
+    (void) fgets(buffer, BUFFER_SIZE, cpipe);
     }
 
   retVal = pclose(cpipe);

+ 8 - 2
Source/cmake.cxx

@@ -1276,7 +1276,10 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
       int count;
       if (countFile)
         {
-        fscanf(countFile,"%i",&count);
+        if (1!=fscanf(countFile,"%i",&count))
+          {
+          cmSystemTools::Message("Could not read from count file.");
+          }
         fclose(countFile);
         }
       else
@@ -1318,7 +1321,10 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
         }
       else
         {
-        fscanf(progFile,"%i",&count);
+        if (1!=fscanf(progFile,"%i",&count))
+          {
+          cmSystemTools::Message("Could not read from progress file.");
+          }
         fclose(progFile);
         }
       unsigned int i;

+ 2 - 2
Source/cmakewizard.cxx

@@ -29,7 +29,7 @@ void cmakewizard::AskUser(const char* key,
   printf("New Value (Enter to keep current value): ");
   char buffer[4096];
   buffer[0] = 0;
-  fgets(buffer, sizeof(buffer)-1, stdin);
+  (void) fgets(buffer, sizeof(buffer)-1, stdin);
 
   if(strlen(buffer) > 0)
     {
@@ -66,7 +66,7 @@ bool cmakewizard::AskAdvanced()
   printf("Would you like to see advanced options? [No]:");
   char buffer[4096];
   buffer[0] = 0;
-  fgets(buffer, sizeof(buffer)-1, stdin);
+  (void) fgets(buffer, sizeof(buffer)-1, stdin);
   if(buffer[0])
     {
     if(buffer[0] == 'y' || buffer[0] == 'Y')