]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] added the correct cast to call localtime()
authorWilly Tarreau <w@1wt.eu>
Sun, 15 Oct 2006 20:54:47 +0000 (22:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 15 Oct 2006 20:54:47 +0000 (22:54 +0200)
Calling localtime() with a timeval.tv_sec causes a warning on
OpenBSD where the tv_sec is declared long.

src/haproxy.c
src/log.c

index 92dc6264bce81eb602de207ad03260afcf21f9ec..1459543850fcde153ee446a88d80025d185df0b4 100644 (file)
@@ -349,7 +349,7 @@ void init(int argc, char **argv)
         * 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();
index 0711c030fb4eb187fd64b774f5a3aeae8cde1388..3f0625e30d6661ad0da0b8f78647c8d202fdad9b 100644 (file)
--- 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 : "<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;