Fix some warnings and a bug where it went past the length of a vector.

Fix a kwstyle warning and an unused variable warning. Also fix a case
where it could crash because a vector was referenced passed its
end.
This commit is contained in:
Bill Hoffman 2012-05-01 17:32:23 -04:00
parent 7955e995ec
commit f5c5db0753
1 changed files with 10 additions and 3 deletions

View File

@ -7,8 +7,9 @@
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
cmParseCacheCoverage::cmParseCacheCoverage(cmCTestCoverageHandlerContainer& cont, cmParseCacheCoverage::cmParseCacheCoverage(
cmCTest* ctest) cmCTestCoverageHandlerContainer& cont,
cmCTest* ctest)
:cmParseMumpsCoverage(cont, ctest) :cmParseMumpsCoverage(cont, ctest)
{ {
} }
@ -101,7 +102,6 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
} }
std::string routine; std::string routine;
std::string filepath; std::string filepath;
bool foundFile = false;
while(cmSystemTools::GetLineFromStream(in, line)) while(cmSystemTools::GetLineFromStream(in, line))
{ {
// clear out line argument vector // clear out line argument vector
@ -181,6 +181,13 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
continue; // skip setting count to avoid crash continue; // skip setting count to avoid crash
} }
// now add to count for linenumber // now add to count for linenumber
// for some reason the cache coverage adds extra lines to the
// end of the file in some cases. Since they do not exist, we will
// mark them as non executable
while(linenumber >= coverageVector.size())
{
coverageVector.push_back(-1);
}
coverageVector[linenumber] += count; coverageVector[linenumber] += count;
} }
return true; return true;