Module: check_mk
Branch: master
Commit: 2627c10310405f392df3b113e1a4ea2865535f68
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2627c10310405f…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jul 28 13:16:46 2016 +0200
Fetched Livestatus from upstream.
---
livestatus/src/StringUtils.cc | 2 +-
livestatus/src/TableHostgroups.cc | 4 +---
livestatus/src/TableHosts.cc | 12 ++++++-----
livestatus/src/TableServicegroups.cc | 4 +---
livestatus/src/TableServices.cc | 39 +++++++++++++++++-----------------
5 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/livestatus/src/StringUtils.cc b/livestatus/src/StringUtils.cc
index 5d5f42a..bb19f0c 100644
--- a/livestatus/src/StringUtils.cc
+++ b/livestatus/src/StringUtils.cc
@@ -63,7 +63,7 @@ string strip(const string &str, const string &chars) {
}
std::pair<string, string> nextField(const string &str, const string &chars)
{
- auto s = lstrip(str);
+ auto s = lstrip(str, chars);
auto pos = s.find_first_of(chars);
return pos == string::npos ? make_pair(s, "")
: make_pair(s.substr(0, pos), s.substr(pos + 1));
diff --git a/livestatus/src/TableHostgroups.cc b/livestatus/src/TableHostgroups.cc
index 3eb42ca..5950adf 100644
--- a/livestatus/src/TableHostgroups.cc
+++ b/livestatus/src/TableHostgroups.cc
@@ -178,12 +178,10 @@ void TableHostgroups::addColumns(Table *table, string prefix,
}
void TableHostgroups::answerQuery(Query *query) {
- hostgroup *hg = hostgroup_list;
- while (hg != nullptr) {
+ for (hostgroup *hg = hostgroup_list; hg != nullptr; hg = hg->next) {
if (!query->processDataset(hg)) {
break;
}
- hg = hg->next;
}
}
diff --git a/livestatus/src/TableHosts.cc b/livestatus/src/TableHosts.cc
index 541cd08..4e1c429 100644
--- a/livestatus/src/TableHosts.cc
+++ b/livestatus/src/TableHosts.cc
@@ -697,11 +697,13 @@ void TableHosts::addColumns(Table *table, string prefix, int
indirect_offset,
void TableHosts::answerQuery(Query *query) {
// do we know the host group?
if (const string *value = query->findValueForIndexing("groups")) {
- hostgroup *hgroup = find_hostgroup(const_cast<char *>(value->c_str()));
- for (hostsmember *mem = hgroup->members; mem != nullptr;
- mem = mem->next) {
- if (!query->processDataset(mem->host_ptr)) {
- break;
+ if (hostgroup *hg =
+ find_hostgroup(const_cast<char *>(value->c_str()))) {
+ for (hostsmember *mem = hg->members; mem != nullptr;
+ mem = mem->next) {
+ if (!query->processDataset(mem->host_ptr)) {
+ break;
+ }
}
}
return;
diff --git a/livestatus/src/TableServicegroups.cc b/livestatus/src/TableServicegroups.cc
index b7478e6..e1f0a12 100644
--- a/livestatus/src/TableServicegroups.cc
+++ b/livestatus/src/TableServicegroups.cc
@@ -128,12 +128,10 @@ void TableServicegroups::addColumns(Table *table, string prefix,
}
void TableServicegroups::answerQuery(Query *query) {
- servicegroup *sg = servicegroup_list;
- while (sg != nullptr) {
+ for (servicegroup *sg = servicegroup_list; sg != nullptr; sg = sg->next) {
if (!query->processDataset(sg)) {
break;
}
- sg = sg->next;
}
}
diff --git a/livestatus/src/TableServices.cc b/livestatus/src/TableServices.cc
index 458a90a..3c514b1 100644
--- a/livestatus/src/TableServices.cc
+++ b/livestatus/src/TableServices.cc
@@ -489,25 +489,25 @@ void TableServices::answerQuery(Query *query) {
// do we know the host?
if (const string *value = query->findValueForIndexing("host_name")) {
// Older Nagios headers are not const-correct... :-P
- host *host = find_host(const_cast<char *>(value->c_str()));
- if (host == nullptr) {
- return;
- }
- for (servicesmember *m = host->services; m != nullptr; m = m->next) {
- if (!query->processDataset(m->service_ptr)) {
- break;
+ if (host *host = find_host(const_cast<char *>(value->c_str()))) {
+ for (servicesmember *m = host->services; m != nullptr;
+ m = m->next) {
+ if (!query->processDataset(m->service_ptr)) {
+ break;
+ }
}
+ return;
}
- return;
}
// do we know the service group?
if (const string *name = query->findValueForIndexing("groups")) {
- servicegroup *sgroup =
- find_servicegroup(const_cast<char *>(name->c_str()));
- for (servicesmember *m = sgroup->members; m != nullptr; m = m->next) {
- if (!query->processDataset(m->service_ptr)) {
- break;
+ if (servicegroup *sg =
+ find_servicegroup(const_cast<char *>(name->c_str()))) {
+ for (servicesmember *m = sg->members; m != nullptr; m = m->next) {
+ if (!query->processDataset(m->service_ptr)) {
+ break;
+ }
}
}
return;
@@ -515,12 +515,13 @@ void TableServices::answerQuery(Query *query) {
// do we know the host group?
if (const string *name = query->findValueForIndexing("host_groups")) {
- hostgroup *hgroup = find_hostgroup(const_cast<char *>(name->c_str()));
- for (hostsmember *m = hgroup->members; m != nullptr; m = m->next) {
- for (servicesmember *smem = m->host_ptr->services; smem != nullptr;
- smem = smem->next) {
- if (!query->processDataset(smem->service_ptr)) {
- break;
+ if (hostgroup *hg = find_hostgroup(const_cast<char *>(name->c_str())))
{
+ for (hostsmember *m = hg->members; m != nullptr; m = m->next) {
+ for (servicesmember *smem = m->host_ptr->services;
+ smem != nullptr; smem = smem->next) {
+ if (!query->processDataset(smem->service_ptr)) {
+ break;
+ }
}
}
}