* 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:
Ingo Weinhold
2009-12-30 15:17:09 +00:00
parent 3069ca963e
commit 3ce2634533
12 changed files with 199 additions and 180 deletions
+9 -2
View File
@@ -7,12 +7,15 @@
* Distributed under the terms of the NewOS License.
*/
#include "debug_commands.h"
#include <setjmp.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <KernelExport.h>
#include <debug.h>
@@ -111,8 +114,12 @@ public:
return;
// print directly into the buffer
fBufferSize += vsnprintf(fBuffer + fBufferSize,
fBufferCapacity - fBufferSize, format, args);
if (fBufferSize < fBufferCapacity) {
size_t totalBytes = vsnprintf(fBuffer + fBufferSize,
fBufferCapacity - fBufferSize, format, args);
fBufferSize += std::min(totalBytes,
fBufferCapacity - fBufferSize - 1);
}
// execute every complete line
fBuffer[fBufferSize] = '\0';