From ff6000745886cb085ca80e42498020497bc7f95f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 3 Apr 2011 22:23:14 +0000 Subject: Fix build with NDEBUG defined svn path=/trunk/netsurf/; revision=12154 --- utils/log.c | 13 +++++++++---- utils/log.h | 9 ++++----- utils/utils.c | 3 --- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'utils') diff --git a/utils/log.c b/utils/log.c index 31ca89d13..0f9290bf7 100644 --- a/utils/log.c +++ b/utils/log.c @@ -28,9 +28,6 @@ #include "utils/utils.h" #include "utils/log.h" -static struct timeval start_tv; -static char buff[32]; - nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) { nserror ret = NSERROR_OK; @@ -59,9 +56,13 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) return ret; } +#ifndef NDEBUG const char *nslog_gettime(void) { + static struct timeval start_tv; + static char buff[32]; + struct timeval tv; struct timeval now_tv; @@ -72,7 +73,9 @@ const char *nslog_gettime(void) timeval_subtract(&tv, &now_tv, &start_tv); - snprintf(buff, sizeof(buff),"(%ld.%ld)", (long)tv.tv_sec, (long)tv.tv_usec); + snprintf(buff, sizeof(buff),"(%ld.%ld)", + (long)tv.tv_sec, (long)tv.tv_usec); + return buff; } @@ -89,3 +92,5 @@ void nslog_log(const char *format, ...) } } +#endif + diff --git a/utils/log.h b/utils/log.h index 84a211d95..b49f439db 100644 --- a/utils/log.h +++ b/utils/log.h @@ -24,11 +24,6 @@ #include "desktop/netsurf.h" #include "utils/errors.h" -#ifdef NDEBUG -# define LOG(x) ((void) 0) -#else - - /** * Ensures the FILE handle is available to write logging to. * @@ -45,6 +40,10 @@ typedef bool(nslog_ensure_t)(FILE *fptr); */ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); +#ifdef NDEBUG +# define LOG(x) ((void) 0) +#else + /** * Obtain a formatted string suitable for prepending to a log message * diff --git a/utils/utils.c b/utils/utils.c index 66c020f1d..f632af9e4 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -33,9 +33,6 @@ #include #include "utils/config.h" -#define NDEBUG -#include "utils/log.h" -#undef NDEBUG #include "utils/messages.h" #include "utils/utf8.h" #include "utils/utils.h" -- cgit v1.2.3