aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuca <deri@ntop.org>2019-08-29 16:08:18 +0200
committerLuca <deri@ntop.org>2019-08-29 16:08:18 +0200
commitc3284526871f164de42227a3cb466cd3f2f2a335 (patch)
treec7e71bf45ce7e8104d937643e275c43d6a4c78e2 /src
parent536b5207500cb7a7139c315bcd9bb85dd2276675 (diff)
Average calculation fix
Diffstat (limited to 'src')
-rw-r--r--src/lib/ndpi_analyze.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c
index 8facdf371..eb36cb516 100644
--- a/src/lib/ndpi_analyze.c
+++ b/src/lib/ndpi_analyze.c
@@ -89,7 +89,7 @@ void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value) {
/* Compute the average on all values */
float ndpi_data_average(struct ndpi_analyze_struct *s) {
- return((float)s->sum_total / (float)s->num_data_entries);
+ return((s->num_data_entries == 0) ? 0 : ((float)s->sum_total / (float)s->num_data_entries));
}
/* ********************************************************************************* */