summaryrefslogtreecommitdiff
path: root/libnm-util/nm-param-spec-specialized.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-11-26 16:59:47 +0000
committerDan Williams <dcbw@redhat.com>2007-11-26 16:59:47 +0000
commit6076621fd0fb54dcc4c538d387cc2045b9321ce5 (patch)
treed30a105b35bc8f0f4d814c60568c62fcdcec3230 /libnm-util/nm-param-spec-specialized.c
parent9bcfe259917a080174578eaef76374eefe3b9cfd (diff)
downloadNetworkManager-6076621fd0fb54dcc4c538d387cc2045b9321ce5.tar.gz
2007-11-26 Dan Williams <dcbw@redhat.com>
* Fix warnings so everything compiles with --enable-more-warnings git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3108 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-util/nm-param-spec-specialized.c')
-rw-r--r--libnm-util/nm-param-spec-specialized.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c
index aba86b0b9b..d13411535b 100644
--- a/libnm-util/nm-param-spec-specialized.c
+++ b/libnm-util/nm-param-spec-specialized.c
@@ -7,6 +7,7 @@ struct _NMParamSpecSpecialized {
};
#include <string.h>
+#include <math.h>
#include <dbus/dbus-glib.h>
/***********************************************************/
@@ -35,6 +36,8 @@ type_is_fixed_size (GType type)
}
}
+#define FLOAT_FACTOR 0.00000001
+
static gint
nm_gvalues_compare_fixed (const GValue *value1, const GValue *value2)
{
@@ -107,14 +110,15 @@ nm_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);
- if (val1 != val2)
+ /* Can't use == or != here due to inexactness of FP */
+ if (fabsf (val1 - val2) > 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 (val1 != val2)
+ if (fabs (val1 - val2) > FLOAT_FACTOR)
ret = val1 < val2 ? -1 : val1 > val2;
break;
}