[icinga-checkins] icinga.org: icinga2/master: Fix cppcheck warnings.

git at icinga.org git at icinga.org
Wed Mar 6 15:41:54 CET 2013


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

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Mar  6 15:41:13 2013 +0100

Fix cppcheck warnings.

---

 components/compat/compatcomponent.cpp         |   13 -------------
 components/delegation/delegationcomponent.cpp |    8 ++------
 lib/base/dynamicobject.cpp                    |    6 +++---
 lib/config/configtype.cpp                     |    2 +-
 lib/icinga/externalcommandprocessor.cpp       |    2 +-
 lib/icinga/notification.cpp                   |    2 +-
 lib/icinga/service-comment.cpp                |    2 +-
 lib/icinga/service-downtime.cpp               |    2 +-
 lib/icinga/service-notification.cpp           |    2 +-
 lib/remoting/endpointmanager.cpp              |    2 +-
 10 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp
index ae02194..fa0c187 100644
--- a/components/compat/compatcomponent.cpp
+++ b/components/compat/compatcomponent.cpp
@@ -270,23 +270,10 @@ 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);
 
 	fp << "\t" << "}" << "\n"
diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp
index 10109d4..eb37f74 100644
--- a/components/delegation/delegationcomponent.cpp
+++ b/components/delegation/delegationcomponent.cpp
@@ -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>();
 
diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp
index df9c382..7cf332d 100644
--- a/lib/base/dynamicobject.cpp
+++ b/lib/base/dynamicobject.cpp
@@ -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;
 
diff --git a/lib/config/configtype.cpp b/lib/config/configtype.cpp
index 85234ef..669269c 100644
--- a/lib/config/configtype.cpp
+++ b/lib/config/configtype.cpp
@@ -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();
diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp
index c07494e..c908c5d 100644
--- a/lib/icinga/externalcommandprocessor.cpp
+++ b/lib/icinga/externalcommandprocessor.cpp
@@ -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());
diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp
index cd4d557..5e18cea 100644
--- a/lib/icinga/notification.cpp
+++ b/lib/icinga/notification.cpp
@@ -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());
 	}
diff --git a/lib/icinga/service-comment.cpp b/lib/icinga/service-comment.cpp
index f956954..823b850 100644
--- a/lib/icinga/service-comment.cpp
+++ b/lib/icinga/service-comment.cpp
@@ -277,7 +277,7 @@ void Service::RemoveExpiredComments(void)
 		}
 	}
 
-	if (expiredComments.size() > 0) {
+	if (!expiredComments.empty()) {
 		BOOST_FOREACH(const String& id, expiredComments) {
 			comments->Remove(id);
 		}
diff --git a/lib/icinga/service-downtime.cpp b/lib/icinga/service-downtime.cpp
index 96b5801..3d04336 100644
--- a/lib/icinga/service-downtime.cpp
+++ b/lib/icinga/service-downtime.cpp
@@ -350,7 +350,7 @@ void Service::RemoveExpiredDowntimes(void)
 		}
 	}
 
-	if (expiredDowntimes.size() > 0) {
+	if (!expiredDowntimes.empty()) {
 		BOOST_FOREACH(const String& id, expiredDowntimes) {
 			downtimes->Remove(id);
 		}
diff --git a/lib/icinga/service-notification.cpp b/lib/icinga/service-notification.cpp
index dc55f4e..23faac1 100644
--- a/lib/icinga/service-notification.cpp
+++ b/lib/icinga/service-notification.cpp
@@ -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) {
diff --git a/lib/remoting/endpointmanager.cpp b/lib/remoting/endpointmanager.cpp
index 41899ea..fc09b10 100644
--- a/lib/remoting/endpointmanager.cpp
+++ b/lib/remoting/endpointmanager.cpp
@@ -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);





More information about the icinga-checkins mailing list