[icinga-checkins] icinga.org: icinga2/master: Use 'auto' keyword for iterator declarations ( part 2)

git at icinga.org git at icinga.org
Sat Aug 27 19:58:21 CEST 2016


Module: icinga2
Branch: master
Commit: e8b0797ec46e67bd7779dc1529ab9298f5418e4f
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=e8b0797ec46e67bd7779dc1529ab9298f5418e4f

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Sat Aug 27 19:56:12 2016 +0200

Use 'auto' keyword for iterator declarations (part 2)

refs #12561

---

 lib/base/configtype.cpp                 |    2 +-
 lib/base/dependencygraph.cpp            |    4 ++--
 lib/base/process.cpp                    |    8 +++-----
 lib/base/socketevents-epoll.cpp         |    2 +-
 lib/base/socketevents-poll.cpp          |    2 +-
 lib/base/timer.cpp                      |    2 +-
 lib/checker/checkercomponent.cpp        |    9 +++++----
 lib/cli/troubleshootcommand.cpp         |    4 ++--
 lib/config/applyrule.cpp                |    2 +-
 lib/icinga/comment.cpp                  |    2 +-
 lib/icinga/downtime.cpp                 |    2 +-
 lib/icinga/externalcommandprocessor.cpp |    3 +--
 lib/livestatus/table.cpp                |    2 +-
 lib/methods/clrchecktask.cpp            |    2 +-
 lib/remote/eventqueue.cpp               |    5 ++---
 lib/remote/url.cpp                      |    4 ++--
 16 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/lib/base/configtype.cpp b/lib/base/configtype.cpp
index 12877bf..b8008d5 100644
--- a/lib/base/configtype.cpp
+++ b/lib/base/configtype.cpp
@@ -45,7 +45,7 @@ void ConfigType::RegisterObject(const ConfigObject::Ptr& object)
 	{
 		boost::mutex::scoped_lock lock(m_Mutex);
 
-		ObjectMap::iterator it = m_ObjectMap.find(name);
+		auto it = m_ObjectMap.find(name);
 
 		if (it != m_ObjectMap.end()) {
 			if (it->second == object)
diff --git a/lib/base/dependencygraph.cpp b/lib/base/dependencygraph.cpp
index 9f8e563..9db6b28 100644
--- a/lib/base/dependencygraph.cpp
+++ b/lib/base/dependencygraph.cpp
@@ -34,8 +34,8 @@ void DependencyGraph::RemoveDependency(Object *parent, Object *child)
 {
 	boost::mutex::scoped_lock lock(m_Mutex);
 
-	std::map<Object *, int>& refs = m_Dependencies[child];
-	std::map<Object *, int>::iterator it = refs.find(parent);
+	auto& refs = m_Dependencies[child];
+	auto it = refs.find(parent);
 
 	if (it == refs.end())
 		return;
diff --git a/lib/base/process.cpp b/lib/base/process.cpp
index 1b1bb69..f29de86 100644
--- a/lib/base/process.cpp
+++ b/lib/base/process.cpp
@@ -260,17 +260,15 @@ void Process::IOThreadProc(int tid)
 #endif /* _WIN32 */
 
 			for (int i = 1; i < count; i++) {
-				std::map<ProcessHandle, Process::Ptr>::iterator it;
 #ifdef _WIN32
-				it = l_Processes[tid].find(handles[i]);
+				auto it = l_Processes[tid].find(handles[i]);
 #else /* _WIN32 */
-				std::map<ConsoleHandle, ProcessHandle>::iterator it2;
-				it2 = l_FDs[tid].find(pfds[i].fd);
+				auto it2 = l_FDs[tid].find(pfds[i].fd);
 
 				if (it2 == l_FDs[tid].end())
 					continue; /* This should never happen. */
 
-				it = l_Processes[tid].find(it2->second);
+				auto it = l_Processes[tid].find(it2->second);
 #endif /* _WIN32 */
 
 				if (it == l_Processes[tid].end())
diff --git a/lib/base/socketevents-epoll.cpp b/lib/base/socketevents-epoll.cpp
index bfb3910..7d626d9 100644
--- a/lib/base/socketevents-epoll.cpp
+++ b/lib/base/socketevents-epoll.cpp
@@ -193,7 +193,7 @@ void SocketEventEngineEpoll::ChangeEvents(SocketEvents *se, int events)
 	{
 		boost::mutex::scoped_lock lock(m_EventMutex[tid]);
 
-		std::map<SOCKET, SocketEventDescriptor>::iterator it = m_Sockets[tid].find(se->m_FD);
+		auto it = m_Sockets[tid].find(se->m_FD);
 
 		if (it == m_Sockets[tid].end())
 			return;
diff --git a/lib/base/socketevents-poll.cpp b/lib/base/socketevents-poll.cpp
index c1bcb1b..4e9e443 100644
--- a/lib/base/socketevents-poll.cpp
+++ b/lib/base/socketevents-poll.cpp
@@ -182,7 +182,7 @@ void SocketEventEnginePoll::ChangeEvents(SocketEvents *se, int events)
 	{
 		boost::mutex::scoped_lock lock(m_EventMutex[tid]);
 
-		std::map<SOCKET, SocketEventDescriptor>::iterator it = m_Sockets[tid].find(se->m_FD);
+		auto it = m_Sockets[tid].find(se->m_FD);
 
 		if (it == m_Sockets[tid].end())
 			return;
diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp
index 2555130..c7284ec 100644
--- a/lib/base/timer.cpp
+++ b/lib/base/timer.cpp
@@ -259,7 +259,7 @@ void Timer::TimerThreadProc(void)
 		if (l_StopTimerThread)
 			break;
 
-		NextTimerView::iterator it = idx.begin();
+		auto it = idx.begin();
 		Timer *timer = *it;
 
 		double wait = timer->m_Next - Utility::GetTime();
diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp
index b90d0a5..ac8da33 100644
--- a/lib/checker/checkercomponent.cpp
+++ b/lib/checker/checkercomponent.cpp
@@ -115,7 +115,7 @@ void CheckerComponent::CheckThreadProc(void)
 		if (m_Stopped)
 			break;
 
-		CheckTimeView::iterator it = idx.begin();
+		auto it = idx.begin();
 		CheckableScheduleInfo csi = *it;
 
 		double wait = csi.NextCheck - Utility::GetTime();
@@ -227,8 +227,8 @@ void CheckerComponent::ExecuteCheckHelper(const Checkable::Ptr& checkable)
 		/* remove the object from the list of pending objects; if it's not in the
 		 * list this was a manual (i.e. forced) check and we must not re-add the
 		 * object to the list because it's already there. */
-		CheckerComponent::CheckableSet::iterator it;
-		it = m_PendingCheckables.find(checkable);
+		auto it = m_PendingCheckables.find(checkable);
+
 		if (it != m_PendingCheckables.end()) {
 			m_PendingCheckables.erase(it);
 
@@ -300,7 +300,8 @@ void CheckerComponent::NextCheckChangedHandler(const Checkable::Ptr& checkable)
 	typedef boost::multi_index::nth_index<CheckableSet, 0>::type CheckableView;
 	CheckableView& idx = boost::get<0>(m_IdleCheckables);
 
-	CheckableView::iterator it = idx.find(checkable);
+	auto it = idx.find(checkable);
+
 	if (it == idx.end())
 		return;
 
diff --git a/lib/cli/troubleshootcommand.cpp b/lib/cli/troubleshootcommand.cpp
index d280b12..6c5f98b 100644
--- a/lib/cli/troubleshootcommand.cpp
+++ b/lib/cli/troubleshootcommand.cpp
@@ -593,9 +593,9 @@ void TroubleshootCommand::PrintObjectOrigin(InfoLog& log, const std::set<String>
 	InfoLogLine(log)
 	     << "The objects origins are:\n";
 
-	for (std::set<String>::iterator it = configSet.begin(); it != configSet.end(); it++) {
+	for (const String& config : configSet) {
 		InfoLogLine(log)
-		     << "  " << *it << '\n';
+		     << "  " << config << '\n';
 	}
 }
 
diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp
index b7bb72e..9201ae8 100644
--- a/lib/config/applyrule.cpp
+++ b/lib/config/applyrule.cpp
@@ -150,7 +150,7 @@ bool ApplyRule::HasMatches(void) const
 
 std::vector<ApplyRule>& ApplyRule::GetRules(const String& type)
 {
-	RuleMap::iterator it = m_Rules.find(type);
+	auto it = m_Rules.find(type);
 	if (it == m_Rules.end()) {
 		static std::vector<ApplyRule> emptyList;
 		return emptyList;
diff --git a/lib/icinga/comment.cpp b/lib/icinga/comment.cpp
index 380f298..eea6964 100644
--- a/lib/icinga/comment.cpp
+++ b/lib/icinga/comment.cpp
@@ -230,7 +230,7 @@ String Comment::GetCommentIDFromLegacyID(int id)
 {
 	boost::mutex::scoped_lock lock(l_CommentMutex);
 
-	std::map<int, String>::iterator it = l_LegacyCommentsCache.find(id);
+	auto it = l_LegacyCommentsCache.find(id);
 
 	if (it == l_LegacyCommentsCache.end())
 		return Empty;
diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp
index 6e75660..d69f6e5 100644
--- a/lib/icinga/downtime.cpp
+++ b/lib/icinga/downtime.cpp
@@ -363,7 +363,7 @@ String Downtime::GetDowntimeIDFromLegacyID(int id)
 {
 	boost::mutex::scoped_lock lock(l_DowntimeMutex);
 
-	std::map<int, String>::iterator it = l_LegacyDowntimesCache.find(id);
+	auto it = l_LegacyDowntimesCache.find(id);
 
 	if (it == l_LegacyDowntimesCache.end())
 		return Empty;
diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp
index 92d7dd8..9a67c0b 100644
--- a/lib/icinga/externalcommandprocessor.cpp
+++ b/lib/icinga/externalcommandprocessor.cpp
@@ -114,8 +114,7 @@ void ExternalCommandProcessor::Execute(double time, const String& command, const
 	{
 		boost::mutex::scoped_lock lock(GetMutex());
 
-		std::map<String, ExternalCommandInfo>::iterator it;
-		it = GetCommands().find(command);
+		auto it = GetCommands().find(command);
 
 		if (it == GetCommands().end())
 			BOOST_THROW_EXCEPTION(std::invalid_argument("The external command '" + command + "' does not exist."));
diff --git a/lib/livestatus/table.cpp b/lib/livestatus/table.cpp
index a128dda..62302e8 100644
--- a/lib/livestatus/table.cpp
+++ b/lib/livestatus/table.cpp
@@ -92,7 +92,7 @@ void Table::AddColumn(const String& name, const Column& column)
 {
 	std::pair<String, Column> item = std::make_pair(name, column);
 
-	std::pair<std::map<String, Column>::iterator, bool> ret = m_Columns.insert(item);
+	auto ret = m_Columns.insert(item);
 
 	if (!ret.second)
 		ret.first->second = column;
diff --git a/lib/methods/clrchecktask.cpp b/lib/methods/clrchecktask.cpp
index 6bc8ad1..64008b9 100644
--- a/lib/methods/clrchecktask.cpp
+++ b/lib/methods/clrchecktask.cpp
@@ -182,7 +182,7 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
 	{
 		boost::mutex::scoped_lock lock(l_ObjectsMutex);
 
-		std::map<Checkable::Ptr, variant_t>::iterator it = l_Objects.find(checkable);
+		auto it = l_Objects.find(checkable);
 
 		if (it != l_Objects.end()) {
 			vtObject = it->second;
diff --git a/lib/remote/eventqueue.cpp b/lib/remote/eventqueue.cpp
index 0e08265..0972770 100644
--- a/lib/remote/eventqueue.cpp
+++ b/lib/remote/eventqueue.cpp
@@ -61,8 +61,7 @@ void EventQueue::AddClient(void *client)
 {
 	boost::mutex::scoped_lock lock(m_Mutex);
 
-	typedef std::map<void *, std::deque<Dictionary::Ptr> >::iterator it_type;
-	std::pair<it_type, bool> result = m_Events.insert(std::make_pair(client, std::deque<Dictionary::Ptr>()));
+	auto result = m_Events.insert(std::make_pair(client, std::deque<Dictionary::Ptr>()));
 	ASSERT(result.second);
 }
 
@@ -99,7 +98,7 @@ Dictionary::Ptr EventQueue::WaitForEvent(void *client, double timeout)
 	boost::mutex::scoped_lock lock(m_Mutex);
 
 	for (;;) {
-		std::map<void *, std::deque<Dictionary::Ptr> >::iterator it = m_Events.find(client);
+		auto it = m_Events.find(client);
 		ASSERT(it != m_Events.end());
 
 		if (!it->second.empty()) {
diff --git a/lib/remote/url.cpp b/lib/remote/url.cpp
index a87aa06..78119f0 100644
--- a/lib/remote/url.cpp
+++ b/lib/remote/url.cpp
@@ -208,7 +208,7 @@ void Url::SetQuery(const std::map<String, std::vector<String> >& query)
 
 void Url::AddQueryElement(const String& name, const String& value)
 {
-	std::map<String, std::vector<String> >::iterator it = m_Query.find(name);
+	auto it = m_Query.find(name);
 	if (it == m_Query.end()) {
 		m_Query[name] = std::vector<String>();
 		m_Query[name].push_back(value);
@@ -395,7 +395,7 @@ bool Url::ParseQuery(const String& query)
 
 		key = Utility::UnescapeString(key);
 
-		std::map<String, std::vector<String> >::iterator it = m_Query.find(key);
+		auto it = m_Query.find(key);
 
 		if (it == m_Query.end()) {
 			m_Query[key] = std::vector<String>();



More information about the icinga-checkins mailing list