summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2018-08-30 21:26:06 +1200
committerRobert Ancell <robert.ancell@canonical.com>2018-08-30 21:26:06 +1200
commit519534cf1bf26abb41a936df2e3547a501864915 (patch)
treeef6cce3463f476c64c056f6e1f66a40122eb6df7
parent6b98b30199e7a12c48a27c3a31171b02bf0d4de5 (diff)
downloadlightdm-git-519534cf1bf26abb41a936df2e3547a501864915.tar.gz
Use g_autoptr with GVariantIter
-rw-r--r--common/user-list.c16
-rw-r--r--src/login1.c12
2 files changed, 11 insertions, 17 deletions
diff --git a/common/user-list.c b/common/user-list.c
index ffd8646c..95951d34 100644
--- a/common/user-list.c
+++ b/common/user-list.c
@@ -511,7 +511,7 @@ load_accounts_user (CommonUser *user)
return FALSE;
/* Store the properties we need */
- GVariantIter *iter;
+ g_autoptr(GVariantIter) iter = NULL;
g_variant_get (result, "(a{sv})", &iter);
const gchar *name;
GVariant *value;
@@ -561,7 +561,6 @@ load_accounts_user (CommonUser *user)
else if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64))
priv->uid = g_variant_get_uint64 (value);
}
- g_variant_iter_free (iter);
g_autoptr(GVariant) extra_result = g_dbus_connection_call_sync (priv->bus,
"org.freedesktop.Accounts",
@@ -577,8 +576,10 @@ load_accounts_user (CommonUser *user)
if (error)
g_warning ("Error updating user %s: %s", priv->path, error->message);
if (extra_result) {
- g_variant_get (extra_result, "(a{sv})", &iter);
- while (g_variant_iter_loop (iter, "{&sv}", &name, &value))
+ g_autoptr(GVariantIter) extra_iter = NULL;
+
+ g_variant_get (extra_result, "(a{sv})", &extra_iter);
+ while (g_variant_iter_loop (extra_iter, "{&sv}", &name, &value))
{
if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
{
@@ -600,7 +601,6 @@ load_accounts_user (CommonUser *user)
}
}
}
- g_variant_iter_free (iter);
}
return !system_account;
@@ -841,12 +841,11 @@ load_sessions (CommonUserList *user_list)
g_variant_get (result, "(v)", &value);
g_debug ("Loading sessions from org.freedesktop.DisplayManager");
- GVariantIter *iter;
+ g_autoptr(GVariantIter) iter = NULL;
g_variant_get (value, "ao", &iter);
const gchar *path;
while (g_variant_iter_loop (iter, "&o", &path))
load_session (user_list, path);
- g_variant_iter_free (iter);
}
else
g_warning ("Unexpected type from org.freedesktop.DisplayManager.Sessions: %s", g_variant_get_type_string (result));
@@ -901,12 +900,11 @@ load_users (CommonUserList *user_list)
if (result)
{
g_debug ("Loading users from org.freedesktop.Accounts");
- GVariantIter *iter;
+ g_autoptr(GVariantIter) iter = NULL;
g_variant_get (result, "(ao)", &iter);
const gchar *path;
while (g_variant_iter_loop (iter, "&o", &path))
add_accounts_user (user_list, path, FALSE);
- g_variant_iter_free (iter);
}
else
{
diff --git a/src/login1.c b/src/login1.c
index a6e9b9dc..42e8fe26 100644
--- a/src/login1.c
+++ b/src/login1.c
@@ -114,15 +114,14 @@ seat_properties_changed_cb (GDBusConnection *connection,
Login1Seat *seat = user_data;
Login1SeatPrivate *priv = login1_seat_get_instance_private (seat);
- GVariantIter *iter;
- GVariantIter *invalidated_properties;
+ g_autoptr(GVariantIter) iter = NULL;
+ g_autoptr(GVariantIter) invalidated_properties = NULL;
g_variant_get (parameters, "(sa{sv}as)", NULL, &iter, &invalidated_properties);
const gchar *name;
GVariant *value;
while (g_variant_iter_loop (iter, "{&sv}", &name, &value))
update_property (seat, name, value);
- g_variant_iter_free (iter);
while (g_variant_iter_loop (invalidated_properties, "&s", &name))
{
@@ -147,7 +146,6 @@ seat_properties_changed_cb (GDBusConnection *connection,
update_property (seat, name, v);
}
}
- g_variant_iter_free (invalidated_properties);
}
static Login1Seat *
@@ -190,7 +188,7 @@ add_seat (Login1Service *service, const gchar *id, const gchar *path)
g_warning ("Failed to get seat properties: %s", error->message);
if (result)
{
- GVariantIter *properties;
+ g_autoptr(GVariantIter) properties = NULL;
g_variant_get (result, "(a{sv})", &properties);
const gchar *name;
@@ -202,7 +200,6 @@ add_seat (Login1Service *service, const gchar *id, const gchar *path)
else if (strcmp (name, "CanMultiSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
s_priv->can_multi_session = g_variant_get_boolean (value);
}
- g_variant_iter_free (properties);
}
priv->seats = g_list_append (priv->seats, seat);
@@ -292,13 +289,12 @@ login1_service_connect (Login1Service *service)
if (!result)
return FALSE;
- GVariantIter *seat_iter;
+ g_autoptr(GVariantIter) seat_iter = NULL;
g_variant_get (result, "(a(so))", &seat_iter);
const gchar *id, *path;
while (g_variant_iter_loop (seat_iter, "(&s&o)", &id, &path))
add_seat (service, id, path);
- g_variant_iter_free (seat_iter);
priv->connected = TRUE;