Fix compile errors possible on some platforms.

Include <algorithm> 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.
This commit is contained in:
Jon Siwek 2011-05-08 19:53:41 -05:00
parent cde6076857
commit 35b7caf44f
3 changed files with 10 additions and 4 deletions

View file

@ -9,6 +9,8 @@
#include <assert.h>
#include <openssl/ssl.h>
#include <algorithm>
#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<uint32>(BUFFER_SIZE - sizeof(uint32), left);
part->data = new char[part->len];
memcpy(part->data, p, part->len);
left -= part->len;

View file

@ -1,5 +1,7 @@
// See the file "COPYING" in the main distribution directory for copyright.
#include <algorithm>
#include "LogMgr.h"
#include "Event.h"
#include "EventHandler.h"

View file

@ -173,6 +173,8 @@
#endif
#include <sys/resource.h>
#include <algorithm>
#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<size_t>(len, PRINT_BUFFER_SIZE - strlen(fname) - 2);
// If there's not enough space in the buffer, flush it.