diff options
author | Luca <deri@ntop.org> | 2019-08-29 16:08:18 +0200 |
---|---|---|
committer | Luca <deri@ntop.org> | 2019-08-29 16:08:18 +0200 |
commit | c3284526871f164de42227a3cb466cd3f2f2a335 (patch) | |
tree | c7e71bf45ce7e8104d937643e275c43d6a4c78e2 /src | |
parent | 536b5207500cb7a7139c315bcd9bb85dd2276675 (diff) |
Average calculation fix
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_analyze.c | 2 |
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)); } /* ********************************************************************************* */ |