From 2066e0494c5ddb51af6decbe6941ea3495603fe2 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 7 Nov 2022 10:01:47 -0500 Subject: math: Replace naughty macro by an inline function Part of #40708 Signed-off-by: David Goulet --- src/lib/math/stats.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/lib/math') diff --git a/src/lib/math/stats.h b/src/lib/math/stats.h index fae93c6213..328d61a9d6 100644 --- a/src/lib/math/stats.h +++ b/src/lib/math/stats.h @@ -13,7 +13,10 @@ /** Update an average making it a "running average". The "avg" is the current * value that will be updated to the new one. The "value" is the new value to * add to the average and "n" is the new count as in including the "value". */ -#define STATS_UPDATE_AVG(avg, value, n) \ - avg = ((avg) * ((n) - 1) + (value)) / (n) +static inline double +stats_update_running_avg(double avg, double value, double n) +{ + return ((avg * (n - 1)) + value) / n; +} #endif /* !defined(TOR_STATS_H) */ -- cgit v1.2.3-54-g00ecf