aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-08-28 05:01:16 +0000
committerEric Wong <normalperson@yhbt.net>2007-08-28 05:01:16 +0000
commitcd6e584c35c4709b3aeef54b69e0504f2440a8c0 (patch)
tree650d5672ebee33bd3bbc86f30fa1f49d24e8d454 /src
parent1b045d0672cb1a069efd2d150d81ae3d5253ada5 (diff)
downloadmpd-cd6e584c35c4709b3aeef54b69e0504f2440a8c0.tar.gz
mpd-cd6e584c35c4709b3aeef54b69e0504f2440a8c0.tar.xz
mpd-cd6e584c35c4709b3aeef54b69e0504f2440a8c0.zip
log: cleanup: avoid "magic" numbers
We used a bare '15' in several places and it's not immediately obvious where it came from. This makes it more obvious git-svn-id: https://svn.musicpd.org/mpd/trunk@6829 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/log.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/log.c b/src/log.c
index 7701da3a5..39c1d0442 100644
--- a/src/log.c
+++ b/src/log.c
@@ -28,6 +28,8 @@
#include <stdarg.h>
#include <time.h>
+#define LOG_DATE_BUF_SIZE 16
+#define LOG_DATE_LEN (LOG_DATE_BUF_SIZE - 1)
static unsigned int logLevel = LOG_LEVEL_LOW;
static int warningFlushed;
static int stdout_mode = 1;
@@ -59,9 +61,9 @@ static void redirect_logs(void)
static const char *log_date(void)
{
- static char buf[16];
+ static char buf[LOG_DATE_BUF_SIZE];
time_t t = time(NULL);
- strftime(buf, 16, "%b %d %H:%M : ", localtime(&t));
+ strftime(buf, LOG_DATE_BUF_SIZE, "%b %d %H:%M : ", localtime(&t));
return buf;
}
@@ -73,9 +75,9 @@ static void buffer_warning(const char *fmt, va_list args)
size_t len = BUFFER_LENGTH;
if (!stdout_mode) {
- memcpy(buffer, log_date(), 15);
- tmp += 15;
- len -= 15;
+ memcpy(buffer, log_date(), LOG_DATE_LEN);
+ tmp += LOG_DATE_LEN;
+ len -= LOG_DATE_LEN;
}
vsnprintf(tmp, len, fmt, args);
@@ -87,7 +89,7 @@ static void buffer_warning(const char *fmt, va_list args)
static void do_log(FILE *fp, const char *fmt, va_list args)
{
if (!stdout_mode)
- fwrite(log_date(), 15, 1, fp);
+ fwrite(log_date(), LOG_DATE_LEN, 1, fp);
vfprintf(fp, fmt, args);
}