From 6b8ba9a4bcdd0e31d9c59666387e56df29ddc2c3 Mon Sep 17 00:00:00 2001
From: Erik Auerswald <auerswal@unix-ag.uni-kl.de>
Date: Sat, 5 Feb 2022 11:40:07 +0100
Subject: [PATCH 3/5] use function stats_reset_interval()

Git commit bb8d71ef27f673f25c7e1648ea982c27bb61ac0d from 2020 among many
other things introduced the function stats_reset_interval() to reset the
*_i interval (or split) host statistics, but did not use it.  This commit
replaces the open-coded reset of interval stats inside print_host_splits()
with calling stats_reset_interval().

As a side effect the code in function stats_reset_interval() is now
covered by tests.
---
 src/fping.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/fping.c b/src/fping.c
index 3ac480b..acbc3a8 100644
--- a/src/fping.c
+++ b/src/fping.c
@@ -380,6 +380,7 @@ void usage(int);
 int wait_for_reply(int64_t);
 void print_per_system_stats(void);
 void print_per_system_splits(void);
+void stats_reset_interval(HOST_ENTRY *h);
 void print_netdata(void);
 void print_global_stats(void);
 void main_loop();
@@ -1783,7 +1784,7 @@ void print_host_splits(HOST_ENTRY* h)
     }
 
     fprintf(stderr, "\n");
-    h->num_sent_i = h->num_recv_i = h->max_reply_i = h->min_reply_i = h->total_time_i = 0;
+    stats_reset_interval(h);
 }
 
 /************************************************************
-- 
2.25.1

