Fix errors/warnings when compiling with -std=c++11

These are compatibility changes only.
This commit is contained in:
Jon Siwek 2014-10-27 12:54:17 -05:00
parent a26c674dfd
commit e60ceea87c
15 changed files with 33 additions and 32 deletions

View file

@ -96,7 +96,7 @@ bool Brofiler::WriteStats()
map<pair<string, string>, uint64 >::const_iterator it; map<pair<string, string>, uint64 >::const_iterator it;
for ( it = usage_map.begin(); it != usage_map.end(); ++it ) for ( it = usage_map.begin(); it != usage_map.end(); ++it )
{ {
fprintf(f, "%"PRIu64"%c%s%c%s\n", it->second, delim, fprintf(f, "%" PRIu64"%c%s%c%s\n", it->second, delim,
it->first.first.c_str(), delim, it->first.second.c_str()); it->first.first.c_str(), delim, it->first.second.c_str());
} }

View file

@ -214,7 +214,7 @@ DNS_Mapping::DNS_Mapping(FILE* f)
char req_buf[512+1], name_buf[512+1]; char req_buf[512+1], name_buf[512+1];
int is_req_host; int is_req_host;
if ( sscanf(buf, "%lf %d %512s %d %512s %d %d %"PRIu32, &creation_time, if ( sscanf(buf, "%lf %d %512s %d %512s %d %d %" PRIu32, &creation_time,
&is_req_host, req_buf, &failed, name_buf, &map_type, &num_addrs, &is_req_host, req_buf, &failed, name_buf, &map_type, &num_addrs,
&req_ttl) != 8 ) &req_ttl) != 8 )
return; return;
@ -360,7 +360,7 @@ void DNS_Mapping::Clear()
void DNS_Mapping::Save(FILE* f) const void DNS_Mapping::Save(FILE* f) const
{ {
fprintf(f, "%.0f %d %s %d %s %d %d %"PRIu32"\n", creation_time, req_host != 0, fprintf(f, "%.0f %d %s %d %s %d %d %" PRIu32"\n", creation_time, req_host != 0,
req_host ? req_host : req_addr.AsString().c_str(), req_host ? req_host : req_addr.AsString().c_str(),
failed, (names && names[0]) ? names[0] : "*", failed, (names && names[0]) ? names[0] : "*",
map_type, num_addrs, req_ttl); map_type, num_addrs, req_ttl);

View file

@ -110,7 +110,7 @@ public:
T result = 0; T result = 0;
// loop optmized with Duff's Device // loop optmized with Duff's Device
register unsigned n = (size + 7) / 8; unsigned n = (size + 7) / 8;
switch ( size % 8 ) { switch ( size % 8 ) {
case 0: do { result ^= byte_lookup[offset++][*p++]; case 0: do { result ^= byte_lookup[offset++][*p++];
case 7: result ^= byte_lookup[offset++][*p++]; case 7: result ^= byte_lookup[offset++][*p++];

View file

@ -182,7 +182,7 @@ DataBlock* Reassembler::AddAndCheck(DataBlock* b, uint64 seq, uint64 upper,
{ {
if ( DEBUG_reassem ) if ( DEBUG_reassem )
{ {
DEBUG_MSG("%.6f Reassembler::AddAndCheck seq=%"PRIu64", upper=%"PRIu64"\n", DEBUG_MSG("%.6f Reassembler::AddAndCheck seq=%" PRIu64", upper=%" PRIu64"\n",
network_time, seq, upper); network_time, seq, upper);
} }

View file

@ -707,7 +707,7 @@ RemoteSerializer::PeerID RemoteSerializer::Connect(const IPAddr& ip,
const size_t BUFSIZE = 1024; const size_t BUFSIZE = 1024;
char* data = new char[BUFSIZE]; char* data = new char[BUFSIZE];
snprintf(data, BUFSIZE, snprintf(data, BUFSIZE,
"%"PRI_PTR_COMPAT_UINT",%s,%s,%"PRIu16",%"PRIu32",%d", p->id, "%" PRI_PTR_COMPAT_UINT",%s,%s,%" PRIu16",%" PRIu32",%d", p->id,
ip.AsString().c_str(), zone_id.c_str(), port, uint32(retry), ip.AsString().c_str(), zone_id.c_str(), port, uint32(retry),
use_ssl); use_ssl);
@ -1267,7 +1267,7 @@ bool RemoteSerializer::Listen(const IPAddr& ip, uint16 port, bool expect_ssl,
const size_t BUFSIZE = 1024; const size_t BUFSIZE = 1024;
char* data = new char[BUFSIZE]; char* data = new char[BUFSIZE];
snprintf(data, BUFSIZE, "%s,%"PRIu16",%d,%d,%s,%"PRIu32, snprintf(data, BUFSIZE, "%s,%" PRIu16",%d,%d,%s,%" PRIu32,
ip.AsString().c_str(), port, expect_ssl, ipv6, zone_id.c_str(), ip.AsString().c_str(), port, expect_ssl, ipv6, zone_id.c_str(),
(uint32) retry); (uint32) retry);
@ -4075,7 +4075,7 @@ bool SocketComm::Connect(Peer* peer)
const size_t BUFSIZE = 1024; const size_t BUFSIZE = 1024;
char* data = new char[BUFSIZE]; char* data = new char[BUFSIZE];
snprintf(data, BUFSIZE, "%s,%"PRIu32, peer->ip.AsString().c_str(), snprintf(data, BUFSIZE, "%s,%" PRIu32, peer->ip.AsString().c_str(),
peer->port); peer->port);
if ( ! SendToParent(MSG_CONNECTED, peer, data) ) if ( ! SendToParent(MSG_CONNECTED, peer, data) )
@ -4190,7 +4190,7 @@ bool SocketComm::Listen()
setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0 ) setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0 )
Error(fmt("can't set IPV6_V6ONLY, %s", strerror(errno))); Error(fmt("can't set IPV6_V6ONLY, %s", strerror(errno)));
if ( bind(fd, res->ai_addr, res->ai_addrlen) < 0 ) if ( ::bind(fd, res->ai_addr, res->ai_addrlen) < 0 )
{ {
Error(fmt("can't bind to %s:%s, %s", l_addr_str.c_str(), Error(fmt("can't bind to %s:%s, %s", l_addr_str.c_str(),
port_str, strerror(errno))); port_str, strerror(errno)));
@ -4287,7 +4287,7 @@ bool SocketComm::AcceptConnection(int fd)
const size_t BUFSIZE = 1024; const size_t BUFSIZE = 1024;
char* data = new char[BUFSIZE]; char* data = new char[BUFSIZE];
snprintf(data, BUFSIZE, "%s,%"PRIu32, peer->ip.AsString().c_str(), snprintf(data, BUFSIZE, "%s,%" PRIu32, peer->ip.AsString().c_str(),
peer->port); peer->port);
if ( ! SendToParent(MSG_CONNECTED, peer, data) ) if ( ! SendToParent(MSG_CONNECTED, peer, data) )

View file

@ -541,19 +541,19 @@ bool XMLSerializationFormat::Write(uint16 v, const char* tag)
bool XMLSerializationFormat::Write(uint32 v, const char* tag) bool XMLSerializationFormat::Write(uint32 v, const char* tag)
{ {
const char* tmp = fmt("%"PRIu32, v); const char* tmp = fmt("%" PRIu32, v);
return WriteElem(tag, "uint32", tmp, strlen(tmp)); return WriteElem(tag, "uint32", tmp, strlen(tmp));
} }
bool XMLSerializationFormat::Write(uint64 v, const char* tag) bool XMLSerializationFormat::Write(uint64 v, const char* tag)
{ {
const char* tmp = fmt("%"PRIu64, v); const char* tmp = fmt("%" PRIu64, v);
return WriteElem(tag, "uint64", tmp, strlen(tmp)); return WriteElem(tag, "uint64", tmp, strlen(tmp));
} }
bool XMLSerializationFormat::Write(int64 v, const char* tag) bool XMLSerializationFormat::Write(int64 v, const char* tag)
{ {
const char* tmp = fmt("%"PRId64, v); const char* tmp = fmt("%" PRId64, v);
return WriteElem(tag, "int64", tmp, strlen(tmp)); return WriteElem(tag, "int64", tmp, strlen(tmp));
} }

View file

@ -544,7 +544,7 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
if ( proto_typ != 0x0800 && proto_typ != 0x86dd ) if ( proto_typ != 0x0800 && proto_typ != 0x86dd )
{ {
// Not IPv4/IPv6 payload. // Not IPv4/IPv6 payload.
Weird(fmt("unknown_gre_protocol_%"PRIu16, proto_typ), ip_hdr, Weird(fmt("unknown_gre_protocol_%" PRIu16, proto_typ), ip_hdr,
encapsulation); encapsulation);
return; return;
} }

View file

@ -160,7 +160,7 @@ void ProfileLogger::Log()
file->Write(fmt("%.06f Connections expired due to inactivity: %d\n", file->Write(fmt("%.06f Connections expired due to inactivity: %d\n",
network_time, killed_by_inactivity)); network_time, killed_by_inactivity));
file->Write(fmt("%.06f Total reassembler data: %"PRIu64"K\n", network_time, file->Write(fmt("%.06f Total reassembler data: %" PRIu64"K\n", network_time,
Reassembler::TotalMemoryAllocation() / 1024)); Reassembler::TotalMemoryAllocation() / 1024));
// Signature engine. // Signature engine.

View file

@ -598,7 +598,7 @@ SupportAnalyzer* Analyzer::FirstSupportAnalyzer(bool orig)
void Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, void Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
uint64 seq, const IP_Hdr* ip, int caplen) uint64 seq, const IP_Hdr* ip, int caplen)
{ {
DBG_LOG(DBG_ANALYZER, "%s DeliverPacket(%d, %s, %"PRIu64", %p, %d) [%s%s]", DBG_LOG(DBG_ANALYZER, "%s DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]",
fmt_analyzer(this).c_str(), len, is_orig ? "T" : "F", seq, ip, caplen, fmt_analyzer(this).c_str(), len, is_orig ? "T" : "F", seq, ip, caplen,
fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : ""); fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : "");
} }
@ -612,7 +612,7 @@ void Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
void Analyzer::Undelivered(uint64 seq, int len, bool is_orig) void Analyzer::Undelivered(uint64 seq, int len, bool is_orig)
{ {
DBG_LOG(DBG_ANALYZER, "%s Undelivered(%"PRIu64", %d, %s)", DBG_LOG(DBG_ANALYZER, "%s Undelivered(%" PRIu64", %d, %s)",
fmt_analyzer(this).c_str(), seq, len, is_orig ? "T" : "F"); fmt_analyzer(this).c_str(), seq, len, is_orig ? "T" : "F");
} }

View file

@ -416,7 +416,7 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h)
int64_t len = l - f + 1; int64_t len = l - f + 1;
if ( DEBUG_http ) if ( DEBUG_http )
DEBUG_MSG("Content-Range length = %"PRId64"\n", len); DEBUG_MSG("Content-Range length = %" PRId64"\n", len);
if ( len > 0 ) if ( len > 0 )
{ {
@ -1060,7 +1060,7 @@ void HTTP_Analyzer::Undelivered(uint64 seq, int len, bool is_orig)
{ {
if ( msg ) if ( msg )
msg->SubmitEvent(mime::MIME_EVENT_CONTENT_GAP, msg->SubmitEvent(mime::MIME_EVENT_CONTENT_GAP,
fmt("seq=%"PRIu64", len=%d", seq, len)); fmt("seq=%" PRIu64", len=%d", seq, len));
} }
// Check if the content gap falls completely within a message body // Check if the content gap falls completely within a message body

View file

@ -21,7 +21,9 @@ static const char* smtp_cmd_word[] = {
#include "SMTP_cmd.def" #include "SMTP_cmd.def"
}; };
#define SMTP_CMD_WORD(code) ((code >= 0) ? smtp_cmd_word[code] : "(UNKNOWN)") static const char* unknown_cmd = "(UNKNOWN)";
#define SMTP_CMD_WORD(code) ((code >= 0) ? smtp_cmd_word[code] : unknown_cmd)
SMTP_Analyzer::SMTP_Analyzer(Connection* conn) SMTP_Analyzer::SMTP_Analyzer(Connection* conn)
@ -83,7 +85,7 @@ void SMTP_Analyzer::Undelivered(uint64 seq, int len, bool is_orig)
if ( len <= 0 ) if ( len <= 0 )
return; return;
const char* buf = fmt("seq = %"PRIu64", len = %d", seq, len); const char* buf = fmt("seq = %" PRIu64", len = %d", seq, len);
int buf_len = strlen(buf); int buf_len = strlen(buf);
Unexpected(is_orig, "content gap", buf_len, buf); Unexpected(is_orig, "content gap", buf_len, buf);
@ -422,7 +424,6 @@ void SMTP_Analyzer::NewReply(const int reply_code)
if ( state == SMTP_AFTER_GAP && reply_code > 0 ) if ( state == SMTP_AFTER_GAP && reply_code > 0 )
{ {
state = SMTP_GAP_RECOVERY; state = SMTP_GAP_RECOVERY;
const char* unknown_cmd = SMTP_CMD_WORD(-1);
RequestEvent(strlen(unknown_cmd), unknown_cmd, 0, ""); RequestEvent(strlen(unknown_cmd), unknown_cmd, 0, "");
/* /*
if ( line_after_gap ) if ( line_after_gap )

View file

@ -84,7 +84,7 @@ StringVal* asn1_oid_to_val(const ASN1Encoding* oid)
if ( i > 0 ) if ( i > 0 )
{ {
rval += "."; rval += ".";
snprintf(tmp, sizeof(tmp), "%"PRIu64, subidentifier_values[i]); snprintf(tmp, sizeof(tmp), "%" PRIu64, subidentifier_values[i]);
rval += tmp; rval += tmp;
} }
else else

View file

@ -1901,7 +1901,7 @@ void TCP_ApplicationAnalyzer::DeliverPacket(int len, const u_char* data,
const IP_Hdr* ip, int caplen) const IP_Hdr* ip, int caplen)
{ {
Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen); Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen);
DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %"PRIu64", %p, %d) [%s%s]", DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]",
len, is_orig ? "T" : "F", seq, ip, caplen, len, is_orig ? "T" : "F", seq, ip, caplen,
fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : ""); fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : "");
} }
@ -2053,7 +2053,7 @@ int TCPStats_Endpoint::DataSent(double /* t */, uint64 seq, int len, int caplen,
num_rxmit_bytes += len; num_rxmit_bytes += len;
} }
DEBUG_MSG("%.6f rexmit %"PRIu64" + %d <= %"PRIu64" data_in_flight = %d\n", DEBUG_MSG("%.6f rexmit %" PRIu64" + %d <= %" PRIu64" data_in_flight = %d\n",
network_time, seq, len, max_top_seq, data_in_flight); network_time, seq, len, max_top_seq, data_in_flight);
if ( tcp_rexmit ) if ( tcp_rexmit )

View file

@ -188,7 +188,7 @@ void TCP_Reassembler::Undelivered(uint64 up_to_seq)
if ( DEBUG_tcp_contents ) if ( DEBUG_tcp_contents )
{ {
DEBUG_MSG("%.6f Undelivered: IsOrig()=%d up_to_seq=%"PRIu64", last_reassm=%"PRIu64", " DEBUG_MSG("%.6f Undelivered: IsOrig()=%d up_to_seq=%" PRIu64", last_reassm=%" PRIu64", "
"endp: FIN_cnt=%d, RST_cnt=%d, " "endp: FIN_cnt=%d, RST_cnt=%d, "
"peer: FIN_cnt=%d, RST_cnt=%d\n", "peer: FIN_cnt=%d, RST_cnt=%d\n",
network_time, IsOrig(), up_to_seq, last_reassem_seq, network_time, IsOrig(), up_to_seq, last_reassem_seq,
@ -219,7 +219,7 @@ void TCP_Reassembler::Undelivered(uint64 up_to_seq)
{ {
if ( DEBUG_tcp_contents ) if ( DEBUG_tcp_contents )
{ {
DEBUG_MSG("%.6f Undelivered: IsOrig()=%d, seq=%"PRIu64", len=%"PRIu64", " DEBUG_MSG("%.6f Undelivered: IsOrig()=%d, seq=%" PRIu64", len=%" PRIu64", "
"skip_deliveries=%d\n", "skip_deliveries=%d\n",
network_time, IsOrig(), last_reassem_seq, network_time, IsOrig(), last_reassem_seq,
up_to_seq - last_reassem_seq, up_to_seq - last_reassem_seq,
@ -350,7 +350,7 @@ void TCP_Reassembler::RecordBlock(DataBlock* b, BroFile* f)
void TCP_Reassembler::RecordGap(uint64 start_seq, uint64 upper_seq, BroFile* f) void TCP_Reassembler::RecordGap(uint64 start_seq, uint64 upper_seq, BroFile* f)
{ {
if ( f->Write(fmt("\n<<gap %"PRIu64">>\n", upper_seq - start_seq)) ) if ( f->Write(fmt("\n<<gap %" PRIu64">>\n", upper_seq - start_seq)) )
return; return;
reporter->Error("TCP_Reassembler contents gap write failed"); reporter->Error("TCP_Reassembler contents gap write failed");
@ -420,7 +420,7 @@ void TCP_Reassembler::BlockInserted(DataBlock* start_block)
void TCP_Reassembler::Overlap(const u_char* b1, const u_char* b2, uint64 n) void TCP_Reassembler::Overlap(const u_char* b1, const u_char* b2, uint64 n)
{ {
if ( DEBUG_tcp_contents ) if ( DEBUG_tcp_contents )
DEBUG_MSG("%.6f TCP contents overlap: %"PRIu64" IsOrig()=%d\n", network_time, n, IsOrig()); DEBUG_MSG("%.6f TCP contents overlap: %" PRIu64" IsOrig()=%d\n", network_time, n, IsOrig());
if ( rexmit_inconsistency && if ( rexmit_inconsistency &&
memcmp((const void*) b1, (const void*) b2, n) && memcmp((const void*) b1, (const void*) b2, n) &&
@ -465,7 +465,7 @@ int TCP_Reassembler::DataSent(double t, uint64 seq, int len,
if ( DEBUG_tcp_contents ) if ( DEBUG_tcp_contents )
{ {
DEBUG_MSG("%.6f DataSent: IsOrig()=%d seq=%"PRIu64" upper=%"PRIu64" ack=%"PRIu64"\n", DEBUG_MSG("%.6f DataSent: IsOrig()=%d seq=%" PRIu64" upper=%" PRIu64" ack=%" PRIu64"\n",
network_time, IsOrig(), seq, upper_seq, ack); network_time, IsOrig(), seq, upper_seq, ack);
} }

View file

@ -357,7 +357,7 @@ cq_remove(register struct cq_handle *hp, register double pri,
/* The priority must be positive and the cookie non-null */ /* The priority must be positive and the cookie non-null */
if (pri <= 0.0 || cookie == NULL) if (pri <= 0.0 || cookie == NULL)
return (-0); return (0);
bp = hp->buckets + PRI2BUCKET(hp, pri); bp = hp->buckets + PRI2BUCKET(hp, pri);
if (! BUCKETINUSE(bp)) if (! BUCKETINUSE(bp))
@ -370,7 +370,7 @@ cq_remove(register struct cq_handle *hp, register double pri,
} }
if ( ! bp ) if ( ! bp )
return (-0); return (0);
/* Unlink entry */ /* Unlink entry */
if ( ! bp2 ) { if ( ! bp2 ) {