summary refs log tree commit diff
path: root/libnm-util/nm-param-spec-specialized.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2017-05-11 14:55:55 +0200
committerMichael Biebl <biebl@debian.org>2017-05-11 14:55:55 +0200
commitc333f062ddcba9b35330647bf6cbd0a07f2d786e (patch)
tree257c3a0c74c09f4ad2328eab5b932806405f0c1c /libnm-util/nm-param-spec-specialized.c
parenta222e56e103f949b148a6942e385ccca2c26d9f3 (diff)
New upstream version 1.8.0 upstream/1.8.0
Diffstat (limited to 'libnm-util/nm-param-spec-specialized.c')
-rw-r--r--libnm-util/nm-param-spec-specialized.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c
index 7021e108..a4e01d8f 100644
--- a/libnm-util/nm-param-spec-specialized.c
+++ b/libnm-util/nm-param-spec-specialized.c
@@ -30,7 +30,6 @@ struct _NMParamSpecSpecialized {
 };
 
 #include <string.h>
-#include <math.h>
 #include <netinet/in.h>
 #include <dbus/dbus-glib.h>
 
@@ -157,15 +156,19 @@ _gvalues_compare_fixed (const GValue *value1, const GValue *value2)
 	case G_TYPE_FLOAT: {
 		gfloat val1 = g_value_get_float (value1);
 		gfloat val2 = g_value_get_float (value2);
+		float diff = val1 - val2;
+
 		/* Can't use == or != here due to inexactness of FP */
-		if (fabsf (val1 - val2) > FLOAT_FACTOR)
+		if (diff > FLOAT_FACTOR || diff < -FLOAT_FACTOR)
 			ret = val1 < val2 ? -1 : val1 > val2;
 		break;
 	}
 	case G_TYPE_DOUBLE: {
 		gdouble val1 = g_value_get_double (value1);
 		gdouble val2 = g_value_get_double (value2);
-		if (fabs (val1 - val2) > FLOAT_FACTOR)
+		double diff = val1 - val2;
+
+		if (diff > FLOAT_FACTOR || diff < -FLOAT_FACTOR)
 			ret = val1 < val2 ? -1 : val1 > val2;
 		break;
 	}