mirror of
https://github.com/weechat/weechat.git
synced 2026-07-10 03:33:12 +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:
@@ -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
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user