[libbluray-devel] Fix for logging failure on Win32 platform
tourettes
tourettesmp at gmail.com
Wed Mar 20 15:57:44 CET 2013
logging.c is using zero as the buffer size for the log stream. It is not
a valid parameter on Win32 platform:
http://msdn.microsoft.com/en-us/library/86cebhfs(v=vs.80).aspx
"Buffer size in bytes. Allowable range: 2 <= size <= INT_MAX
(2147483647). Internally, the value supplied for size is rounded down to
the nearest multiple of 2."
An error will be thrown from the C runtime:
if ((type == _IOFBF) || (type == _IOLBF))
{
_VALIDATE_RETURN( ((2 <= size) && (size <= INT_MAX)),
EINVAL, -1 );
}
-------------- next part --------------
>From 901ddbc4c8a66e3ef7d307e3b85f415b1d87fd3f Mon Sep 17 00:00:00 2001
From: tourettes <tourettesmp at gmail.com>
Date: Wed, 20 Mar 2013 16:50:15 +0200
Subject: [PATCH 3/3] Configure stream buffer size for the log stream
Provide a buffer size parameter for setvbuf(). Currently zero is used and that is not a valid buffer size on Win32 platform.
---
src/util/logging.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/logging.c b/src/util/logging.c
index c8aa488..a546660 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -25,6 +25,8 @@
#include <stdarg.h>
#include <string.h>
+#define DEBUG_BUFFER_SIZE 4096
+
uint32_t debug_mask = DBG_CRIT;
static BD_LOG_FUNC log_func = NULL;
@@ -72,7 +74,7 @@ void bd_debug(const char *file, int line, uint32_t mask, const char *format, ...
FILE *fp = fopen(env, "wb");
if (fp) {
logfile = fp;
- setvbuf(logfile, NULL, _IOLBF, 0);
+ setvbuf(logfile, NULL, _IOLBF, DEBUG_BUFFER_SIZE);
} else {
fprintf(logfile, "%s:%d: Error opening log file %s\n", __FILE__, __LINE__, env);
}
@@ -80,7 +82,7 @@ void bd_debug(const char *file, int line, uint32_t mask, const char *format, ...
}
if (mask & debug_mask) {
- char buffer[4096], *pt = buffer;
+ char buffer[DEBUG_BUFFER_SIZE], *pt = buffer;
va_list args;
pt += sprintf(buffer, "%s:%d: ", file, line);
--
1.8.1.msysgit.1
More information about the libbluray-devel
mailing list