From ca22e4904193b94acd208d84eafd7c93f3feb68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 16 Mar 2025 14:05:11 +0100 Subject: [PATCH] core, irc: replace "long" by "long long" to store seconds in timeval structure --- src/core/core-util.c | 8 ++++---- src/gui/gui-chat.c | 8 ++++---- src/plugins/irc/irc-ctcp.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/core-util.c b/src/core/core-util.c index c4f69aa8d..6a38dd9dc 100644 --- a/src/core/core-util.c +++ b/src/core/core-util.c @@ -288,7 +288,7 @@ util_parse_time (const char *datetime, struct timeval *tv) char *string, *pos, *pos2, str_usec[16], *error, str_date[128]; struct tm tm_date, tm_date_gm, tm_date_local, *local_time; time_t time_now, time_gm, time_local; - long value; + long long value; int rc, length, use_local_time, timezone_offset, offset_factor, hour, min; if (!datetime || !datetime[0] || !tv) @@ -330,14 +330,14 @@ util_parse_time (const char *datetime, struct timeval *tv) strcat (str_usec, "0"); } error = NULL; - value = strtol (str_usec, &error, 10); + value = strtoll (str_usec, &error, 10); if (error && !error[0]) { if (value < 0) value = 0; else if (value > 999999) value = 999999; - tv->tv_usec = (int)value; + tv->tv_usec = (long)value; } } memmove (pos, pos2, strlen (pos2) + 1); @@ -474,7 +474,7 @@ util_parse_time (const char *datetime, struct timeval *tv) { /* timestamp format: "1704402062" */ error = NULL; - value = strtol (string, &error, 10); + value = strtoll (string, &error, 10); if (error && !error[0] && (value >= 0)) { tv->tv_sec = (time_t)value; diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 5c12c38e0..f18d53a30 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -1395,7 +1395,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data, struct t_hashtable *hashtable) { const char *ptr_date, *ptr_date_usec, *line, *prefix, *ptr_prefix, *message; - long number; + long long number; struct timeval tv; struct t_gui_line *ptr_line; int is_nick, rc; @@ -1415,7 +1415,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data, if (ptr_date) { error = NULL; - number = strtol (ptr_date, &error, 10); + number = strtoll (ptr_date, &error, 10); if (error && !error[0]) { tv.tv_sec = (time_t)number; @@ -1425,9 +1425,9 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data, if (ptr_date_usec) { error = NULL; - number = strtol (ptr_date_usec, &error, 10); + number = strtoll (ptr_date_usec, &error, 10); if (error && !error[0]) - tv.tv_usec = (int)number; + tv.tv_usec = (long)number; } util_strftimeval (str_time, sizeof (str_time), CONFIG_STRING(config_look_quote_time_format), diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 13ae51b96..7f363304f 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -253,7 +253,7 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt, { char *dup_arguments, *ptr_args, *pos_end, *pos_space, *pos_args, *pos_usec; struct timeval tv; - long sec1, usec1, sec2, usec2, difftime; + long long sec1, usec1, sec2, usec2, difftime; dup_arguments = strdup (arguments); if (!dup_arguments) @@ -284,8 +284,8 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt, pos_usec[0] = '\0'; gettimeofday (&tv, NULL); - sec1 = atol (pos_args); - usec1 = atol (pos_usec + 1); + sec1 = atoll (pos_args); + usec1 = atoll (pos_usec + 1); sec2 = tv.tv_sec; usec2 = tv.tv_usec;