diff options
author | Ilya Maximets <i.maximets@samsung.com> | 2018-12-18 19:38:27 +0300 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-12-18 15:39:48 -0800 |
commit | ea2b62239f282ac9dc75fd498d96c36638eb4300 (patch) | |
tree | b7b78f2d9ebf101ddb256481367f9d40e528dac7 /lib | |
parent | fe07df8026c6075cdacd9b17bc0af245c7d2912c (diff) | |
download | openvswitch-ea2b62239f282ac9dc75fd498d96c36638eb4300.tar.gz |
stopwatch: Fix qsort comparison function.
Current version is broken because it converts first argument to
integer and after that substracts the duoble value. At the end
the result converted to integer again.
This does not cause unit test failures because qsort on linux
accidentially makes right order. On FreeBSD this leads to the
test failure:
TEST '10-intervals-linear-growth'
Assertion \
'|(&stats)->pctl_95 - (&d->expected_stats)->pctl_95| < 1e-1' failed:
|9 - 10| < 0.1
CC: Mark Michelson <mmichels@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Fixes: aed45befeff2 ("Add stopwatch timing API")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stopwatch.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/stopwatch.c b/lib/stopwatch.c index 2e69d8189..54a85edb4 100644 --- a/lib/stopwatch.c +++ b/lib/stopwatch.c @@ -104,7 +104,7 @@ comp_samples(const void *left, const void *right) const double *left_d = left; const double *right_d = right; - return (int) *right_d - *left_d; + return *right_d > *left_d ? -1 : *right_d < *left_d; } /* Calculate the percentile using the P-square algorithm. For more |