summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-02-08 13:34:32 +0100
committerThomas Haller <thaller@redhat.com>2015-02-09 11:51:08 +0100
commit76745817c3e77b7d6c22290a7564b73224147516 (patch)
tree7f797ac2f0924ef8ce5487292eedb7d57c5d37b2
parentc50f30e79c67593532392f0f251d662e4294f5b2 (diff)
downloadNetworkManager-76745817c3e77b7d6c22290a7564b73224147516.tar.gz
libnm/tests: fix memleaks in test code for valgrind
-rw-r--r--libnm-glib/tests/test-remote-settings-client.c6
-rw-r--r--libnm/tests/test-remote-settings-client.c6
-rw-r--r--libnm/tests/test-secret-agent.c10
3 files changed, 13 insertions, 9 deletions
diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c
index 237e287f85..a109f8df4a 100644
--- a/libnm-glib/tests/test-remote-settings-client.c
+++ b/libnm-glib/tests/test-remote-settings-client.c
@@ -36,6 +36,7 @@
#include "nm-remote-settings.h"
#include "common.h"
+#include "gsystem-local-alloc.h"
static NMTestServiceInfo *sinfo;
static NMRemoteSettings *settings = NULL;
@@ -63,7 +64,7 @@ add_cb (NMRemoteSettings *s,
static void
test_add_connection (void)
{
- NMConnection *connection;
+ gs_unref_object NMConnection *connection = NULL;
NMSettingConnection *s_con;
NMSettingWired *s_wired;
char *uuid;
@@ -256,6 +257,7 @@ test_make_visible (void)
break;
}
}
+ g_slist_free (list);
g_assert (found == TRUE);
g_free (path);
@@ -298,6 +300,7 @@ test_remove_connection (void)
g_assert_cmpint (g_slist_length (list), >, 0);
connection = NM_REMOTE_CONNECTION (list->data);
+ g_slist_free (list);
g_assert (connection);
g_assert (remote == connection);
path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection)));
@@ -329,6 +332,7 @@ test_remove_connection (void)
g_assert ((gpointer) connection != (gpointer) candidate);
g_assert_cmpstr (path, ==, nm_connection_get_path (candidate));
}
+ g_slist_free (list);
g_free (path);
g_object_unref (proxy);
diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c
index 8f9dc27f2e..15590fac1a 100644
--- a/libnm/tests/test-remote-settings-client.c
+++ b/libnm/tests/test-remote-settings-client.c
@@ -370,7 +370,7 @@ add_remove_cb (GObject *s,
{
NMRemoteConnection *connection;
gboolean *done = user_data;
- GError *error = NULL;
+ gs_free_error GError *error = NULL;
connection = nm_client_add_connection_finish (client, result, &error);
g_assert_error (error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_OBJECT_CREATION_FAILED);
@@ -426,7 +426,7 @@ add_bad_cb (GObject *s,
gpointer user_data)
{
gboolean *done = user_data;
- GError *error = NULL;
+ gs_free_error GError *error = NULL;
remote = nm_client_add_connection_finish (client, result, &error);
g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY);
@@ -469,7 +469,7 @@ save_hostname_cb (GObject *s,
gpointer user_data)
{
gboolean *done = user_data;
- GError *error = NULL;
+ gs_free_error GError *error = NULL;
nm_client_save_hostname_finish (client, result, &error);
g_assert_no_error (error);
diff --git a/libnm/tests/test-secret-agent.c b/libnm/tests/test-secret-agent.c
index 0424b74e9b..dc1b9d6833 100644
--- a/libnm/tests/test-secret-agent.c
+++ b/libnm/tests/test-secret-agent.c
@@ -354,7 +354,7 @@ connection_activated_none_cb (GObject *c,
{
TestSecretAgentData *sadata = user_data;
NMActiveConnection *ac;
- GError *error = NULL;
+ gs_free_error GError *error = NULL;
ac = nm_client_activate_connection_finish (sadata->client, result, &error);
g_assert_error (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS);
@@ -399,8 +399,8 @@ connection_activated_no_secrets_cb (GObject *c,
gpointer user_data)
{
TestSecretAgentData *sadata = user_data;
- NMActiveConnection *ac;
- GError *error = NULL;
+ gs_unref_object NMActiveConnection *ac = NULL;
+ gs_free_error GError *error = NULL;
ac = nm_client_activate_connection_finish (sadata->client, result, &error);
g_assert_error (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS);
@@ -434,8 +434,8 @@ connection_activated_cancel_cb (GObject *c,
gpointer user_data)
{
TestSecretAgentData *sadata = user_data;
- NMActiveConnection *ac;
- GError *error = NULL;
+ gs_unref_object NMActiveConnection *ac;
+ gs_free_error GError *error = NULL;
ac = nm_client_activate_connection_finish (sadata->client, result, &error);
g_assert_error (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_USER_CANCELED);