Average calculation fix

This commit is contained in:
Luca
2019-08-29 16:08:18 +02:00
parent 536b520750
commit c328452687
22 changed files with 135 additions and 135 deletions
+1 -1
View File
@@ -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));
}
/* ********************************************************************************* */