mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 06:34:42 +02:00
Fix compiler warnings by not unnecessarily (copy-)constructing loop variables
This commit is contained in:
parent
c2ddd20ef3
commit
22e75f08fa
@ -643,8 +643,7 @@ void Process::IOThreadProc(int tid)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
int i = 1;
|
||||
typedef std::pair<ProcessHandle, Process::Ptr> kv_pair;
|
||||
for (const kv_pair& kv : l_Processes[tid]) {
|
||||
for (auto& kv : l_Processes[tid]) {
|
||||
const Process::Ptr& process = kv.second;
|
||||
#ifdef _WIN32
|
||||
handles[i] = kv.first;
|
||||
|
@ -58,7 +58,7 @@ int FeatureUtility::EnableFeatures(const std::vector<std::string>& features)
|
||||
|
||||
std::vector<std::string> errors;
|
||||
|
||||
for (const String& feature : features) {
|
||||
for (auto& feature : features) {
|
||||
String source = features_available_dir + "/" + feature + ".conf";
|
||||
|
||||
if (!Utility::PathExists(source) ) {
|
||||
@ -126,7 +126,7 @@ int FeatureUtility::DisableFeatures(const std::vector<std::string>& features)
|
||||
|
||||
std::vector<std::string> errors;
|
||||
|
||||
for (const String& feature : features) {
|
||||
for (auto& feature : features) {
|
||||
String target = features_enabled_dir + "/" + feature + ".conf";
|
||||
|
||||
if (!Utility::PathExists(target) ) {
|
||||
|
@ -88,8 +88,7 @@ std::vector<Service::Ptr> Host::GetServices() const
|
||||
|
||||
std::vector<Service::Ptr> services;
|
||||
services.reserve(m_Services.size());
|
||||
typedef std::pair<String, Service::Ptr> ServicePair;
|
||||
for (const ServicePair& kv : m_Services) {
|
||||
for (auto& kv : m_Services) {
|
||||
services.push_back(kv.second);
|
||||
}
|
||||
|
||||
|
@ -643,8 +643,7 @@ String Notification::NotificationFilterToString(int filter, const std::map<Strin
|
||||
{
|
||||
std::vector<String> sFilters;
|
||||
|
||||
typedef std::pair<String, int> kv_pair;
|
||||
for (const kv_pair& kv : filterMap) {
|
||||
for (auto& kv : filterMap) {
|
||||
if (filter & kv.second)
|
||||
sFilters.push_back(kv.first);
|
||||
}
|
||||
|
@ -42,17 +42,17 @@ String CommandsTable::GetPrefix() const
|
||||
|
||||
void CommandsTable::FetchRows(const AddRowFunction& addRowFn)
|
||||
{
|
||||
for (const ConfigObject::Ptr& object : ConfigType::GetObjectsByType<CheckCommand>()) {
|
||||
for (auto& object : ConfigType::GetObjectsByType<CheckCommand>()) {
|
||||
if (!addRowFn(object, LivestatusGroupByNone, Empty))
|
||||
return;
|
||||
}
|
||||
|
||||
for (const ConfigObject::Ptr& object : ConfigType::GetObjectsByType<EventCommand>()) {
|
||||
for (auto& object : ConfigType::GetObjectsByType<EventCommand>()) {
|
||||
if (!addRowFn(object, LivestatusGroupByNone, Empty))
|
||||
return;
|
||||
}
|
||||
|
||||
for (const ConfigObject::Ptr& object : ConfigType::GetObjectsByType<NotificationCommand>()) {
|
||||
for (auto& object : ConfigType::GetObjectsByType<NotificationCommand>()) {
|
||||
if (!addRowFn(object, LivestatusGroupByNone, Empty))
|
||||
return;
|
||||
}
|
||||
|
@ -376,8 +376,8 @@ void OpenTsdbWriter::SendMetric(const Checkable::Ptr& checkable, const String& m
|
||||
{
|
||||
String tags_string = "";
|
||||
|
||||
for (const Dictionary::Pair& tag : tags) {
|
||||
tags_string += " " + tag.first + "=" + Convert::ToString(tag.second);
|
||||
for (auto& tag : tags) {
|
||||
tags_string += " " + tag.first + "=" + tag.second;
|
||||
}
|
||||
|
||||
std::ostringstream msgbuf;
|
||||
|
@ -133,7 +133,7 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
|
||||
<< "Could not create object '" << objName << "':";
|
||||
|
||||
ObjectLock olock(errors);
|
||||
for (const String& error : errors) {
|
||||
for (auto& error : errors) {
|
||||
Log(LogCritical, "ApiListener", error);
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
|
||||
Log(LogCritical, "ApiListener", "Could not delete object:");
|
||||
|
||||
ObjectLock olock(errors);
|
||||
for (const String& error : errors) {
|
||||
for (auto& error : errors) {
|
||||
Log(LogCritical, "ApiListener", error);
|
||||
}
|
||||
}
|
||||
|
@ -32,9 +32,7 @@ static void ScriptFrameCleanupHandler()
|
||||
|
||||
std::vector<String> cleanup_keys;
|
||||
|
||||
typedef std::pair<String, ApiScriptFrame> KVPair;
|
||||
|
||||
for (const KVPair& kv : l_ApiScriptFrames) {
|
||||
for (auto& kv : l_ApiScriptFrames) {
|
||||
if (kv.second.Seen < Utility::GetTime() - 1800)
|
||||
cleanup_keys.push_back(kv.first);
|
||||
}
|
||||
|
@ -44,8 +44,7 @@ void EventQueue::ProcessEvent(const Dictionary::Ptr& event)
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_Mutex);
|
||||
|
||||
typedef std::pair<void *const, std::deque<Dictionary::Ptr> > kv_pair;
|
||||
for (kv_pair& kv : m_Events) {
|
||||
for (auto& kv : m_Events) {
|
||||
kv.second.push_back(event);
|
||||
}
|
||||
|
||||
@ -108,8 +107,7 @@ std::vector<EventQueue::Ptr> EventQueue::GetQueuesForType(const String& type)
|
||||
|
||||
std::vector<EventQueue::Ptr> availQueues;
|
||||
|
||||
typedef std::pair<String, EventQueue::Ptr> kv_pair;
|
||||
for (const kv_pair& kv : queues) {
|
||||
for (auto& kv : queues) {
|
||||
if (kv.second->CanProcessEvent(type))
|
||||
availQueues.push_back(kv.second);
|
||||
}
|
||||
|
@ -902,7 +902,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||
if (field.Type.ArrayRank > 0) {
|
||||
m_Impl << "\t" << "if (oldValue) {" << std::endl
|
||||
<< "\t\t" << "ObjectLock olock(oldValue);" << std::endl
|
||||
<< "\t\t" << "for (const String& ref : oldValue) {" << std::endl
|
||||
<< "\t\t" << "for (auto& ref : oldValue) {" << std::endl
|
||||
<< "\t\t\tDependencyGraph::RemoveDependency(";
|
||||
|
||||
/* Ew */
|
||||
@ -916,7 +916,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||
<< "\t" << "}" << std::endl
|
||||
<< "\t" << "if (newValue) {" << std::endl
|
||||
<< "\t\t" << "ObjectLock olock(newValue);" << std::endl
|
||||
<< "\t\t" << "for (const String& ref : newValue) {" << std::endl
|
||||
<< "\t\t" << "for (auto& ref : newValue) {" << std::endl
|
||||
<< "\t\t\tDependencyGraph::AddDependency(";
|
||||
|
||||
/* Ew */
|
||||
|
Loading…
x
Reference in New Issue
Block a user