aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-11-07 10:01:47 -0500
committerDavid Goulet <dgoulet@torproject.org>2022-11-07 14:49:41 -0500
commit2066e0494c5ddb51af6decbe6941ea3495603fe2 (patch)
tree1a4d73e87ee58a9fdd2e5cefd6ef121d56c38611 /src/lib
parentfec9757a37d9e2700802a7ebfc87b4fd33070983 (diff)
downloadtor-2066e0494c5ddb51af6decbe6941ea3495603fe2.tar.gz
tor-2066e0494c5ddb51af6decbe6941ea3495603fe2.zip
math: Replace naughty macro by an inline function
Part of #40708 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/math/stats.h7
1 files changed, 5 insertions, 2 deletions
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) */