From 35b7caf44fdb045e2e729cfbf6f84fde707985db Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Sun, 8 May 2011 19:53:41 -0500 Subject: [PATCH] Fix compile errors possible on some platforms. Include in some sources that require it; addresses #430 Places where STL's min() template function could get used with arguments of differing types can fail to deduce the right template type. These are fixed with some type tweaking of local variables and also giving an explicit template argument for good measure. --- src/ChunkedIO.cc | 6 ++++-- src/LogMgr.cc | 2 ++ src/RemoteSerializer.cc | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ChunkedIO.cc b/src/ChunkedIO.cc index 67cfe6dd25..9ca8f23508 100644 --- a/src/ChunkedIO.cc +++ b/src/ChunkedIO.cc @@ -9,6 +9,8 @@ #include #include +#include + #include "config.h" #include "ChunkedIO.h" #include "NetVar.h" @@ -166,13 +168,13 @@ bool ChunkedIOFd::Write(Chunk* chunk) // We have to split it up. char* p = chunk->data; - unsigned long left = chunk->len; + uint32 left = chunk->len; while ( left ) { Chunk* part = new Chunk; - part->len = min(BUFFER_SIZE - sizeof(uint32), left); + part->len = min(BUFFER_SIZE - sizeof(uint32), left); part->data = new char[part->len]; memcpy(part->data, p, part->len); left -= part->len; diff --git a/src/LogMgr.cc b/src/LogMgr.cc index 165f954dc4..834829591a 100644 --- a/src/LogMgr.cc +++ b/src/LogMgr.cc @@ -1,5 +1,7 @@ // See the file "COPYING" in the main distribution directory for copyright. +#include + #include "LogMgr.h" #include "Event.h" #include "EventHandler.h" diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index a471c603ef..6f33a33bca 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -173,6 +173,8 @@ #endif #include +#include + #include "RemoteSerializer.h" #include "Func.h" #include "EventRegistry.h" @@ -2394,12 +2396,12 @@ bool RemoteSerializer::SendPrintHookEvent(BroFile* f, const char* txt) if ( ! fname ) continue; // not a managed file. - long unsigned int len = strlen(txt); + size_t len = strlen(txt); // We cut off everything after the max buffer size. That // makes the code a bit easier, and we shouldn't have such // long lines anyway. - len = min(len, PRINT_BUFFER_SIZE - strlen(fname) - 2); + len = min(len, PRINT_BUFFER_SIZE - strlen(fname) - 2); // If there's not enough space in the buffer, flush it.