mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 23:00:28 +01:00
2008-10-01 Dan Williams <dcbw@redhat.com>
Fix setting value comparison issue that caused some settings to look the same when they were really different (rh #464417) * libnm-util/nm-param-spec-specialized.c - (type_is_fixed_size): return fundamental size of the fixed type too - (nm_gvalues_compare_collection): use the fundamental fixed type size in the comparison so that the _entire_ fixed type collection gets compared rather than just the first 'len1' bytes git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4134 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
7d94e978a3
commit
95798eb451
2 changed files with 37 additions and 5 deletions
11
ChangeLog
11
ChangeLog
|
|
@ -1,3 +1,14 @@
|
|||
2008-10-01 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Fix setting value comparison issue that caused some settings to look the
|
||||
same when they were really different (rh #464417)
|
||||
|
||||
* libnm-util/nm-param-spec-specialized.c
|
||||
- (type_is_fixed_size): return fundamental size of the fixed type too
|
||||
- (nm_gvalues_compare_collection): use the fundamental fixed type size
|
||||
in the comparison so that the _entire_ fixed type collection gets
|
||||
compared rather than just the first 'len1' bytes
|
||||
|
||||
2008-09-30 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/NetworkManagerPolicy.c
|
||||
|
|
|
|||
|
|
@ -39,20 +39,41 @@ struct _NMParamSpecSpecialized {
|
|||
static gint nm_gvalues_compare (const GValue *value1, const GValue *value2);
|
||||
|
||||
static gboolean
|
||||
type_is_fixed_size (GType type)
|
||||
type_is_fixed_size (GType type, gsize *tsize)
|
||||
{
|
||||
switch (type) {
|
||||
case G_TYPE_CHAR:
|
||||
if (tsize) *tsize = sizeof (char);
|
||||
return TRUE;
|
||||
case G_TYPE_UCHAR:
|
||||
if (tsize) *tsize = sizeof (guchar);
|
||||
return TRUE;
|
||||
case G_TYPE_BOOLEAN:
|
||||
if (tsize) *tsize = sizeof (gboolean);
|
||||
return TRUE;
|
||||
case G_TYPE_LONG:
|
||||
if (tsize) *tsize = sizeof (glong);
|
||||
return TRUE;
|
||||
case G_TYPE_ULONG:
|
||||
if (tsize) *tsize = sizeof (gulong);
|
||||
return TRUE;
|
||||
case G_TYPE_INT:
|
||||
if (tsize) *tsize = sizeof (gint);
|
||||
return TRUE;
|
||||
case G_TYPE_UINT:
|
||||
if (tsize) *tsize = sizeof (guint);
|
||||
return TRUE;
|
||||
case G_TYPE_INT64:
|
||||
if (tsize) *tsize = sizeof (gint64);
|
||||
return TRUE;
|
||||
case G_TYPE_UINT64:
|
||||
if (tsize) *tsize = sizeof (guint64);
|
||||
return TRUE;
|
||||
case G_TYPE_FLOAT:
|
||||
if (tsize) *tsize = sizeof (gfloat);
|
||||
return TRUE;
|
||||
case G_TYPE_DOUBLE:
|
||||
if (tsize) *tsize = sizeof (gdouble);
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
|
@ -232,8 +253,9 @@ nm_gvalues_compare_collection (const GValue *value1, const GValue *value2)
|
|||
guint len1;
|
||||
guint len2;
|
||||
GType value_type = dbus_g_type_get_collection_specialization (G_VALUE_TYPE (value1));
|
||||
gsize element_size = 0;
|
||||
|
||||
if (type_is_fixed_size (value_type)) {
|
||||
if (type_is_fixed_size (value_type, &element_size)) {
|
||||
gpointer data1 = NULL;
|
||||
gpointer data2 = NULL;
|
||||
|
||||
|
|
@ -243,7 +265,7 @@ nm_gvalues_compare_collection (const GValue *value1, const GValue *value2)
|
|||
if (len1 != len2)
|
||||
ret = len1 < len2 ? -1 : len1 > len2;
|
||||
else
|
||||
ret = memcmp (data1, data2, len1);
|
||||
ret = memcmp (data1, data2, len1 * element_size);
|
||||
} else {
|
||||
GSList *list1 = NULL;
|
||||
GSList *list2 = NULL;
|
||||
|
|
@ -372,8 +394,7 @@ nm_gvalues_compare (const GValue *value1, const GValue *value2)
|
|||
if (type1 != type2)
|
||||
return type1 < type2 ? -1 : type1 > type2;
|
||||
|
||||
|
||||
if (type_is_fixed_size (type1))
|
||||
if (type_is_fixed_size (type1, NULL))
|
||||
ret = nm_gvalues_compare_fixed (value1, value2);
|
||||
else if (type1 == G_TYPE_STRING)
|
||||
ret = nm_gvalues_compare_string (value1, value2);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue