* src/util/logging.c (virLogStartup, virLogSetBufferSize): Over-allocate, so that a debugger can just print the circular buffer. Suggested by Daniel Veillard. --- > > I see two ways to do things - either malloc an extra byte (which will > > always be NUL from the malloc, so deleting 'virLogBuffer[virLogSize] = > > 0' is still okay), or by touching the rest of the code to always leave > > virLogBuffer[virLogSize-1] as NUL (more invasive, and caps the useful > > log to virLogSize-1). Do you want me to prepare a followup patch, and > > if so, for which of those two options? > > it's really a minor issue, malloc'ing an extra byte sounds fine to me. src/util/logging.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/logging.c b/src/util/logging.c index f4910ad..48c0cfd 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -197,14 +197,14 @@ int virLogStartup(void) { virLogInitialized = 1; virLogLock(); - if (VIR_ALLOC_N(virLogBuffer, virLogSize) < 0) { + if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) { /* * The debug buffer is not a critical component, allow startup * even in case of failure to allocate it in case of a * configuration mistake. */ virLogSize = 64 * 1024; - if (VIR_ALLOC_N(virLogBuffer, virLogSize) < 0) { + if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) { pbm = "Failed to allocate debug buffer: deactivating debug log\n"; virLogSize = 0; } else { @@ -249,14 +249,14 @@ virLogSetBufferSize(int size) { oldsize = virLogSize; oldLogBuffer = virLogBuffer; - if (INT_MAX / 1024 < size) { + if (INT_MAX / 1024 <= size) { pbm = "Requested log size of %d kB too large\n"; ret = -1; goto error; } virLogSize = size * 1024; - if (VIR_ALLOC_N(virLogBuffer, virLogSize) < 0) { + if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) { pbm = "Failed to allocate debug buffer of %d kB\n"; virLogBuffer = oldLogBuffer; virLogSize = oldsize; -- 1.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list