summaryrefslogtreecommitdiff
path: root/src/helper/log.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-04-09 05:55:23 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-04-09 05:55:23 +0000
commit2585fc34200938fb3fa55a450ea37f68012aafa7 (patch)
tree1b43cf1f32e7ac5f52596fe7660923a7f63b8927 /src/helper/log.c
parenta0647227439434c4a71470e336ec8715d43d0501 (diff)
downloadopenocd_libswd-2585fc34200938fb3fa55a450ea37f68012aafa7.tar.gz
openocd_libswd-2585fc34200938fb3fa55a450ea37f68012aafa7.tar.bz2
openocd_libswd-2585fc34200938fb3fa55a450ea37f68012aafa7.tar.xz
openocd_libswd-2585fc34200938fb3fa55a450ea37f68012aafa7.zip
Don Porges fixed c99 issues.
git-svn-id: svn://svn.berlios.de/openocd/trunk@553 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper/log.c')
-rw-r--r--src/helper/log.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/helper/log.c b/src/helper/log.c
index d0f0e3dd..34e73b6a 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
-#include <time.h>
int debug_level = -1;
@@ -61,6 +60,7 @@ static int count = 0;
*/
static void log_puts(enum log_levels level, const char *file, int line, const char *function, const char *string)
{
+ char *f;
if (level == LOG_LVL_OUTPUT)
{
/* do not prepend any headers, just print out what we were given and return */
@@ -69,7 +69,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
return;
}
- char *f = strrchr(file, '/');
+ f = strrchr(file, '/');
if (f != NULL)
file = f + 1;
@@ -112,12 +112,12 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
{
char *string;
+ va_list ap;
count++;
if (level > debug_level)
return;
- va_list ap;
va_start(ap, format);
string = alloc_vprintf(format, ap);
@@ -133,12 +133,12 @@ void log_printf(enum log_levels level, const char *file, int line, const char *f
void log_printf_lf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
{
char *string;
+ va_list ap;
count++;
if (level > debug_level)
return;
- va_list ap;
va_start(ap, format);
string = alloc_vprintf(format, ap);
@@ -276,6 +276,8 @@ char *alloc_vprintf(const char *fmt, va_list ap)
for (;;)
{
char *t = string;
+ va_list ap_copy;
+ int ret;
string = realloc(string, size);
if (string == NULL)
{
@@ -284,10 +286,8 @@ char *alloc_vprintf(const char *fmt, va_list ap)
return NULL;
}
- va_list ap_copy;
va_copy(ap_copy, ap);
- int ret;
ret = vsnprintf(string, size, fmt, ap_copy);
/* NB! The result of the vsnprintf() might be an *EMPTY* string! */
if ((ret >= 0) && ((ret + 1) < size))