Merge topic 'size-empty'

c6220de2 Use the empty() method to check for emptyness.
This commit is contained in:
Brad King 2016-06-03 10:45:52 -04:00 committed by CMake Topic Stage
commit 3d6638471a
16 changed files with 34 additions and 32 deletions

View File

@ -790,7 +790,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
// First generate the command and arguments
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if (args.size() < 1) {
if (args.empty()) {
return false;
}

View File

@ -88,10 +88,10 @@ bool cmCTestCurl::InitCurl()
if (this->VerifyHostOff) {
curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYHOST, 0);
}
if (this->HTTPProxy.size()) {
if (!this->HTTPProxy.empty()) {
curl_easy_setopt(this->Curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
curl_easy_setopt(this->Curl, CURLOPT_PROXYTYPE, this->HTTPProxyType);
if (this->HTTPProxyAuth.size() > 0) {
if (!this->HTTPProxyAuth.empty()) {
curl_easy_setopt(this->Curl, CURLOPT_PROXYUSERPWD,
this->HTTPProxyAuth.c_str());
}
@ -160,17 +160,17 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL);
::curl_slist_free_all(headers);
if (responseData.size() > 0) {
if (!responseData.empty()) {
response = std::string(responseData.begin(), responseData.end());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Curl response: ["
<< response << "]\n");
}
std::string curlDebug;
if (debugData.size() > 0) {
if (!debugData.empty()) {
curlDebug = std::string(debugData.begin(), debugData.end());
cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
}
if (response.size() == 0) {
if (response.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n"
<< curlDebug);
return false;
@ -205,11 +205,11 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
CURLcode res = ::curl_easy_perform(this->Curl);
if (responseData.size() > 0) {
if (!responseData.empty()) {
response = std::string(responseData.begin(), responseData.end());
cmCTestLog(this->CTest, DEBUG, "Curl response: [" << response << "]\n");
}
if (debugData.size() > 0) {
if (!debugData.empty()) {
std::string curlDebug = std::string(debugData.begin(), debugData.end());
cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
}

View File

@ -499,11 +499,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
// Setup the options
std::string memoryTesterOptions;
if (this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions").size()) {
if (!this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions")
.empty()) {
memoryTesterOptions =
this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions");
} else if (this->CTest->GetCTestConfiguration("ValgrindCommandOptions")
.size()) {
} else if (!this->CTest->GetCTestConfiguration("ValgrindCommandOptions")
.empty()) {
memoryTesterOptions =
this->CTest->GetCTestConfiguration("ValgrindCommandOptions");
}
@ -522,8 +523,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterOptions.push_back("--show-reachable=yes");
this->MemoryTesterOptions.push_back("--num-callers=50");
}
if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.size()) {
if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.empty()) {
if (!cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.c_str())) {

View File

@ -16,7 +16,7 @@
bool cmCTestReadCustomFilesCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
if (args.size() < 1) {
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
}

View File

@ -16,7 +16,7 @@
bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
if (args.size() < 1) {
if (args.empty()) {
this->CTestScriptHandler->RunCurrentScript();
return true;
}

View File

@ -207,7 +207,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
}
if (res == cmsysProcess_State_Exited) {
bool success = !forceFail &&
(retVal == 0 || this->TestProperties->RequiredRegularExpressions.size());
(retVal == 0 ||
!this->TestProperties->RequiredRegularExpressions.empty());
if (this->TestProperties->SkipReturnCode >= 0 &&
this->TestProperties->SkipReturnCode == retVal) {
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
@ -537,7 +538,7 @@ void cmCTestRunTest::ComputeArguments()
<< " command: " << testCommand << std::endl);
// Print any test-specific env vars in verbose mode
if (this->TestProperties->Environment.size()) {
if (!this->TestProperties->Environment.empty()) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
<< ": "
<< "Environment variables: " << std::endl);

View File

@ -17,7 +17,7 @@
bool cmCTestSleepCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
if (args.size() < 1) {
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
}

View File

@ -25,7 +25,7 @@ cmCTestStartCommand::cmCTestStartCommand()
bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
if (args.size() < 1) {
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
}

View File

@ -992,12 +992,12 @@ void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
url = dropMethod;
url += "://";
if (this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0) {
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
url += this->CTest->GetCTestConfiguration("DropSiteUser");
cmCTestOptionalLog(
this->CTest, HANDLER_OUTPUT,
this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), this->Quiet);
if (this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0) {
if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", this->Quiet);
}

View File

@ -69,7 +69,7 @@ public:
bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
if (args.size() < 1) {
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
}
@ -150,7 +150,7 @@ public:
bool cmCTestAddSubdirectoryCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
if (args.size() < 1) {
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
}
@ -1125,7 +1125,7 @@ void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
cmCTestTestResult* result)
{
if (result->Status != cmCTestTestHandler::COMPLETED &&
result->Properties->AttachOnFail.size()) {
!result->Properties->AttachOnFail.empty()) {
result->Properties->AttachedFiles.insert(
result->Properties->AttachedFiles.end(),
result->Properties->AttachOnFail.begin(),

View File

@ -111,7 +111,7 @@ protected:
gl.RecurseThroughSymlinksOn();
gl.FindFiles(packageGlob);
std::vector<std::string> const& files = gl.GetFiles();
if (files.size() == 0) {
if (files.empty()) {
return false;
}

View File

@ -255,7 +255,7 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
archive_entry_set_gid(e, this->Gid.Get());
}
if (this->Uname.size() && this->Gname.size()) {
if (!this->Uname.empty() && !this->Gname.empty()) {
archive_entry_set_uname(e, this->Uname.c_str());
archive_entry_set_gname(e, this->Gname.c_str());
}

View File

@ -1020,7 +1020,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
// First generate the command and arguments
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if (args.size() < 1) {
if (args.empty()) {
return false;
}
@ -2525,7 +2525,7 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut,
{
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if (args.size() < 1) {
if (args.empty()) {
return false;
}

View File

@ -248,7 +248,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// We don't want paths with CMakeFiles in them
// or do we?
// In speedcrunch those where purely internal
if (splitted.size() >= 1 &&
if (!splitted.empty() &&
relative.find("CMakeFiles") == std::string::npos) {
tree.InsertPath(splitted, 1, fileName);
}
@ -729,7 +729,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
const std::string& makeFlags)
{
std::string command = make;
if (makeFlags.size() > 0) {
if (!makeFlags.empty()) {
command += " ";
command += makeFlags;
}

View File

@ -848,7 +848,7 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
const std::vector<std::string>& commands, bool in_help)
{
bool symbolic = false;
if (outputs.size() == 0) {
if (outputs.empty()) {
return symbolic;
}

View File

@ -702,7 +702,7 @@ bool cmSystemTools::RunSingleCommand(const char* command,
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if (args.size() < 1) {
if (args.empty()) {
return false;
}
return cmSystemTools::RunSingleCommand(args, captureStdOut, captureStdErr,