* Fixed the semantics of [v]snprintf(): If the buffer is not large enough,
the function shall nevertheless return the length of the string that would be written, if the buffer were large enough. Added a touch of C++ while doing that. :-) * Fixed the instances in boot loader, kernel, and kernel modules where the wrong semantics were expected. The majority of uses actually. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34826 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <arch/debug.h>
|
||||
#include <debug.h>
|
||||
#include <elf.h>
|
||||
@@ -596,10 +598,14 @@ TraceOutput::Print(const char* format,...)
|
||||
if (IsFull())
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
fSize += vsnprintf(fBuffer + fSize, fCapacity - fSize, format, args);
|
||||
va_end(args);
|
||||
if (fSize < fCapacity) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
size_t length = vsnprintf(fBuffer + fSize, fCapacity - fSize, format,
|
||||
args);
|
||||
fSize += std::min(length, fCapacity - fSize - 1);
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user