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.
return "-b";
} }
// Use the default branch.
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,
" Cannot find GTM coverage file: " << coverageFile
<< std::endl,
this->Quiet);
} }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Cannot find GTM coverage file: " << coverageFile
<< std::endl,
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->RealArgV = CM_NULLPTR;
std::cerr << "No launch/command separator ('--') found!\n";
return false;
} }
this->RealArgC = 0;
this->RealArgV = CM_NULLPTR;
std::cerr << "No launch/command separator ('--') found!\n";
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) {
return this->ProcessMemCheckValgrindOutput(str, log, results); case cmCTestMemCheckHandler::VALGRIND:
} else if (this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY) { return this->ProcessMemCheckValgrindOutput(str, log, results);
return this->ProcessMemCheckPurifyOutput(str, log, results); case cmCTestMemCheckHandler::PURIFY:
} else if (this->MemoryTesterStyle == return this->ProcessMemCheckPurifyOutput(str, log, results);
cmCTestMemCheckHandler::ADDRESS_SANITIZER || case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
this->MemoryTesterStyle == case cmCTestMemCheckHandler::THREAD_SANITIZER:
cmCTestMemCheckHandler::THREAD_SANITIZER || case cmCTestMemCheckHandler::MEMORY_SANITIZER:
this->MemoryTesterStyle == case cmCTestMemCheckHandler::UB_SANITIZER:
cmCTestMemCheckHandler::MEMORY_SANITIZER || return this->ProcessMemCheckSanitizerOutput(str, log, results);
this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) { case cmCTestMemCheckHandler::BOUNDS_CHECKER:
return this->ProcessMemCheckSanitizerOutput(str, log, results); return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
} else if (this->MemoryTesterStyle == default:
cmCTestMemCheckHandler::BOUNDS_CHECKER) { log.append("\nMemory checking style used was: ");
return this->ProcessMemCheckBoundsCheckerOutput(str, log, results); log.append("None that I know");
} else { log = str;
log.append("\nMemory checking style used was: "); return true;
log.append("None that I know");
log = str;
} }
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) {
val = -1;
} else {
val = atoi(in.substr(pos, in.size() - pos).c_str());
}
return 0;
} }
if (in.size() - pos == 0) {
val = -1;
} else {
val = atoi(in.substr(pos, in.size() - pos).c_str());
}
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) {
val = -1;
} else {
val = atof(in.substr(pos, in.size() - pos).c_str());
}
return 0;
} }
if (in.size() - pos == 0) {
val = -1;
} else {
val = atof(in.substr(pos, in.size() - pos).c_str());
}
return 0;
} }
cmCTestTestHandler::cmCTestTestHandler() cmCTestTestHandler::cmCTestTestHandler()

View File

@ -49,14 +49,13 @@ 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;
e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
return false;
} }
std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
return false;
} }
// Look for other arguments. // Look for other arguments.

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,16 +128,15 @@ 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++) {
std::string routine2 = routine + tryname[k]; std::string routine2 = routine + tryname[k];
i = this->RoutineToDirectory.find(routine2); i = this->RoutineToDirectory.find(routine2);
if (i != this->RoutineToDirectory.end()) { if (i != this->RoutineToDirectory.end()) {
filepath = i->second; filepath = i->second;
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;
} }