aboutsummaryrefslogtreecommitdiffstats
path: root/epan/stats_tree.c
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2017-09-29 20:55:23 +0200
committerMichael Mann <mmann78@netscape.net>2017-10-01 15:11:10 +0000
commit9ab17810bcc334ca76e4b470f7302013dc0bd261 (patch)
treec891ae2749a28afde623009f4d1f21da60a7cf1b /epan/stats_tree.c
parentd8903ce3975b57c3f4cbd24d58994a1db8c572c8 (diff)
stats_tree: fix the comparison routine for COL_AVERAGE
Generally, the average is calculated as node->total / node->count. The curent code does not handle the case where we compare two nodes and both have count == 0. It defines one of the nodes to be bigger. This triggers (at least on Windows) an assertion about invalid operator<. To fix this, we define average = 0 for a node with count == 0. We can then simply compare the two averages. Change-Id: Ie7d9cd590deddcdb9214c4a2693c2eb47c66b287 Reviewed-on: https://code.wireshark.org/review/23799 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/stats_tree.c')
-rw-r--r--epan/stats_tree.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/epan/stats_tree.c b/epan/stats_tree.c
index 8592c197db..6c60500d97 100644
--- a/epan/stats_tree.c
+++ b/epan/stats_tree.c
@@ -1081,17 +1081,9 @@ stats_tree_sort_compare (const stat_node *a, const stat_node *b, gint sort_colum
break;
case COL_AVERAGE:
- if (a->counter) {
- result= 1; /* assume a>b */
- if (b->counter) {
- avg_a= ((float)a->total)/a->counter;
- avg_b= ((float)b->total)/b->counter;
- result= (avg_a>avg_b)?1:((avg_a<avg_b)?-1:0);
- }
- }
- else {
- result= -1; /* let b>a */
- }
+ avg_a = a->counter ? ((float)a->total)/a->counter : 0;
+ avg_b = b->counter ? ((float)b->total)/b->counter : 0;
+ result = (avg_a>avg_b) ? 1 : ( (avg_a<avg_b) ? -1 : 0);
break;
case COL_MIN: