From 21de8d4b9466880b21b4d43d172112045977670f Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 13 Feb 2025 09:25:09 -0400 Subject: [PATCH] MT#55283 modernise timeval_subtract Change-Id: I7715ee92e12e88d69e3f714a6714f691646e240c --- daemon/call.c | 2 +- daemon/cdr.c | 2 +- daemon/cli.c | 2 +- daemon/control_ng.c | 2 +- lib/auxlib.h | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 4eab3e331..ec9e36632 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -3901,7 +3901,7 @@ static struct timeval add_ongoing_calls_dur_in_interval(struct timeval *interval if (timercmp(interval_start, &ml->started, >)) { res = timeval_add(&res, interval_duration); } else { - timeval_subtract(&call_duration, &rtpe_now, &ml->started); + call_duration = timeval_subtract(&rtpe_now, &ml->started); res = timeval_add(&res, &call_duration); } next: diff --git a/daemon/cdr.c b/daemon/cdr.c index 99d61b10c..b05a082b8 100644 --- a/daemon/cdr.c +++ b/daemon/cdr.c @@ -60,7 +60,7 @@ void cdr_update_entry(call_t * c) { ml->term_reason = UNKNOWN; } - timeval_subtract(&tim_result_duration,&ml->terminated,&ml->started); + tim_result_duration = timeval_subtract(&ml->terminated, &ml->started); if (_log_facility_cdr) { g_string_append_printf(cdr, diff --git a/daemon/cli.c b/daemon/cli.c index 90f7ec5d0..336183f56 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -726,7 +726,7 @@ static void cli_list_tag_info(struct cli_writer *cw, struct call_monologue *ml) else now = ml->terminated; - timeval_subtract(&tim_result_duration, &now, &ml->started); + tim_result_duration = timeval_subtract(&now, &ml->started); cw->cw_printf(cw, "--- Tag '" STR_FORMAT "', type: %s, label '" STR_FORMAT "', " "branch '" STR_FORMAT "', " diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 44eddaa4b..8178a377e 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -863,7 +863,7 @@ static void control_ng_process_payload(ng_ctx *hctx, str *reply, str *data, cons // stop command timer gettimeofday(&cmd_stop, NULL); //print command duration - timeval_subtract(&cmd_process_time, &cmd_stop, &cmd_start); + cmd_process_time = timeval_subtract(&cmd_stop, &cmd_start); if (command_ctx.opmode >= 0 && command_ctx.opmode < OP_COUNT) { mutex_lock(&cur->cmd[command_ctx.opmode].lock); diff --git a/lib/auxlib.h b/lib/auxlib.h index a86b575ae..8d7f35d4d 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -356,8 +356,8 @@ INLINE struct timeval timeval_from_us(long long ms) { INLINE long long timeval_diff(const struct timeval *a, const struct timeval *b) { return timeval_us(a) - timeval_us(b); } -INLINE void timeval_subtract(struct timeval *result, const struct timeval *a, const struct timeval *b) { - *result = timeval_from_us(timeval_diff(a, b)); +INLINE struct timeval timeval_subtract(const struct timeval *a, const struct timeval *b) { + return timeval_from_us(timeval_diff(a, b)); } INLINE struct timeval timeval_add(const struct timeval *a, const struct timeval *b) { return timeval_from_us(timeval_us(a) + timeval_us(b));