From: Simon Ruderich Date: Fri, 9 Aug 2013 19:03:33 +0000 (+0200) Subject: log.c: Simplify #ifdef DEBUG in log_message(). X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=d87efa4a7a6285603950f5780ef57a72b651c8e9;p=tlsproxy%2Ftlsproxy.git log.c: Simplify #ifdef DEBUG in log_message(). As we use flockfile() multiple fprintf() don't create a race-condition. This also prevents a warning with clang which uses a macro for fprintf(). #ifdefs within macro arguments is not portable. --- diff --git a/src/log.c b/src/log.c index 4dc53f7..b3c2083 100644 --- a/src/log.c +++ b/src/log.c @@ -45,18 +45,13 @@ void log_message(int level, const char *file, int line, const char *format, ...) (void)line; #endif - /* Prevent another thread from interrupting the two printfs(). */ + /* Prevent another thread from interrupting the printfs(). */ flockfile(stderr); - fprintf(stderr, #ifdef DEBUG - "%-12s:%-3d " + fprintf(stderr, "%-12s:%-3d ", file, line); #endif - "[%s] [%d] ", -#ifdef DEBUG - file, line, -#endif - level_string, (int)pthread_self()); + fprintf(stderr, "[%s] [%d] ", level_string, (int)pthread_self()); va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);