mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-15 15:27:00 +00:00
sort: ensure NaN will not trip over comp_double()
In unlikely event of NaN being compared avoid exception. If NaN appears in input data it will be evaluated as equal with any value. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
27c70a0efe
commit
5027b50ade
1 changed files with 7 additions and 1 deletions
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -118,9 +119,14 @@ int rangecomp(const void *restrict r1, const void *restrict r2)
|
|||
*/
|
||||
int comp_double(double f1, double f2)
|
||||
{
|
||||
return f1 < f2 ? -1 : f1 > f2 ? 1 : 0;
|
||||
if (isless(f1, f2))
|
||||
return -1;
|
||||
else if (isless(f2, f1))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Compare two range_t by their first_ip.
|
||||
* \param r1,r2 Pointers to data to compare.
|
||||
* \return Like strcmp.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue