Commit b0ba17e9 authored by Thomas Haller's avatar Thomas Haller Committed by Lubomir Rintel

libnm-core: consider attributes in nm_tc_action_equal()

parent 7c8ce778
......@@ -340,18 +340,36 @@ nm_tc_action_unref (NMTCAction *action)
gboolean
nm_tc_action_equal (NMTCAction *action, NMTCAction *other)
{
if (action == NULL && other == NULL)
return TRUE;
GHashTableIter iter;
const char *key;
GVariant *value, *value2;
guint n;
if (action == NULL || other == NULL)
return FALSE;
g_return_val_if_fail (!action || action->refcount > 0, FALSE);
g_return_val_if_fail (!other || other->refcount > 0, FALSE);
g_return_val_if_fail (action->refcount > 0, FALSE);
g_return_val_if_fail (other->refcount > 0, FALSE);
if (action == other)
return TRUE;
if (!action || !other)
return FALSE;
if (g_strcmp0 (action->kind, other->kind) != 0)
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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment