Module: check_mk
Branch: master
Commit: fd39f66fb7c3605541d4c8244af66cc4db361625
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fd39f66fb7c360…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed May 18 10:28:55 2016 +0200
Make cppcheck happy again.
These are the minimal changes to make cppcheck happy again so we can put
this into our CI. Note that all those '#ifdef CMC' are an ugly temporary
measure only and should vanish when our repos/classes have the right
structure.
---
Makefile | 2 +-
livestatus/src/HostServiceState.cc | 2 ++
livestatus/src/HostServiceState.h | 3 ++-
livestatus/src/LogCache.cc | 2 ++
livestatus/src/LogCache.h | 2 ++
livestatus/src/LogEntry.cc | 4 ++--
livestatus/src/Logfile.cc | 2 ++
livestatus/src/Logfile.h | 2 ++
livestatus/src/pnp4nagios.cc | 2 ++
livestatus/src/pnp4nagios.h | 2 ++
10 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 7aca4bd..9d34062 100644
--- a/Makefile
+++ b/Makefile
@@ -293,7 +293,7 @@ analyze:
cd livestatus && $(SCAN_BUILD) -o ../clang-analyzer $(MAKE)
CXXFLAGS="-std=c++14"
cppcheck:
- $(CPPCHECK) --quiet --enable=all --max-configs=20 --inline-suppr --template=gcc -I
livestatus/src -I livestatus livestatus
+ $(CPPCHECK) --quiet --enable=all -UCMC --max-configs=20 --inline-suppr --template=gcc -I
livestatus/src -I livestatus livestatus
# TODO: We should probably handle this rule via AM_EXTRA_RECURSIVE_TARGETS in
# src/configure.ac, but this needs at least automake-1.13, which in turn is only
diff --git a/livestatus/src/HostServiceState.cc b/livestatus/src/HostServiceState.cc
index 6225fa7..be10da2 100644
--- a/livestatus/src/HostServiceState.cc
+++ b/livestatus/src/HostServiceState.cc
@@ -31,6 +31,7 @@ HostServiceState::~HostServiceState() {
}
}
+#ifdef CMC
void HostServiceState::computePerStateDurations() {
_duration_state_UNMONITORED = 0;
_duration_part_UNMONITORED = 0;
@@ -66,3 +67,4 @@ void HostServiceState::computePerStateDurations() {
break;
}
}
+#endif
diff --git a/livestatus/src/HostServiceState.h b/livestatus/src/HostServiceState.h
index 556496a..9ae14e6 100644
--- a/livestatus/src/HostServiceState.h
+++ b/livestatus/src/HostServiceState.h
@@ -95,8 +95,9 @@ struct HostServiceState {
HostServiceState() { bzero(this, sizeof(HostServiceState)); }
~HostServiceState();
+#ifdef CMC
void computePerStateDurations();
- void debug_me(const char *loginfo, ...);
+#endif
};
#endif // HostServiceState_h
diff --git a/livestatus/src/LogCache.cc b/livestatus/src/LogCache.cc
index 4f00e80..8c93a12 100644
--- a/livestatus/src/LogCache.cc
+++ b/livestatus/src/LogCache.cc
@@ -81,12 +81,14 @@ LogCache::LogCache(const CommandsHolder &commands_holder,
updateLogfileIndex();
}
+#ifdef CMC
void LogCache::setMaxCachedMessages(unsigned long m) {
if (m != _max_cached_messages) {
logger(LOG_NOTICE, "Logfile cache: Changing max messages to %ld", m);
_max_cached_messages = m;
}
}
+#endif
LogCache::~LogCache() { forgetLogfiles(); }
diff --git a/livestatus/src/LogCache.h b/livestatus/src/LogCache.h
index 28c2aa7..778f3fa 100644
--- a/livestatus/src/LogCache.h
+++ b/livestatus/src/LogCache.h
@@ -51,7 +51,9 @@ public:
LogCache(const CommandsHolder &commands_holder,
unsigned long max_cached_messages);
~LogCache();
+#ifdef CMC
void setMaxCachedMessages(unsigned long m);
+#endif
time_t _last_index_update;
const char *name() { return "log"; }
diff --git a/livestatus/src/LogEntry.cc b/livestatus/src/LogEntry.cc
index 14602d9..6f63f4c 100644
--- a/livestatus/src/LogEntry.cc
+++ b/livestatus/src/LogEntry.cc
@@ -28,11 +28,11 @@
#include "strutil.h"
LogEntry::LogEntry(const CommandsHolder &commands_holder, unsigned lineno,
- char *line) {
+ char *line)
+ : _type(NONE) {
// TODO(sp) Fix all handleFooEntry() member functions below to always set
// all fields and remove this set-me-to-zero-to-be-sure-block.
_logclass = LOGCLASS_INFO;
- _type = NONE;
_host_name = nullptr;
_svc_desc = nullptr;
_command_name = nullptr;
diff --git a/livestatus/src/Logfile.cc b/livestatus/src/Logfile.cc
index 6755f9f..e80714a 100644
--- a/livestatus/src/Logfile.cc
+++ b/livestatus/src/Logfile.cc
@@ -287,6 +287,7 @@ void Logfile::updateReferences() {
#endif
}
+#ifdef CMC
// Read complete file into newly allocated buffer. Returns a pointer
// to a malloced buffer, that the caller must free (or 0, in case of
// an error). The buffer is 2 bytes larger then the file. One byte
@@ -340,3 +341,4 @@ char *Logfile::readIntoBuffer(int *size) {
close(fd);
return buffer;
}
+#endif
diff --git a/livestatus/src/Logfile.h b/livestatus/src/Logfile.h
index fc1402a..d450803 100644
--- a/livestatus/src/Logfile.h
+++ b/livestatus/src/Logfile.h
@@ -65,7 +65,9 @@ public:
~Logfile();
char *path() { return _path; }
+#ifdef CMC
char *readIntoBuffer(int *size);
+#endif
void load(LogCache *logcache, time_t since, time_t until,
unsigned logclasses);
void flush();
diff --git a/livestatus/src/pnp4nagios.cc b/livestatus/src/pnp4nagios.cc
index c37a8f7..c687b32 100644
--- a/livestatus/src/pnp4nagios.cc
+++ b/livestatus/src/pnp4nagios.cc
@@ -62,6 +62,7 @@ int pnpgraph_present(const string& host, const string& service)
{
return access(path.c_str(), R_OK) == 0 ? 1 : 0;
}
+#ifdef CMC
string rrd_path(const string& host, const string& service,
const string& varname) {
string pnp_path(g_pnp_path);
@@ -78,3 +79,4 @@ string rrd_path(const string& host, const string& service,
struct stat st;
return stat(path.c_str(), &st) == 0 ? path : "";
}
+#endif
diff --git a/livestatus/src/pnp4nagios.h b/livestatus/src/pnp4nagios.h
index 89f6fb3..e3b4855 100644
--- a/livestatus/src/pnp4nagios.h
+++ b/livestatus/src/pnp4nagios.h
@@ -33,10 +33,12 @@ std::string pnp_cleanup(const std::string& name);
int pnpgraph_present(const std::string& host,
const std::string& service = "_HOST_");
+#ifdef CMC
// Determines if a RRD database exists and returns its path name. Returns an
// empty string otherwise. This assumes paths created in the PNP4Nagios style
// with storage type MULTIPLE.
std::string rrd_path(const std::string& host, const std::string& service,
const std::string& varname);
+#endif
#endif // pnp4nagios_h