diff options
Diffstat (limited to 'libnm-util/tests/test-general.c')
| -rw-r--r-- | libnm-util/tests/test-general.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c index f748fcf5..d8f9dcc4 100644 --- a/libnm-util/tests/test-general.c +++ b/libnm-util/tests/test-general.c @@ -30,6 +30,7 @@ #include <sys/resource.h> #include <nm-utils.h> +#include "gsystem-local-alloc.h" #include "nm-setting-private.h" #include "nm-setting-connection.h" @@ -310,6 +311,13 @@ test_setting_vpn_modify_during_foreach (void) g_object_unref (s_vpn); } +static void +_g_value_array_free (void *ptr) +{ + if (ptr) + g_value_array_free ((GValueArray *) ptr); +} + #define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID)) #define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS)) @@ -338,7 +346,7 @@ test_setting_ip6_config_old_address_array (void) g_value_init (&written_value, OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS); - addresses = g_ptr_array_new (); + addresses = g_ptr_array_new_full (0, _g_value_array_free); array = g_value_array_new (3); /* IP address */ @@ -398,6 +406,7 @@ test_setting_ip6_config_old_address_array (void) ASSERT (memcmp (ba->data, &gw[0], sizeof (gw)) == 0, "ip6-old-addr", "unexpected failure comparing gateways"); + g_ptr_array_unref (addresses); g_value_unset (&written_value); g_value_unset (&read_value); g_object_unref (s_ip6); @@ -406,7 +415,7 @@ test_setting_ip6_config_old_address_array (void) static void test_setting_gsm_apn_spaces (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; const char *tmp; s_gsm = (NMSettingGsm *) nm_setting_gsm_new (); @@ -434,7 +443,7 @@ test_setting_gsm_apn_spaces (void) static void test_setting_gsm_apn_bad_chars (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; s_gsm = (NMSettingGsm *) nm_setting_gsm_new (); ASSERT (s_gsm != NULL, @@ -472,7 +481,7 @@ test_setting_gsm_apn_bad_chars (void) static void test_setting_gsm_apn_underscore (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; GError *error = NULL; gboolean success; @@ -491,7 +500,7 @@ test_setting_gsm_apn_underscore (void) static void test_setting_gsm_without_number (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; GError *error = NULL; gboolean success; @@ -1573,6 +1582,7 @@ test_connection_good_base_types (void) NM_SETTING_GSM_APN, "metered.billing.sucks", NULL); nm_connection_add_setting (connection, setting); + g_clear_object (&connection); /* CDMA connection */ connection = nm_connection_new (); @@ -1671,7 +1681,7 @@ test_connection_bad_base_types (void) static void test_setting_compare_id (void) { - NMSetting *old, *new; + gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; old = nm_setting_connection_new (); @@ -1697,7 +1707,7 @@ test_setting_compare_secrets (NMSettingSecretFlags secret_flags, NMSettingCompareFlags comp_flags, gboolean remove_secret) { - NMSetting *old, *new; + gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; /* Make sure that a connection with transient/unsaved secrets compares @@ -1729,7 +1739,7 @@ test_setting_compare_vpn_secrets (NMSettingSecretFlags secret_flags, NMSettingCompareFlags comp_flags, gboolean remove_secret) { - NMSetting *old, *new; + gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; /* Make sure that a connection with transient/unsaved secrets compares @@ -1908,7 +1918,7 @@ test_setting_connection_changed_signal (void) NMConnection *connection; gboolean changed = FALSE; NMSettingConnection *s_con; - char *uuid; + gs_free char *uuid = NULL; connection = nm_connection_new (); g_signal_connect (connection, @@ -2318,7 +2328,7 @@ static void test_setting_old_uuid (void) { GError *error = NULL; - NMSetting *setting; + gs_unref_object NMSetting *setting = NULL; gboolean success; /* NetworkManager-0.9.4.0 generated 40-character UUIDs with no dashes, |