[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.
diff --git a/src/haproxy.c b/src/haproxy.c
index 92dc626..1459543 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -349,7 +349,7 @@
* Also, the Alert() and Warning() functions need <now> 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 0711c03..3f0625e 100644
--- a/src/log.c
+++ b/src/log.c
@@ -73,7 +73,7 @@
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 @@
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 @@
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 @@
(s->data_source != DATA_SRC_STATS) ?
(s->srv != NULL) ? s->srv->id : "<NOSRV>" : "<STATS>" : "-";
- 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;