From c464cf78dd9d3e8b16c53141e080bfc5560ac17d Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Fri, 12 Aug 2016 15:42:02 -0700 Subject: [PATCH] Fix a number of format errors when using debug macros. --- src/DebugLogger.h | 4 ++-- src/RemoteSerializer.cc | 2 +- src/SerializationFormat.cc | 8 ++++---- src/analyzer/Analyzer.cc | 4 ++-- src/file_analysis/File.cc | 2 +- src/file_analysis/FileTimer.cc | 2 +- src/input/Manager.cc | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/DebugLogger.h b/src/DebugLogger.h index 18068419b8..3ec3979e7f 100644 --- a/src/DebugLogger.h +++ b/src/DebugLogger.h @@ -58,8 +58,8 @@ public: void OpenDebugLog(const char* filename = 0); - void Log(DebugStream stream, const char* fmt, ...); - void Log(const plugin::Plugin& plugin, const char* fmt, ...); + void Log(DebugStream stream, const char* fmt, ...) __attribute__((format(printf, 3, 4))); + void Log(const plugin::Plugin& plugin, const char* fmt, ...) __attribute__((format(printf, 3, 4))); void PushIndent(DebugStream stream) { ++streams[int(stream)].indent; } diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index 16add7c9c5..4842f819b6 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -250,7 +250,7 @@ struct ping_args { }; #ifdef DEBUG -# define DEBUG_COMM(msg) DBG_LOG(DBG_COMM, msg) +# define DEBUG_COMM(msg) DBG_LOG(DBG_COMM, "%s", msg) #else # define DEBUG_COMM(msg) #endif diff --git a/src/SerializationFormat.cc b/src/SerializationFormat.cc index 9bceb5a5b2..1090c24d93 100644 --- a/src/SerializationFormat.cc +++ b/src/SerializationFormat.cc @@ -126,7 +126,7 @@ bool BinarySerializationFormat::Read(uint32* v, const char* tag) return false; *v = ntohl(*v); - DBG_LOG(DBG_SERIAL, "Read uint32 %ld [%s]", *v, tag); + DBG_LOG(DBG_SERIAL, "Read uint32 %u [%s]", *v, tag); return true; } @@ -313,7 +313,7 @@ bool BinarySerializationFormat::Write(uint16 v, const char* tag) bool BinarySerializationFormat::Write(uint32 v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write uint32 %ld [%s]", v, tag); + DBG_LOG(DBG_SERIAL, "Write uint32 %u [%s]", v, tag); v = htonl(v); return WriteData(&v, sizeof(v)); } @@ -327,7 +327,7 @@ bool BinarySerializationFormat::Write(int v, const char* tag) bool BinarySerializationFormat::Write(uint64 v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write uint64 %lu [%s]", v, tag); + DBG_LOG(DBG_SERIAL, "Write uint64 %llu [%s]", v, tag); uint32 x[2]; x[0] = htonl(v >> 32); x[1] = htonl(v & 0xffffffff); @@ -336,7 +336,7 @@ bool BinarySerializationFormat::Write(uint64 v, const char* tag) bool BinarySerializationFormat::Write(int64 v, const char* tag) { - DBG_LOG(DBG_SERIAL, "Write int64 %ld [%s]", v, tag); + DBG_LOG(DBG_SERIAL, "Write int64 %lld [%s]", v, tag); uint32 x[2]; x[0] = htonl(v >> 32); x[1] = htonl(v & 0xffffffff); diff --git a/src/analyzer/Analyzer.cc b/src/analyzer/Analyzer.cc index b44e0cc978..1dc9df5872 100644 --- a/src/analyzer/Analyzer.cc +++ b/src/analyzer/Analyzer.cc @@ -441,7 +441,7 @@ void Analyzer::RemoveChildAnalyzer(ID id) LOOP_OVER_CHILDREN(i) if ( (*i)->id == id && ! ((*i)->finished || (*i)->removing) ) { - DBG_LOG(DBG_ANALYZER, "%s disabling child %s", GetAnalyzerName(), id, + DBG_LOG(DBG_ANALYZER, "%s disabling child %s", fmt_analyzer(this).c_str(), fmt_analyzer(*i).c_str()); // See comment above. (*i)->removing = true; @@ -638,7 +638,7 @@ void Analyzer::EndOfData(bool is_orig) void Analyzer::FlipRoles() { - DBG_LOG(DBG_ANALYZER, "%s FlipRoles()"); + DBG_LOG(DBG_ANALYZER, "%s FlipRoles()", fmt_analyzer(this).c_str()); LOOP_OVER_CHILDREN(i) (*i)->FlipRoles(); diff --git a/src/file_analysis/File.cc b/src/file_analysis/File.cc index 9f554899fa..3b674b3ef9 100644 --- a/src/file_analysis/File.cc +++ b/src/file_analysis/File.cc @@ -533,7 +533,7 @@ void File::EndOfFile() void File::Gap(uint64 offset, uint64 len) { - DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Gap of size %" PRIu64 " at offset %," PRIu64, + DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Gap of size %" PRIu64 " at offset %" PRIu64, id.c_str(), len, offset); if ( file_reassembler && ! file_reassembler->IsCurrentlyFlushing() ) diff --git a/src/file_analysis/FileTimer.cc b/src/file_analysis/FileTimer.cc index 6b1d70f136..40237ebb54 100644 --- a/src/file_analysis/FileTimer.cc +++ b/src/file_analysis/FileTimer.cc @@ -9,7 +9,7 @@ FileTimer::FileTimer(double t, const string& id, double interval) : Timer(t + interval, TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id) { DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s", - file_id.c_str(), interval); + interval, file_id.c_str()); } void FileTimer::Dispatch(double t, int is_expire) diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 1b12e57ea3..14de6305c8 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -1853,7 +1853,7 @@ bool Manager::SendEvent(ReaderFrontend* reader, const string& name, const int nu } #ifdef DEBUG - DBG_LOG(DBG_INPUT, "SendEvent for event %s with num_vals vals", + DBG_LOG(DBG_INPUT, "SendEvent for event %s with %d vals", name.c_str(), num_vals); #endif @@ -1909,7 +1909,7 @@ void Manager::SendEvent(EventHandlerPtr ev, list events) val_list* vl = new val_list; #ifdef DEBUG - DBG_LOG(DBG_INPUT, "SendEvent with %d vals (list)", + DBG_LOG(DBG_INPUT, "SendEvent with %lu vals (list)", events.size()); #endif