1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 10:05:41 +02:00

core: convert "long long" to "unsigned long long" in functions util_get_microseconds_string and util_parse_delay

This commit is contained in:
Sébastien Helleu
2025-03-16 11:13:25 +01:00
parent e8a335a3e3
commit 9fe5fa23a0
8 changed files with 118 additions and 89 deletions
+9 -8
View File
@@ -2035,7 +2035,7 @@ COMMAND_CALLBACK(debug)
struct t_weechat_plugin *ptr_plugin;
struct timeval time_start, time_end;
char *result, *str_threshold;
long long threshold;
unsigned long long threshold;
int debug;
/* make C compiler happy */
@@ -2073,7 +2073,8 @@ COMMAND_CALLBACK(debug)
if (string_strcmp (argv[1], "callbacks") == 0)
{
COMMAND_MIN_ARGS(3, argv[1]);
threshold = util_parse_delay (argv[2], 1);
if (!util_parse_delay (argv[2], 1, &threshold))
COMMAND_ERROR;
if (threshold > 0)
{
str_threshold = util_get_microseconds_string (threshold);
@@ -6174,7 +6175,7 @@ command_repeat_timer_cb (const void *pointer, void *data, int remaining_calls)
COMMAND_CALLBACK(repeat)
{
int arg_count, count, i;
long long interval;
unsigned long long interval;
char *error;
struct t_command_repeat *cmd_repeat;
@@ -6189,9 +6190,8 @@ COMMAND_CALLBACK(repeat)
if ((argc >= 5) && (string_strcmp (argv[1], "-interval") == 0))
{
interval = util_parse_delay (argv[2], 1000000);
if (interval < 0)
interval = 0;
if (!util_parse_delay (argv[2], 1000000, &interval))
COMMAND_ERROR;
interval /= 1000;
arg_count = 3;
}
@@ -7871,7 +7871,7 @@ COMMAND_CALLBACK(version)
COMMAND_CALLBACK(wait)
{
long long delay;
unsigned long long delay;
/* make C compiler happy */
(void) pointer;
@@ -7879,7 +7879,8 @@ COMMAND_CALLBACK(wait)
COMMAND_MIN_ARGS(3, "");
delay = util_parse_delay (argv[1], 1000000);
if (!util_parse_delay (argv[1], 1000000, &delay))
COMMAND_ERROR;
if (delay < 1)
COMMAND_ERROR;
+3 -1
View File
@@ -865,7 +865,9 @@ debug_display_time_elapsed (struct timeval *time1, struct timeval *time2,
gettimeofday (&debug_timeval_end, NULL);
diff = util_timeval_diff (time1, time2);
str_diff = util_get_microseconds_string (diff);
if (diff < 0)
diff *= -1;
str_diff = util_get_microseconds_string ((unsigned long long)diff);
if (display)
{
+1 -1
View File
@@ -523,7 +523,7 @@ hook_callback_end (struct t_hook *hook, struct t_hook_exec_cb *hook_exec_cb)
time_diff = util_timeval_diff (&hook_exec_cb->start_time, &end_time);
if (time_diff >= debug_long_callbacks)
{
str_diff = util_get_microseconds_string (time_diff);
str_diff = util_get_microseconds_string ((unsigned long long)time_diff);
log_printf (
_("debug: long callback: hook %s (%s), plugin: %s, "
"subplugin: %s, time elapsed: %s"),
+5 -5
View File
@@ -285,14 +285,14 @@ sys_display_rusage (void)
#ifdef HAVE_SYS_RESOURCE_H
struct rusage usage;
char *str_time;
long long microseconds;
unsigned long long microseconds;
gui_chat_printf (NULL, "");
gui_chat_printf (NULL, _("Resource usage (see \"man getrusage\" for help):"));
getrusage (RUSAGE_SELF, &usage);
/* ru_utime: user CPU time used */
microseconds = ((long long)usage.ru_utime.tv_sec * 1000000)
+ (long long)usage.ru_utime.tv_usec;
microseconds = ((unsigned long long)usage.ru_utime.tv_sec * 1000000)
+ (unsigned long long)usage.ru_utime.tv_usec;
str_time = util_get_microseconds_string (microseconds);
if (str_time)
{
@@ -300,8 +300,8 @@ sys_display_rusage (void)
free (str_time);
}
/* ru_stime: system CPU time used */
microseconds = ((long long)usage.ru_stime.tv_sec * 1000000)
+ (long long)usage.ru_stime.tv_usec;
microseconds = ((unsigned long long)usage.ru_stime.tv_sec * 1000000)
+ (unsigned long long)usage.ru_stime.tv_usec;
str_time = util_get_microseconds_string (microseconds);
if (str_time)
{
+32 -19
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -29,7 +29,7 @@ extern long long util_timeval_diff (struct timeval *tv1, struct timeval *tv2);
extern void util_timeval_add (struct timeval *tv, long long interval);
/* time */
extern char *util_get_microseconds_string (long long diff);
extern char *util_get_microseconds_string (unsigned long long microseconds);
extern const char *util_get_time_string (const time_t *date);
extern int util_strftimeval (char *string, int max, const char *format,
struct timeval *tv);
@@ -41,8 +41,9 @@ extern void util_get_time_diff (time_t time1, time_t time2,
/* delay */
extern long long util_parse_delay (const char *string_delay,
long long default_factor);
extern int util_parse_delay (const char *string_delay,
unsigned long long default_factor,
unsigned long long *delay);
/* version */
extern int util_version_number (const char *version);
+1 -1
View File
@@ -435,7 +435,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window,
time_diff = util_timeval_diff (&start_time, &end_time);
if (time_diff >= debug_long_callbacks)
{
str_diff = util_get_microseconds_string (time_diff);
str_diff = util_get_microseconds_string ((unsigned long long)time_diff);
log_printf (
_("debug: long callback: bar: %s, item: %s, plugin: %s, "
"time elapsed: %s"),
File diff suppressed because it is too large Load Diff