Module: check_mk
Branch: master
Commit: 7175f07842bb933b644b3506d740eb2cb6ed0e0c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7175f07842bb93…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Feb 4 16:18:23 2016 +0100
Some clang-tidy aftermath for cmc.
There are lots of code paths in check_mk which are only visible in cmc. We
should really change to git submodules plus subclassing... :-/
---
livestatus/src/AttributelistColumn.cc | 4 +++-
livestatus/src/DownCommColumn.cc | 5 ++---
livestatus/src/Logfile.cc | 13 ++++++-------
livestatus/src/TableLog.cc | 2 +-
livestatus/src/TableStateHistory.cc | 7 ++++---
5 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/livestatus/src/AttributelistColumn.cc
b/livestatus/src/AttributelistColumn.cc
index 7fa403b..2d060f1 100644
--- a/livestatus/src/AttributelistColumn.cc
+++ b/livestatus/src/AttributelistColumn.cc
@@ -67,8 +67,10 @@ unsigned long AttributelistColumn::getValue(void *data) {
return 0;
}
+// TODO(sp) Why on earth do we have different types here?
#ifdef CMC
- return *(uint16_t *)((char *)data + _offset);
+ return *reinterpret_cast<uint16_t *>(reinterpret_cast<char *>(data) +
+ _offset);
#else
return *reinterpret_cast<unsigned long *>(reinterpret_cast<char *>(data)
+
_offset);
diff --git a/livestatus/src/DownCommColumn.cc b/livestatus/src/DownCommColumn.cc
index c13e637..11a1146 100644
--- a/livestatus/src/DownCommColumn.cc
+++ b/livestatus/src/DownCommColumn.cc
@@ -93,9 +93,8 @@ void DownCommColumn::output(void *data, Query *query) {
}
void *DownCommColumn::getNagiosObject(char *name) {
- unsigned long id = strtoul(name, nullptr, 10);
- return reinterpret_cast<void *>(
- static_cast<uintptr_t>(id)); // Hack. Convert number into pointer.
+ // Hack. Convert number into pointer.
+ return static_cast<char *>(nullptr) + strtoul(name, nullptr, 10);
}
bool DownCommColumn::isNagiosMember(void *data, void *member) {
diff --git a/livestatus/src/Logfile.cc b/livestatus/src/Logfile.cc
index 31bf813..51ea0b4 100644
--- a/livestatus/src/Logfile.cc
+++ b/livestatus/src/Logfile.cc
@@ -47,9 +47,8 @@ using std::make_pair;
extern unsigned long g_max_lines_per_logfile;
// TODO(sp): We need the suppression pragma below because _readpos and
-// _linebuffer
-// is not initialized in the constructor. Just replace all this manual fiddling
-// with pointers, offsets, etc. with vector.
+// _linebuffer is not initialized in the constructor. Just replace all this
+// manual fiddling with pointers, offsets, etc. with vector.
// cppcheck-suppress uninitMemberVar
Logfile::Logfile(const char *path, bool watch)
@@ -58,7 +57,7 @@ Logfile::Logfile(const char *path, bool watch)
, _watch(watch)
, _lineno(0)
#ifdef CMC
- , _world(0)
+ , _world(nullptr)
#endif
, _logclasses_read(0) {
int fd = open(path, O_RDONLY);
@@ -277,9 +276,9 @@ void Logfile::updateReferences() {
// active configuration world, then update all references
if (_world != g_live_world) {
unsigned num = 0;
- for (logfile_entries_t::iterator it = _entries.begin();
- it != _entries.end(); ++it)
- num += it->second->updateReferences();
+ for (auto &entry : _entries) {
+ num += entry.second->updateReferences();
+ }
logger(LOG_NOTICE,
"Updated %u log cache references of %s to new world.", num,
_path);
diff --git a/livestatus/src/TableLog.cc b/livestatus/src/TableLog.cc
index 7547fbe..5124a39 100644
--- a/livestatus/src/TableLog.cc
+++ b/livestatus/src/TableLog.cc
@@ -228,7 +228,7 @@ bool TableLog::isAuthorized(contact *ctc, void *data) {
host *hst = entry->_host;
if ((hst != nullptr) || (svc != nullptr)) {
- return is_authorized_for(ctc, hst, svc) != 0;
+ return static_cast<int>(is_authorized_for(ctc, hst, svc)) != 0;
// suppress entries for messages that belong to
// hosts that do not exist anymore.
}
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 2984171..f8cf455 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -476,8 +476,9 @@ void TableStateHistory::answerQuery(Query *query) {
state->_service = entry->_service;
#ifdef CMC
state->_host_name = entry->_host->_name;
- state->_service_description =
- entry->_service != 0 ? entry->_service->_name :
"";
+ state->_service_description = entry->_service != nullptr
+ ? entry->_service->_name
+ : "";
#else
state->_host_name = entry->_host->name;
state->_service_description =
@@ -993,7 +994,7 @@ bool TableStateHistory::isAuthorized(contact *ctc, void *data) {
host *hst = entry->_host;
if ((hst != nullptr) || (svc != nullptr)) {
- return is_authorized_for(ctc, hst, svc) != 0;
+ return static_cast<int>(is_authorized_for(ctc, hst, svc)) != 0;
}
return false;
}