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