From c6220de27605f33b2793729680c32714cd126690 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 26 May 2016 23:05:30 +0200 Subject: [PATCH] Use the empty() method to check for emptyness. Apply fix-its from clang-tidy's readability-container-size-empty checker. --- Source/CTest/cmCTestBuildHandler.cxx | 2 +- Source/CTest/cmCTestCurl.cxx | 14 +++++++------- Source/CTest/cmCTestMemCheckHandler.cxx | 11 ++++++----- Source/CTest/cmCTestReadCustomFilesCommand.cxx | 2 +- Source/CTest/cmCTestRunScriptCommand.cxx | 2 +- Source/CTest/cmCTestRunTest.cxx | 5 +++-- Source/CTest/cmCTestSleepCommand.cxx | 2 +- Source/CTest/cmCTestStartCommand.cxx | 2 +- Source/CTest/cmCTestSubmitHandler.cxx | 4 ++-- Source/CTest/cmCTestTestHandler.cxx | 6 +++--- Source/CTest/cmParseJacocoCoverage.cxx | 2 +- Source/cmArchiveWrite.cxx | 2 +- Source/cmCTest.cxx | 4 ++-- Source/cmExtraCodeBlocksGenerator.cxx | 4 ++-- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmSystemTools.cxx | 2 +- 16 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 7141daf76..a4d9deeaa 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -790,7 +790,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, // First generate the command and arguments std::vector args = cmSystemTools::ParseArguments(command); - if (args.size() < 1) { + if (args.empty()) { return false; } diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index 59675dd0e..4818324fe 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -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"); } diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 5ae98aff5..f9f7ab7ba 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -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())) { diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx index 2613c1c52..fec23e91f 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx +++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx @@ -16,7 +16,7 @@ bool cmCTestReadCustomFilesCommand::InitialPass( std::vector const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index e143d5028..6b5e6ed5a 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -16,7 +16,7 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->CTestScriptHandler->RunCurrentScript(); return true; } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 9dda8652e..48582c9a5 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -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); diff --git a/Source/CTest/cmCTestSleepCommand.cxx b/Source/CTest/cmCTestSleepCommand.cxx index 102a3036c..a6dd6bc97 100644 --- a/Source/CTest/cmCTestSleepCommand.cxx +++ b/Source/CTest/cmCTestSleepCommand.cxx @@ -17,7 +17,7 @@ bool cmCTestSleepCommand::InitialPass(std::vector const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index d56139357..99d431af5 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -25,7 +25,7 @@ cmCTestStartCommand::cmCTestStartCommand() bool cmCTestStartCommand::InitialPass(std::vector const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index f37334867..155294e2d 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -999,12 +999,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); } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 20ef6930d..b461f97c7 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -69,7 +69,7 @@ public: bool cmCTestSubdirCommand::InitialPass(std::vector 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 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(), diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 335535d92..e456f39f9 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -111,7 +111,7 @@ protected: gl.RecurseThroughSymlinksOn(); gl.FindFiles(packageGlob); std::vector const& files = gl.GetFiles(); - if (files.size() == 0) { + if (files.empty()) { return false; } diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index a0150ec60..235cf88c6 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -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()); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index bc36c5adc..6e0893296 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1020,7 +1020,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, // First generate the command and arguments std::vector 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 args = cmSystemTools::ParseArguments(command); - if (args.size() < 1) { + if (args.empty()) { return false; } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 2070b1f7f..162d98dde 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -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; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 93f9e498b..3086bb106 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -848,7 +848,7 @@ bool cmMakefileTargetGenerator::WriteMakeRule( const std::vector& commands, bool in_help) { bool symbolic = false; - if (outputs.size() == 0) { + if (outputs.empty()) { return symbolic; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 99d8569f5..44e76e770 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -702,7 +702,7 @@ bool cmSystemTools::RunSingleCommand(const char* command, std::vector args = cmSystemTools::ParseArguments(command); - if (args.size() < 1) { + if (args.empty()) { return false; } return cmSystemTools::RunSingleCommand(args, captureStdOut, captureStdErr,