Bläddra i källkod

Fix warnings in CMake source code. Suppress warnings in Lexer and Parser files that are 'too hard' to fix.

David Cole 16 år sedan
förälder
incheckning
a9dcc7fd47

+ 1 - 0
CTestCustom.cmake.in

@@ -24,6 +24,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
   "Clock skew detected"
   "remark\\(1209"
   "stl_deque.h:1051"
+  "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"
   "Parser.cxx.*warning.*2111-D.*statement is unreachable"
   "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element"
   )

+ 4 - 2
Source/cmCacheManager.cxx

@@ -462,11 +462,13 @@ bool cmCacheManager::SaveCache(const char* path)
   if ( currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' &&
        currentcwd[1] == ':' )
     {
-    currentcwd[0] = currentcwd[0] - 'A' + 'a';
+    // Cast added to avoid compiler warning. Cast is ok because
+    // value is guaranteed to fit in char by the above if...
+    currentcwd[0] = static_cast<char>(currentcwd[0] - 'A' + 'a');
     }
   cmSystemTools::ConvertToUnixSlashes(currentcwd);
   this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd.c_str(),
-                      "This is the directory where this CMakeCahe.txt"
+                      "This is the directory where this CMakeCache.txt"
                       " was created", cmCacheManager::INTERNAL);
 
   fout << "# This is the CMakeCache file.\n"

+ 2 - 2
Source/cmComputeLinkInformation.cxx

@@ -987,8 +987,8 @@ std::string cmComputeLinkInformation::NoCaseExpression(const char* str)
     else
       {
       ret += "[";
-      ret += tolower(*s);
-      ret += toupper(*s);
+      ret += static_cast<char>(tolower(*s));
+      ret += static_cast<char>(toupper(*s));
       ret += "]";
       }
     s++;

+ 3 - 1
Source/cmFileCommand.cxx

@@ -589,7 +589,9 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
             (c == '\n' && newline_consume))
       {
       // This is an ASCII character that may be part of a string.
-      s += c;
+      // Cast added to avoid compiler warning. Cast is ok because
+      // c is guaranteed to fit in char by the above if...
+      s += static_cast<char>(c);
       }
     else
       {

+ 6 - 3
Source/cmGlobalGenerator.cxx

@@ -889,7 +889,8 @@ void cmGlobalGenerator::Generate()
     this->LocalGenerators[i]->GenerateInstallRules();
     this->LocalGenerators[i]->GenerateTestFiles();
     this->CMakeInstance->UpdateProgress("Generating",
-                                    (i+1.0f)/this->LocalGenerators.size());
+      (static_cast<float>(i)+1.0f)/
+       static_cast<float>(this->LocalGenerators.size()));
     }
   this->SetCurrentLocalGenerator(0);
 
@@ -996,7 +997,8 @@ void cmGlobalGenerator::CheckLocalGenerators()
         }
       }
     this->CMakeInstance->UpdateProgress
-      ("Configuring", 0.9f+0.1f*(i+1.0f)/this->LocalGenerators.size());
+      ("Configuring", 0.9f+0.1f*(static_cast<float>(i)+1.0f)/
+        static_cast<float>(this->LocalGenerators.size()));
     }
 
   if(notFoundMap.size())
@@ -1262,7 +1264,8 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
     }
 
   int numGen = atoi(numGenC);
-  float prog = 0.9f*this->LocalGenerators.size()/numGen;
+  float prog = 0.9f*static_cast<float>(this->LocalGenerators.size())/
+    static_cast<float>(numGen);
   if (prog > 0.9f)
     {
     prog = 0.9f;

+ 1 - 1
Source/cmStringCommand.cxx

@@ -126,7 +126,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args)
     else
       {
       std::string error = "Character with code ";
-      error += ch;
+      error += args[cc];
       error += " does not exist.";
       this->SetError(error.c_str());
       return false;

+ 1 - 1
Source/kwsys/testProcess.c

@@ -266,7 +266,7 @@ int runChild2(kwsysProcess* kp,
           }
         else
           {
-          fwrite(data, 1, length, stdout);
+          fwrite(data, 1, (size_t) length, stdout);
           fflush(stdout);
           }
         }