From 4d8d8c1f387a2f5a8a0297ee9e072e292db0e16d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 19 Apr 2009 23:44:20 +0000 Subject: [PATCH] * Added a "reserved" field to the debug event file header to align it to 8 bytes. * strlcpy() isn't a particularly good string compare function. * BDebugEventInputStream::_GetData(): - Also need to reset fBufferPosition to 0 when the buffer is empty. - Fixed read position. BDebugEventInputStream does now actually read the files written by BDebugEventOutputStream. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30273 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/debug/DebugEventStream.h | 1 + src/kits/debug/DebugEventStream.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/headers/private/debug/DebugEventStream.h b/headers/private/debug/DebugEventStream.h index 85951ef07f..6c07d4db95 100644 --- a/headers/private/debug/DebugEventStream.h +++ b/headers/private/debug/DebugEventStream.h @@ -16,6 +16,7 @@ struct debug_event_stream_header { uint32 version; uint32 flags; uint32 event_mask; + uint32 reserved; }; diff --git a/src/kits/debug/DebugEventStream.cpp b/src/kits/debug/DebugEventStream.cpp index db94250b92..e7f72ee833 100644 --- a/src/kits/debug/DebugEventStream.cpp +++ b/src/kits/debug/DebugEventStream.cpp @@ -75,7 +75,7 @@ BDebugEventInputStream::SetTo(BDataIO* stream) } // check the header - if (strlcpy(header.signature, B_DEBUG_EVENT_STREAM_SIGNATURE, + if (strncmp(header.signature, B_DEBUG_EVENT_STREAM_SIGNATURE, sizeof(header.signature)) != 0 || header.version != B_DEBUG_EVENT_STREAM_VERSION || (header.flags & B_DEBUG_EVENT_STREAM_FLAG_HOST_ENDIAN) == 0) { @@ -185,13 +185,12 @@ BDebugEventInputStream::_GetData(size_t size) return B_BUFFER_OVERFLOW; // move remaining data to the start of the buffer - if (fBufferSize > 0 && fBufferPosition > 0) { + if (fBufferSize > 0 && fBufferPosition > 0) memmove(fBuffer, fBuffer + fBufferPosition, fBufferSize); - fBufferPosition = 0; - } + fBufferPosition = 0; // read more data - ssize_t bytesRead = _Read(fBuffer + fBufferPosition, + ssize_t bytesRead = _Read(fBuffer + fBufferSize, fBufferCapacity - fBufferSize); if (bytesRead < 0) return bytesRead;