From 4e6e5335d29c039bed820c43bfd1c19cb62539ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Tue, 27 Oct 2020 15:38:28 +0100
Subject: [PATCH] display: Use autoptr to handle errors in look for existing
 users

It will make things just cleaner
---
 daemon/gdm-display.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 5e193f2..a65cbf1 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -539,9 +539,9 @@ gdm_display_real_prepare (GdmDisplay *self)
 static void
 look_for_existing_users_sync (GdmDisplay *self)
 {
-        GError *error = NULL;
-        GVariant *call_result;
-        GVariant *user_list;
+        g_autoptr(GError) error = NULL;
+        g_autoptr(GVariant) call_result = NULL;
+        g_autoptr(GVariant) user_list = NULL;
 
         self->priv->accountsservice_proxy = g_dbus_proxy_new_sync (self->priv->connection,
                                                                    0, NULL,
@@ -553,7 +553,7 @@ look_for_existing_users_sync (GdmDisplay *self)
 
         if (!self->priv->accountsservice_proxy) {
                 g_warning ("Failed to contact accountsservice: %s", error->message);
-                goto out;
+                return FALSE;
         }
 
         call_result = g_dbus_proxy_call_sync (self->priv->accountsservice_proxy,
@@ -566,15 +566,12 @@ look_for_existing_users_sync (GdmDisplay *self)
 
         if (!call_result) {
                 g_warning ("Failed to list cached users: %s", error->message);
-                goto out;
+                return FALSE;
         }
 
         g_variant_get (call_result, "(@ao)", &user_list);
         self->priv->have_existing_user_accounts = g_variant_n_children (user_list) > 0;
-        g_variant_unref (user_list);
-        g_variant_unref (call_result);
-out:
-        g_clear_error (&error);
+        return TRUE;
 }
 
 gboolean
-- 
1.8.3.1

