libnm-core: consider attributes in nm_tc_action_equal()
This commit is contained in:

committed by
Lubomir Rintel

parent
7c8ce778fb
commit
b0ba17e903
@@ -340,18 +340,36 @@ nm_tc_action_unref (NMTCAction *action)
|
|||||||
gboolean
|
gboolean
|
||||||
nm_tc_action_equal (NMTCAction *action, NMTCAction *other)
|
nm_tc_action_equal (NMTCAction *action, NMTCAction *other)
|
||||||
{
|
{
|
||||||
if (action == NULL && other == NULL)
|
GHashTableIter iter;
|
||||||
|
const char *key;
|
||||||
|
GVariant *value, *value2;
|
||||||
|
guint n;
|
||||||
|
|
||||||
|
g_return_val_if_fail (!action || action->refcount > 0, FALSE);
|
||||||
|
g_return_val_if_fail (!other || other->refcount > 0, FALSE);
|
||||||
|
|
||||||
|
if (action == other)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
if (!action || !other)
|
||||||
if (action == NULL || other == NULL)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (action->refcount > 0, FALSE);
|
|
||||||
g_return_val_if_fail (other->refcount > 0, FALSE);
|
|
||||||
|
|
||||||
if (g_strcmp0 (action->kind, other->kind) != 0)
|
if (g_strcmp0 (action->kind, other->kind) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
n = action->attributes ? g_hash_table_size (action->attributes) : 0;
|
||||||
|
if (n != (other->attributes ? g_hash_table_size (other->attributes) : 0))
|
||||||
|
return FALSE;
|
||||||
|
if (n) {
|
||||||
|
g_hash_table_iter_init (&iter, action->attributes);
|
||||||
|
while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
|
||||||
|
value2 = g_hash_table_lookup (other->attributes, key);
|
||||||
|
if (!value2)
|
||||||
|
return FALSE;
|
||||||
|
if (!g_variant_equal (value, value2))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user