From 44bcba746156ad1d5fe7f784380c3fb4f4672f6b Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 1 Oct 2009 16:47:08 -0400 Subject: [PATCH] Fix warnings in CMake source code. Suppress rampant warnings emanating from Qt files. --- CTestCustom.cmake.in | 1 + Source/CPack/cmCPackTGZGenerator.cxx | 4 ++-- Source/CTest/cmCTestBuildHandler.cxx | 4 ++-- Source/CTest/cmCTestCoverageHandler.cxx | 4 ++-- Source/CursesDialog/cmCursesMainForm.cxx | 2 +- Source/cmHexFileConverter.cxx | 3 ++- Source/cmScriptGenerator.cxx | 4 ++-- Source/cmSystemTools.cxx | 9 +++++---- Source/cmake.cxx | 10 ++++++++-- Source/cmakewizard.cxx | 4 ++-- 10 files changed, 27 insertions(+), 18 deletions(-) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index a9d4d75d3..2a6ce0604 100644 --- a/CTestCustom.cmake.in +++ b/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" ) diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 3ca0e53ce..1c56d81a9 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/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(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(x & 0xff); x >>= 8; } diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index d93da07b8..0095bbccb 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -596,8 +596,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os) std::vector::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. diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index b6e10bfe1..50b1d2606 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/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(percentBranch + percentFunction); if(totalBranches > 0) { cper /= 2.0f; } percent_coverage += cper; - float cmet = percentFunction + percentBranch; + float cmet = static_cast(percentFunction + percentBranch); if(totalBranches > 0) { cmet /= 2.0f; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 854b91952..cd231ad90 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -920,7 +920,7 @@ void cmCursesMainForm::HandleInput() { if ( this->SearchString.size() < static_cast(x-10) ) { - this->SearchString += key; + this->SearchString += static_cast(key); } } else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC ) diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index 297053158..91565b444 100644 --- a/Source/cmHexFileConverter.cxx +++ b/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; diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 20246d734..86ecebe64 100644 --- a/Source/cmScriptGenerator.cxx +++ b/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(*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(*c + 'a' - 'A'); result += "]"; } else diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bf829810a..0af46c1ba 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -338,7 +338,7 @@ bool cmSystemTools::IsOn(const char* val) for(std::basic_string::iterator c = v.begin(); c != v.end(); c++) { - *c = toupper(*c); + *c = static_cast(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::iterator c = v.begin(); c != v.end(); c++) { - *c = toupper(*c); + *c = static_cast(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); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index cdee8d272..108827a4a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1276,7 +1276,10 @@ int cmake::ExecuteCMakeCommand(std::vector& 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& 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; diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx index 4173413e5..1dcfcc194 100644 --- a/Source/cmakewizard.cxx +++ b/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')