Merge remote branch 'origin/topic/seth/fix-compiler-warnings'

* origin/topic/seth/fix-compiler-warnings:
  Fixed problem with PRI macros.
  PRI macros are currently not working for some reason.
  Two more small compile time error fixes.
  Cleaned up the output from running binpac.
  Added line to expect shift/reduce errors in parse.in
  Cleaned up g++ warnings.

Addition: I fixed a few more warnings I was getting, and tweaked some
of the existing changes slightly.
This commit is contained in:
Robin Sommer 2011-02-08 21:24:23 -08:00
commit 2f7fa3470b
16 changed files with 58 additions and 44 deletions

View file

@ -1,3 +1,7 @@
1.6-dev.45 Tue Feb 8 21:28:01 PST 2011
- Fixing a number of compiler warnings. (Seth Hall and Robin Sommer)
1.6-dev.44 Tue Feb 8 20:11:44 PST 2011 1.6-dev.44 Tue Feb 8 20:11:44 PST 2011
- A number of updates to the SSL analyzer, including support for new - A number of updates to the SSL analyzer, including support for new

View file

@ -1 +1 @@
1.6-dev.44 1.6-dev.45

View file

@ -160,7 +160,7 @@ macro(BINPAC_TARGET pacFile)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.h add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.h
${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.cc ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.cc
COMMAND ${BinPAC_EXE} COMMAND ${BinPAC_EXE}
ARGS -d ${CMAKE_CURRENT_BINARY_DIR} ARGS -q -d ${CMAKE_CURRENT_BINARY_DIR}
-I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${pacFile} ${CMAKE_CURRENT_SOURCE_DIR}/${pacFile}
DEPENDS ${BinPAC_EXE} ${pacFile} DEPENDS ${BinPAC_EXE} ${pacFile}
@ -177,9 +177,9 @@ binpac_target(binpac_bro-lib.pac)
binpac_target(bittorrent.pac binpac_target(bittorrent.pac
bittorrent-protocol.pac bittorrent-analyzer.pac) bittorrent-protocol.pac bittorrent-analyzer.pac)
binpac_target(dce_rpc.pac binpac_target(dce_rpc.pac
dce_rpc-protocol.pac dce_rpc-analyzer.pac) dce_rpc-protocol.pac dce_rpc-analyzer.pac epmapper.pac)
binpac_target(dce_rpc_simple.pac binpac_target(dce_rpc_simple.pac
dce_rpc-protocol.pac) dce_rpc-protocol.pac epmapper.pac)
binpac_target(dhcp.pac binpac_target(dhcp.pac
dhcp-protocol.pac dhcp-analyzer.pac) dhcp-protocol.pac dhcp-analyzer.pac)
binpac_target(dns.pac binpac_target(dns.pac
@ -217,6 +217,8 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DebugCmdConstants.h
) )
set(dns_SRCS nb_dns.c nb_dns.h) set(dns_SRCS nb_dns.c nb_dns.h)
set_source_files_properties(nb_dns.c PROPERTIES COMPILE_FLAGS
-fno-strict-aliasing)
set(openssl_SRCS X509.cc SSLCiphers.cc SSLInterpreter.cc SSLProxy.cc set(openssl_SRCS X509.cc SSLCiphers.cc SSLInterpreter.cc SSLProxy.cc
SSLv2.cc SSLv3.cc SSLv3Automaton.cc) SSLv2.cc SSLv3.cc SSLv3Automaton.cc)

View file

@ -82,7 +82,7 @@ UUID::UUID(const char* str)
} }
if ( i != 16 ) if ( i != 16 )
internal_error(fmt("invalid UUID string: %s", str)); internal_error("invalid UUID string: %s", str);
} }
typedef map<UUID, BroEnum::dce_rpc_if_id> uuid_map_t; typedef map<UUID, BroEnum::dce_rpc_if_id> uuid_map_t;

View file

@ -99,8 +99,8 @@ void* PrefixTable::Lookup(const Val* value, bool exact) const
break; break;
default: default:
internal_error(fmt("Wrong index type %d for PrefixTable", internal_error("Wrong index type %d for PrefixTable",
value->Type()->Tag())); value->Type()->Tag());
return 0; return 0;
} }
} }

View file

@ -1516,13 +1516,13 @@ bool RemoteSerializer::DoMessage()
{ {
// We shut the connection to this peer down, // We shut the connection to this peer down,
// so we ignore all further messages. // so we ignore all further messages.
DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%d", DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%" PRI_SOURCE_ID,
msgToStr(current_msgtype), msgToStr(current_msgtype),
current_peer ? current_peer->id : 0)); current_peer ? current_peer->id : 0));
return true; return true;
} }
DEBUG_COMM(fmt("parent: %s from child; peer is #%d", DEBUG_COMM(fmt("parent: %s from child; peer is #%" PRI_SOURCE_ID,
msgToStr(current_msgtype), msgToStr(current_msgtype),
current_peer ? current_peer->id : 0)); current_peer ? current_peer->id : 0));
@ -2619,7 +2619,7 @@ bool RemoteSerializer::SendCMsgToChild(char msg_type, Peer* peer)
bool RemoteSerializer::SendToChild(char type, Peer* peer, char* str, int len) bool RemoteSerializer::SendToChild(char type, Peer* peer, char* str, int len)
{ {
DEBUG_COMM(fmt("parent: (->child) %s (#%d, %s)", msgToStr(type), peer ? peer->id : PEER_NONE, str)); DEBUG_COMM(fmt("parent: (->child) %s (#%" PRI_SOURCE_ID ", %s)", msgToStr(type), peer ? peer->id : PEER_NONE, str));
if ( ! child_pid ) if ( ! child_pid )
return false; return false;
@ -2643,7 +2643,7 @@ bool RemoteSerializer::SendToChild(char type, Peer* peer, int nargs, ...)
#ifdef DEBUG #ifdef DEBUG
va_start(ap, nargs); va_start(ap, nargs);
DEBUG_COMM(fmt("parent: (->child) %s (#%d,%s)", DEBUG_COMM(fmt("parent: (->child) %s (#%" PRI_SOURCE_ID ",%s)",
msgToStr(type), peer ? peer->id : PEER_NONE, fmt_uint32s(nargs, ap))); msgToStr(type), peer ? peer->id : PEER_NONE, fmt_uint32s(nargs, ap)));
va_end(ap); va_end(ap);
#endif #endif
@ -3074,7 +3074,7 @@ bool SocketComm::ProcessParentMessage()
} }
default: default:
internal_error(fmt("unknown msg type %d", parent_msgtype)); internal_error("unknown msg type %d", parent_msgtype);
return true; return true;
} }
@ -3244,7 +3244,7 @@ bool SocketComm::ForwardChunkToPeer()
{ {
#ifdef DEBUG #ifdef DEBUG
if ( parent_peer ) if ( parent_peer )
DEBUG_COMM(fmt("child: not connected to #%d", parent_id)); DEBUG_COMM(fmt("child: not connected to #%" PRI_SOURCE_ID, parent_id));
#endif #endif
} }
@ -3327,7 +3327,7 @@ bool SocketComm::ProcessRemoteMessage(SocketComm::Peer* peer)
CMsg* msg = (CMsg*) c->data; CMsg* msg = (CMsg*) c->data;
DEBUG_COMM(fmt("child: %s from peer #%d", DEBUG_COMM(fmt("child: %s from peer #%" PRI_SOURCE_ID,
msgToStr(msg->Type()), peer->id)); msgToStr(msg->Type()), peer->id));
switch ( msg->Type() ) { switch ( msg->Type() ) {
@ -3804,7 +3804,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, const char* str, int len)
#ifdef DEBUG #ifdef DEBUG
// str may already by constructed with fmt() // str may already by constructed with fmt()
const char* tmp = copy_string(str); const char* tmp = copy_string(str);
DEBUG_COMM(fmt("child: (->parent) %s (#%d, %s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, tmp)); DEBUG_COMM(fmt("child: (->parent) %s (#%" PRI_SOURCE_ID ", %s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, tmp));
delete [] tmp; delete [] tmp;
#endif #endif
if ( sendToIO(io, type, peer ? peer->id : RemoteSerializer::PEER_NONE, if ( sendToIO(io, type, peer ? peer->id : RemoteSerializer::PEER_NONE,
@ -3823,7 +3823,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, int nargs, ...)
#ifdef DEBUG #ifdef DEBUG
va_start(ap,nargs); va_start(ap,nargs);
DEBUG_COMM(fmt("child: (->parent) %s (#%d,%s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, fmt_uint32s(nargs, ap))); DEBUG_COMM(fmt("child: (->parent) %s (#%" PRI_SOURCE_ID ",%s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, fmt_uint32s(nargs, ap)));
va_end(ap); va_end(ap);
#endif #endif
@ -3859,7 +3859,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, const char* str, int len)
#ifdef DEBUG #ifdef DEBUG
// str may already by constructed with fmt() // str may already by constructed with fmt()
const char* tmp = copy_string(str); const char* tmp = copy_string(str);
DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", msgToStr(type), peer->id, tmp)); DEBUG_COMM(fmt("child: (->peer) %s to #%" PRI_SOURCE_ID " (%s)", msgToStr(type), peer->id, tmp));
delete [] tmp; delete [] tmp;
#endif #endif
@ -3878,7 +3878,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...)
#ifdef DEBUG #ifdef DEBUG
va_start(ap,nargs); va_start(ap,nargs);
DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)", DEBUG_COMM(fmt("child: (->peer) %s to #%" PRI_SOURCE_ID " (%s)",
msgToStr(type), peer->id, fmt_uint32s(nargs, ap))); msgToStr(type), peer->id, fmt_uint32s(nargs, ap)));
va_end(ap); va_end(ap);
#endif #endif
@ -3899,7 +3899,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...)
bool SocketComm::SendToPeer(Peer* peer, ChunkedIO::Chunk* c) bool SocketComm::SendToPeer(Peer* peer, ChunkedIO::Chunk* c)
{ {
DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%d", c->len, peer->id)); DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%" PRI_SOURCE_ID, c->len, peer->id));
if ( ! sendToIO(peer->io, c) ) if ( ! sendToIO(peer->io, c) )
{ {
Error(fmt("child: write error %s", io->Error()), peer); Error(fmt("child: write error %s", io->Error()), peer);

View file

@ -166,7 +166,7 @@ void SMB_Session::Deliver(int is_orig, int len, const u_char* data)
const u_char* tmp = data_start + next; const u_char* tmp = data_start + next;
if ( data_start + next < data + body.length() ) if ( data_start + next < data + body.length() )
{ {
Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %d", next, data + body.length() - data_start)); Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %" PRIuPTR, next, data + body.length() - data_start));
break; break;
} }

View file

@ -11,9 +11,6 @@
static scope_list scopes; static scope_list scopes;
static Scope* top_scope; static Scope* top_scope;
extern const char* GLOBAL_MODULE_NAME = "GLOBAL";
// Returns it without trailing "::". // Returns it without trailing "::".
string extract_module_name(const char* name) string extract_module_name(const char* name)
{ {

View file

@ -59,7 +59,7 @@ protected:
id_list* inits; id_list* inits;
}; };
extern const char* GLOBAL_MODULE_NAME; static const char* GLOBAL_MODULE_NAME = "GLOBAL";
extern string extract_module_name(const char* name); extern string extract_module_name(const char* name);
extern string normalized_module_name(const char* module_name); // w/o :: extern string normalized_module_name(const char* module_name); // w/o ::

View file

@ -570,8 +570,8 @@ cq_debugbucket(register struct cq_handle *hp,
bp2 = hp->buckets + PRI2BUCKET(hp, bp->pri); bp2 = hp->buckets + PRI2BUCKET(hp, bp->pri);
if (bp2 != buckets) { if (bp2 != buckets) {
fprintf(stderr, fprintf(stderr,
"%f in wrong bucket! (off by %d)\n", "%f in wrong bucket! (off by %ld)\n",
bp->pri, bp2 - buckets); bp->pri, (long)(bp2 - buckets));
cq_dump(hp); cq_dump(hp);
abort(); abort();
} }

View file

@ -8,5 +8,5 @@ analyzer DCE_RPC withcontext {
flow: DCE_RPC_Flow; flow: DCE_RPC_Flow;
}; };
%include "dce_rpc-protocol.pac" %include dce_rpc-protocol.pac
%include "dce_rpc-analyzer.pac" %include dce_rpc-analyzer.pac

View file

@ -8,6 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <string.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
@ -421,7 +422,7 @@ int main(int argc, char** argv)
prog = argv[0]; prog = argv[0];
prefixes.append(""); // "" = "no prefix" prefixes.append(strdup("")); // "" = "no prefix"
char* p = getenv("BRO_PREFIXES"); char* p = getenv("BRO_PREFIXES");
if ( p ) if ( p )

View file

@ -3,6 +3,8 @@
// See the file "COPYING" in the main distribution directory for copyright. // See the file "COPYING" in the main distribution directory for copyright.
%} %}
%expect 71
%token TOK_ADD TOK_ADD_TO TOK_ADDR TOK_ALARM TOK_ANY %token TOK_ADD TOK_ADD_TO TOK_ADDR TOK_ALARM TOK_ANY
%token TOK_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF %token TOK_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF
%token TOK_BOOL TOK_BREAK TOK_CASE TOK_CONST %token TOK_BOOL TOK_BREAK TOK_CASE TOK_CONST

View file

@ -1027,7 +1027,7 @@ lookup_then_remove (patricia_tree_t *tree, char *string)
{ {
patricia_node_t *node; patricia_node_t *node;
if (node = try_search_exact (tree, string)) if ( (node = try_search_exact(tree, string)) )
patricia_remove (tree, node); patricia_remove (tree, node);
} }

View file

@ -215,7 +215,7 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep,
{ {
offset = 0; offset = 0;
// Find next match offset. // Find next match offset.
int end_of_match; int end_of_match = 0;
while ( n > 0 && while ( n > 0 &&
(end_of_match = re->MatchPrefix(s + offset, n)) <= 0 ) (end_of_match = re->MatchPrefix(s + offset, n)) <= 0 )
{ {

View file

@ -11,6 +11,11 @@
#include <stdarg.h> #include <stdarg.h>
#include "config.h" #include "config.h"
// Expose C99 functionality from inttypes.h, which would otherwise not be
// available in C++.
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#if __STDC__ #if __STDC__
#define myattribute __attribute__ #define myattribute __attribute__
#else #else
@ -39,19 +44,17 @@
extern HeapLeakChecker* heap_checker; extern HeapLeakChecker* heap_checker;
#endif #endif
typedef unsigned int uint32; #include <stdint.h>
typedef unsigned short uint16;
typedef unsigned char uint8;
#if SIZEOF_LONG_LONG == 8 typedef uint64_t uint64;
typedef unsigned long long uint64; typedef uint32_t uint32;
typedef long long int64; typedef uint16_t uint16;
#elif SIZEOF_LONG_INT == 8 typedef uint8_t uint8;
typedef unsigned long int uint64;
typedef long int int64; typedef int64_t int64;
#else typedef int32_t int32;
# error "Couldn't reliably identify 64-bit type. Please report to bro@bro-ids.org." typedef int16_t int16;
#endif typedef int8_t int8;
typedef int64 bro_int_t; typedef int64 bro_int_t;
typedef uint64 bro_uint_t; typedef uint64 bro_uint_t;
@ -63,9 +66,13 @@ typedef uint64 bro_uint_t;
#if SIZEOF_VOID_P == 8 #if SIZEOF_VOID_P == 8
typedef uint64 ptr_compat_uint; typedef uint64 ptr_compat_uint;
typedef int64 ptr_compat_int; typedef int64 ptr_compat_int;
#define PRI_PTR_COMPAT_INT PRId64 // Format to use with printf.
#define PRI_PTR_COMPAT_UINT PRIu64
#elif SIZEOF_VOID_P == 4 #elif SIZEOF_VOID_P == 4
typedef uint32 ptr_compat_uint; typedef uint32 ptr_compat_uint;
typedef int ptr_compat_int; typedef int32 ptr_compat_int;
#define PRI_PTR_COMPAT_INT PRId32
#define PRI_PTR_COMPAT_UINT PRIu32
#else #else
# error "Unusual pointer size. Please report to bro@bro-ids.org." # error "Unusual pointer size. Please report to bro@bro-ids.org."
#endif #endif
@ -156,6 +163,7 @@ extern uint8 uhash_key[UHASH_KEY_SIZE];
// the obvious places (like Event.h or RemoteSerializer.h) // the obvious places (like Event.h or RemoteSerializer.h)
typedef ptr_compat_uint SourceID; typedef ptr_compat_uint SourceID;
#define PRI_SOURCE_ID PRI_PTR_COMPAT_UINT
static const SourceID SOURCE_LOCAL = 0; static const SourceID SOURCE_LOCAL = 0;
class BroObj; class BroObj;