From 90f5d9114f9bb69a0420fa3f460bac03bdd83954 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 6 May 2021 18:26:30 +0200 Subject: [PATCH] libnm: use nm_auto_unref_tc_action cleanup macro in nm_utils_tc_action_from_str() --- src/libnm-core-impl/nm-utils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index b606aaa39f..1bc44bb5de 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -2587,9 +2587,9 @@ nm_utils_tc_action_to_str(NMTCAction *action, GError **error) NMTCAction * nm_utils_tc_action_from_str(const char *str, GError **error) { - const char * kind = NULL; - const char * rest = NULL; - NMTCAction * action = NULL; + const char * kind = NULL; + const char * rest = NULL; + nm_auto_unref_tc_action NMTCAction *action = NULL; gs_unref_hashtable GHashTable *ht = NULL; gs_unref_hashtable GHashTable * options = NULL; GVariant * variant; @@ -2631,23 +2631,20 @@ nm_utils_tc_action_from_str(const char *str, GError **error) gpointer key, value; if (!attrs) { - nm_tc_action_unref(action); g_set_error(error, 1, 0, _("unsupported action option: '%s'."), rest); return NULL; } options = nm_utils_parse_variant_attributes(rest, ' ', ' ', FALSE, attrs, error); - if (!options) { - nm_tc_action_unref(action); + if (!options) return NULL; - } g_hash_table_iter_init(&iter, options); while (g_hash_table_iter_next(&iter, &key, &value)) nm_tc_action_set_attribute(action, key, g_variant_ref_sink(value)); } - return action; + return g_steal_pointer(&action); } /*****************************************************************************/