diff --git a/CHANGES b/CHANGES index 0acca5f28e..d12cd02ebb 100644 --- a/CHANGES +++ b/CHANGES @@ -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 - A number of updates to the SSL analyzer, including support for new diff --git a/VERSION b/VERSION index 0b5bef5473..e80e9b3ff5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6-dev.44 +1.6-dev.45 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f67dc173e..9aab94cc6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,7 +160,7 @@ macro(BINPAC_TARGET pacFile) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.h ${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.cc COMMAND ${BinPAC_EXE} - ARGS -d ${CMAKE_CURRENT_BINARY_DIR} + ARGS -q -d ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${pacFile} DEPENDS ${BinPAC_EXE} ${pacFile} @@ -177,9 +177,9 @@ binpac_target(binpac_bro-lib.pac) binpac_target(bittorrent.pac bittorrent-protocol.pac bittorrent-analyzer.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 - dce_rpc-protocol.pac) + dce_rpc-protocol.pac epmapper.pac) binpac_target(dhcp.pac dhcp-protocol.pac dhcp-analyzer.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_source_files_properties(nb_dns.c PROPERTIES COMPILE_FLAGS + -fno-strict-aliasing) set(openssl_SRCS X509.cc SSLCiphers.cc SSLInterpreter.cc SSLProxy.cc SSLv2.cc SSLv3.cc SSLv3Automaton.cc) diff --git a/src/DCE_RPC.cc b/src/DCE_RPC.cc index fe163f2632..62f7806c51 100644 --- a/src/DCE_RPC.cc +++ b/src/DCE_RPC.cc @@ -82,7 +82,7 @@ UUID::UUID(const char* str) } if ( i != 16 ) - internal_error(fmt("invalid UUID string: %s", str)); + internal_error("invalid UUID string: %s", str); } typedef map uuid_map_t; diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index e654b8440e..b3313c82e5 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -99,8 +99,8 @@ void* PrefixTable::Lookup(const Val* value, bool exact) const break; default: - internal_error(fmt("Wrong index type %d for PrefixTable", - value->Type()->Tag())); + internal_error("Wrong index type %d for PrefixTable", + value->Type()->Tag()); return 0; } } diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index 22e98b29ae..15b1872680 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -1516,13 +1516,13 @@ bool RemoteSerializer::DoMessage() { // We shut the connection to this peer down, // 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), current_peer ? current_peer->id : 0)); 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), 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) { - 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 ) return false; @@ -2643,7 +2643,7 @@ bool RemoteSerializer::SendToChild(char type, Peer* peer, int nargs, ...) #ifdef DEBUG 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))); va_end(ap); #endif @@ -3074,7 +3074,7 @@ bool SocketComm::ProcessParentMessage() } default: - internal_error(fmt("unknown msg type %d", parent_msgtype)); + internal_error("unknown msg type %d", parent_msgtype); return true; } @@ -3244,7 +3244,7 @@ bool SocketComm::ForwardChunkToPeer() { #ifdef DEBUG 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 } @@ -3327,7 +3327,7 @@ bool SocketComm::ProcessRemoteMessage(SocketComm::Peer* peer) 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)); switch ( msg->Type() ) { @@ -3804,7 +3804,7 @@ bool SocketComm::SendToParent(char type, Peer* peer, const char* str, int len) #ifdef DEBUG // str may already by constructed with fmt() 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; #endif 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 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); #endif @@ -3859,7 +3859,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, const char* str, int len) #ifdef DEBUG // str may already by constructed with fmt() 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; #endif @@ -3878,7 +3878,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...) #ifdef DEBUG 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))); va_end(ap); #endif @@ -3899,7 +3899,7 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...) 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) ) { Error(fmt("child: write error %s", io->Error()), peer); diff --git a/src/SMB.cc b/src/SMB.cc index db4d4608b2..e33c7ac73a 100644 --- a/src/SMB.cc +++ b/src/SMB.cc @@ -166,7 +166,7 @@ void SMB_Session::Deliver(int is_orig, int len, const u_char* data) const u_char* tmp = data_start + next; 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; } diff --git a/src/Scope.cc b/src/Scope.cc index f8fa9f4883..9b75f5f22b 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -11,9 +11,6 @@ static scope_list scopes; static Scope* top_scope; -extern const char* GLOBAL_MODULE_NAME = "GLOBAL"; - - // Returns it without trailing "::". string extract_module_name(const char* name) { diff --git a/src/Scope.h b/src/Scope.h index 19b37ef600..ffc695210a 100644 --- a/src/Scope.h +++ b/src/Scope.h @@ -59,7 +59,7 @@ protected: 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 normalized_module_name(const char* module_name); // w/o :: diff --git a/src/cq.c b/src/cq.c index 63e4275369..b669dabd35 100644 --- a/src/cq.c +++ b/src/cq.c @@ -570,8 +570,8 @@ cq_debugbucket(register struct cq_handle *hp, bp2 = hp->buckets + PRI2BUCKET(hp, bp->pri); if (bp2 != buckets) { fprintf(stderr, - "%f in wrong bucket! (off by %d)\n", - bp->pri, bp2 - buckets); + "%f in wrong bucket! (off by %ld)\n", + bp->pri, (long)(bp2 - buckets)); cq_dump(hp); abort(); } diff --git a/src/dce_rpc.pac b/src/dce_rpc.pac index 0aa689b532..58c2250c26 100644 --- a/src/dce_rpc.pac +++ b/src/dce_rpc.pac @@ -8,5 +8,5 @@ analyzer DCE_RPC withcontext { flow: DCE_RPC_Flow; }; -%include "dce_rpc-protocol.pac" -%include "dce_rpc-analyzer.pac" +%include dce_rpc-protocol.pac +%include dce_rpc-analyzer.pac diff --git a/src/main.cc b/src/main.cc index 82866302fd..a8f283dcbc 100644 --- a/src/main.cc +++ b/src/main.cc @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef HAVE_GETOPT_H #include #endif @@ -421,7 +422,7 @@ int main(int argc, char** argv) prog = argv[0]; - prefixes.append(""); // "" = "no prefix" + prefixes.append(strdup("")); // "" = "no prefix" char* p = getenv("BRO_PREFIXES"); if ( p ) diff --git a/src/parse.y b/src/parse.y index 3cf2c07b18..82ee3cadfb 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3,6 +3,8 @@ // 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_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF %token TOK_BOOL TOK_BREAK TOK_CASE TOK_CONST diff --git a/src/patricia.c b/src/patricia.c index c9d271803c..8e40cb5ef6 100644 --- a/src/patricia.c +++ b/src/patricia.c @@ -1027,7 +1027,7 @@ lookup_then_remove (patricia_tree_t *tree, char *string) { patricia_node_t *node; - if (node = try_search_exact (tree, string)) + if ( (node = try_search_exact(tree, string)) ) patricia_remove (tree, node); } diff --git a/src/strings.bif b/src/strings.bif index c324e493a9..e41ae196b2 100644 --- a/src/strings.bif +++ b/src/strings.bif @@ -215,7 +215,7 @@ Val* do_split(StringVal* str_val, RE_Matcher* re, TableVal* other_sep, { offset = 0; // Find next match offset. - int end_of_match; + int end_of_match = 0; while ( n > 0 && (end_of_match = re->MatchPrefix(s + offset, n)) <= 0 ) { diff --git a/src/util.h b/src/util.h index 43e0f2c6c1..ab7cb3c6fe 100644 --- a/src/util.h +++ b/src/util.h @@ -11,6 +11,11 @@ #include #include "config.h" +// Expose C99 functionality from inttypes.h, which would otherwise not be +// available in C++. +#define __STDC_FORMAT_MACROS +#include + #if __STDC__ #define myattribute __attribute__ #else @@ -39,19 +44,17 @@ extern HeapLeakChecker* heap_checker; #endif -typedef unsigned int uint32; -typedef unsigned short uint16; -typedef unsigned char uint8; +#include -#if SIZEOF_LONG_LONG == 8 -typedef unsigned long long uint64; -typedef long long int64; -#elif SIZEOF_LONG_INT == 8 -typedef unsigned long int uint64; -typedef long int int64; -#else -# error "Couldn't reliably identify 64-bit type. Please report to bro@bro-ids.org." -#endif +typedef uint64_t uint64; +typedef uint32_t uint32; +typedef uint16_t uint16; +typedef uint8_t uint8; + +typedef int64_t int64; +typedef int32_t int32; +typedef int16_t int16; +typedef int8_t int8; typedef int64 bro_int_t; typedef uint64 bro_uint_t; @@ -63,9 +66,13 @@ typedef uint64 bro_uint_t; #if SIZEOF_VOID_P == 8 typedef uint64 ptr_compat_uint; 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 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 # error "Unusual pointer size. Please report to bro@bro-ids.org." #endif @@ -156,6 +163,7 @@ extern uint8 uhash_key[UHASH_KEY_SIZE]; // the obvious places (like Event.h or RemoteSerializer.h) typedef ptr_compat_uint SourceID; +#define PRI_SOURCE_ID PRI_PTR_COMPAT_UINT static const SourceID SOURCE_LOCAL = 0; class BroObj;