Module: check_mk
Branch: master
Commit: 3525343bbcf7d5d57c19091e42c33ebb47eb152f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3525343bbcf7d5…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Oct 2 13:44:08 2017 +0200
A few more -Wshorten-64-to-32 fixes.
Change-Id: I07b4752c1f1c19b8c06d2be774739112877d839a
---
livestatus/src/DowntimeOrComment.cc | 4 ++--
livestatus/src/DowntimeOrComment.h | 2 ++
livestatus/src/InputBuffer.cc | 7 ++++---
livestatus/src/LogEntry.h | 2 +-
livestatus/src/Logfile.cc | 3 ++-
livestatus/src/Store.cc | 3 +--
6 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/livestatus/src/DowntimeOrComment.cc b/livestatus/src/DowntimeOrComment.cc
index 3dee1a7..32df461 100644
--- a/livestatus/src/DowntimeOrComment.cc
+++ b/livestatus/src/DowntimeOrComment.cc
@@ -44,8 +44,8 @@ Downtime::Downtime(nebstruct_downtime_struct *dt)
, _start_time(dt->start_time)
, _end_time(dt->end_time)
, _fixed(dt->fixed)
- , _duration(dt->duration)
- , _triggered_by(dt->triggered_by) {}
+ , _duration(static_cast<int>(dt->duration))
+ , _triggered_by(static_cast<int>(dt->triggered_by)) {}
Comment::Comment(nebstruct_comment_struct *co)
: DowntimeOrComment(reinterpret_cast<nebstruct_downtime_struct *>(co),
diff --git a/livestatus/src/DowntimeOrComment.h b/livestatus/src/DowntimeOrComment.h
index 70bf6bb..a647866 100644
--- a/livestatus/src/DowntimeOrComment.h
+++ b/livestatus/src/DowntimeOrComment.h
@@ -99,6 +99,8 @@ public:
time_t _start_time;
time_t _end_time;
int _fixed;
+ // TODO(sp): Wrong types, caused by TableDowntimes accessing it via
+ // OffsetIntColumn, should be unsigned long
int _duration;
int _triggered_by;
explicit Downtime(nebstruct_downtime_struct *dt);
diff --git a/livestatus/src/InputBuffer.cc b/livestatus/src/InputBuffer.cc
index ecc3a13..5ad9f7d 100644
--- a/livestatus/src/InputBuffer.cc
+++ b/livestatus/src/InputBuffer.cc
@@ -144,8 +144,9 @@ InputBuffer::Result InputBuffer::readRequest() {
// of the buffer's content is already processed. So we simply
// shift the yet unprocessed data to the very left of the buffer.
else if (_read_index > 0) {
- int shift_by = _read_index; // distance to beginning of buffer
- int size =
+ size_t shift_by =
+ _read_index; // distance to beginning of buffer
+ size_t size =
_write_index - _read_index; // amount of data to shift
memmove(&_readahead_buffer[0], &_readahead_buffer[_read_index],
size);
@@ -176,7 +177,7 @@ InputBuffer::Result InputBuffer::readRequest() {
return Result::request_read;
} // non-empty line: belongs to current request
- int length = r - _read_index;
+ size_t length = r - _read_index;
for (size_t end = r; end > _read_index &&
(isspace(_readahead_buffer[--end]) != 0);) {
length--;
diff --git a/livestatus/src/LogEntry.h b/livestatus/src/LogEntry.h
index 283a520..0d56ea7 100644
--- a/livestatus/src/LogEntry.h
+++ b/livestatus/src/LogEntry.h
@@ -78,7 +78,7 @@ public:
// TODO(sp): Wrong type, caused by TableLog accessing it via
// OffsetIntColumn, should be size_t
- int32_t _lineno; // line number in file
+ int _lineno; // line number in file
time_t _time;
Class _logclass;
LogEntryType _type;
diff --git a/livestatus/src/Logfile.cc b/livestatus/src/Logfile.cc
index f4a5159..515a1a8 100644
--- a/livestatus/src/Logfile.cc
+++ b/livestatus/src/Logfile.cc
@@ -151,7 +151,8 @@ void Logfile::loadRange(FILE *file, unsigned missing_types, LogCache
*logcache,
time_t since, time_t until, unsigned logclasses) {
vector<char> linebuffer(65536);
// TODO(sp) We should really use C++ I/O here...
- while (fgets(&linebuffer[0], linebuffer.size(), file) != nullptr) {
+ while (fgets(&linebuffer[0], static_cast<int>(linebuffer.size()), file) !=
+ nullptr) {
if (_lineno >= _mc->maxLinesPerLogFile()) {
Error(logger()) << "more than " <<
_mc->maxLinesPerLogFile()
<< " lines in " << _path <<
", ignoring the rest!";
diff --git a/livestatus/src/Store.cc b/livestatus/src/Store.cc
index b6bafc7..406c40b 100644
--- a/livestatus/src/Store.cc
+++ b/livestatus/src/Store.cc
@@ -195,8 +195,7 @@ bool Store::answerRequest(InputBuffer &input, OutputBuffer
&output) {
}
void Store::answerCommandRequest(const char *command) {
- int len = strlen(command);
- if (len < 14 || command[0] != '[' || command[11] != ']' ||
+ if (strlen(command) < 14 || command[0] != '[' || command[11] !=
']' ||
command[12] != ' ') {
Warning(logger()) << "Ignoring malformed command '" <<
command << "'";
return;