From ccb0cf130673b55035106067997e9d135d4d27fa Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 2 Oct 2009 15:30:01 -0400 Subject: Fix warnings in CMake source code. --- Source/CTest/cmCTestMultiProcessHandler.cxx | 5 +++-- Source/CTest/cmCTestTestHandler.cxx | 10 +++++----- Source/cmHexFileConverter.cxx | 6 ++++-- Source/cmSystemTools.cxx | 12 ++++++++---- Source/cmakewizard.cxx | 12 ++++++++---- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7ab9cac..c62dbce 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -251,7 +251,8 @@ bool cmCTestMultiProcessHandler::CheckOutput() this->TestRunningMap[test] = false; this->RunningTests.erase(p); this->WriteCheckpoint(test); - this->WriteCostData(test, p->GetTestResults().ExecutionTime); + this->WriteCostData(test, static_cast( + p->GetTestResults().ExecutionTime)); this->RunningCount -= GetProcessorsUsed(test); delete p; } @@ -276,7 +277,7 @@ void cmCTestMultiProcessHandler::ReadCostData() cmSystemTools::SplitString(line.c_str(), ' '); int index = atoi(parts[0].c_str()); - float cost = atof(parts[1].c_str()); + float cost = static_cast(atof(parts[1].c_str())); if(this->Properties[index] && this->Properties[index]->Cost == 0) { this->Properties[index]->Cost = cost; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2ad2e37..5090cd0 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -574,16 +574,16 @@ int cmCTestTestHandler::ProcessHandler() } } - float percent = float(passed.size()) * 100.0f / total; + float percent = float(passed.size()) * 100.0f / float(total); if ( failed.size() > 0 && percent > 99) { percent = 99; } - + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << static_cast(percent + .5) << "% tests passed, " - << failed.size() << " tests failed out of " - << total << std::endl); + << failed.size() << " tests failed out of " + << total << std::endl); if(this->CTest->GetLabelSummary()) { this->PrintLabelSummary(); @@ -1982,7 +1982,7 @@ bool cmCTestTestHandler::SetTestsProperties( } if ( key == "COST" ) { - rtit->Cost = atof(val.c_str()); + rtit->Cost = static_cast(atof(val.c_str())); } if ( key == "RUN_SERIAL" ) { diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index 91565b4..2ff7945 100644 --- a/Source/cmHexFileConverter.cxx +++ b/Source/cmHexFileConverter.cxx @@ -172,8 +172,10 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType( return Binary; } - buf[0] = 0; - (void) fgets(buf, 1024, inFile); + if(!fgets(buf, 1024, inFile)) + { + buf[0] = 0; + } fclose(inFile); FileType type = Binary; unsigned int minLineLength = 0; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 0af46c1..219c1ef 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -915,8 +915,10 @@ bool RunCommandViaPopen(const char* command, #endif return false; } - buffer[0] = 0; - (void) fgets(buffer, BUFFER_SIZE, cpipe); + if (!fgets(buffer, BUFFER_SIZE, cpipe)) + { + buffer[0] = 0; + } while(!feof(cpipe)) { if(verbose) @@ -924,8 +926,10 @@ bool RunCommandViaPopen(const char* command, cmSystemTools::Stdout(buffer); } output += buffer; - buffer[0] = 0; - (void) fgets(buffer, BUFFER_SIZE, cpipe); + if(!fgets(buffer, BUFFER_SIZE, cpipe)) + { + buffer[0] = 0; + } } retVal = pclose(cpipe); diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx index 1dcfcc1..cd427cb 100644 --- a/Source/cmakewizard.cxx +++ b/Source/cmakewizard.cxx @@ -28,8 +28,10 @@ void cmakewizard::AskUser(const char* key, printf("Current Value: %s\n", iter.GetValue()); printf("New Value (Enter to keep current value): "); char buffer[4096]; - buffer[0] = 0; - (void) fgets(buffer, sizeof(buffer)-1, stdin); + if(!fgets(buffer, sizeof(buffer)-1, stdin)) + { + buffer[0] = 0; + } if(strlen(buffer) > 0) { @@ -65,8 +67,10 @@ bool cmakewizard::AskAdvanced() { printf("Would you like to see advanced options? [No]:"); char buffer[4096]; - buffer[0] = 0; - (void) fgets(buffer, sizeof(buffer)-1, stdin); + if(!fgets(buffer, sizeof(buffer)-1, stdin)) + { + buffer[0] = 0; + } if(buffer[0]) { if(buffer[0] == 'y' || buffer[0] == 'Y') -- cgit v0.12