[ovs-dev] [PATCH] stopwatch: Fix qsort comparison function.

Ben Pfaff blp at ovn.org
Tue Dec 18 23:40:49 UTC 2018


On Tue, Dec 18, 2018 at 07:38:27PM +0300, Ilya Maximets wrote:
> 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 at redhat.com>
> Fixes: aed45befeff2 ("Add stopwatch timing API")
> Signed-off-by: Ilya Maximets <i.maximets at samsung.com>

Thanks a lot for the fix!

I hope that you are not too irritated that I changed the code here to
the form that I generally consider idiomatic for this kind of 3-way
comparison:

    return *right_d > *left_d ? -1 : *right_d < *left_d;

With that change, I applied this to master.


More information about the dev mailing list