1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

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().
This commit is contained in:
Sebastien Helleu
2014-01-05 10:42:49 +01:00
parent f840c64626
commit a571d599d3
3 changed files with 16 additions and 7 deletions
+6 -2
View File
@@ -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 */
+5 -2
View File
@@ -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),
+5 -3
View File
@@ -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))
{