]> granicus.if.org Git - icinga2/commitdiff
Use 'auto' keyword for iterator declarations (part 2)
authorGunnar Beutner <gunnar.beutner@netways.de>
Sat, 27 Aug 2016 17:56:12 +0000 (19:56 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Sat, 27 Aug 2016 17:56:12 +0000 (19:56 +0200)
refs #12561

16 files changed:
lib/base/configtype.cpp
lib/base/dependencygraph.cpp
lib/base/process.cpp
lib/base/socketevents-epoll.cpp
lib/base/socketevents-poll.cpp
lib/base/timer.cpp
lib/checker/checkercomponent.cpp
lib/cli/troubleshootcommand.cpp
lib/config/applyrule.cpp
lib/icinga/comment.cpp
lib/icinga/downtime.cpp
lib/icinga/externalcommandprocessor.cpp
lib/livestatus/table.cpp
lib/methods/clrchecktask.cpp
lib/remote/eventqueue.cpp
lib/remote/url.cpp

index 12877bfeb2394c51b14f1f8e9f1c8b163dbfd105..b8008d5b0f226732aa4c35e079855f619e55b3b1 100644 (file)
@@ -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)
index 9f8e563fa1adff5070a25180e31ee1da0aa525ae..9db6b28d3e64856dea0b453ea241844942df0723 100644 (file)
@@ -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;
index 1b1bb690b92da4685167a29fa7b7f662f832bc21..f29de86fe951f00a2499c8b763c1546cdcee830f 100644 (file)
@@ -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())
index bfb3910275a7fec428584d5050b699e3d4d971b1..7d626d944513485108900479277053aea8663c52 100644 (file)
@@ -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;
index c1bcb1bb8dfdbb4b09503c08c03f07dac8498525..4e9e443ad3a1d6698d095d6c2a8834078435a5fc 100644 (file)
@@ -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;
index 2555130c10ddbf3bd5250e9daa414a33994d083a..c7284ec3f73e52cfead046df288099dae0a459c0 100644 (file)
@@ -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();
index b90d0a526eea48c4629dc1dfcd0fd74a995afb52..ac8da330adcedb499f1b8e03272af480f16fcf11 100644 (file)
@@ -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;
 
index d280b12dc658c0633f33a3b6ac182e406f96056d..6c5f98bb2739597552fe0608d84877862b63c1d9 100644 (file)
@@ -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';
        }
 }
 
index b7bb72e08eb5fb0bcf5e0c960c08e708aae9a4ed..9201ae8e1068e7d89fe985975e3d3c381fd0dfa7 100644 (file)
@@ -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;
index 380f29886e607e1669c843f6ed94838b79cca9d8..eea6964ec6ecc0716391b6ee7b6c70f919d2c5af 100644 (file)
@@ -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;
index 6e75660055df8d4beca0ca16ceb521bf4268f60a..d69f6e5fb011b60a34f6c439c68ba94148d1e7f6 100644 (file)
@@ -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;
index 92d7dd8af83b176ee97e9e5ad405f0fadabd3296..9a67c0bdbb5bddc25139eff910f3ba9ba569e15e 100644 (file)
@@ -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."));
index a128dda22dd71b0274e3f85eb89960d08c78638b..62302e8fbdab4e27062fb6dd88265ec3bb425c10 100644 (file)
@@ -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;
index 6bc8ad1a64805d0272300adebdb04491ba15c114..64008b90b77ca78c18eb982fcdc5f110eadae84f 100644 (file)
@@ -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;
index 0e08265f50bb986a92e3c40067a874b3616f475a..09727700b3cbafcdc72d4f203e00aca0eba03aca 100644 (file)
@@ -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()) {
index a87aa062436a912e943c6ff13d28f1873b6e3dba..78119f0537d37778427661c4bc0c678941b6ed78 100644 (file)
@@ -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>();