Module: check_mk
Branch: master
Commit: f9ce41b949112c6b01a4943029932236284bd6d2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f9ce41b949112c…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Nov 9 13:03:29 2015 +0100
Enabled format string checks. Fixed the resulting warnings.
Special note: POSIX doesn't even require pthread_t to be an arithmetic type
anymore!
---
livestatus/src/AndingFilter.cc | 5 +++--
livestatus/src/Logfile.cc | 6 ++++--
livestatus/src/Query.cc | 2 +-
livestatus/src/TableDownComm.cc | 2 +-
livestatus/src/logger.h | 2 +-
livestatus/src/module.c | 2 +-
6 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/livestatus/src/AndingFilter.cc b/livestatus/src/AndingFilter.cc
index 416bbc0..568dc16 100644
--- a/livestatus/src/AndingFilter.cc
+++ b/livestatus/src/AndingFilter.cc
@@ -23,6 +23,7 @@
// Boston, MA 02110-1301 USA.
#include "AndingFilter.h"
+#include <inttypes.h>
#include "OringFilter.h"
#include "Query.h"
#include "logger.h"
@@ -111,8 +112,8 @@ bool AndingFilter::optimizeBitmask(const char *columnname, uint32_t
*mask)
void AndingFilter::combineFilters(int count, int andor)
{
if (count > (int)_subfilters.size()) {
- logger(LG_INFO, "Cannot combine %d filters with '%s': only %d are on
stack",
- count, andor == ANDOR_AND ? "AND" : "OR",
_subfilters.size());
+ logger(LG_INFO, "Cannot combine %d filters with '%s': only %"
PRIuMAX " are on stack",
+ count, andor == ANDOR_AND ? "AND" : "OR",
static_cast<uintmax_t>(_subfilters.size()));
return;
}
diff --git a/livestatus/src/Logfile.cc b/livestatus/src/Logfile.cc
index 93baa4c..45547b8 100644
--- a/livestatus/src/Logfile.cc
+++ b/livestatus/src/Logfile.cc
@@ -25,6 +25,7 @@
#include "Logfile.h"
#include <errno.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
@@ -157,7 +158,7 @@ void Logfile::loadRange(FILE *file, unsigned missing_types,
while (fgets(_linebuffer, MAX_LOGLINE, file))
{
if (_lineno >= g_max_lines_per_logfile) {
- logger(LG_ERR, "More than %u lines in %s. Ignoring the rest!",
g_max_lines_per_logfile, this->_path);
+ logger(LG_ERR, "More than %lu lines in %s. Ignoring the rest!",
g_max_lines_per_logfile, this->_path);
return;
}
_lineno++;
@@ -315,7 +316,8 @@ char *Logfile::readIntoBuffer(int *size)
return 0;
}
else if (r != *size) {
- logger(LOG_WARNING, "Read only %d out of %d bytes from %s", r, *size,
_path);
+ logger(LOG_WARNING, "Read only %" PRIdMAX " out of %d bytes from
%s",
+ static_cast<intmax_t>(r), *size, _path);
free(buffer);
close(fd);
return 0;
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 47946ff..50a4e96 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -865,7 +865,7 @@ bool Query::timelimitReached()
bool Query::processDataset(void *data)
{
if (_output->size() > g_max_response_size) {
- logger(LG_INFO, "Maximum response size of %d bytes exceeded!",
g_max_response_size);
+ logger(LG_INFO, "Maximum response size of %lu bytes exceeded!",
g_max_response_size);
// _output->setError(RESPONSE_CODE_LIMIT_EXCEEDED, "Maximum response size
of %d reached", g_max_response_size);
// currently we only log an error into the log file and do
// not abort the query. We handle it like Limit:
diff --git a/livestatus/src/TableDownComm.cc b/livestatus/src/TableDownComm.cc
index 0ab1509..bfcca21 100644
--- a/livestatus/src/TableDownComm.cc
+++ b/livestatus/src/TableDownComm.cc
@@ -145,7 +145,7 @@ void TableDownComm::remove(DowntimeOrComment *data)
dc_key tmp_key = make_pair(data->_id, data->_service != 0);
_entries_t::iterator it = _entries.find(tmp_key);
if (it == _entries.end())
- logger(LG_INFO, "Cannot delete non-existing downtime/comment %u",
data->_id);
+ logger(LG_INFO, "Cannot delete non-existing downtime/comment %lu",
data->_id);
else {
delete it->second;
_entries.erase(it);
diff --git a/livestatus/src/logger.h b/livestatus/src/logger.h
index b2129c9..a7ec3dd 100644
--- a/livestatus/src/logger.h
+++ b/livestatus/src/logger.h
@@ -50,7 +50,7 @@
extern "C" {
#endif
-void logger(int priority, const char *loginfo, ...);
+void logger(int priority, const char *loginfo, ...) __attribute__ ((format (printf, 2,
3)));
void open_logfile();
void close_logfile();
diff --git a/livestatus/src/module.c b/livestatus/src/module.c
index 55489bc..6f744f7 100644
--- a/livestatus/src/module.c
+++ b/livestatus/src/module.c
@@ -291,7 +291,7 @@ void terminate_threads()
int t;
for (t=0; t < g_num_clientthreads; t++) {
if (0 != pthread_join(g_clientthread_id[t], NULL))
- logger(LG_INFO, "Warning: could not join thread %p",
g_clientthread_id[t]);
+ logger(LG_INFO, "Warning: could not join thread no. %d", t);
}
if (g_debug_level > 0)
logger(LG_INFO, "Main thread + %d client threads have finished",
g_num_clientthreads);