summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-01-05 10:42:49 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-01-05 10:42:49 +0100
commita571d599d39e7b05d90c53aaa23cee7c68197e38 (patch)
tree72b27cfc06aa67bc174d187ca472a35a9abf8e23 /src
parentf840c64626cfba47a55a9f158a13f6f57a12e35e (diff)
downloadweechat-a571d599d39e7b05d90c53aaa23cee7c68197e38.zip
core: fix compilation warnings on OpenBSD
On OpenBSD, the variable "tv_sec" in struct timeval has type "long" (type "time_t" under Linux). So we need to copy this value to a temporary variable before using its pointer with function localtime().
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c8
-rw-r--r--src/core/wee-hook.c7
-rw-r--r--src/gui/curses/gui-curses-chat.c8
3 files changed, 16 insertions, 7 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 9afaf6562..b91e89d03 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -851,6 +851,7 @@ config_day_change_timer_cb (void *data, int remaining_calls)
{
struct timeval tv_time;
struct tm *local_time;
+ time_t seconds;
int new_mday;
char str_time[256];
@@ -859,7 +860,8 @@ config_day_change_timer_cb (void *data, int remaining_calls)
(void) remaining_calls;
gettimeofday (&tv_time, NULL);
- local_time = localtime (&tv_time.tv_sec);
+ seconds = tv_time.tv_sec;
+ local_time = localtime (&seconds);
new_mday = local_time->tm_mday;
if ((config_day_change_old_day >= 0)
@@ -3362,6 +3364,7 @@ config_weechat_init ()
int rc;
struct timeval tv_time;
struct tm *local_time;
+ time_t seconds;
rc = config_weechat_init_options ();
@@ -3375,7 +3378,8 @@ config_weechat_init ()
{
/* create timer to check if day has changed */
gettimeofday (&tv_time, NULL);
- local_time = localtime (&tv_time.tv_sec);
+ seconds = tv_time.tv_sec;
+ local_time = localtime (&seconds);
config_day_change_old_day = local_time->tm_mday;
config_day_change_timer = hook_timer (NULL,
60 * 1000, /* each minute */
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 2806ce65d..762705bcb 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -3942,6 +3942,7 @@ hook_print_log ()
int type, i, j;
struct t_hook *ptr_hook;
struct tm *local_time;
+ time_t seconds;
char text_time[1024];
for (type = 0; type < HOOK_NUM_TYPES; type++)
@@ -4012,7 +4013,8 @@ hook_print_log ()
log_printf (" align_second. . . . . : %d", HOOK_TIMER(ptr_hook, align_second));
log_printf (" remaining_calls . . . : %d", HOOK_TIMER(ptr_hook, remaining_calls));
text_time[0] = '\0';
- local_time = localtime (&HOOK_TIMER(ptr_hook, last_exec).tv_sec);
+ seconds = HOOK_TIMER(ptr_hook, last_exec).tv_sec;
+ local_time = localtime (&seconds);
if (local_time)
{
strftime (text_time, sizeof (text_time),
@@ -4023,7 +4025,8 @@ hook_print_log ()
text_time);
log_printf (" last_exec.tv_usec . . : %ld", HOOK_TIMER(ptr_hook, last_exec.tv_usec));
text_time[0] = '\0';
- local_time = localtime (&HOOK_TIMER(ptr_hook, next_exec).tv_sec);
+ seconds = HOOK_TIMER(ptr_hook, next_exec).tv_sec;
+ local_time = localtime (&seconds);
if (local_time)
{
strftime (text_time, sizeof (text_time),
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index eb5021d44..430e62d6b 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -1229,7 +1229,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
struct t_gui_line *ptr_prev_line, *ptr_next_line;
struct tm local_time, local_time2;
struct timeval tv_time;
- time_t *ptr_time;
+ time_t seconds, *ptr_time;
if (!line)
return 0;
@@ -1274,7 +1274,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (!ptr_prev_line)
{
gettimeofday (&tv_time, NULL);
- localtime_r (&tv_time.tv_sec, &local_time);
+ seconds = tv_time.tv_sec;
+ localtime_r (&seconds, &local_time);
localtime_r (&line->data->date, &local_time2);
if ((local_time.tm_mday != local_time2.tm_mday)
|| (local_time.tm_mon != local_time2.tm_mon)
@@ -1470,7 +1471,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
{
/* it was the last line => compare with current system time */
gettimeofday (&tv_time, NULL);
- ptr_time = &tv_time.tv_sec;
+ seconds = tv_time.tv_sec;
+ ptr_time = &seconds;
}
if (ptr_time && (*ptr_time != 0))
{