core: fix cast of time_t (to "long long" instead of "long") (closes #1051)

v2.8-utf8proc
Sébastien Helleu 2017-08-12 18:36:45 +02:00
parent 6e366095f9
commit aeeec38d6f
24 changed files with 66 additions and 65 deletions

View File

@ -31,6 +31,7 @@ Improvements::
Bug fixes::
* core: fix cast of time_t (to "long long" instead of "long") (issue #1051)
* core: call the config hook when options are renamed or removed
* buflist: fix crash in auto-scroll of bar when the buflist item is not the first item in the bar
* relay: fix send of "PART" command in backlog (irc protocol)

View File

@ -216,7 +216,7 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path)
break;
case WEECHAT_HDATA_TIME:
snprintf (str_value, sizeof (str_value),
"%ld", (long)hdata_time (hdata, pointer, var_name));
"%lld", (long long)hdata_time (hdata, pointer, var_name));
value = strdup (str_value);
break;
case WEECHAT_HDATA_HASHTABLE:
@ -249,7 +249,7 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path)
break;
case HASHTABLE_TIME:
snprintf (str_value, sizeof (str_value),
"%ld", (long)(*((time_t *)ptr_value)));
"%lld", (long long)(*((time_t *)ptr_value)));
value = strdup (str_value);
break;
case HASHTABLE_NUM_TYPES:

View File

@ -554,7 +554,7 @@ hashtable_to_string (enum t_hashtable_type type, const void *value)
break;
case HASHTABLE_TIME:
snprintf (str_value, sizeof (str_value),
"%ld", (long)(*((time_t *)value)));
"%lld", (long long)(*((time_t *)value)));
return str_value;
break;
case HASHTABLE_NUM_TYPES:
@ -1235,7 +1235,7 @@ hashtable_print_log (struct t_hashtable *hashtable, const char *name)
log_printf (" key (buffer) . . . : 0x%lx", ptr_item->key);
break;
case HASHTABLE_TIME:
log_printf (" key (time) . . . . : %ld", *((time_t *)ptr_item->key));
log_printf (" key (time) . . . . : %lld", (long long)(*((time_t *)ptr_item->key)));
break;
case HASHTABLE_NUM_TYPES:
break;

View File

@ -4807,8 +4807,8 @@ hook_print_log ()
strftime (text_time, sizeof (text_time),
"%d/%m/%Y %H:%M:%S", local_time);
}
log_printf (" last_exec.tv_sec. . . : %ld (%s)",
HOOK_TIMER(ptr_hook, last_exec.tv_sec),
log_printf (" last_exec.tv_sec. . . : %lld (%s)",
(long long)(HOOK_TIMER(ptr_hook, last_exec.tv_sec)),
text_time);
log_printf (" last_exec.tv_usec . . : %ld", HOOK_TIMER(ptr_hook, last_exec.tv_usec));
text_time[0] = '\0';
@ -4819,8 +4819,8 @@ hook_print_log ()
strftime (text_time, sizeof (text_time),
"%d/%m/%Y %H:%M:%S", local_time);
}
log_printf (" next_exec.tv_sec. . . : %ld (%s)",
HOOK_TIMER(ptr_hook, next_exec.tv_sec),
log_printf (" next_exec.tv_sec. . . : %lld (%s)",
(long long)(HOOK_TIMER(ptr_hook, next_exec.tv_sec)),
text_time);
log_printf (" next_exec.tv_usec . . : %ld", HOOK_TIMER(ptr_hook, next_exec.tv_usec));
break;

View File

@ -770,7 +770,7 @@ infolist_print_log ()
log_printf (" size of buffer . . . : %d", ptr_var->size);
break;
case INFOLIST_TIME:
log_printf (" value (time) . . . . : %ld", *((time_t *)ptr_var->value));
log_printf (" value (time) . . . . : %lld", (long long)(*((time_t *)ptr_var->value)));
break;
}
log_printf (" prev_var . . . . . . : 0x%lx", ptr_var->prev_var);

View File

@ -39,26 +39,26 @@
#include "gui-window.h"
#define FOCUS_STR(__name, __string) \
#define FOCUS_STR(__name, __string) \
hashtable_set (hashtable, __name, __string);
#define FOCUS_STR_VAR(__name, __var) \
#define FOCUS_STR_VAR(__name, __var) \
hashtable_set (hashtable, __name, (__var) ? __var : "");
#define FOCUS_INT(__name, __int) \
snprintf (str_value, sizeof (str_value), "%d", __int); \
#define FOCUS_INT(__name, __int) \
snprintf (str_value, sizeof (str_value), "%d", __int); \
hashtable_set (hashtable, __name, str_value);
#define FOCUS_TIME(__name, __time) \
snprintf (str_value, sizeof (str_value), "%ld", (long)__time); \
#define FOCUS_TIME(__name, __time) \
snprintf (str_value, sizeof (str_value), "%lld", (long long)__time); \
hashtable_set (hashtable, __name, str_value);
#define FOCUS_PTR(__name, __pointer) \
if (__pointer) \
{ \
snprintf (str_value, sizeof (str_value), \
"0x%lx", (long unsigned int)__pointer); \
hashtable_set (hashtable, __name, str_value); \
} \
else \
{ \
hashtable_set (hashtable, __name, ""); \
#define FOCUS_PTR(__name, __pointer) \
if (__pointer) \
{ \
snprintf (str_value, sizeof (str_value), \
"0x%lx", (long unsigned int)__pointer); \
hashtable_set (hashtable, __name, str_value); \
} \
else \
{ \
hashtable_set (hashtable, __name, ""); \
}

View File

@ -128,10 +128,10 @@ end:
break;
case WEECHAT_HDATA_TIME:
snprintf (str_value, sizeof (str_value),
"%ld",
"%lld",
(ptr_buffer) ?
(long int)weechat_hdata_time (buflist_hdata_buffer,
ptr_buffer, list_keys[i]) : -1);
(long long)weechat_hdata_time (buflist_hdata_buffer,
ptr_buffer, list_keys[i]) : -1);
weechat_hashtable_set (info, list_keys[i], str_value);
break;
default: /* ignore other types */

View File

@ -691,8 +691,8 @@ exec_print_log ()
weechat_log_printf (" command . . . . . . . . . : '%s'", ptr_exec_cmd->command);
weechat_log_printf (" pid . . . . . . . . . . . : %d", ptr_exec_cmd->pid);
weechat_log_printf (" detached. . . . . . . . . : %d", ptr_exec_cmd->detached);
weechat_log_printf (" start_time. . . . . . . . : %ld", ptr_exec_cmd->start_time);
weechat_log_printf (" end_time. . . . . . . . . : %ld", ptr_exec_cmd->end_time);
weechat_log_printf (" start_time. . . . . . . . : %lld", (long long)ptr_exec_cmd->start_time);
weechat_log_printf (" end_time. . . . . . . . . : %lld", (long long)ptr_exec_cmd->end_time);
weechat_log_printf (" output_to_buffer. . . . . : %d", ptr_exec_cmd->output_to_buffer);
weechat_log_printf (" output_to_buffer_exec_cmd : %d", ptr_exec_cmd->output_to_buffer_exec_cmd);
weechat_log_printf (" buffer_full_name. . . . . : '%s'", ptr_exec_cmd->buffer_full_name);

View File

@ -2487,7 +2487,7 @@ weechat_guile_api_hook_print_cb (const void *pointer, void *data,
if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);

View File

@ -1686,9 +1686,9 @@ irc_channel_print_log (struct t_irc_channel *channel)
ptr_nick_speaking;
ptr_nick_speaking = ptr_nick_speaking->next_nick)
{
weechat_log_printf (" nick speaking time: '%s', time: %ld",
weechat_log_printf (" nick speaking time: '%s', time: %lld",
ptr_nick_speaking->nick,
ptr_nick_speaking->time_last_message);
(long long)ptr_nick_speaking->time_last_message);
}
}
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)

View File

@ -1526,8 +1526,8 @@ IRC_COMMAND_CALLBACK(ctcp)
{
/* generate argument for PING if not provided */
gettimeofday (&tv, NULL);
snprintf (str_time, sizeof (str_time), "%ld %ld",
(long)tv.tv_sec, (long)tv.tv_usec);
snprintf (str_time, sizeof (str_time), "%lld %ld",
(long long)tv.tv_sec, (long)tv.tv_usec);
ctcp_args = str_time;
}
else

View File

@ -1209,7 +1209,7 @@ irc_redirect_print_log (struct t_irc_server *server)
weechat_log_printf (" timeout . . . . . . : %d", ptr_redirect->timeout);
weechat_log_printf (" command . . . . . . : '%s'", ptr_redirect->command);
weechat_log_printf (" assigned_to_command : %d", ptr_redirect->assigned_to_command);
weechat_log_printf (" start_time. . . . . : %ld", ptr_redirect->start_time);
weechat_log_printf (" start_time. . . . . : %lld", (long long)ptr_redirect->start_time);
weechat_log_printf (" cmd_start . . . . . : 0x%lx (hashtable: '%s')",
ptr_redirect->cmd_start,
weechat_hashtable_get_string (ptr_redirect->cmd_start, "keys_values"));

View File

@ -6061,26 +6061,26 @@ irc_server_print_log ()
weechat_log_printf (" chantypes. . . . . . : '%s'", ptr_server->chantypes);
weechat_log_printf (" chanmodes. . . . . . : '%s'", ptr_server->chanmodes);
weechat_log_printf (" monitor. . . . . . . : %d", ptr_server->monitor);
weechat_log_printf (" monitor_time . . . . : %ld", ptr_server->monitor_time);
weechat_log_printf (" monitor_time . . . . : %lld", (long long)ptr_server->monitor_time);
weechat_log_printf (" reconnect_delay. . . : %d", ptr_server->reconnect_delay);
weechat_log_printf (" reconnect_start. . . : %ld", ptr_server->reconnect_start);
weechat_log_printf (" command_time . . . . : %ld", ptr_server->command_time);
weechat_log_printf (" reconnect_start. . . : %lld", (long long)ptr_server->reconnect_start);
weechat_log_printf (" command_time . . . . : %lld", (long long)ptr_server->command_time);
weechat_log_printf (" reconnect_join . . . : %d", ptr_server->reconnect_join);
weechat_log_printf (" disable_autojoin . . : %d", ptr_server->disable_autojoin);
weechat_log_printf (" is_away. . . . . . . : %d", ptr_server->is_away);
weechat_log_printf (" away_message . . . . : '%s'", ptr_server->away_message);
weechat_log_printf (" away_time. . . . . . : %ld", ptr_server->away_time);
weechat_log_printf (" away_time. . . . . . : %lld", (long long)ptr_server->away_time);
weechat_log_printf (" lag. . . . . . . . . : %d", ptr_server->lag);
weechat_log_printf (" lag_displayed. . . . : %d", ptr_server->lag_displayed);
weechat_log_printf (" lag_check_time . . . : tv_sec:%d, tv_usec:%d",
ptr_server->lag_check_time.tv_sec,
ptr_server->lag_check_time.tv_usec);
weechat_log_printf (" lag_next_check . . . : %ld", ptr_server->lag_next_check);
weechat_log_printf (" lag_last_refresh . . : %ld", ptr_server->lag_last_refresh);
weechat_log_printf (" lag_next_check . . . : %lld", (long long)ptr_server->lag_next_check);
weechat_log_printf (" lag_last_refresh . . : %lld", (long long)ptr_server->lag_last_refresh);
weechat_log_printf (" cmd_list_regexp. . . : 0x%lx", ptr_server->cmd_list_regexp);
weechat_log_printf (" last_user_message. . : %ld", ptr_server->last_user_message);
weechat_log_printf (" last_away_check. . . : %ld", ptr_server->last_away_check);
weechat_log_printf (" last_data_purge. . . : %ld", ptr_server->last_data_purge);
weechat_log_printf (" last_user_message. . : %lld", (long long)ptr_server->last_user_message);
weechat_log_printf (" last_away_check. . . : %lld", (long long)ptr_server->last_away_check);
weechat_log_printf (" last_data_purge. . . : %lld", (long long)ptr_server->last_data_purge);
for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
{
weechat_log_printf (" outqueue[%02d] . . . . : 0x%lx", i, ptr_server->outqueue[i]);

View File

@ -2609,7 +2609,7 @@ weechat_lua_api_hook_print_cb (const void *pointer, void *data,
if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);

View File

@ -2523,7 +2523,7 @@ weechat_perl_api_hook_print_cb (const void *pointer, void *data,
if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);

View File

@ -643,7 +643,7 @@ plugin_api_info_inactivity_cb (const void *pointer, void *data,
inactivity = 0;
else
inactivity = time (NULL) - gui_key_last_activity_time;
snprintf (value, sizeof (value), "%ld", (long int)inactivity);
snprintf (value, sizeof (value), "%lld", (long long)inactivity);
return value;
}
@ -890,7 +890,7 @@ plugin_api_info_uptime_cb (const void *pointer, void *data,
{
/* return the number of seconds */
util_get_uptime (&total_seconds, NULL, NULL, NULL, NULL);
snprintf (value, sizeof (value), "%ld", (long)total_seconds);
snprintf (value, sizeof (value), "%lld", (long long)total_seconds);
return value;
}

View File

@ -2544,7 +2544,7 @@ weechat_python_api_hook_print_cb (const void *pointer, void *data,
if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);

View File

@ -1784,11 +1784,11 @@ relay_client_print_log ()
relay_protocol_string[ptr_client->protocol]);
weechat_log_printf (" protocol_string . . . : '%s'", ptr_client->protocol_string);
weechat_log_printf (" protocol_args . . . . : '%s'", ptr_client->protocol_args);
weechat_log_printf (" listen_start_time . . : %ld", ptr_client->listen_start_time);
weechat_log_printf (" start_time. . . . . . : %ld", ptr_client->start_time);
weechat_log_printf (" end_time. . . . . . . : %ld", ptr_client->end_time);
weechat_log_printf (" listen_start_time . . : %lld", (long long)ptr_client->listen_start_time);
weechat_log_printf (" start_time. . . . . . : %lld", (long long)ptr_client->start_time);
weechat_log_printf (" end_time. . . . . . . : %lld", (long long)ptr_client->end_time);
weechat_log_printf (" hook_fd . . . . . . . : 0x%lx", ptr_client->hook_fd);
weechat_log_printf (" last_activity . . . . : %ld", ptr_client->last_activity);
weechat_log_printf (" last_activity . . . . : %lld", (long long)ptr_client->last_activity);
weechat_log_printf (" bytes_recv. . . . . . : %llu", ptr_client->bytes_recv);
weechat_log_printf (" bytes_sent. . . . . . : %llu", ptr_client->bytes_sent);
weechat_log_printf (" recv_data_type. . . . : %d (%s)",

View File

@ -761,8 +761,8 @@ relay_server_print_log ()
weechat_log_printf (" ssl . . . . . . . . . : %d", ptr_server->ssl);
weechat_log_printf (" sock. . . . . . . . . : %d", ptr_server->sock);
weechat_log_printf (" hook_fd . . . . . . . : 0x%lx", ptr_server->hook_fd);
weechat_log_printf (" start_time. . . . . . : %ld", ptr_server->start_time);
weechat_log_printf (" last_client_disconnect: %ld", ptr_server->last_client_disconnect);
weechat_log_printf (" start_time. . . . . . : %lld", (long long)ptr_server->start_time);
weechat_log_printf (" last_client_disconnect: %lld", (long long)ptr_server->last_client_disconnect);
weechat_log_printf (" prev_server . . . . . : 0x%lx", ptr_server->prev_server);
weechat_log_printf (" next_server . . . . . : 0x%lx", ptr_server->next_server);
}

View File

@ -242,7 +242,7 @@ relay_weechat_msg_add_time (struct t_relay_weechat_msg *msg, time_t time)
char str_time[128];
unsigned char length;
snprintf (str_time, sizeof (str_time), "%ld", (long)time);
snprintf (str_time, sizeof (str_time), "%lld", (long long)time);
length = strlen (str_time);
relay_weechat_msg_add_bytes (msg, &length, 1);
relay_weechat_msg_add_bytes (msg, str_time, length);

View File

@ -3070,7 +3070,7 @@ weechat_ruby_api_hook_print_cb (const void *pointer, void *data,
if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);

View File

@ -1657,8 +1657,8 @@ script_repo_print_log ()
weechat_log_printf (" md5sum. . . . . . . . : '%s'", ptr_script->md5sum);
weechat_log_printf (" url . . . . . . . . . : '%s'", ptr_script->url);
weechat_log_printf (" popularity. . . . . . : %d", ptr_script->popularity);
weechat_log_printf (" date_added. . . . . . : %ld", ptr_script->date_added);
weechat_log_printf (" date_updated. . . . . : %ld", ptr_script->date_updated);
weechat_log_printf (" date_added. . . . . . : %lld", (long long)ptr_script->date_added);
weechat_log_printf (" date_updated. . . . . : %lld", (long long)ptr_script->date_updated);
weechat_log_printf (" status. . . . . . . . : %d (%s%s%s%s%s )",
ptr_script->status,
(ptr_script->status & SCRIPT_STATUS_INSTALLED) ? " installed": "",

View File

@ -2795,7 +2795,7 @@ weechat_tcl_api_hook_print_cb (const void *pointer, void *data,
if (ptr_function && ptr_function[0])
{
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)date);
snprintf (timebuffer, sizeof (timebuffer), "%lld", (long long)date);
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
func_argv[1] = API_PTR2STR(buffer);

View File

@ -1726,8 +1726,8 @@ xfer_print_log ()
weechat_log_printf (" remote_nick_color . . . : '%s'", ptr_xfer->remote_nick_color);
weechat_log_printf (" fast_send . . . . . . . : %d", ptr_xfer->fast_send);
weechat_log_printf (" blocksize . . . . . . . : %d", ptr_xfer->blocksize);
weechat_log_printf (" start_time. . . . . . . : %ld", ptr_xfer->start_time);
weechat_log_printf (" start_transfer. . . . . : %ld", ptr_xfer->start_transfer);
weechat_log_printf (" start_time. . . . . . . : %lld", (long long)ptr_xfer->start_time);
weechat_log_printf (" start_transfer. . . . . : %lld", (long long)ptr_xfer->start_transfer);
weechat_log_printf (" sock. . . . . . . . . . : %d", ptr_xfer->sock);
weechat_log_printf (" child_pid . . . . . . . : %d", ptr_xfer->child_pid);
weechat_log_printf (" child_read. . . . . . . : %d", ptr_xfer->child_read);
@ -1742,9 +1742,9 @@ xfer_print_log ()
weechat_log_printf (" pos . . . . . . . . . . : %llu", ptr_xfer->pos);
weechat_log_printf (" ack . . . . . . . . . . : %llu", ptr_xfer->ack);
weechat_log_printf (" start_resume. . . . . . : %llu", ptr_xfer->start_resume);
weechat_log_printf (" last_check_time . . . . : %ld", ptr_xfer->last_check_time);
weechat_log_printf (" last_check_time . . . . : %lld", (long long)ptr_xfer->last_check_time);
weechat_log_printf (" last_check_pos. . . . . : %llu", ptr_xfer->last_check_pos);
weechat_log_printf (" last_activity . . . . . : %ld", ptr_xfer->last_activity);
weechat_log_printf (" last_activity . . . . . : %lld", (long long)ptr_xfer->last_activity);
weechat_log_printf (" bytes_per_sec . . . . . : %llu", ptr_xfer->bytes_per_sec);
weechat_log_printf (" eta . . . . . . . . . . : %llu", ptr_xfer->eta);
weechat_log_printf (" hash_target . . . . . . : '%s'", ptr_xfer->hash_target);