From bf73613543e99ac53cba3cca9465b538fad73aa2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 15 Oct 2006 22:54:47 +0200 Subject: [PATCH] [CLEANUP] added the correct cast to call localtime() Calling localtime() with a timeval.tv_sec causes a warning on OpenBSD where the tv_sec is declared long. --- src/haproxy.c | 2 +- src/log.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index 92dc6264bc..1459543850 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -349,7 +349,7 @@ void init(int argc, char **argv) * Also, the Alert() and Warning() functions need to be initialized. */ tv_now(&now); - localtime(&now.tv_sec); + localtime((time_t *)&now.tv_sec); start_date = now; init_log(); diff --git a/src/log.c b/src/log.c index 0711c030fb..3f0625e30d 100644 --- a/src/log.c +++ b/src/log.c @@ -73,7 +73,7 @@ void Alert(const char *fmt, ...) if (!(global.mode & MODE_QUIET) || (global.mode & (MODE_VERBOSE | MODE_STARTING))) { va_start(argp, fmt); - tm = localtime(&now.tv_sec); + tm = localtime((time_t *)&now.tv_sec); fprintf(stderr, "[ALERT] %03d/%02d%02d%02d (%d) : ", tm->tm_yday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)getpid()); vfprintf(stderr, fmt, argp); @@ -94,7 +94,7 @@ void Warning(const char *fmt, ...) if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { va_start(argp, fmt); - tm = localtime(&now.tv_sec); + tm = localtime((time_t *)&now.tv_sec); fprintf(stderr, "[WARNING] %03d/%02d%02d%02d (%d) : ", tm->tm_yday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)getpid()); vfprintf(stderr, fmt, argp); @@ -194,7 +194,7 @@ void send_log(struct proxy *p, int level, const char *message, ...) if (now.tv_sec != tvsec || dataptr == NULL) { /* this string is rebuild only once a second */ - struct tm *tm = localtime(&now.tv_sec); + struct tm *tm = localtime((time_t *)&now.tv_sec); tvsec = now.tv_sec; hdr_len = snprintf(logmsg, sizeof(logmsg), @@ -317,7 +317,7 @@ void sess_log(struct session *s) (s->data_source != DATA_SRC_STATS) ? (s->srv != NULL) ? s->srv->id : "" : "" : "-"; - tm = localtime(&s->logs.tv_accept.tv_sec); + tm = localtime((time_t *)&s->logs.tv_accept.tv_sec); if (p->to_log & LW_REQ) { char tmpline[MAX_SYSLOG_LEN], *h; int hdr; -- 2.47.2