mirror of https://github.com/Icinga/icinga2.git
Fix cppcheck warnings.
This commit is contained in:
parent
6f7b553acd
commit
659fcf8fa3
|
@ -270,22 +270,9 @@ void CompatComponent::DumpHostStatus(ostream& fp, const Host::Ptr& host)
|
|||
fp << "hoststatus {" << "\n"
|
||||
<< "\t" << "host_name=" << host->GetName() << "\n";
|
||||
|
||||
ServiceState hcState = StateOK;
|
||||
|
||||
Service::Ptr hc = host->GetHostCheckService();
|
||||
ObjectLock olock(hc);
|
||||
|
||||
if (hc)
|
||||
hcState = hc->GetState();
|
||||
|
||||
int state;
|
||||
if (!host->IsReachable())
|
||||
state = 2; /* unreachable */
|
||||
else if (hcState != StateOK)
|
||||
state = 1; /* down */
|
||||
else
|
||||
state = 0; /* up */
|
||||
|
||||
if (hc)
|
||||
DumpServiceStatusAttrs(fp, hc, CompatTypeHost);
|
||||
|
||||
|
|
|
@ -104,8 +104,6 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
histogram[endpoint]++;
|
||||
}
|
||||
|
||||
//std::random_shuffle(services.begin(), services.end());
|
||||
|
||||
int delegated = 0;
|
||||
|
||||
/* re-assign services */
|
||||
|
@ -119,9 +117,7 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
int avg_services = 0, overflow_tolerance = 0;
|
||||
vector<Endpoint::Ptr>::iterator cit;
|
||||
|
||||
if (candidates.size() > 0) {
|
||||
//std::random_shuffle(candidates.begin(), candidates.end());
|
||||
|
||||
if (!candidates.empty()) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Service: " << service->GetName() << ", candidates: " << candidates.size();
|
||||
Logger::Write(LogDebug, "delegation", msgbuf.str());
|
||||
|
@ -176,7 +172,7 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
break;
|
||||
}
|
||||
|
||||
if (candidates.size() == 0) {
|
||||
if (candidates.empty()) {
|
||||
if (service->GetState() != StateUncheckable && service->GetEnableActiveChecks()) {
|
||||
Dictionary::Ptr cr = boost::make_shared<Dictionary>();
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ Dictionary::Ptr DynamicObject::BuildUpdate(double sinceTx, int attributeTypes) c
|
|||
{
|
||||
boost::mutex::scoped_lock lock(m_AttributeMutex);
|
||||
|
||||
for (it = m_Attributes.begin(); it != m_Attributes.end(); it++) {
|
||||
for (it = m_Attributes.begin(); it != m_Attributes.end(); ++it) {
|
||||
if (it->second.GetType() == Attribute_Transient)
|
||||
continue;
|
||||
|
||||
|
@ -132,7 +132,7 @@ void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate,
|
|||
|
||||
if (configTx > m_ConfigTx) {
|
||||
DynamicObject::AttributeIterator at;
|
||||
for (at = m_Attributes.begin(); at != m_Attributes.end(); at++) {
|
||||
for (at = m_Attributes.begin(); at != m_Attributes.end(); ++at) {
|
||||
if ((at->second.GetType() & Attribute_Config) == 0)
|
||||
continue;
|
||||
|
||||
|
@ -149,7 +149,7 @@ void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate,
|
|||
ObjectLock alock(attrs);
|
||||
|
||||
Dictionary::Iterator it;
|
||||
for (it = attrs->Begin(); it != attrs->End(); it++) {
|
||||
for (it = attrs->Begin(); it != attrs->End(); ++it) {
|
||||
if (!it->second.IsObjectType<Dictionary>())
|
||||
continue;
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ void ConfigType::ValidateDictionary(const Dictionary::Ptr& dictionary,
|
|||
else if (overallResult == ValidationInvalidType)
|
||||
ConfigCompilerContext::GetContext()->AddError(false, "Invalid type for attribute: " + LocationToString(locations));
|
||||
|
||||
if (subRuleLists.size() > 0 && value.IsObjectType<Dictionary>())
|
||||
if (!subRuleLists.empty() && value.IsObjectType<Dictionary>())
|
||||
ValidateDictionary(value, subRuleLists, locations);
|
||||
|
||||
locations.pop_back();
|
||||
|
|
|
@ -51,7 +51,7 @@ void ExternalCommandProcessor::Execute(const String& line)
|
|||
|
||||
vector<String> argv = args.Split(is_any_of(";"));
|
||||
|
||||
if (argv.size() == 0)
|
||||
if (argv.empty())
|
||||
BOOST_THROW_EXCEPTION(invalid_argument("Missing arguments in command: " + line));
|
||||
|
||||
vector<String> argvExtra(argv.begin() + 1, argv.end());
|
||||
|
|
|
@ -209,7 +209,7 @@ void Notification::BeginExecuteNotification(NotificationType type)
|
|||
BeginExecuteNotificationHelper(macros, type, user);
|
||||
}
|
||||
|
||||
if (allUsers.size() == 0) {
|
||||
if (allUsers.empty()) {
|
||||
/* Send a notification even if there are no users specified. */
|
||||
BeginExecuteNotificationHelper(macros, type, User::Ptr());
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ void Service::RemoveExpiredComments(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (expiredComments.size() > 0) {
|
||||
if (!expiredComments.empty()) {
|
||||
BOOST_FOREACH(const String& id, expiredComments) {
|
||||
comments->Remove(id);
|
||||
}
|
||||
|
|
|
@ -350,7 +350,7 @@ void Service::RemoveExpiredDowntimes(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (expiredDowntimes.size() > 0) {
|
||||
if (!expiredDowntimes.empty()) {
|
||||
BOOST_FOREACH(const String& id, expiredDowntimes) {
|
||||
downtimes->Remove(id);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ void Service::SendNotifications(NotificationType type)
|
|||
|
||||
set<Notification::Ptr> notifications = GetNotifications();
|
||||
|
||||
if (notifications.size() == 0)
|
||||
if (notifications.empty())
|
||||
Logger::Write(LogInformation, "icinga", "Service '" + GetName() + "' does not have any notifications.");
|
||||
|
||||
BOOST_FOREACH(const Notification::Ptr& notification, notifications) {
|
||||
|
|
|
@ -397,7 +397,7 @@ void EndpointManager::RequestTimerHandler(void)
|
|||
ObjectLock olock(this);
|
||||
|
||||
map<String, PendingRequest>::iterator it;
|
||||
for (it = m_Requests.begin(); it != m_Requests.end(); it++) {
|
||||
for (it = m_Requests.begin(); it != m_Requests.end(); ++it) {
|
||||
if (it->second.HasTimedOut()) {
|
||||
it->second.Callback(GetSelf(), Endpoint::Ptr(),
|
||||
it->second.Request, ResponseMessage(), true);
|
||||
|
|
Loading…
Reference in New Issue