CTest: don't use else after return

This commit is contained in:
Daniel Pfeifer 2016-08-18 20:04:21 +02:00
parent 7f97a6c94b
commit 50ad1e0a14
14 changed files with 69 additions and 84 deletions

View File

@ -532,9 +532,8 @@ public:
if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) && if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
result != 0) { result != 0) {
return result < 0; return result < 0;
} else {
return l < r;
} }
return l < r;
} }
private: private:

View File

@ -216,10 +216,9 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
std::string flag = "-r"; std::string flag = "-r";
flag += tagLine.substr(1); flag += tagLine.substr(1);
return flag; return flag;
} else { }
// Use the default branch. // Use the default branch.
return "-b"; return "-b";
}
} }
void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag, void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag,

View File

@ -763,12 +763,11 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
this->Quiet); this->Quiet);
cov.ReadCoverageFile(coverageFile.c_str()); cov.ReadCoverageFile(coverageFile.c_str());
return static_cast<int>(cont->TotalCoverage.size()); return static_cast<int>(cont->TotalCoverage.size());
} else { }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Cannot find GTM coverage file: " << coverageFile " Cannot find GTM coverage file: " << coverageFile
<< std::endl, << std::endl,
this->Quiet); this->Quiet);
}
cmParseCacheCoverage ccov(*cont, this->CTest); cmParseCacheCoverage ccov(*cont, this->CTest);
coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov"; coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
if (cmSystemTools::FileExists(coverageFile.c_str())) { if (cmSystemTools::FileExists(coverageFile.c_str())) {

View File

@ -126,12 +126,11 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv)
this->HandleRealArg(this->RealArgV[i]); this->HandleRealArg(this->RealArgV[i]);
} }
return true; return true;
} else { }
this->RealArgC = 0; this->RealArgC = 0;
this->RealArgV = CM_NULLPTR; this->RealArgV = CM_NULLPTR;
std::cerr << "No launch/command separator ('--') found!\n"; std::cerr << "No launch/command separator ('--') found!\n";
return false; return false;
}
} }
void cmCTestLaunch::HandleRealArg(const char* arg) void cmCTestLaunch::HandleRealArg(const char* arg)

View File

@ -638,27 +638,24 @@ bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
std::string& log, std::string& log,
std::vector<int>& results) std::vector<int>& results)
{ {
if (this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND) { switch (this->MemoryTesterStyle) {
case cmCTestMemCheckHandler::VALGRIND:
return this->ProcessMemCheckValgrindOutput(str, log, results); return this->ProcessMemCheckValgrindOutput(str, log, results);
} else if (this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY) { case cmCTestMemCheckHandler::PURIFY:
return this->ProcessMemCheckPurifyOutput(str, log, results); return this->ProcessMemCheckPurifyOutput(str, log, results);
} else if (this->MemoryTesterStyle == case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
cmCTestMemCheckHandler::ADDRESS_SANITIZER || case cmCTestMemCheckHandler::THREAD_SANITIZER:
this->MemoryTesterStyle == case cmCTestMemCheckHandler::MEMORY_SANITIZER:
cmCTestMemCheckHandler::THREAD_SANITIZER || case cmCTestMemCheckHandler::UB_SANITIZER:
this->MemoryTesterStyle ==
cmCTestMemCheckHandler::MEMORY_SANITIZER ||
this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) {
return this->ProcessMemCheckSanitizerOutput(str, log, results); return this->ProcessMemCheckSanitizerOutput(str, log, results);
} else if (this->MemoryTesterStyle == case cmCTestMemCheckHandler::BOUNDS_CHECKER:
cmCTestMemCheckHandler::BOUNDS_CHECKER) {
return this->ProcessMemCheckBoundsCheckerOutput(str, log, results); return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
} else { default:
log.append("\nMemory checking style used was: "); log.append("\nMemory checking style used was: ");
log.append("None that I know"); log.append("None that I know");
log = str; log = str;
}
return true; return true;
}
} }
std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning( std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning(

View File

@ -824,9 +824,8 @@ bool cmCTestMultiProcessHandler::CheckCycles()
<< this->Properties[root]->Name << this->Properties[root]->Name
<< "\".\nPlease fix the cycle and run ctest again.\n"); << "\".\nPlease fix the cycle and run ctest again.\n");
return false; return false;
} else {
s.push(*d);
} }
s.push(*d);
} }
} }
} }

View File

@ -373,9 +373,8 @@ std::string cmCTestP4::GetWorkingRevision()
if (rev.empty()) { if (rev.empty()) {
return "0"; return "0";
} else {
return rev;
} }
return rev;
} }
void cmCTestP4::NoteOldRevision() void cmCTestP4::NoteOldRevision()

View File

@ -54,7 +54,8 @@ bool cmCTestRunTest::CheckOutput()
if (p == cmsysProcess_Pipe_None) { if (p == cmsysProcess_Pipe_None) {
// Process has terminated and all output read. // Process has terminated and all output read.
return false; return false;
} else if (p == cmsysProcess_Pipe_STDOUT) { }
if (p == cmsysProcess_Pipe_STDOUT) {
// Store this line of output. // Store this line of output.
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
<< ": " << line << std::endl); << ": " << line << std::endl);
@ -82,8 +83,7 @@ bool cmCTestRunTest::CheckOutput()
} }
} }
} }
} else // if(p == cmsysProcess_Pipe_Timeout) } else { // if(p == cmsysProcess_Pipe_Timeout)
{
break; break;
} }
} }

View File

@ -80,11 +80,11 @@ static bool cmCTestSVNPathStarts(std::string const& p1, std::string const& p2)
// Does path p1 start with path p2? // Does path p1 start with path p2?
if (p1.size() == p2.size()) { if (p1.size() == p2.size()) {
return p1 == p2; return p1 == p2;
} else if (p1.size() > p2.size() && p1[p2.size()] == '/') {
return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
} else {
return false;
} }
if (p1.size() > p2.size() && p1[p2.size()] == '/') {
return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
}
return false;
} }
std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo) std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
@ -295,9 +295,8 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
if (strcmp(parameters[0], "update") == 0) { if (strcmp(parameters[0], "update") == 0) {
return RunUpdateCommand(&args[0], out, err); return RunUpdateCommand(&args[0], out, err);
} else {
return RunChild(&args[0], out, err);
} }
return RunChild(&args[0], out, err);
} }
class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger, class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger,

View File

@ -284,14 +284,13 @@ inline int GetNextNumber(std::string const& in, int& val,
} }
pos = pos2 + 1; pos = pos2 + 1;
return 1; return 1;
} else { }
if (in.size() - pos == 0) { if (in.size() - pos == 0) {
val = -1; val = -1;
} else { } else {
val = atoi(in.substr(pos, in.size() - pos).c_str()); val = atoi(in.substr(pos, in.size() - pos).c_str());
} }
return 0; return 0;
}
} }
// get the next number in a string with numbers separated by , // get the next number in a string with numbers separated by ,
@ -311,14 +310,13 @@ inline int GetNextRealNumber(std::string const& in, double& val,
} }
pos = pos2 + 1; pos = pos2 + 1;
return 1; return 1;
} else { }
if (in.size() - pos == 0) { if (in.size() - pos == 0) {
val = -1; val = -1;
} else { } else {
val = atof(in.substr(pos, in.size() - pos).c_str()); val = atof(in.substr(pos, in.size() - pos).c_str());
} }
return 0; return 0;
}
} }
cmCTestTestHandler::cmCTestTestHandler() cmCTestTestHandler::cmCTestTestHandler()

View File

@ -49,7 +49,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
if (cmSystemTools::FileExists(arg.c_str())) { if (cmSystemTools::FileExists(arg.c_str())) {
this->Files.insert(arg); this->Files.insert(arg);
return true; return true;
} else { }
std::ostringstream e; std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit " e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file."; << "a non-existent file.";
@ -57,7 +57,6 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
this->ArgumentDoing = ArgumentDoingError; this->ArgumentDoing = ArgumentDoingError;
return false; return false;
} }
}
// Look for other arguments. // Look for other arguments.
return this->Superclass::CheckArgumentValue(arg); return this->Superclass::CheckArgumentValue(arg);

View File

@ -42,9 +42,8 @@ public:
std::string foundFileName = std::string foundFileName =
line.substr(begIndex + 3, endIndex - (begIndex + 4)); line.substr(begIndex + 3, endIndex - (begIndex + 4));
return foundFileName; return foundFileName;
} else {
return line.substr(begIndex, line.npos);
} }
return line.substr(begIndex, line.npos);
} }
bool ParseFile(std::string const& file) bool ParseFile(std::string const& file)
{ {

View File

@ -128,7 +128,7 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
if (i != this->RoutineToDirectory.end()) { if (i != this->RoutineToDirectory.end()) {
filepath = i->second; filepath = i->second;
return true; return true;
} else { }
// try some alternate names // try some alternate names
const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR }; const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR };
for (int k = 0; tryname[k] != CM_NULLPTR; k++) { for (int k = 0; tryname[k] != CM_NULLPTR; k++) {
@ -139,6 +139,5 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
return true; return true;
} }
} }
}
return false; return false;
} }

View File

@ -124,10 +124,10 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout); int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout);
if (p == cmsysProcess_Pipe_Timeout) { if (p == cmsysProcess_Pipe_Timeout) {
return cmsysProcess_Pipe_Timeout; return cmsysProcess_Pipe_Timeout;
} else if (p == cmsysProcess_Pipe_STDOUT) { }
if (p == cmsysProcess_Pipe_STDOUT) {
this->Output.insert(this->Output.end(), data, data + length); this->Output.insert(this->Output.end(), data, data + length);
} else // p == cmsysProcess_Pipe_None } else { // p == cmsysProcess_Pipe_None
{
// The process will provide no more data. // The process will provide no more data.
break; break;
} }