[Bro-Dev] [Bro-Commits] [git/bro] topic/seth/fix-compiler-warnings: PRI macros are currently not working for some reason. (275c6e6)
Gregor Maier
gregor at icir.org
Tue Feb 8 14:01:42 PST 2011
Annoyingly, C++ compilers don't enable these macros per default as they
are in the C99 standard. Grrr. You have to define
#define _ISOC99_SOURCE
#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS
#define __STDC_FORMAT_MACROS
before you include any of the header files. util.h or so might be a good
place to add these defines. (For the printf macros to work, you probably
only need the first and the last define, but I the others are probably
handy too).
See also:
http://publib.boulder.ibm.com/infocenter/zos/v1r9/topic/com.ibm.zos.r9.cbcpx01/c99ftmacros.htm
cu
Gregor
On 2/8/11 9:47 , Seth Hall wrote:
> Repository : ssh://bro@envoy.icir.org/bro
>
> On branch : topic/seth/fix-compiler-warnings
>
>> ---------------------------------------------------------------
>
> commit 275c6e64cce6a0a9e187c347864c909e04b4ef03
> Author: Seth Hall <seth at icir.org>
> Date: Tue Feb 8 12:47:10 2011 -0500
>
> PRI macros are currently not working for some reason.
>
>
>> ---------------------------------------------------------------
>
> src/RemoteSerializer.cc | 29 +++++++++++++++--------------
> src/SMB.cc | 4 +++-
> 2 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc
> index 6709ea0..7d731c5 100644
> --- a/src/RemoteSerializer.cc
> +++ b/src/RemoteSerializer.cc
> @@ -159,6 +159,7 @@
> #include <signal.h>
> #include <strings.h>
> #include <stdarg.h>
> +#include <inttypes.h>
>
> #include "config.h"
> #ifdef TIME_WITH_SYS_TIME
> @@ -1505,13 +1506,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 #%llu",
> + DEBUG_COMM(fmt("parent: ignoring %s due to shutdown of peer #%" PRId64,
> msgToStr(current_msgtype),
> current_peer ? current_peer->id : 0));
> return true;
> }
>
> - DEBUG_COMM(fmt("parent: %s from child; peer is #%llu",
> + DEBUG_COMM(fmt("parent: %s from child; peer is #%" PRId64,
> msgToStr(current_msgtype),
> current_peer ? current_peer->id : 0));
>
> @@ -2610,7 +2611,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), (uint32_t) (peer ? peer->id : PEER_NONE), str));
> + DEBUG_COMM(fmt("parent: (->child) %s (#%" PRId64 ", %s)", msgToStr(type), peer ? peer->id : PEER_NONE, str));
>
> if ( ! child_pid )
> return false;
> @@ -2634,8 +2635,8 @@ bool RemoteSerializer::SendToChild(char type, Peer* peer, int nargs, ...)
>
> #ifdef DEBUG
> va_start(ap, nargs);
> - DEBUG_COMM(fmt("parent: (->child) %s (#%d,%s)",
> - msgToStr(type), (uint32_t) (peer ? peer->id : PEER_NONE), fmt_uint32s(nargs, ap)));
> + DEBUG_COMM(fmt("parent: (->child) %s (#%" PRId64 ",%s)",
> + msgToStr(type), peer ? peer->id : PEER_NONE, fmt_uint32s(nargs, ap)));
> va_end(ap);
> #endif
>
> @@ -3235,7 +3236,7 @@ bool SocketComm::ForwardChunkToPeer()
> {
> #ifdef DEBUG
> if ( parent_peer )
> - DEBUG_COMM(fmt("child: not connected to #%d", (uint) parent_id));
> + DEBUG_COMM(fmt("child: not connected to #%" PRId64, parent_id));
> #endif
> }
>
> @@ -3318,8 +3319,8 @@ bool SocketComm::ProcessRemoteMessage(SocketComm::Peer* peer)
>
> CMsg* msg = (CMsg*) c->data;
>
> - DEBUG_COMM(fmt("child: %s from peer #%d",
> - msgToStr(msg->Type()), (uint) peer->id));
> + DEBUG_COMM(fmt("child: %s from peer #%" PRId64,
> + msgToStr(msg->Type()), peer->id));
>
> switch ( msg->Type() ) {
> case MSG_PHASE_DONE:
> @@ -3795,7 +3796,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), (uint) (peer ? peer->id : RemoteSerializer::PEER_NONE), tmp));
> + DEBUG_COMM(fmt("child: (->parent) %s (#%" PRId64 ", %s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, tmp));
> delete [] tmp;
> #endif
> if ( sendToIO(io, type, peer ? peer->id : RemoteSerializer::PEER_NONE,
> @@ -3814,7 +3815,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), (uint) (peer ? peer->id : RemoteSerializer::PEER_NONE), fmt_uint32s(nargs, ap)));
> + DEBUG_COMM(fmt("child: (->parent) %s (#%" PRId64 ",%s)", msgToStr(type), peer ? peer->id : RemoteSerializer::PEER_NONE, fmt_uint32s(nargs, ap)));
> va_end(ap);
> #endif
>
> @@ -3850,7 +3851,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), (uint) peer->id, tmp));
> + DEBUG_COMM(fmt("child: (->peer) %s to #%" PRId64 " (%s)", msgToStr(type), peer->id, tmp));
> delete [] tmp;
> #endif
>
> @@ -3869,8 +3870,8 @@ bool SocketComm::SendToPeer(Peer* peer, char type, int nargs, ...)
>
> #ifdef DEBUG
> va_start(ap,nargs);
> - DEBUG_COMM(fmt("child: (->peer) %s to #%d (%s)",
> - msgToStr(type), (uint) peer->id, fmt_uint32s(nargs, ap)));
> + DEBUG_COMM(fmt("child: (->peer) %s to #%" PRId64 " (%s)",
> + msgToStr(type), peer->id, fmt_uint32s(nargs, ap)));
> va_end(ap);
> #endif
>
> @@ -3890,7 +3891,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, (uint) peer->id));
> + DEBUG_COMM(fmt("child: (->peer) chunk of size %d to #%" PRId64, 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 a950302..5520ef4 100644
> --- a/src/SMB.cc
> +++ b/src/SMB.cc
> @@ -6,6 +6,7 @@
> #include "SMB.h"
> #include "smb_pac.h"
> #include "Val.h"
> +#include "inttypes.h"
>
> namespace {
> const bool DEBUG_smb_ipc = true;
> @@ -166,7 +167,8 @@ 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 = %ld", next, data + body.length() - data_start));
> + //Weird(fmt("ANDX buffer overlapping: next = %d, buffer_end = %" PRId32, next, data + body.length() - data_start));
> + printf("ANDX buffer overlapping: next = %" PRId64 ", buffer_end = %" PRId32 " ", next, data + body.length() - data_start);
> break;
> }
>
>
> _______________________________________________
> bro-commits mailing list
> bro-commits at bro-ids.org
> http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-commits
>
--
Gregor Maier
<gregor at icir.org> <gregor at icsi.berkeley.edu>
Int. Computer Science Institute (ICSI)
1947 Center St., Ste. 600
Berkeley, CA 94704, USA
http://www.icir.org/gregor/
More information about the bro-dev
mailing list